Skip to content

Commit

Permalink
feat: Make more clickup metadata public
Browse files Browse the repository at this point in the history
  • Loading branch information
zachelrath committed Nov 20, 2023
1 parent 14a7cb0 commit 00c880a
Show file tree
Hide file tree
Showing 31 changed files with 85 additions and 11 deletions.
27 changes: 21 additions & 6 deletions apps/clickup/bundle/bots/load/clickup_folders_load/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ type FoldersResponse = {
}

export default function clickup_folders_load(bot: LoadBotApi) {
const spaceID = bot.getCredentials().defaultSpaceId
if (!spaceID) {
throw new Error(
"Default Clickup Space ID Config Value must be set. Please check your Site / Workspace settings."
)
}
const { conditions, collectionMetadata } = bot.loadRequest
// Build maps for quickly converting to/from Uesio/external field names
const uesioFieldsByExternalName = {
Expand Down Expand Up @@ -60,6 +54,27 @@ export default function clickup_folders_load(bot: LoadBotApi) {
{}
)

let spaceID = bot.getCredentials().defaultSpaceId

// See if there is a Condition that specifies a particular space id
if (conditions && conditions.length) {
const spaceIdCondition = conditions.find(
(condition) =>
condition.field === "space.id" &&
condition.operator === "EQ" &&
!!condition.value
)
if (spaceIdCondition) {
spaceID = spaceIdCondition.value as string
}
}

if (!spaceID) {
throw new Error(
"A valid space id is required, but no condition on space.id was provided, nor was a default Clickup Space ID Config Value found."
)
}

const url = `${bot
.getIntegration()
.getBaseURL()}/space/${spaceID}/folder?archived=false`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: clickup_folders_load
public: true
type: LOAD
dialect: TYPESCRIPT
1 change: 1 addition & 0 deletions apps/clickup/bundle/bots/load/clickup_tasks_load/bot.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: clickup_tasks_load
public: true
type: LOAD
dialect: TYPESCRIPT
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: clickup_folders_save
public: true
type: SAVE
dialect: TYPESCRIPT
1 change: 1 addition & 0 deletions apps/clickup/bundle/collections/folder.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: folder
public: true
type: EXTERNAL
label: Folder
pluralLabel: Folders
Expand Down
1 change: 1 addition & 0 deletions apps/clickup/bundle/collections/task.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: task
public: true
type: EXTERNAL
label: Task
pluralLabel: Tasks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: default_clickup_space_id
public: true
store: platform
managedBy: site
11 changes: 11 additions & 0 deletions apps/clickup/bundle/credentials/clickup_api_key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: clickup_api_key
type: API_KEY
apiKey:
key: clickup_api_key
location: header
locationName: Authorization
locationValue: ${apikey}
entries:
defaultSpaceId:
type: configvalue
value: default_clickup_space_id
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: archived
public: true
type: CHECKBOX
label: Archived
columnname: archived
1 change: 1 addition & 0 deletions apps/clickup/bundle/fields/uesio/clickup/folder/lists.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: lists
public: true
type: LIST
label: Lists
subfields:
Expand Down
1 change: 1 addition & 0 deletions apps/clickup/bundle/fields/uesio/clickup/folder/name.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: name
public: true
type: TEXT
label: Name
columnname: name
12 changes: 12 additions & 0 deletions apps/clickup/bundle/fields/uesio/clickup/folder/space.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: space
public: true
type: STRUCT
label: Space
subfields:
- name: id
label: Id
type: TEXT
- name: name
label: Name
type: TEXT
columnname: space
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: task_count
public: true
type: NUMBER
label: Task Count
columnname: task_count
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: assignees
public: true
type: LIST
label: Assignees
subtype: TEXT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: checklists
public: true
type: LIST
label: Checklist
subtype: TEXT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: custom_fields
public: true
type: STRUCT
label: List
subfields:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: date_closed
public: true
type: TIMESTAMP
label: Date Closed
required: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: date_done
public: true
type: TIMESTAMP
label: Date Done
columnname: date_done
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: due_date
public: true
type: TIMESTAMP
label: Due Date
required: true
Expand Down
1 change: 1 addition & 0 deletions apps/clickup/bundle/fields/uesio/clickup/task/list.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: list
public: true
type: STRUCT
label: List
subfields:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: markdown_description
public: true
type: LONGTEXT
label: Markdown Description
columnname: markdown_description
1 change: 1 addition & 0 deletions apps/clickup/bundle/fields/uesio/clickup/task/name.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: name
public: true
type: TEXT
label: Name
required: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: orderindex
public: true
type: NUMBER
label: Order Index
columnname: orderindex
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: priority
public: true
type: TEXT
label: Priority
required: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: start_date
public: true
type: TIMESTAMP
label: Start Date
required: true
Expand Down
1 change: 1 addition & 0 deletions apps/clickup/bundle/fields/uesio/clickup/task/status.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: status
public: true
type: STRUCT
label: Status
subfields:
Expand Down
1 change: 1 addition & 0 deletions apps/clickup/bundle/fields/uesio/clickup/task/tags.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: tags
public: true
type: LIST
label: Tags
subtype: TEXT
Expand Down
4 changes: 2 additions & 2 deletions apps/clickup/bundle/integrations/clickup.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: clickup
type: clickup
authentication: OAUTH2_AUTHORIZATION_CODE
credentials: clickup_oauth
authentication: API_KEY
credentials: clickup_api_key
baseUrl: https://api.clickup.com/api/v2
3 changes: 1 addition & 2 deletions apps/clickup/bundle/integrationtypes/clickup.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
name: clickup
loadBot: clickup_load
saveBot: clickup_save
public: true
4 changes: 4 additions & 0 deletions apps/clickup/bundle/secrets/clickup_api_key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: clickup_api_key
public: true
store: platform
managedBy: site
11 changes: 10 additions & 1 deletion apps/clickup/generated/@types/@uesio/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ type ConditionOperator =
| "GTE"
| "LTE"
| "IN"
| "NOT_IN"
| "IS_BLANK"
| "IS_NOT_BLANK"
type FieldValue = string | number | boolean | object | null
type ConditionType = "SEARCH" | "GROUP"
type ConditionType = "SEARCH" | "GROUP" | "SUBQUERY"
interface ConditionRequest {
field: string
operator: ConditionOperator
Expand Down Expand Up @@ -126,6 +127,11 @@ type RunIntegrationAction = (
options: unknown
) => unknown

type CallBot = (
botName: string,
params: Record<string, FieldValue>
) => Record<string, FieldValue>

interface BeforeSaveBotApi {
addError: (error: string) => void
load: (loadRequest: LoadRequest) => WireRecord[]
Expand All @@ -144,6 +150,7 @@ interface AsAdminApi {
delete: (collectionName: string, records: WireRecord[]) => void
save: (collectionName: string, records: WireRecord[]) => void
runIntegrationAction: RunIntegrationAction
callBot: CallBot
getConfigValue: (configValueKey: string) => string
}
interface ListenerBotApi {
Expand All @@ -153,6 +160,7 @@ interface ListenerBotApi {
delete: (collectionName: string, records: WireRecord[]) => void
save: (collectionName: string, records: WireRecord[]) => void
runIntegrationAction: RunIntegrationAction
callBot: CallBot
getConfigValue: (configValueKey: string) => string
asAdmin: AsAdminApi
getSession: () => SessionApi
Expand Down Expand Up @@ -586,6 +594,7 @@ type ConditionOperators =
| "GTE"
| "LTE"
| "IN"
| "NOT_IN"
| "IS_BLANK"
| "IS_NOT_BLANK"
type WireCondition =
Expand Down

0 comments on commit 00c880a

Please sign in to comment.