@knpkv/clockify-api-client 0.3.0 → 1.0.1

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +92 -80
  3. package/dist/ClockifyApiClient.d.ts +44 -45
  4. package/dist/ClockifyApiClient.d.ts.map +1 -1
  5. package/dist/ClockifyApiClient.js +52 -121
  6. package/dist/ClockifyApiClient.js.map +1 -1
  7. package/dist/generated/ClockifyApi.d.ts +14432 -0
  8. package/dist/generated/ClockifyApi.d.ts.map +1 -0
  9. package/dist/generated/ClockifyApi.js +1239 -0
  10. package/dist/generated/ClockifyApi.js.map +1 -0
  11. package/dist/index.d.ts +4 -6
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -4
  14. package/dist/index.js.map +1 -1
  15. package/package.json +15 -21
  16. package/scripts/regenerate.ts +182 -201
  17. package/scripts/tsconfig.json +13 -0
  18. package/src/ClockifyApiClient.ts +125 -226
  19. package/src/generated/ClockifyApi.ts +3020 -0
  20. package/src/index.ts +10 -14
  21. package/test/ClockifyApiClient.test.ts +195 -0
  22. package/vitest.config.ts +7 -0
  23. package/.specs/VERSION +0 -1
  24. package/.specs/clockify-v1.json +0 -31670
  25. package/.specs/clockify-v1.patch.json +0 -48
  26. package/dist/ClockifyApiError.d.ts +0 -11
  27. package/dist/ClockifyApiError.d.ts.map +0 -1
  28. package/dist/ClockifyApiError.js +0 -14
  29. package/dist/ClockifyApiError.js.map +0 -1
  30. package/dist/OpenApiFetchClient.d.ts +0 -55
  31. package/dist/OpenApiFetchClient.d.ts.map +0 -1
  32. package/dist/OpenApiFetchClient.js +0 -63
  33. package/dist/OpenApiFetchClient.js.map +0 -1
  34. package/dist/generated/index.d.ts +0 -2
  35. package/dist/generated/index.d.ts.map +0 -1
  36. package/dist/generated/index.js +0 -2
  37. package/dist/generated/index.js.map +0 -1
  38. package/dist/generated/schema.d.ts +0 -16204
  39. package/src/ClockifyApiError.ts +0 -17
  40. package/src/OpenApiFetchClient.ts +0 -92
  41. package/src/generated/index.ts +0 -1
  42. package/src/generated/schema.d.ts +0 -16204
  43. package/tsconfig.tsbuildinfo +0 -1
@@ -1,48 +0,0 @@
1
- {
2
- "$comment": "Patches for clockify-v1.json — the official spec has incomplete DTOs. Applied by scripts/regenerate.ts before generating types.",
3
- "schemas": {
4
- "UserDto": {
5
- "addProperties": {
6
- "activeWorkspace": { "type": "string" },
7
- "defaultWorkspace": { "type": "string" },
8
- "profilePicture": { "type": "string" },
9
- "status": { "type": "string" }
10
- },
11
- "required": ["id", "name", "email", "activeWorkspace", "defaultWorkspace", "status"]
12
- },
13
- "TimeEntryDto": {
14
- "renameProperties": {
15
- "get_id": "id"
16
- },
17
- "addProperties": {
18
- "workspaceId": { "type": "string" },
19
- "type": { "type": "string" },
20
- "isLocked": { "type": "boolean" },
21
- "tagIds": { "type": "array", "items": { "type": "string" } }
22
- },
23
- "required": ["id", "description", "billable", "userId", "workspaceId", "timeInterval"]
24
- },
25
- "TimeIntervalDto": {
26
- "required": ["start"],
27
- "patchProperties": {
28
- "end": { "type": "string", "format": "date-time", "nullable": true },
29
- "duration": { "type": "string", "nullable": true }
30
- }
31
- },
32
- "TagDto": {
33
- "required": ["id", "name", "workspaceId", "archived"]
34
- },
35
- "ProjectDtoV1": {
36
- "addProperties": {
37
- "name": { "type": "string" },
38
- "note": { "type": "string" },
39
- "workspaceId": { "type": "string" },
40
- "public": { "type": "boolean" }
41
- },
42
- "required": ["id", "name", "archived", "billable", "color", "workspaceId"]
43
- },
44
- "CreateTimeEntryRequest": {
45
- "required": ["description", "start"]
46
- }
47
- }
48
- }
@@ -1,11 +0,0 @@
1
- declare const ClockifyApiError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
2
- readonly _tag: "ClockifyApiError";
3
- } & Readonly<A>;
4
- export declare class ClockifyApiError extends ClockifyApiError_base<{
5
- readonly status: number;
6
- readonly message: string;
7
- readonly cause?: unknown;
8
- }> {
9
- }
10
- export {};
11
- //# sourceMappingURL=ClockifyApiError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClockifyApiError.d.ts","sourceRoot":"","sources":["../src/ClockifyApiError.ts"],"names":[],"mappings":";;;AAYA,qBAAa,gBAAiB,SAAQ,sBAAqC;IACzE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC;CAAG"}
@@ -1,14 +0,0 @@
1
- /**
2
- * Tagged error for Clockify API failures.
3
- *
4
- * **Mental model**
5
- *
6
- * - **Catch by tag**: `Effect.catchTag("ClockifyApiError", ...)` handles all API errors.
7
- * The `status` field distinguishes HTTP errors (>0) from network errors (0).
8
- *
9
- * @module
10
- */
11
- import * as Data from "effect/Data";
12
- export class ClockifyApiError extends Data.TaggedError("ClockifyApiError") {
13
- }
14
- //# sourceMappingURL=ClockifyApiError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ClockifyApiError.js","sourceRoot":"","sources":["../src/ClockifyApiError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AAEnC,MAAM,OAAO,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAIvE;CAAG"}
@@ -1,55 +0,0 @@
1
- import * as Effect from "effect/Effect";
2
- import { type Client, type FetchResponse } from "openapi-fetch";
3
- import type { MediaType } from "openapi-typescript-helpers";
4
- declare const FetchClientError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
5
- readonly _tag: "FetchClientError";
6
- } & Readonly<A>;
7
- /**
8
- * Error from openapi-fetch operations.
9
- *
10
- * @category Errors
11
- */
12
- export declare class FetchClientError extends FetchClientError_base<{
13
- readonly error: unknown;
14
- readonly status: number;
15
- readonly message: string;
16
- }> {
17
- }
18
- /** Extract success `data` from a FetchResponse discriminated union. */
19
- export type SuccessData<T> = T extends {
20
- data: infer D;
21
- error?: undefined;
22
- } ? D : T extends {
23
- data?: infer D;
24
- } ? NonNullable<D> : never;
25
- /**
26
- * Wrap an openapi-fetch `Promise<FetchResponse>` in Effect.
27
- *
28
- * Extracts `data` on success, maps errors to `FetchClientError`.
29
- * Fully type-safe — path/body constraints come from the `Client<Paths>` call site.
30
- *
31
- * @example
32
- * ```typescript
33
- * const page = yield* toEffect(client.GET("/pages/{id}", { params: { path: { id: 123 } } }))
34
- * ```
35
- *
36
- * @category Utilities
37
- */
38
- export declare const toEffect: <T extends Record<string | number, any>, O, M extends MediaType>(promise: Promise<FetchResponse<T, O, M>>) => Effect.Effect<SuccessData<FetchResponse<T, O, M>>, FetchClientError>;
39
- /**
40
- * openapi-fetch client paired with the `toEffect` helper.
41
- *
42
- * @category Client
43
- */
44
- export interface OpenApiFetchClient<Paths extends {}> {
45
- /** Type-safe openapi-fetch client. Use with `toEffect()` to get Effect. */
46
- readonly client: Client<Paths, "application/json">;
47
- }
48
- /**
49
- * Create an openapi-fetch client with auth headers pre-configured.
50
- *
51
- * @category Constructors
52
- */
53
- export declare const makeOpenApiFetchClient: <Paths extends {}>(baseUrl: string, headers: Record<string, string>) => OpenApiFetchClient<Paths>;
54
- export {};
55
- //# sourceMappingURL=OpenApiFetchClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OpenApiFetchClient.d.ts","sourceRoot":"","sources":["../src/OpenApiFetchClient.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAqB,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7E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+0,0 @@
1
- /**
2
- * Generic Effect wrapper for openapi-fetch clients.
3
- *
4
- * Exposes a type-safe `Client<Paths>` and a `toEffect` helper that wraps
5
- * any `Promise<FetchResponse>` in Effect with error mapping.
6
- *
7
- * @example
8
- * ```typescript
9
- * const page = yield* toEffect(client.GET("/pages/{id}", {
10
- * params: { path: { id: 123 } }
11
- * }))
12
- * ```
13
- *
14
- * @module
15
- */
16
- import * as Data from "effect/Data";
17
- import * as Effect from "effect/Effect";
18
- import createClient, {} from "openapi-fetch";
19
- /**
20
- * Error from openapi-fetch operations.
21
- *
22
- * @category Errors
23
- */
24
- export class FetchClientError extends Data.TaggedError("FetchClientError") {
25
- }
26
- /**
27
- * Wrap an openapi-fetch `Promise<FetchResponse>` in Effect.
28
- *
29
- * Extracts `data` on success, maps errors to `FetchClientError`.
30
- * Fully type-safe — path/body constraints come from the `Client<Paths>` call site.
31
- *
32
- * @example
33
- * ```typescript
34
- * const page = yield* toEffect(client.GET("/pages/{id}", { params: { path: { id: 123 } } }))
35
- * ```
36
- *
37
- * @category Utilities
38
- */
39
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches FetchResponse generic constraint
40
- export const toEffect = (promise) => Effect.tryPromise({
41
- try: () => promise.then(({ data, error, response }) => {
42
- if (error !== undefined || !response.ok) {
43
- throw { error, status: response.status };
44
- }
45
- return data;
46
- }),
47
- catch: (e) => new FetchClientError({
48
- error: e.error ?? e,
49
- status: e.status ?? 0,
50
- message: typeof e.error === "string"
51
- ? e.error
52
- : JSON.stringify(e.error ?? e)
53
- })
54
- });
55
- /**
56
- * Create an openapi-fetch client with auth headers pre-configured.
57
- *
58
- * @category Constructors
59
- */
60
- export const makeOpenApiFetchClient = (baseUrl, headers) => ({
61
- client: createClient({ baseUrl, headers })
62
- });
63
- //# sourceMappingURL=OpenApiFetchClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OpenApiFetchClient.js","sourceRoot":"","sources":["../src/OpenApiFetchClient.ts"],"names":[],"m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AAO,EAAE,OAAO,EAAE,CAAC;CACtE,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export type { paths, components, operations } from "./schema.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":""}