@upvoiced/sdk 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +133 -2
- package/dist/client.d.ts +54 -0
- package/dist/client.js +209 -0
- package/dist/errors.d.ts +43 -0
- package/dist/errors.js +64 -0
- package/dist/generated/schema.d.ts +54413 -0
- package/dist/generated/schema.js +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +6 -0
- package/dist/types.d.ts +91 -0
- package/dist/types.js +1 -0
- package/package.json +39 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated from the UpVoiced API OpenAPI document (version 0.1.0)
|
|
3
|
+
* by openapi-typescript. Do not edit by hand (P2-015, ADR-0067):
|
|
4
|
+
* run `pnpm --filter @upvoiced/sdk generate` after changing routes.
|
|
5
|
+
* Document sha256: b2e98a3bd5edbe654e2e232efd73a133e4323e3ebc5263b931d0d0b9dbe01144
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @upvoiced/sdk — typed client for the UpVoiced API (P2-015, ADR-0067, INT-004).
|
|
3
|
+
* The `paths`/`operations` types are generated from the API's OpenAPI document.
|
|
4
|
+
*/
|
|
5
|
+
export { UpVoiced, defaultBaseUrl, defaultMaxRetries, defaultMaxRetryDelayMs } from './client.js';
|
|
6
|
+
export type { ClientOptions } from './client.js';
|
|
7
|
+
export { UpVoicedError } from './errors.js';
|
|
8
|
+
export type { ErrorDetail } from './errors.js';
|
|
9
|
+
export type { ApiResponse, CommonRequestOptions, HttpMethod, Operation, PageItem, PaginatedPath, PathParams, PathsWith, QueryParams, RequestArgs, RequestBody, RequestOptions, ResponseData, } from './types.js';
|
|
10
|
+
export type { components, operations, paths, webhooks } from './generated/schema.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @upvoiced/sdk — typed client for the UpVoiced API (P2-015, ADR-0067, INT-004).
|
|
3
|
+
* The `paths`/`operations` types are generated from the API's OpenAPI document.
|
|
4
|
+
*/
|
|
5
|
+
export { UpVoiced, defaultBaseUrl, defaultMaxRetries, defaultMaxRetryDelayMs } from './client.js';
|
|
6
|
+
export { UpVoicedError } from './errors.js';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { paths } from './generated/schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* P2-015 (ADR-0067): compile-time view over the generated `paths` interface. Every name the
|
|
4
|
+
* client accepts (paths, path/query parameters, bodies, response data) comes from the API's
|
|
5
|
+
* OpenAPI document; nothing here is written per route.
|
|
6
|
+
*/
|
|
7
|
+
export type HttpMethod = 'get' | 'put' | 'post' | 'patch' | 'delete';
|
|
8
|
+
/** Headers the client manages itself (credentials, workspace, idempotency). */
|
|
9
|
+
export type ManagedHeader = 'authorization' | 'x-workspace' | 'idempotency-key';
|
|
10
|
+
type Empty<T> = [T] extends [never] ? true : [T] extends [undefined] ? true : false;
|
|
11
|
+
/** Paths that define `method`. */
|
|
12
|
+
export type PathsWith<M extends HttpMethod> = {
|
|
13
|
+
[P in keyof paths]: Empty<paths[P][M]> extends true ? never : P;
|
|
14
|
+
}[keyof paths];
|
|
15
|
+
export type Operation<P extends keyof paths, M extends HttpMethod> = Exclude<paths[P][M], undefined>;
|
|
16
|
+
type ParametersOf<O> = O extends {
|
|
17
|
+
parameters: infer X;
|
|
18
|
+
} ? X : never;
|
|
19
|
+
type ParameterIn<O, Where extends 'path' | 'query' | 'header'> = ParametersOf<O> extends Partial<Record<Where, infer V>> ? Exclude<V, undefined> : never;
|
|
20
|
+
export type PathParams<O> = ParameterIn<O, 'path'>;
|
|
21
|
+
export type QueryParams<O> = ParameterIn<O, 'query'>;
|
|
22
|
+
type PathOption<O> = Empty<PathParams<O>> extends true ? unknown : {
|
|
23
|
+
path: PathParams<O>;
|
|
24
|
+
};
|
|
25
|
+
type QueryOption<O> = Empty<QueryParams<O>> extends true ? unknown : object extends QueryParams<O> ? {
|
|
26
|
+
query?: QueryParams<O>;
|
|
27
|
+
} : {
|
|
28
|
+
query: QueryParams<O>;
|
|
29
|
+
};
|
|
30
|
+
type JsonContent<B> = B extends {
|
|
31
|
+
content: {
|
|
32
|
+
'application/json': infer J;
|
|
33
|
+
};
|
|
34
|
+
} ? J : never;
|
|
35
|
+
export type RequestBody<O> = O extends {
|
|
36
|
+
requestBody: infer B;
|
|
37
|
+
} ? JsonContent<B> : O extends {
|
|
38
|
+
requestBody?: infer B;
|
|
39
|
+
} ? JsonContent<Exclude<B, undefined>> : never;
|
|
40
|
+
type BodyOption<O> = Empty<RequestBody<O>> extends true ? unknown : O extends {
|
|
41
|
+
requestBody: unknown;
|
|
42
|
+
} ? {
|
|
43
|
+
body: RequestBody<O>;
|
|
44
|
+
} : {
|
|
45
|
+
body?: RequestBody<O>;
|
|
46
|
+
};
|
|
47
|
+
/** Options every call accepts. */
|
|
48
|
+
export interface CommonRequestOptions {
|
|
49
|
+
/** Overrides the client's `workspace` (X-Workspace) for this call. */
|
|
50
|
+
workspace?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Idempotency-Key for this POST (the API replays the first response for 24 h). When omitted
|
|
53
|
+
* and retries are enabled, the client generates one so a retried POST cannot apply twice.
|
|
54
|
+
*/
|
|
55
|
+
idempotencyKey?: string;
|
|
56
|
+
/** Extra headers; the managed ones (Authorization, X-Workspace, Idempotency-Key) win. */
|
|
57
|
+
headers?: Record<string, string>;
|
|
58
|
+
signal?: AbortSignal;
|
|
59
|
+
}
|
|
60
|
+
export type RequestOptions<O> = PathOption<O> & QueryOption<O> & BodyOption<O> & CommonRequestOptions;
|
|
61
|
+
/** The options argument is required only when the operation has a required part. */
|
|
62
|
+
export type RequestArgs<O> = object extends RequestOptions<O> ? [options?: RequestOptions<O>] : [options: RequestOptions<O>];
|
|
63
|
+
type SuccessStatus = 200 | 201 | 202 | 203 | 204 | 205 | 206;
|
|
64
|
+
type ResponsesOf<O> = O extends {
|
|
65
|
+
responses: infer R;
|
|
66
|
+
} ? R : never;
|
|
67
|
+
type ContentOf<R> = R extends {
|
|
68
|
+
content: infer C;
|
|
69
|
+
} ? 'application/json' extends keyof C ? C['application/json'] : string : undefined;
|
|
70
|
+
/** The parsed body of the operation's success response(s). */
|
|
71
|
+
export type ResponseData<O> = {
|
|
72
|
+
[S in keyof ResponsesOf<O> & SuccessStatus]: ContentOf<ResponsesOf<O>[S]>;
|
|
73
|
+
}[keyof ResponsesOf<O> & SuccessStatus];
|
|
74
|
+
/** GET paths answering `{ items, next_cursor }` and accepting `?cursor=`. */
|
|
75
|
+
export type PaginatedPath = {
|
|
76
|
+
[P in PathsWith<'get'>]: ResponseData<Operation<P, 'get'>> extends {
|
|
77
|
+
items: readonly unknown[];
|
|
78
|
+
next_cursor: string | null;
|
|
79
|
+
} ? QueryParams<Operation<P, 'get'>> extends {
|
|
80
|
+
cursor?: string;
|
|
81
|
+
} ? P : never : never;
|
|
82
|
+
}[PathsWith<'get'>];
|
|
83
|
+
export type PageItem<P extends PaginatedPath> = ResponseData<Operation<P, 'get'>> extends {
|
|
84
|
+
items: readonly (infer I)[];
|
|
85
|
+
} ? I : never;
|
|
86
|
+
export interface ApiResponse<T> {
|
|
87
|
+
data: T;
|
|
88
|
+
status: number;
|
|
89
|
+
headers: Headers;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upvoiced/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Typed TypeScript client for the UpVoiced API, generated from its OpenAPI document.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://docs.upvoiced.com",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/jpereiramp/upvoiced.git",
|
|
10
|
+
"directory": "packages/sdk"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"upvoiced",
|
|
14
|
+
"feedback",
|
|
15
|
+
"roadmap",
|
|
16
|
+
"changelog",
|
|
17
|
+
"openapi",
|
|
18
|
+
"sdk"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=22"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
}
|
|
41
|
+
}
|