@knpkv/clockify-api-client 1.0.3 → 2.0.0
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 +39 -0
- package/dist/ClockifyApiClient.d.ts +4 -4
- package/dist/ClockifyApiClient.d.ts.map +1 -1
- package/dist/ClockifyApiClient.js +9 -9
- package/dist/ClockifyApiClient.js.map +1 -1
- package/dist/ClockifyApiConfig.d.ts +2 -2
- package/dist/ClockifyApiConfig.d.ts.map +1 -1
- package/dist/ClockifyApiConfig.js.map +1 -1
- package/dist/generated/ClockifyApi.d.ts +5165 -4178
- package/dist/generated/ClockifyApi.d.ts.map +1 -1
- package/dist/generated/ClockifyApi.js +336 -329
- package/dist/generated/ClockifyApi.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/scripts/regenerate.ts +10 -8
- package/src/ClockifyApiClient.ts +12 -12
- package/src/ClockifyApiConfig.ts +2 -2
- package/src/generated/ClockifyApi.ts +570 -544
- package/src/index.ts +2 -2
- package/test/ClockifyApiClient.test.ts +166 -215
- package/test/CustomFieldValues.test.ts +18 -0
- package/test/GeneratedSchemas.test.ts +60 -0
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
export { ClockifyApiClient, type
|
|
6
|
+
export { ClockifyApiClient, type ClockifyApiClientContract, type ClockifyClientError, layer, make } from "./ClockifyApiClient.js";
|
|
7
7
|
export type { AuthenticatedClockifyApi, CreateTimeEntryParams, GetTimeEntriesParams, GetTimeEntryParams, Project, StopTimeEntryParams, Tag, TimeEntry, TimeInterval, UpdateTimeEntryParams, User, Workspace, WorkspaceUser } from "./ClockifyApiClient.js";
|
|
8
|
-
export { ClockifyApiConfig, type
|
|
8
|
+
export { ClockifyApiConfig, type ClockifyApiConfigContract } 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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,EACjB,KAAK,yBAAyB,EAC9B,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,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAE1F,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;AAkB/B,OAAO,EAAE,iBAAiB,
|
|
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,EAAkC,MAAM,wBAAwB,CAAA;AAE1F,OAAO,KAAK,WAAW,MAAM,4BAA4B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knpkv/clockify-api-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Effect-based Clockify REST API client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "knpkv",
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"effect": "4.0.0
|
|
38
|
+
"effect": "4.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@effect/openapi-generator": "4.0.0
|
|
42
|
-
"@effect/platform-node": "4.0.0
|
|
43
|
-
"@effect/vitest": "4.0.0
|
|
41
|
+
"@effect/openapi-generator": "4.0.0",
|
|
42
|
+
"@effect/platform-node": "4.0.0",
|
|
43
|
+
"@effect/vitest": "4.0.0",
|
|
44
44
|
"@types/node": "latest",
|
|
45
|
-
"effect": "4.0.0
|
|
46
|
-
"prettier": "^3.9.
|
|
47
|
-
"tsx": "^4.23.
|
|
48
|
-
"typescript": "
|
|
49
|
-
"vitest": "^
|
|
45
|
+
"effect": "4.0.0",
|
|
46
|
+
"prettier": "^3.9.9",
|
|
47
|
+
"tsx": "^4.23.15",
|
|
48
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
49
|
+
"vitest": "^5.0.3"
|
|
50
50
|
},
|
|
51
51
|
"keywords": [
|
|
52
52
|
"effect",
|
package/scripts/regenerate.ts
CHANGED
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
import * as OpenApiGenerator from "@effect/openapi-generator/OpenApiGenerator"
|
|
9
9
|
import * as OpenApiPatch from "@effect/openapi-generator/OpenApiPatch"
|
|
10
10
|
import { NodeHttpClient, NodeRuntime, NodeServices } from "@effect/platform-node"
|
|
11
|
+
import * as Command from "effect/cli/Command"
|
|
12
|
+
import * as Flag from "effect/cli/Flag"
|
|
11
13
|
import * as Console from "effect/Console"
|
|
12
14
|
import * as Data from "effect/Data"
|
|
13
15
|
import * as Effect from "effect/Effect"
|
|
14
16
|
import * as FileSystem from "effect/FileSystem"
|
|
17
|
+
import type { OpenAPISpec } from "effect/http-api/OpenApi"
|
|
18
|
+
import * as HttpClient from "effect/http/HttpClient"
|
|
15
19
|
import type * as JsonSchema from "effect/JsonSchema"
|
|
16
20
|
import * as Layer from "effect/Layer"
|
|
17
21
|
import * as Path from "effect/Path"
|
|
18
22
|
import * as Predicate from "effect/Predicate"
|
|
19
23
|
import * as Schema from "effect/Schema"
|
|
20
|
-
import * as Command from "effect/unstable/cli/Command"
|
|
21
|
-
import * as Flag from "effect/unstable/cli/Flag"
|
|
22
|
-
import * as HttpClient from "effect/unstable/http/HttpClient"
|
|
23
|
-
import type { OpenAPISpec } from "effect/unstable/httpapi/OpenApi"
|
|
24
24
|
import { format as formatSource } from "prettier"
|
|
25
25
|
|
|
26
26
|
const SPEC_URL = "https://docs.clockify.me/openapi.json"
|
|
@@ -169,12 +169,14 @@ const generate = Effect.fn("Clockify.regenerate.generate")(function*(
|
|
|
169
169
|
)
|
|
170
170
|
})
|
|
171
171
|
|
|
172
|
-
const check = Flag.
|
|
173
|
-
Flag.withDescription("Exit non-zero when the committed upstream spec differs from Clockify")
|
|
172
|
+
const check = Flag.Boolean("check").pipe(
|
|
173
|
+
Flag.withDescription("Exit non-zero when the committed upstream spec differs from Clockify"),
|
|
174
|
+
Flag.withDefault(false)
|
|
174
175
|
)
|
|
175
176
|
|
|
176
|
-
const local = Flag.
|
|
177
|
-
Flag.withDescription("Regenerate from the committed spec without contacting Clockify")
|
|
177
|
+
const local = Flag.Boolean("local").pipe(
|
|
178
|
+
Flag.withDescription("Regenerate from the committed spec without contacting Clockify"),
|
|
179
|
+
Flag.withDefault(false)
|
|
178
180
|
)
|
|
179
181
|
|
|
180
182
|
const root = Command.make("clockify-api-regenerate", { check, local }).pipe(
|
package/src/ClockifyApiClient.ts
CHANGED
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
import * as Context from "effect/Context"
|
|
11
11
|
import * as Effect from "effect/Effect"
|
|
12
12
|
import { flow } from "effect/Function"
|
|
13
|
+
import * as HttpClient from "effect/http/HttpClient"
|
|
14
|
+
import type * as HttpClientError from "effect/http/HttpClientError"
|
|
15
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest"
|
|
16
|
+
import * as HttpClientResponse from "effect/http/HttpClientResponse"
|
|
13
17
|
import * as Layer from "effect/Layer"
|
|
14
18
|
import * as Redacted from "effect/Redacted"
|
|
15
19
|
import type { SchemaError } from "effect/Schema"
|
|
16
|
-
import * as HttpClient from "effect/unstable/http/HttpClient"
|
|
17
|
-
import type * as HttpClientError from "effect/unstable/http/HttpClientError"
|
|
18
|
-
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest"
|
|
19
|
-
import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse"
|
|
20
20
|
import { ClockifyApiConfig } from "./ClockifyApiConfig.js"
|
|
21
21
|
import * as Generated from "./generated/ClockifyApi.js"
|
|
22
22
|
|
|
@@ -49,7 +49,7 @@ export interface GetTimeEntryParams {
|
|
|
49
49
|
readonly hydrated?: boolean | undefined
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export interface
|
|
52
|
+
export interface ClockifyApiClientContract {
|
|
53
53
|
readonly getUser: () => Effect.Effect<User, ClockifyClientError>
|
|
54
54
|
readonly getWorkspaceUsers?: (
|
|
55
55
|
workspaceId: string
|
|
@@ -127,7 +127,7 @@ export const make = (
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
export class ClockifyApiClient extends Context.Service<ClockifyApiClient,
|
|
130
|
+
export class ClockifyApiClient extends Context.Service<ClockifyApiClient, ClockifyApiClientContract>()(
|
|
131
131
|
"@knpkv/clockify-api-client/ClockifyApiClient"
|
|
132
132
|
) {
|
|
133
133
|
static readonly layer: Layer.Layer<ClockifyApiClient, never, ClockifyApiConfig | HttpClient.HttpClient> = Layer
|
|
@@ -187,11 +187,11 @@ export class ClockifyApiClient extends Context.Service<ClockifyApiClient, Clocki
|
|
|
187
187
|
getTimeEntries: (workspaceId, userId, params) =>
|
|
188
188
|
api.getTimeEntries(workspaceId, userId, {
|
|
189
189
|
params: {
|
|
190
|
-
...(params?.start !== undefined
|
|
191
|
-
...(params?.end !== undefined
|
|
192
|
-
...(params?.hydrated === undefined
|
|
193
|
-
...(params?.page !== undefined
|
|
194
|
-
...(params?.pageSize !== undefined
|
|
190
|
+
...((params?.start !== undefined) && { start: params.start }),
|
|
191
|
+
...((params?.end !== undefined) && { end: params.end }),
|
|
192
|
+
...(!(params?.hydrated === undefined) && { hydrated: params.hydrated }),
|
|
193
|
+
...((params?.page !== undefined) && { page: params.page }),
|
|
194
|
+
...((params?.pageSize !== undefined) && { "page-size": params.pageSize })
|
|
195
195
|
}
|
|
196
196
|
}),
|
|
197
197
|
getRunningTimer: (workspaceId, userId) =>
|
|
@@ -212,7 +212,7 @@ export class ClockifyApiClient extends Context.Service<ClockifyApiClient, Clocki
|
|
|
212
212
|
getTimeEntry: (workspaceId, timeEntryId, params) =>
|
|
213
213
|
api.getTimeEntry(workspaceId, timeEntryId, {
|
|
214
214
|
params: {
|
|
215
|
-
...(params?.hydrated === undefined
|
|
215
|
+
...(!(params?.hydrated === undefined) && { hydrated: params.hydrated })
|
|
216
216
|
}
|
|
217
217
|
}),
|
|
218
218
|
deleteTimeEntry: (workspaceId, timeEntryId) => api.deleteTimeEntry(workspaceId, timeEntryId, undefined),
|
package/src/ClockifyApiConfig.ts
CHANGED
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
import * as Context from "effect/Context"
|
|
14
14
|
import type * as Redacted from "effect/Redacted"
|
|
15
15
|
|
|
16
|
-
export interface
|
|
16
|
+
export interface ClockifyApiConfigContract {
|
|
17
17
|
readonly apiKey: Redacted.Redacted<string>
|
|
18
18
|
readonly workspaceId: string
|
|
19
19
|
readonly userId: string
|
|
20
20
|
readonly baseUrl: string
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export class ClockifyApiConfig extends Context.Service<ClockifyApiConfig,
|
|
23
|
+
export class ClockifyApiConfig extends Context.Service<ClockifyApiConfig, ClockifyApiConfigContract>()(
|
|
24
24
|
"@knpkv/clockify-api-client/ClockifyApiConfig"
|
|
25
25
|
) {}
|