@knpkv/clockify-api-client 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/ClockifyApiClient.d.ts +8 -1
- package/dist/ClockifyApiClient.d.ts.map +1 -1
- package/dist/ClockifyApiClient.js +31 -1
- package/dist/ClockifyApiClient.js.map +1 -1
- package/dist/generated/ClockifyApi.d.ts +502 -132
- package/dist/generated/ClockifyApi.d.ts.map +1 -1
- package/dist/generated/ClockifyApi.js +65 -19
- package/dist/generated/ClockifyApi.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ClockifyApiClient.ts +51 -2
- package/src/generated/ClockifyApi.ts +150 -37
- package/src/index.ts +3 -1
- package/test/ClockifyApiClient.test.ts +101 -0
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
export { ClockifyApiClient, type ClockifyApiClientShape, type ClockifyClientError, layer, make } from "./ClockifyApiClient.js";
|
|
7
|
-
export type { AuthenticatedClockifyApi, CreateTimeEntryParams, GetTimeEntriesParams, Project, StopTimeEntryParams, Tag, TimeEntry, TimeInterval, UpdateTimeEntryParams, User, Workspace } from "./ClockifyApiClient.js";
|
|
7
|
+
export type { AuthenticatedClockifyApi, CreateTimeEntryParams, GetTimeEntriesParams, GetTimeEntryParams, Project, StopTimeEntryParams, Tag, TimeEntry, TimeInterval, UpdateTimeEntryParams, User, Workspace, WorkspaceUser } from "./ClockifyApiClient.js";
|
|
8
8
|
export { ClockifyApiConfig, type ClockifyApiConfigShape } from "./ClockifyApiConfig.js";
|
|
9
9
|
export * as ClockifyApi from "./generated/ClockifyApi.js";
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,EACL,IAAI,EACL,MAAM,wBAAwB,CAAA;AAE/B,YAAY,EACV,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,OAAO,EACP,mBAAmB,EACnB,GAAG,EACH,SAAS,EACT,YAAY,EACZ,qBAAqB,EACrB,IAAI,EACJ,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,EACL,IAAI,EACL,MAAM,wBAAwB,CAAA;AAE/B,YAAY,EACV,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,OAAO,EACP,mBAAmB,EACnB,GAAG,EACH,SAAS,EACT,YAAY,EACZ,qBAAqB,EACrB,IAAI,EACJ,SAAS,EACT,aAAa,EACd,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAEvF,OAAO,KAAK,WAAW,MAAM,4BAA4B,CAAA"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,EAGjB,KAAK,EACL,IAAI,EACL,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,EAGjB,KAAK,EACL,IAAI,EACL,MAAM,wBAAwB,CAAA;AAkB/B,OAAO,EAAE,iBAAiB,EAA+B,MAAM,wBAAwB,CAAA;AAEvF,OAAO,KAAK,WAAW,MAAM,4BAA4B,CAAA"}
|
package/package.json
CHANGED
package/src/ClockifyApiClient.ts
CHANGED
|
@@ -23,6 +23,7 @@ import * as Generated from "./generated/ClockifyApi.js"
|
|
|
23
23
|
export type ClockifyClientError = HttpClientError.HttpClientError | SchemaError
|
|
24
24
|
|
|
25
25
|
export type User = Generated.GetLoggedUser200
|
|
26
|
+
export type WorkspaceUser = Generated.GetUsersOfWorkspace200[number]
|
|
26
27
|
export type Workspace = Generated.GetWorkspacesOfUser200[number]
|
|
27
28
|
export type Project = Generated.GetProjects200[number]
|
|
28
29
|
export type Tag = Generated.GetTags200[number]
|
|
@@ -39,12 +40,25 @@ export type AuthenticatedClockifyApi = Omit<Generated.ClockifyApi, "uploadImage"
|
|
|
39
40
|
export interface GetTimeEntriesParams {
|
|
40
41
|
readonly start?: string | undefined
|
|
41
42
|
readonly end?: string | undefined
|
|
43
|
+
readonly hydrated?: boolean | undefined
|
|
42
44
|
readonly page?: number | undefined
|
|
43
45
|
readonly pageSize?: number | undefined
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
export interface GetTimeEntryParams {
|
|
49
|
+
readonly hydrated?: boolean | undefined
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
export interface ClockifyApiClientShape {
|
|
47
53
|
readonly getUser: () => Effect.Effect<User, ClockifyClientError>
|
|
54
|
+
readonly getWorkspaceUsers?: (
|
|
55
|
+
workspaceId: string
|
|
56
|
+
) => Effect.Effect<ReadonlyArray<WorkspaceUser>, ClockifyClientError>
|
|
57
|
+
readonly getWorkspaceUsersPage?: (
|
|
58
|
+
workspaceId: string,
|
|
59
|
+
page: number,
|
|
60
|
+
pageSize: number
|
|
61
|
+
) => Effect.Effect<ReadonlyArray<WorkspaceUser>, ClockifyClientError>
|
|
48
62
|
readonly getWorkspaces: () => Effect.Effect<ReadonlyArray<Workspace>, ClockifyClientError>
|
|
49
63
|
readonly getProjects: (workspaceId: string) => Effect.Effect<ReadonlyArray<Project>, ClockifyClientError>
|
|
50
64
|
readonly getProjectByName: (workspaceId: string, name: string) => Effect.Effect<Project | null, ClockifyClientError>
|
|
@@ -77,7 +91,8 @@ export interface ClockifyApiClientShape {
|
|
|
77
91
|
) => Effect.Effect<Generated.GetTags200[number] | Generated.CreateNewTag201, ClockifyClientError>
|
|
78
92
|
readonly getTimeEntry: (
|
|
79
93
|
workspaceId: string,
|
|
80
|
-
timeEntryId: string
|
|
94
|
+
timeEntryId: string,
|
|
95
|
+
params?: GetTimeEntryParams
|
|
81
96
|
) => Effect.Effect<Generated.GetTimeEntry200, ClockifyClientError>
|
|
82
97
|
readonly deleteTimeEntry: (workspaceId: string, timeEntryId: string) => Effect.Effect<void, ClockifyClientError>
|
|
83
98
|
readonly updateTimeEntry: (
|
|
@@ -129,8 +144,36 @@ export class ClockifyApiClient extends Context.Service<ClockifyApiClient, Clocki
|
|
|
129
144
|
const getTags = (workspaceId: string) =>
|
|
130
145
|
api.getTags(workspaceId, { params: { archived: false, "page-size": 200 } })
|
|
131
146
|
|
|
147
|
+
const getWorkspaceUsersPage = Effect.fn("ClockifyApiClient.getWorkspaceUsersPage")(function*(
|
|
148
|
+
workspaceId: string,
|
|
149
|
+
page: number,
|
|
150
|
+
pageSize: number
|
|
151
|
+
) {
|
|
152
|
+
return yield* api.getUsersOfWorkspace(workspaceId, {
|
|
153
|
+
params: {
|
|
154
|
+
"account-statuses": "ACTIVE,PENDING_EMAIL_VERIFICATION,DELETED,NOT_REGISTERED,LIMITED,LIMITED_DELETED",
|
|
155
|
+
"include-roles": "false",
|
|
156
|
+
memberships: "ALL",
|
|
157
|
+
page,
|
|
158
|
+
"page-size": pageSize,
|
|
159
|
+
status: "ALL"
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
const getWorkspaceUsers = Effect.fn("ClockifyApiClient.getWorkspaceUsers")(function*(workspaceId: string) {
|
|
164
|
+
const users: Array<WorkspaceUser> = []
|
|
165
|
+
for (let page = 1;; page++) {
|
|
166
|
+
const batch = yield* getWorkspaceUsersPage(workspaceId, page, 500)
|
|
167
|
+
for (const user of batch) users.push(user)
|
|
168
|
+
if (batch.length < 500) break
|
|
169
|
+
}
|
|
170
|
+
return users
|
|
171
|
+
})
|
|
172
|
+
|
|
132
173
|
return ClockifyApiClient.of({
|
|
133
174
|
getUser: () => api.getLoggedUser(undefined),
|
|
175
|
+
getWorkspaceUsers,
|
|
176
|
+
getWorkspaceUsersPage,
|
|
134
177
|
getWorkspaces: () => api.getWorkspacesOfUser(undefined),
|
|
135
178
|
getProjects,
|
|
136
179
|
getProjectByName: (workspaceId, name) =>
|
|
@@ -146,6 +189,7 @@ export class ClockifyApiClient extends Context.Service<ClockifyApiClient, Clocki
|
|
|
146
189
|
params: {
|
|
147
190
|
...(params?.start !== undefined ? { start: params.start } : {}),
|
|
148
191
|
...(params?.end !== undefined ? { end: params.end } : {}),
|
|
192
|
+
...(params?.hydrated === undefined ? {} : { hydrated: params.hydrated }),
|
|
149
193
|
...(params?.page !== undefined ? { page: params.page } : {}),
|
|
150
194
|
...(params?.pageSize !== undefined ? { "page-size": params.pageSize } : {})
|
|
151
195
|
}
|
|
@@ -165,7 +209,12 @@ export class ClockifyApiClient extends Context.Service<ClockifyApiClient, Clocki
|
|
|
165
209
|
: Effect.succeed(existing)
|
|
166
210
|
})
|
|
167
211
|
),
|
|
168
|
-
getTimeEntry: (workspaceId, timeEntryId) =>
|
|
212
|
+
getTimeEntry: (workspaceId, timeEntryId, params) =>
|
|
213
|
+
api.getTimeEntry(workspaceId, timeEntryId, {
|
|
214
|
+
params: {
|
|
215
|
+
...(params?.hydrated === undefined ? {} : { hydrated: params.hydrated })
|
|
216
|
+
}
|
|
217
|
+
}),
|
|
169
218
|
deleteTimeEntry: (workspaceId, timeEntryId) => api.deleteTimeEntry(workspaceId, timeEntryId, undefined),
|
|
170
219
|
updateTimeEntry: (workspaceId, timeEntryId, payload) =>
|
|
171
220
|
api.updateTimeEntry(workspaceId, timeEntryId, { payload })
|