From 2fdbcaf9ddb5808f5956c7456010f301509d2107 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 18 Feb 2025 14:31:38 -0300 Subject: [PATCH 1/5] Added actions --- components/clicktime/.gitignore | 3 - .../actions/create-client/create-client.mjs | 77 +++++++ .../actions/create-job/create-job.mjs | 119 +++++++++++ .../actions/create-user/create-user.mjs | 84 ++++++++ components/clicktime/app/clicktime.app.ts | 13 -- components/clicktime/clicktime.app.mjs | 192 ++++++++++++++++++ components/clicktime/package.json | 8 +- pnpm-lock.yaml | 6 +- 8 files changed, 482 insertions(+), 20 deletions(-) delete mode 100644 components/clicktime/.gitignore create mode 100644 components/clicktime/actions/create-client/create-client.mjs create mode 100644 components/clicktime/actions/create-job/create-job.mjs create mode 100644 components/clicktime/actions/create-user/create-user.mjs delete mode 100644 components/clicktime/app/clicktime.app.ts create mode 100644 components/clicktime/clicktime.app.mjs diff --git a/components/clicktime/.gitignore b/components/clicktime/.gitignore deleted file mode 100644 index ec761ccab7595..0000000000000 --- a/components/clicktime/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.js -*.mjs -dist \ No newline at end of file diff --git a/components/clicktime/actions/create-client/create-client.mjs b/components/clicktime/actions/create-client/create-client.mjs new file mode 100644 index 0000000000000..a1ce7528ed715 --- /dev/null +++ b/components/clicktime/actions/create-client/create-client.mjs @@ -0,0 +1,77 @@ +import app from "../../clicktime.app.mjs"; + +export default { + key: "clicktime-create-client", + name: "Create Client", + description: "Create a Client on ClickTime [See the documentation](https://developer.clicktime.com/docs/api/#/Clients)", + version: "0.0.1", + type: "action", + props: { + app, + accountingPackageId: { + propDefinition: [ + app, + "accountingPackageId", + ], + }, + billingRate: { + propDefinition: [ + app, + "billingRate", + ], + }, + clientNumber: { + propDefinition: [ + app, + "clientNumber", + ], + }, + isActive: { + propDefinition: [ + app, + "isActive", + ], + }, + isEligibleTimeOffAllocation: { + propDefinition: [ + app, + "isEligibleTimeOffAllocation", + ], + }, + name: { + propDefinition: [ + app, + "name", + ], + }, + notes: { + propDefinition: [ + app, + "notes", + ], + }, + shortName: { + propDefinition: [ + app, + "shortName", + ], + }, + }, + async run({ $ }) { + const response = await this.app.createClient({ + $, + data: { + AccountingPackageID: this.accountingPackageId, + BillingRate: this.billingRate, + ClientNumber: this.clientNumber, + IsActive: this.isActive, + IsEligibleTimeOffAllocation: this.isEligibleTimeOffAllocation, + Name: this.name, + Notes: this.notes, + ShortName: this.shortName, + }, + }); + $.export("$summary", `Successfully created Client with the ID: ${response.data.ID}`); + return response; + }, +}; diff --git a/components/clicktime/actions/create-job/create-job.mjs b/components/clicktime/actions/create-job/create-job.mjs new file mode 100644 index 0000000000000..5e4c2ddb57aff --- /dev/null +++ b/components/clicktime/actions/create-job/create-job.mjs @@ -0,0 +1,119 @@ +import app from "../../clicktime.app.mjs"; + +export default { + key: "clicktime-create-job", + name: "Create Job", + description: "Create a Job on Clicktime. [See the documentation](https://developer.clicktime.com/docs/api/#/operations/Jobs/CreateJob)", + version: "0.0.1", + type: "action", + props: { + app, + accountingPackageId: { + propDefinition: [ + app, + "accountingPackageId", + ], + }, + billingRate: { + propDefinition: [ + app, + "billingRate", + ], + }, + isActive: { + propDefinition: [ + app, + "isActive", + ], + }, + isEligibleTimeOffAllocation: { + propDefinition: [ + app, + "isEligibleTimeOffAllocation", + ], + }, + name: { + propDefinition: [ + app, + "name", + ], + }, + notes: { + propDefinition: [ + app, + "notes", + ], + }, + clientId: { + propDefinition: [ + app, + "clientId", + ], + }, + endDate: { + propDefinition: [ + app, + "endDate", + ], + }, + includeInRm: { + propDefinition: [ + app, + "includeInRm", + ], + }, + isBillable: { + propDefinition: [ + app, + "isBillable", + ], + }, + jobNumber: { + propDefinition: [ + app, + "jobNumber", + ], + }, + startDate: { + propDefinition: [ + app, + "startDate", + ], + }, + timeRequiresApproval: { + propDefinition: [ + app, + "timeRequiresApproval", + ], + }, + useCompanyBillingRate: { + propDefinition: [ + app, + "useCompanyBillingRate", + ], + }, + }, + async run({ $ }) { + const response = await this.app.createJob({ + $, + data: { + AccountingPackageID: this.accountingPackageId, + BillingRate: this.billingRate, + IsActive: this.isActive, + IsEligibleTimeOffAllocation: this.isEligibleTimeOffAllocation, + Name: this.name, + Notes: this.notes, + ClientID: this.clientId, + EndDate: this.endDate, + IncludeInRM: this.includeInRm, + IsBillable: this.isBillable, + JobNumber: this.jobNumber, + StartDate: this.startDate, + TimeRequiresApproval: this.timeRequiresApproval, + UseCompanyBillingRate: this.useCompanyBillingRate, + }, + }); + $.export("$summary", `Successfully created Job with ID: ${response.data.ID}`); + return response; + }, +}; diff --git a/components/clicktime/actions/create-user/create-user.mjs b/components/clicktime/actions/create-user/create-user.mjs new file mode 100644 index 0000000000000..5137aa7ee1e82 --- /dev/null +++ b/components/clicktime/actions/create-user/create-user.mjs @@ -0,0 +1,84 @@ +import app from "../../clicktime.app.mjs"; + +export default { + key: "clicktime-create-user", + name: "Create User", + description: "Create an User on ClickTime. [See the documentation](https://developer.clicktime.com/docs/api/#/operations/Users/CreateManagedUser)", + version: "0.0.1", + type: "action", + props: { + app, + billingRate: { + propDefinition: [ + app, + "billingRate", + ], + }, + isActive: { + propDefinition: [ + app, + "isActive", + ], + }, + name: { + propDefinition: [ + app, + "name", + ], + }, + startDate: { + propDefinition: [ + app, + "startDate", + ], + }, + costModel: { + propDefinition: [ + app, + "costModel", + ], + }, + costRate: { + propDefinition: [ + app, + "costRate", + ], + }, + email: { + propDefinition: [ + app, + "email", + ], + }, + employmentTypeId: { + propDefinition: [ + app, + "employmentTypeId", + ], + }, + role: { + propDefinition: [ + app, + "role", + ], + }, + }, + async run({ $ }) { + const response = await this.app.createUser({ + $, + data: { + BillingRate: this.billingRate, + IsActive: this.isActive, + Name: this.name, + StartDate: this.startDate, + CostModel: this.costModel, + CostRate: this.costRate, + Email: this.email, + EmploymentTypeID: this.employmentTypeId, + Role: this.role, + }, + }); + $.export("$summary", `Successfully created User with the ID: ${response.data.ID}`); + return response; + }, +}; diff --git a/components/clicktime/app/clicktime.app.ts b/components/clicktime/app/clicktime.app.ts deleted file mode 100644 index b0dbed95844eb..0000000000000 --- a/components/clicktime/app/clicktime.app.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { defineApp } from "@pipedream/types"; - -export default defineApp({ - type: "app", - app: "clicktime", - propDefinitions: {}, - methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); - }, - }, -}); \ No newline at end of file diff --git a/components/clicktime/clicktime.app.mjs b/components/clicktime/clicktime.app.mjs new file mode 100644 index 0000000000000..e8198166c1a37 --- /dev/null +++ b/components/clicktime/clicktime.app.mjs @@ -0,0 +1,192 @@ +import { axios } from "@pipedream/platform"; + +export default { + type: "app", + app: "clicktime", + propDefinitions: { + accountingPackageId: { + type: "string", + label: "Accounting Package ID", + description: "Unique identifier for the accounting package", + }, + billingRate: { + type: "string", + label: "Billing Rate", + description: "The billing rate for the client, job, or user", + }, + clientNumber: { + type: "string", + label: "Client Number", + description: "A unique identifier for the client in the system", + }, + isActive: { + type: "boolean", + label: "Is Active", + description: "Indicates whether the entity (client, job, or user) is currently active", + }, + isEligibleTimeOffAllocation: { + type: "boolean", + label: "Eligible for Time Off Allocation", + description: "Determines if the entity is eligible for time-off allocation", + }, + name: { + type: "string", + label: "Name", + description: "The name of the client, job, or user", + }, + notes: { + type: "string", + label: "Notes", + description: "Additional information related to the entity", + }, + shortName: { + type: "string", + label: "Short Name", + description: "A shorter version of the name for easier reference", + }, + clientId: { + type: "string", + label: "Client ID", + description: "Unique identifier of the client associated with a job", + async options() { + const response = await this.getClients(); + const clientIds = response.data; + return clientIds.map(({ + ID, Name, + }) => ({ + label: Name, + value: ID, + })); + }, + }, + endDate: { + type: "string", + label: "End Date", + description: "The end date of the job or user, i.e.: `2021-01-01`", + }, + includeInRm: { + type: "boolean", + label: "Include in RM", + description: "Specifies whether the job should be included in RM", + }, + isBillable: { + type: "boolean", + label: "Is Billable", + description: "Indicates whether the job is billable", + }, + jobNumber: { + type: "string", + label: "Job Number", + description: "Unique identifier assigned to a job for tracking purposes", + }, + startDate: { + type: "string", + label: "Start Date", + description: "The start date of the job or user, i.e.: `2020-01-01`", + }, + timeRequiresApproval: { + type: "boolean", + label: "Time Requires Approval", + description: "Indicates whether time entries for the job require approval", + }, + useCompanyBillingRate: { + type: "boolean", + label: "Use Company Billing Rate", + description: "Specifies whether the job uses the company-wide billing rate instead of a custom one", + }, + costModel: { + type: "string", + label: "Cost Model", + description: "Defines the cost model used for the user, such as 'Hourly' or 'Fixed'", + options: [ + "Hourly", + "Salary", + ], + }, + costRate: { + type: "string", + label: "Cost Rate", + description: "The internal cost rate associated with the user", + }, + email: { + type: "string", + label: "Email", + description: "The email address associated with the user", + }, + employmentTypeId: { + type: "string", + label: "Employment Type ID", + description: "Unique identifier for the user's employment type", + async options() { + const response = await this.getEmploymentTypes(); + const employmentTypeIds = response.data; + return employmentTypeIds.map(({ + ID, Name, + }) => ({ + label: Name, + value: ID, + })); + }, + }, + role: { + type: "string", + label: "Role", + description: "The role assigned to the user", + }, + }, + + methods: { + _baseUrl() { + return "https://api.clicktime.com/v2"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + "Authorization": `Token ${this.$auth.api_token}`, + ...headers, + }, + }); + }, + async createClient(args = {}) { + return this._makeRequest({ + path: "/Clients", + method: "post", + ...args, + }); + }, + async createJob(args = {}) { + return this._makeRequest({ + path: "/Jobs", + method: "post", + ...args, + }); + }, + async createUser(args = {}) { + return this._makeRequest({ + path: "/Manage/Users", + method: "post", + ...args, + }); + }, + async getClients(args = {}) { + return this._makeRequest({ + path: "/Clients", + ...args, + }); + }, + async getEmploymentTypes(args = {}) { + return this._makeRequest({ + path: "/EmploymentTypes", + ...args, + }); + }, + }, +}; diff --git a/components/clicktime/package.json b/components/clicktime/package.json index dd2501369f35b..230896b1a57a5 100644 --- a/components/clicktime/package.json +++ b/components/clicktime/package.json @@ -1,16 +1,18 @@ { "name": "@pipedream/clicktime", - "version": "0.0.2", + "version": "0.1.0", "description": "Pipedream ClickTime Components", - "main": "dist/app/clicktime.app.mjs", + "main": "clicktime.app.mjs", "keywords": [ "pipedream", "clicktime" ], - "files": ["dist"], "homepage": "https://pipedream.com/apps/clicktime", "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bb6beb3642cc8..713ced2246620 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1984,7 +1984,11 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/clicktime: {} + components/clicktime: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/clickup: dependencies: From dc28f970943f31260819942ac6e0fff22defe3c3 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Mon, 24 Feb 2025 08:40:17 -0300 Subject: [PATCH 2/5] Done requests changes --- .../actions/create-client/create-client.mjs | 17 ++++++++++------ .../actions/create-job/create-job.mjs | 18 +++++++++++------ .../actions/create-user/create-user.mjs | 4 ++++ components/clicktime/clicktime.app.mjs | 20 +++++++++---------- components/clicktime/common/constants.mjs | 6 ++++++ 5 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 components/clicktime/common/constants.mjs diff --git a/components/clicktime/actions/create-client/create-client.mjs b/components/clicktime/actions/create-client/create-client.mjs index a1ce7528ed715..9080daed3f0b3 100644 --- a/components/clicktime/actions/create-client/create-client.mjs +++ b/components/clicktime/actions/create-client/create-client.mjs @@ -8,47 +8,52 @@ export default { type: "action", props: { app, - accountingPackageId: { + clientNumber: { propDefinition: [ app, - "accountingPackageId", + "clientNumber", ], }, - billingRate: { + accountingPackageId: { propDefinition: [ app, - "billingRate", + "accountingPackageId", ], }, - clientNumber: { + billingRate: { propDefinition: [ app, - "clientNumber", + "billingRate", ], + description: "The billing rate for the client", }, isActive: { propDefinition: [ app, "isActive", ], + description: "Indicates whether the client is currently active", }, isEligibleTimeOffAllocation: { propDefinition: [ app, "isEligibleTimeOffAllocation", ], + description: "Determines if the client is eligible for time-off allocation", }, name: { propDefinition: [ app, "name", ], + description: "The name of the client", }, notes: { propDefinition: [ app, "notes", ], + description: "Additional information related to the client", }, shortName: { propDefinition: [ diff --git a/components/clicktime/actions/create-job/create-job.mjs b/components/clicktime/actions/create-job/create-job.mjs index 5e4c2ddb57aff..b1a9efb9b13c0 100644 --- a/components/clicktime/actions/create-job/create-job.mjs +++ b/components/clicktime/actions/create-job/create-job.mjs @@ -19,30 +19,35 @@ export default { app, "billingRate", ], + description: "The billing rate for the job", }, isActive: { propDefinition: [ app, "isActive", ], + description: "Indicates whether the job is currently active", }, isEligibleTimeOffAllocation: { propDefinition: [ app, "isEligibleTimeOffAllocation", ], + description: "Determines if the client is eligible for time-off allocation", }, name: { propDefinition: [ app, "name", ], + description: "The name of the job", }, notes: { propDefinition: [ app, "notes", ], + description: "Additional information related to the job", }, clientId: { propDefinition: [ @@ -50,12 +55,6 @@ export default { "clientId", ], }, - endDate: { - propDefinition: [ - app, - "endDate", - ], - }, includeInRm: { propDefinition: [ app, @@ -79,6 +78,13 @@ export default { app, "startDate", ], + description: "The start date of the job, i.e.: `2020-01-01`", + }, + endDate: { + propDefinition: [ + app, + "endDate", + ], }, timeRequiresApproval: { propDefinition: [ diff --git a/components/clicktime/actions/create-user/create-user.mjs b/components/clicktime/actions/create-user/create-user.mjs index 5137aa7ee1e82..2fdec6122b411 100644 --- a/components/clicktime/actions/create-user/create-user.mjs +++ b/components/clicktime/actions/create-user/create-user.mjs @@ -13,24 +13,28 @@ export default { app, "billingRate", ], + description: "The billing rate for the user", }, isActive: { propDefinition: [ app, "isActive", ], + description: "Indicates whether the user is currently active", }, name: { propDefinition: [ app, "name", ], + description: "The name of the user", }, startDate: { propDefinition: [ app, "startDate", ], + description: "The start date of the user, i.e.: `2020-01-01`", }, costModel: { propDefinition: [ diff --git a/components/clicktime/clicktime.app.mjs b/components/clicktime/clicktime.app.mjs index e8198166c1a37..5a78fba995718 100644 --- a/components/clicktime/clicktime.app.mjs +++ b/components/clicktime/clicktime.app.mjs @@ -1,4 +1,5 @@ import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; export default { type: "app", @@ -12,7 +13,7 @@ export default { billingRate: { type: "string", label: "Billing Rate", - description: "The billing rate for the client, job, or user", + description: "", }, clientNumber: { type: "string", @@ -22,7 +23,7 @@ export default { isActive: { type: "boolean", label: "Is Active", - description: "Indicates whether the entity (client, job, or user) is currently active", + description: "", }, isEligibleTimeOffAllocation: { type: "boolean", @@ -32,12 +33,12 @@ export default { name: { type: "string", label: "Name", - description: "The name of the client, job, or user", + description: "", }, notes: { type: "string", label: "Notes", - description: "Additional information related to the entity", + description: "", }, shortName: { type: "string", @@ -62,7 +63,7 @@ export default { endDate: { type: "string", label: "End Date", - description: "The end date of the job or user, i.e.: `2021-01-01`", + description: "The end date of the job, i.e.: `2020-01-01`", }, includeInRm: { type: "boolean", @@ -82,7 +83,7 @@ export default { startDate: { type: "string", label: "Start Date", - description: "The start date of the job or user, i.e.: `2020-01-01`", + description: "", }, timeRequiresApproval: { type: "boolean", @@ -97,11 +98,8 @@ export default { costModel: { type: "string", label: "Cost Model", - description: "Defines the cost model used for the user, such as 'Hourly' or 'Fixed'", - options: [ - "Hourly", - "Salary", - ], + description: "Defines the cost model used for the user", + options: constants.COST_MODELS, }, costRate: { type: "string", diff --git a/components/clicktime/common/constants.mjs b/components/clicktime/common/constants.mjs new file mode 100644 index 0000000000000..df00f9757a1e6 --- /dev/null +++ b/components/clicktime/common/constants.mjs @@ -0,0 +1,6 @@ +export default { + COST_MODELS: [ + "Hourly", + "Salary", + ], +}; From cf76d487af0a9dda5fd785b2801d69852482079b Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 25 Feb 2025 15:45:25 -0300 Subject: [PATCH 3/5] Done requests changes --- .../actions/create-client/create-client.mjs | 6 ++ .../actions/create-job/create-job.mjs | 31 +++++++++- .../actions/create-user/create-user.mjs | 25 ++++++++ components/clicktime/clicktime.app.mjs | 57 +++++++++++++++---- 4 files changed, 106 insertions(+), 13 deletions(-) diff --git a/components/clicktime/actions/create-client/create-client.mjs b/components/clicktime/actions/create-client/create-client.mjs index 9080daed3f0b3..4829c8a826c2c 100644 --- a/components/clicktime/actions/create-client/create-client.mjs +++ b/components/clicktime/actions/create-client/create-client.mjs @@ -13,12 +13,14 @@ export default { app, "clientNumber", ], + optional: true, }, accountingPackageId: { propDefinition: [ app, "accountingPackageId", ], + optional: true, }, billingRate: { propDefinition: [ @@ -26,6 +28,7 @@ export default { "billingRate", ], description: "The billing rate for the client", + optional: true, }, isActive: { propDefinition: [ @@ -33,6 +36,7 @@ export default { "isActive", ], description: "Indicates whether the client is currently active", + optional: true, }, isEligibleTimeOffAllocation: { propDefinition: [ @@ -40,6 +44,7 @@ export default { "isEligibleTimeOffAllocation", ], description: "Determines if the client is eligible for time-off allocation", + optional: true, }, name: { propDefinition: [ @@ -54,6 +59,7 @@ export default { "notes", ], description: "Additional information related to the client", + optional: true, }, shortName: { propDefinition: [ diff --git a/components/clicktime/actions/create-job/create-job.mjs b/components/clicktime/actions/create-job/create-job.mjs index b1a9efb9b13c0..355a42db3f5b2 100644 --- a/components/clicktime/actions/create-job/create-job.mjs +++ b/components/clicktime/actions/create-job/create-job.mjs @@ -13,6 +13,7 @@ export default { app, "accountingPackageId", ], + optional: true, }, billingRate: { propDefinition: [ @@ -20,6 +21,7 @@ export default { "billingRate", ], description: "The billing rate for the job", + optional: true, }, isActive: { propDefinition: [ @@ -27,13 +29,15 @@ export default { "isActive", ], description: "Indicates whether the job is currently active", + optional: true, }, isEligibleTimeOffAllocation: { propDefinition: [ app, "isEligibleTimeOffAllocation", ], - description: "Determines if the client is eligible for time-off allocation", + description: "Determines if the job is eligible for time-off allocation", + optional: true, }, name: { propDefinition: [ @@ -48,11 +52,30 @@ export default { "notes", ], description: "Additional information related to the job", + optional: true, + }, + limit: { + propDefinition: [ + app, + "limit", + ], + optional: true, + }, + offset: { + propDefinition: [ + app, + "offset", + ], + optional: true, }, clientId: { propDefinition: [ app, "clientId", + (c) => ({ + offset: c.offset, + limit: c.limit, + }), ], }, includeInRm: { @@ -60,12 +83,14 @@ export default { app, "includeInRm", ], + optional: true, }, isBillable: { propDefinition: [ app, "isBillable", ], + optional: true, }, jobNumber: { propDefinition: [ @@ -79,24 +104,28 @@ export default { "startDate", ], description: "The start date of the job, i.e.: `2020-01-01`", + optional: true, }, endDate: { propDefinition: [ app, "endDate", ], + optional: true, }, timeRequiresApproval: { propDefinition: [ app, "timeRequiresApproval", ], + optional: true, }, useCompanyBillingRate: { propDefinition: [ app, "useCompanyBillingRate", ], + optional: true, }, }, async run({ $ }) { diff --git a/components/clicktime/actions/create-user/create-user.mjs b/components/clicktime/actions/create-user/create-user.mjs index 2fdec6122b411..4e6b9f30f7117 100644 --- a/components/clicktime/actions/create-user/create-user.mjs +++ b/components/clicktime/actions/create-user/create-user.mjs @@ -14,6 +14,7 @@ export default { "billingRate", ], description: "The billing rate for the user", + optional: true, }, isActive: { propDefinition: [ @@ -21,6 +22,7 @@ export default { "isActive", ], description: "Indicates whether the user is currently active", + optional: true, }, name: { propDefinition: [ @@ -35,18 +37,21 @@ export default { "startDate", ], description: "The start date of the user, i.e.: `2020-01-01`", + optional: true, }, costModel: { propDefinition: [ app, "costModel", ], + optional: true, }, costRate: { propDefinition: [ app, "costRate", ], + optional: true, }, email: { propDefinition: [ @@ -54,17 +59,37 @@ export default { "email", ], }, + limit: { + propDefinition: [ + app, + "limit", + ], + optional: true, + }, + offset: { + propDefinition: [ + app, + "offset", + ], + optional: true, + }, employmentTypeId: { propDefinition: [ app, "employmentTypeId", + (c) => ({ + offset: c.offset, + limit: c.limit, + }), ], + optional: true, }, role: { propDefinition: [ app, "role", ], + optional: true, }, }, async run({ $ }) { diff --git a/components/clicktime/clicktime.app.mjs b/components/clicktime/clicktime.app.mjs index 5a78fba995718..f9e4b38706ab2 100644 --- a/components/clicktime/clicktime.app.mjs +++ b/components/clicktime/clicktime.app.mjs @@ -13,7 +13,7 @@ export default { billingRate: { type: "string", label: "Billing Rate", - description: "", + description: "The billing rate for the user, job or client", }, clientNumber: { type: "string", @@ -23,7 +23,7 @@ export default { isActive: { type: "boolean", label: "Is Active", - description: "", + description: "Whether the user, job or client is currently active", }, isEligibleTimeOffAllocation: { type: "boolean", @@ -33,12 +33,12 @@ export default { name: { type: "string", label: "Name", - description: "", + description: "The name of the user, job or client", }, notes: { type: "string", label: "Notes", - description: "", + description: "Additional information related to the user, job or client", }, shortName: { type: "string", @@ -49,8 +49,13 @@ export default { type: "string", label: "Client ID", description: "Unique identifier of the client associated with a job", - async options() { - const response = await this.getClients(); + async options({ + limit, offset, + }) { + const response = await this.getClients({ + limit, + offset, + }); const clientIds = response.data; return clientIds.map(({ ID, Name, @@ -60,6 +65,18 @@ export default { })); }, }, + limit: { + type: "integer", + label: "Limit", + description: "The number of records to return", + optional: true, + }, + offset: { + type: "integer", + label: "Offset", + description: "The number of records to skip", + optional: true, + }, endDate: { type: "string", label: "End Date", @@ -83,7 +100,7 @@ export default { startDate: { type: "string", label: "Start Date", - description: "", + description: "Start date of the user or job, i.e.: `2020-01-01`", }, timeRequiresApproval: { type: "boolean", @@ -115,8 +132,13 @@ export default { type: "string", label: "Employment Type ID", description: "Unique identifier for the user's employment type", - async options() { - const response = await this.getEmploymentTypes(); + async options({ + limit, offset, + }) { + const response = await this.getEmploymentTypes({ + limit, + offset, + }); const employmentTypeIds = response.data; return employmentTypeIds.map(({ ID, Name, @@ -132,7 +154,6 @@ export default { description: "The role assigned to the user", }, }, - methods: { _baseUrl() { return "https://api.clicktime.com/v2"; @@ -174,15 +195,27 @@ export default { ...args, }); }, - async getClients(args = {}) { + async getClients({ + limit, offset, ...args + }) { return this._makeRequest({ path: "/Clients", + params: { + limit, + offset, + }, ...args, }); }, - async getEmploymentTypes(args = {}) { + async getEmploymentTypes({ + limit, offset, ...args + }) { return this._makeRequest({ path: "/EmploymentTypes", + params: { + limit, + offset, + }, ...args, }); }, From af3dba5b5dd7ebadc67a7394dd7944b22f8528d5 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 25 Feb 2025 14:58:22 -0500 Subject: [PATCH 4/5] prop pagination --- .../actions/create-job/create-job.mjs | 18 ------- .../actions/create-user/create-user.mjs | 18 ------- components/clicktime/clicktime.app.mjs | 50 ++++++------------- components/clicktime/common/constants.mjs | 1 + 4 files changed, 15 insertions(+), 72 deletions(-) diff --git a/components/clicktime/actions/create-job/create-job.mjs b/components/clicktime/actions/create-job/create-job.mjs index 355a42db3f5b2..547dd13e996c9 100644 --- a/components/clicktime/actions/create-job/create-job.mjs +++ b/components/clicktime/actions/create-job/create-job.mjs @@ -54,28 +54,10 @@ export default { description: "Additional information related to the job", optional: true, }, - limit: { - propDefinition: [ - app, - "limit", - ], - optional: true, - }, - offset: { - propDefinition: [ - app, - "offset", - ], - optional: true, - }, clientId: { propDefinition: [ app, "clientId", - (c) => ({ - offset: c.offset, - limit: c.limit, - }), ], }, includeInRm: { diff --git a/components/clicktime/actions/create-user/create-user.mjs b/components/clicktime/actions/create-user/create-user.mjs index 4e6b9f30f7117..6dc617df615ac 100644 --- a/components/clicktime/actions/create-user/create-user.mjs +++ b/components/clicktime/actions/create-user/create-user.mjs @@ -59,28 +59,10 @@ export default { "email", ], }, - limit: { - propDefinition: [ - app, - "limit", - ], - optional: true, - }, - offset: { - propDefinition: [ - app, - "offset", - ], - optional: true, - }, employmentTypeId: { propDefinition: [ app, "employmentTypeId", - (c) => ({ - offset: c.offset, - limit: c.limit, - }), ], optional: true, }, diff --git a/components/clicktime/clicktime.app.mjs b/components/clicktime/clicktime.app.mjs index f9e4b38706ab2..a03734d33cfcd 100644 --- a/components/clicktime/clicktime.app.mjs +++ b/components/clicktime/clicktime.app.mjs @@ -49,12 +49,13 @@ export default { type: "string", label: "Client ID", description: "Unique identifier of the client associated with a job", - async options({ - limit, offset, - }) { + async options({ page }) { + const limit = constants.DEFAULT_LIMIT; const response = await this.getClients({ - limit, - offset, + params: { + limit, + offset: page * limit, + }, }); const clientIds = response.data; return clientIds.map(({ @@ -65,18 +66,6 @@ export default { })); }, }, - limit: { - type: "integer", - label: "Limit", - description: "The number of records to return", - optional: true, - }, - offset: { - type: "integer", - label: "Offset", - description: "The number of records to skip", - optional: true, - }, endDate: { type: "string", label: "End Date", @@ -132,12 +121,13 @@ export default { type: "string", label: "Employment Type ID", description: "Unique identifier for the user's employment type", - async options({ - limit, offset, - }) { + async options({ page }) { + const limit = constants.DEFAULT_LIMIT; const response = await this.getEmploymentTypes({ - limit, - offset, + params: { + limit, + offset: page * limit, + }, }); const employmentTypeIds = response.data; return employmentTypeIds.map(({ @@ -195,27 +185,15 @@ export default { ...args, }); }, - async getClients({ - limit, offset, ...args - }) { + async getClients(args = {}) { return this._makeRequest({ path: "/Clients", - params: { - limit, - offset, - }, ...args, }); }, - async getEmploymentTypes({ - limit, offset, ...args - }) { + async getEmploymentTypes(args = {}) { return this._makeRequest({ path: "/EmploymentTypes", - params: { - limit, - offset, - }, ...args, }); }, diff --git a/components/clicktime/common/constants.mjs b/components/clicktime/common/constants.mjs index df00f9757a1e6..6d2c2b05b45ab 100644 --- a/components/clicktime/common/constants.mjs +++ b/components/clicktime/common/constants.mjs @@ -3,4 +3,5 @@ export default { "Hourly", "Salary", ], + DEFAULT_LIMIT: 20, }; From a850018dea21e69d69d6bf52f6aad8dd2e9143ac Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Tue, 25 Feb 2025 15:00:15 -0500 Subject: [PATCH 5/5] pnpm-lock.yaml --- pnpm-lock.yaml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c93fe15005da6..a6819885c5274 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -796,8 +796,7 @@ importers: specifier: ^8.3.2 version: 8.3.2 - components/anchor_browser: - specifiers: {} + components/anchor_browser: {} components/annature: {} @@ -3108,8 +3107,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/databricks_oauth: - specifiers: {} + components/databricks_oauth: {} components/datadog: dependencies: @@ -5568,8 +5566,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/griptape: - specifiers: {} + components/griptape: {} components/grist: dependencies: