feat: Convert all app files to JS
This commit is contained in:
@@ -2,7 +2,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Subject',
|
||||
key: 'subject',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -10,7 +10,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Assignee',
|
||||
key: 'assigneeId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
@@ -37,14 +37,14 @@ export const fields = [
|
||||
{
|
||||
label: 'Collaborators',
|
||||
key: 'collaborators',
|
||||
type: 'dynamic' as const,
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Collaborator',
|
||||
key: 'collaborator',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -68,7 +68,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Collaborator Emails',
|
||||
key: 'collaboratorEmails',
|
||||
type: 'dynamic' as const,
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description:
|
||||
'You have the option to include individuals who are not Zendesk users as Collaborators by adding their email addresses here.',
|
||||
@@ -76,7 +76,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Collaborator Email',
|
||||
key: 'collaboratorEmail',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -86,7 +86,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Group',
|
||||
key: 'groupId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'Allocate this ticket to a specific group.',
|
||||
@@ -104,7 +104,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Requester Name',
|
||||
key: 'requesterName',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
@@ -113,7 +113,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Requester Email',
|
||||
key: 'requesterEmail',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
@@ -122,7 +122,7 @@ export const fields = [
|
||||
{
|
||||
label: 'First Comment/Description Format',
|
||||
key: 'format',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -134,7 +134,7 @@ export const fields = [
|
||||
{
|
||||
label: 'First Comment/Description',
|
||||
key: 'comment',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -142,7 +142,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Should the first comment be public?',
|
||||
key: 'publicOrNot',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -154,7 +154,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Tags',
|
||||
key: 'tags',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'A comma separated list of tags.',
|
||||
@@ -162,7 +162,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Status',
|
||||
key: 'status',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -178,7 +178,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Type',
|
||||
key: 'type',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -192,7 +192,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Due At',
|
||||
key: 'dueAt',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'Limited to tickets typed as "task".',
|
||||
@@ -200,7 +200,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Priority',
|
||||
key: 'priority',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -214,7 +214,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Submitter',
|
||||
key: 'submitterId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -236,7 +236,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Ticket Form',
|
||||
key: 'ticketForm',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
@@ -255,14 +255,14 @@ export const fields = [
|
||||
{
|
||||
label: 'Sharing Agreements',
|
||||
key: 'sharingAgreements',
|
||||
type: 'dynamic' as const,
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Sharing Agreement',
|
||||
key: 'sharingAgreement',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -282,7 +282,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Brand',
|
||||
key: 'brandId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
@@ -1,11 +1,6 @@
|
||||
import { IJSONArray, IJSONObject } from '@automatisch/types';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { fields } from './fields';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
|
||||
type Payload = {
|
||||
ticket: IJSONObject;
|
||||
};
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import { fields } from './fields.js';
|
||||
import isEmpty from 'lodash/isEmpty.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create ticket',
|
||||
@@ -32,15 +27,14 @@ export default defineAction({
|
||||
brandId,
|
||||
} = $.step.parameters;
|
||||
|
||||
const collaborators = $.step.parameters.collaborators as IJSONArray;
|
||||
const collaborators = $.step.parameters.collaborators;
|
||||
const collaboratorIds = collaborators?.map(
|
||||
(collaborator: IJSONObject) => collaborator.collaborator
|
||||
(collaborator) => collaborator.collaborator
|
||||
);
|
||||
|
||||
const collaboratorEmails = $.step.parameters
|
||||
.collaboratorEmails as IJSONArray;
|
||||
const collaboratorEmails = $.step.parameters.collaboratorEmails;
|
||||
const formattedCollaboratorEmails = collaboratorEmails?.map(
|
||||
(collaboratorEmail: IJSONObject) => collaboratorEmail.collaboratorEmail
|
||||
(collaboratorEmail) => collaboratorEmail.collaboratorEmail
|
||||
);
|
||||
|
||||
const formattedCollaborators = [
|
||||
@@ -48,17 +42,15 @@ export default defineAction({
|
||||
...formattedCollaboratorEmails,
|
||||
];
|
||||
|
||||
const sharingAgreements = $.step.parameters.sharingAgreements as IJSONArray;
|
||||
const sharingAgreements = $.step.parameters.sharingAgreements;
|
||||
const sharingAgreementIds = sharingAgreements
|
||||
?.filter(isEmpty)
|
||||
.map((sharingAgreement: IJSONObject) =>
|
||||
Number(sharingAgreement.sharingAgreement)
|
||||
);
|
||||
.map((sharingAgreement) => Number(sharingAgreement.sharingAgreement));
|
||||
|
||||
const tags = $.step.parameters.tags as string;
|
||||
const tags = $.step.parameters.tags;
|
||||
const formattedTags = tags.split(',');
|
||||
|
||||
const payload: Payload = {
|
||||
const payload = {
|
||||
ticket: {
|
||||
subject,
|
||||
assignee_id: assigneeId,
|
@@ -2,7 +2,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -10,7 +10,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Email',
|
||||
key: 'email',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
description:
|
||||
@@ -19,7 +19,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Details',
|
||||
key: 'details',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -27,7 +27,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Notes',
|
||||
key: 'notes',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
@@ -36,7 +36,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Phone',
|
||||
key: 'phone',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
@@ -45,7 +45,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Tags',
|
||||
key: 'tags',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'A comma separated list of tags.',
|
||||
@@ -53,7 +53,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Role',
|
||||
key: 'role',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
@@ -62,7 +62,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Organization',
|
||||
key: 'organizationId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'Assign this user to a specific organization.',
|
||||
@@ -80,7 +80,7 @@ export const fields = [
|
||||
{
|
||||
label: 'External Id',
|
||||
key: 'externalId',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
@@ -89,7 +89,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Verified',
|
||||
key: 'verified',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
"Specify if you can verify that the user's assertion of their identity is accurate.",
|
@@ -1,10 +1,5 @@
|
||||
import { IJSONObject } from '@automatisch/types';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { fields } from './fields';
|
||||
|
||||
type Payload = {
|
||||
user: IJSONObject;
|
||||
};
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import { fields } from './fields.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create user',
|
||||
@@ -25,10 +20,10 @@ export default defineAction({
|
||||
verified,
|
||||
} = $.step.parameters;
|
||||
|
||||
const tags = $.step.parameters.tags as string;
|
||||
const tags = $.step.parameters.tags;
|
||||
const formattedTags = tags.split(',');
|
||||
|
||||
const payload: Payload = {
|
||||
const payload = {
|
||||
user: {
|
||||
name,
|
||||
email,
|
@@ -1,4 +1,4 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Delete ticket',
|
||||
@@ -8,7 +8,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Ticket',
|
||||
key: 'ticketId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
variables: true,
|
||||
description: 'Select the ticket you want to delete.',
|
@@ -1,4 +1,4 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Delete user',
|
||||
@@ -8,7 +8,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'User',
|
||||
key: 'userId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
variables: true,
|
||||
description: 'Select the user you want to modify.',
|
@@ -1,4 +1,4 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Find ticket',
|
||||
@@ -8,7 +8,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Query',
|
||||
key: 'query',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
description:
|
15
packages/backend/src/apps/zendesk/actions/index.js
Normal file
15
packages/backend/src/apps/zendesk/actions/index.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import createTicket from './create-ticket/index.js';
|
||||
import createUser from './create-user/index.js';
|
||||
import deleteTicket from './delete-ticket/index.js';
|
||||
import deleteUser from './delete-user/index.js';
|
||||
import findTicket from './find-ticket/index.js';
|
||||
import updateTicket from './update-ticket/index.js';
|
||||
|
||||
export default [
|
||||
createTicket,
|
||||
createUser,
|
||||
deleteTicket,
|
||||
deleteUser,
|
||||
findTicket,
|
||||
updateTicket,
|
||||
];
|
@@ -1,15 +0,0 @@
|
||||
import createTicket from './create-ticket';
|
||||
import createUser from './create-user';
|
||||
import deleteTicket from './delete-ticket';
|
||||
import deleteUser from './delete-user';
|
||||
import findTicket from './find-ticket';
|
||||
import updateTicket from './update-ticket';
|
||||
|
||||
export default [
|
||||
createTicket,
|
||||
createUser,
|
||||
deleteTicket,
|
||||
deleteUser,
|
||||
findTicket,
|
||||
updateTicket,
|
||||
];
|
@@ -2,7 +2,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Ticket',
|
||||
key: 'ticketId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
variables: true,
|
||||
description: 'Select the ticket you want to change.',
|
||||
@@ -20,7 +20,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Subject',
|
||||
key: 'subject',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -28,7 +28,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Assignee',
|
||||
key: 'assigneeId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description:
|
||||
@@ -55,7 +55,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Group',
|
||||
key: 'groupId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'Allocate this ticket to a specific group.',
|
||||
@@ -73,7 +73,7 @@ export const fields = [
|
||||
{
|
||||
label: 'New Status',
|
||||
key: 'status',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -89,7 +89,7 @@ export const fields = [
|
||||
{
|
||||
label: 'New comment to add to the ticket',
|
||||
key: 'comment',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -97,7 +97,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Should the first comment be public?',
|
||||
key: 'publicOrNot',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -109,7 +109,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Tags',
|
||||
key: 'tags',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'A comma separated list of tags.',
|
||||
@@ -117,7 +117,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Type',
|
||||
key: 'type',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -131,7 +131,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Priority',
|
||||
key: 'priority',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -145,7 +145,7 @@ export const fields = [
|
||||
{
|
||||
label: 'Submitter',
|
||||
key: 'submitterId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
@@ -1,7 +1,7 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { fields } from './fields';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import omitBy from 'lodash/omitBy';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import { fields } from './fields.js';
|
||||
import isEmpty from 'lodash/isEmpty.js';
|
||||
import omitBy from 'lodash/omitBy.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Update ticket',
|
||||
@@ -23,7 +23,7 @@ export default defineAction({
|
||||
submitterId,
|
||||
} = $.step.parameters;
|
||||
|
||||
const tags = $.step.parameters.tags as string;
|
||||
const tags = $.step.parameters.tags;
|
||||
const formattedTags = tags.split(',');
|
||||
|
||||
const payload = {
|
@@ -1,17 +1,16 @@
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
import authScope from '../common/auth-scope';
|
||||
import authScope from '../common/auth-scope.js';
|
||||
|
||||
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||
export default async function generateAuthUrl($) {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
|
||||
const redirectUri = oauthRedirectUrlField.value as string;
|
||||
const redirectUri = oauthRedirectUrlField.value;
|
||||
const searchParams = new URLSearchParams({
|
||||
response_type: 'code',
|
||||
redirect_uri: redirectUri,
|
||||
client_id: $.auth.data.clientId as string,
|
||||
client_id: $.auth.data.clientId,
|
||||
scope: authScope.join(' '),
|
||||
});
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import generateAuthUrl from './generate-auth-url';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
import generateAuthUrl from './generate-auth-url.js';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'oAuthRedirectUrl',
|
||||
label: 'OAuth Redirect URL',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: true,
|
||||
value: '{WEB_APP_URL}/app/zendesk/connections/add',
|
||||
@@ -18,7 +18,7 @@ export default {
|
||||
{
|
||||
key: 'instanceUrl',
|
||||
label: 'Zendesk Subdomain Url',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -28,7 +28,7 @@ export default {
|
||||
{
|
||||
key: 'clientId',
|
||||
label: 'Client ID',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -39,7 +39,7 @@ export default {
|
||||
{
|
||||
key: 'clientSecret',
|
||||
label: 'Client Secret',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
@@ -0,0 +1,8 @@
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
|
||||
const isStillVerified = async ($) => {
|
||||
await getCurrentUser($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,9 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
await getCurrentUser($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,13 +1,12 @@
|
||||
import { IGlobalVariable, IJSONValue, IField } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
import scopes from '../common/auth-scope';
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
import scopes from '../common/auth-scope.js';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const verifyCredentials = async ($) => {
|
||||
await getAccessToken($);
|
||||
|
||||
const user = await getCurrentUser($);
|
||||
const subdomain = extractSubdomain($.auth.data.instanceUrl);
|
||||
const name = user.name as string;
|
||||
const name = user.name;
|
||||
const screenName = [name, subdomain].filter(Boolean).join(' @ ');
|
||||
|
||||
await $.auth.set({
|
||||
@@ -18,19 +17,19 @@ const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
});
|
||||
};
|
||||
|
||||
const getAccessToken = async ($: IGlobalVariable) => {
|
||||
const getAccessToken = async ($) => {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value as string;
|
||||
const redirectUri = oauthRedirectUrlField.value;
|
||||
|
||||
const response = await $.http.post(`/oauth/tokens`, {
|
||||
redirect_uri: redirectUri,
|
||||
code: $.auth.data.code,
|
||||
grant_type: 'authorization_code',
|
||||
scope: scopes.join(' '),
|
||||
client_id: $.auth.data.clientId as string,
|
||||
client_secret: $.auth.data.clientSecret as string,
|
||||
client_id: $.auth.data.clientId,
|
||||
client_secret: $.auth.data.clientSecret,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
@@ -45,8 +44,8 @@ const getAccessToken = async ($: IGlobalVariable) => {
|
||||
});
|
||||
};
|
||||
|
||||
function extractSubdomain(url: IJSONValue) {
|
||||
const match = (url as string).match(/https:\/\/(.*?)\.zendesk\.com/);
|
||||
function extractSubdomain(url) {
|
||||
const match = url.match(/https:\/\/(.*?)\.zendesk\.com/);
|
||||
if (match && match[1]) {
|
||||
return match[1];
|
||||
}
|
@@ -1,10 +1,8 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
const { instanceUrl, tokenType, accessToken } = $.auth.data;
|
||||
|
||||
if (instanceUrl) {
|
||||
requestConfig.baseURL = instanceUrl as string;
|
||||
requestConfig.baseURL = instanceUrl;
|
||||
}
|
||||
|
||||
if (tokenType && accessToken) {
|
3
packages/backend/src/apps/zendesk/common/auth-scope.js
Normal file
3
packages/backend/src/apps/zendesk/common/auth-scope.js
Normal file
@@ -0,0 +1,3 @@
|
||||
const authScope = ['read', 'write'];
|
||||
|
||||
export default authScope;
|
@@ -1,3 +0,0 @@
|
||||
const authScope: string[] = ['read', 'write'];
|
||||
|
||||
export default authScope;
|
@@ -1,6 +1,4 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
|
||||
const getCurrentUser = async ($) => {
|
||||
const response = await $.http.get('/api/v2/users/me');
|
||||
const currentUser = response.data.user;
|
||||
|
20
packages/backend/src/apps/zendesk/dynamic-data/index.js
Normal file
20
packages/backend/src/apps/zendesk/dynamic-data/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import listUsers from './list-users/index.js';
|
||||
import listBrands from './list-brands/index.js';
|
||||
import listFirstPageOfTickets from './list-first-page-of-tickets/index.js';
|
||||
import listGroups from './list-groups/index.js';
|
||||
import listOrganizations from './list-organizations/index.js';
|
||||
import listSharingAgreements from './list-sharing-agreements/index.js';
|
||||
import listTicketForms from './list-ticket-forms/index.js';
|
||||
import listViews from './list-views/index.js';
|
||||
|
||||
export default [
|
||||
listUsers,
|
||||
listBrands,
|
||||
listFirstPageOfTickets,
|
||||
listGroups,
|
||||
listOrganizations,
|
||||
listSharingAgreements,
|
||||
listFirstPageOfTickets,
|
||||
listTicketForms,
|
||||
listViews,
|
||||
];
|
@@ -1,20 +0,0 @@
|
||||
import listUsers from './list-users';
|
||||
import listBrands from './list-brands';
|
||||
import listFirstPageOfTickets from './list-first-page-of-tickets';
|
||||
import listGroups from './list-groups';
|
||||
import listOrganizations from './list-organizations';
|
||||
import listSharingAgreements from './list-sharing-agreements';
|
||||
import listTicketForms from './list-ticket-forms';
|
||||
import listViews from './list-views';
|
||||
|
||||
export default [
|
||||
listUsers,
|
||||
listBrands,
|
||||
listFirstPageOfTickets,
|
||||
listGroups,
|
||||
listOrganizations,
|
||||
listSharingAgreements,
|
||||
listFirstPageOfTickets,
|
||||
listTicketForms,
|
||||
listViews,
|
||||
];
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List brands',
|
||||
key: 'listBrands',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const brands: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const brands = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List first page of tickets',
|
||||
key: 'listFirstPageOfTickets',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const tickets: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const tickets = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,20 +1,16 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List groups',
|
||||
key: 'listGroups',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const groups: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const groups = {
|
||||
data: [],
|
||||
};
|
||||
let hasMore;
|
||||
|
||||
const params = {
|
||||
'page[size]': 100,
|
||||
'page[after]': undefined as unknown as string,
|
||||
'page[after]': undefined,
|
||||
};
|
||||
|
||||
do {
|
@@ -1,20 +1,16 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List organizations',
|
||||
key: 'listOrganizations',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const organizations: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const organizations = {
|
||||
data: [],
|
||||
};
|
||||
let hasMore;
|
||||
|
||||
const params = {
|
||||
'page[size]': 100,
|
||||
'page[after]': undefined as unknown as string,
|
||||
'page[after]': undefined,
|
||||
};
|
||||
|
||||
do {
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List sharing agreements',
|
||||
key: 'listSharingAgreements',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const sharingAgreements: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const sharingAgreements = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List ticket forms',
|
||||
key: 'listTicketForms',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const ticketForms: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const ticketForms = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List users',
|
||||
key: 'listUsers',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const users: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const users = {
|
||||
data: [],
|
||||
};
|
||||
let hasMore;
|
||||
@@ -18,7 +14,7 @@ export default {
|
||||
const params = {
|
||||
'page[size]': 100,
|
||||
role,
|
||||
'page[after]': undefined as unknown as string,
|
||||
'page[after]': undefined,
|
||||
};
|
||||
|
||||
do {
|
@@ -1,20 +1,16 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List views',
|
||||
key: 'listViews',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const views: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const views = {
|
||||
data: [],
|
||||
};
|
||||
let hasMore;
|
||||
|
||||
const params = {
|
||||
'page[size]': 100,
|
||||
'page[after]': undefined as unknown as string,
|
||||
'page[after]': undefined,
|
||||
};
|
||||
|
||||
do {
|
@@ -1,9 +1,9 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-headers';
|
||||
import auth from './auth';
|
||||
import triggers from './triggers';
|
||||
import actions from './actions';
|
||||
import dynamicData from './dynamic-data';
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-headers.js';
|
||||
import auth from './auth/index.js';
|
||||
import triggers from './triggers/index.js';
|
||||
import actions from './actions/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Zendesk',
|
4
packages/backend/src/apps/zendesk/triggers/index.js
Normal file
4
packages/backend/src/apps/zendesk/triggers/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import newTickets from './new-tickets/index.js';
|
||||
import newUsers from './new-users/index.js';
|
||||
|
||||
export default [newTickets, newUsers];
|
@@ -1,4 +0,0 @@
|
||||
import newTickets from './new-tickets';
|
||||
import newUsers from './new-users';
|
||||
|
||||
export default [newTickets, newUsers];
|
@@ -1,4 +1,4 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New tickets',
|
||||
@@ -9,7 +9,7 @@ export default defineTrigger({
|
||||
{
|
||||
label: 'View',
|
||||
key: 'viewId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
variables: true,
|
||||
source: {
|
||||
@@ -30,7 +30,7 @@ export default defineTrigger({
|
||||
|
||||
const params = {
|
||||
'page[size]': 100,
|
||||
'page[after]': undefined as unknown as string,
|
||||
'page[after]': undefined,
|
||||
sort_by: 'nice_id',
|
||||
sort_order: 'desc',
|
||||
};
|
@@ -1,5 +1,5 @@
|
||||
import Crypto from 'crypto';
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New users',
|
Reference in New Issue
Block a user