@bikefinder/api-client 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/README.md +109 -2
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +7 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/client/client.gen.d.ts +3 -0
- package/dist/generated/client/client.gen.d.ts.map +1 -0
- package/dist/generated/client/client.gen.js +218 -0
- package/dist/generated/client/client.gen.js.map +1 -0
- package/dist/generated/client/index.d.ts +11 -0
- package/dist/generated/client/index.d.ts.map +1 -0
- package/dist/generated/client/index.js +7 -0
- package/dist/generated/client/index.js.map +1 -0
- package/dist/generated/client/types.gen.d.ts +121 -0
- package/dist/generated/client/types.gen.d.ts.map +1 -0
- package/dist/generated/client/types.gen.js +3 -0
- package/dist/generated/client/types.gen.js.map +1 -0
- package/dist/generated/client/utils.gen.d.ts +38 -0
- package/dist/generated/client/utils.gen.d.ts.map +1 -0
- package/dist/generated/client/utils.gen.js +232 -0
- package/dist/generated/client/utils.gen.js.map +1 -0
- package/dist/generated/client.gen.d.ts +13 -0
- package/dist/generated/client.gen.d.ts.map +1 -0
- package/dist/generated/client.gen.js +4 -0
- package/dist/generated/client.gen.js.map +1 -0
- package/dist/generated/core/auth.gen.d.ts +26 -0
- package/dist/generated/core/auth.gen.d.ts.map +1 -0
- package/dist/generated/core/auth.gen.js +15 -0
- package/dist/generated/core/auth.gen.js.map +1 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +26 -0
- package/dist/generated/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/generated/core/bodySerializer.gen.js +58 -0
- package/dist/generated/core/bodySerializer.gen.js.map +1 -0
- package/dist/generated/core/params.gen.d.ts +44 -0
- package/dist/generated/core/params.gen.d.ts.map +1 -0
- package/dist/generated/core/params.gen.js +113 -0
- package/dist/generated/core/params.gen.js.map +1 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +34 -0
- package/dist/generated/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/generated/core/pathSerializer.gen.js +115 -0
- package/dist/generated/core/pathSerializer.gen.js.map +1 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +19 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/generated/core/queryKeySerializer.gen.js +100 -0
- package/dist/generated/core/queryKeySerializer.gen.js.map +1 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +72 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/generated/core/serverSentEvents.gen.js +137 -0
- package/dist/generated/core/serverSentEvents.gen.js.map +1 -0
- package/dist/generated/core/types.gen.d.ts +84 -0
- package/dist/generated/core/types.gen.d.ts.map +1 -0
- package/dist/generated/core/types.gen.js +3 -0
- package/dist/generated/core/types.gen.js.map +1 -0
- package/dist/generated/core/utils.gen.d.ts +20 -0
- package/dist/generated/core/utils.gen.d.ts.map +1 -0
- package/dist/generated/core/utils.gen.js +88 -0
- package/dist/generated/core/utils.gen.js.map +1 -0
- package/dist/generated/index.d.ts +3 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +3 -0
- package/dist/generated/index.js.map +1 -0
- package/dist/generated/sdk.gen.d.ts +51 -0
- package/dist/generated/sdk.gen.d.ts.map +1 -0
- package/dist/generated/sdk.gen.js +73 -0
- package/dist/generated/sdk.gen.js.map +1 -0
- package/dist/generated/types.gen.d.ts +152 -0
- package/dist/generated/types.gen.d.ts.map +1 -0
- package/dist/generated/types.gen.js +3 -0
- package/dist/generated/types.gen.js.map +1 -0
- package/dist/generated/zod.gen.d.ts +102 -0
- package/dist/generated/zod.gen.d.ts.map +1 -0
- package/dist/generated/zod.gen.js +73 -0
- package/dist/generated/zod.gen.js.map +1 -0
- package/dist/http-client.d.ts +3 -0
- package/dist/http-client.d.ts.map +1 -0
- package/dist/http-client.js +29 -0
- package/dist/http-client.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/options.d.ts +13 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +40 -0
- package/dist/options.js.map +1 -0
- package/dist/realtime/api-stream-error.d.ts +8 -0
- package/dist/realtime/api-stream-error.d.ts.map +1 -0
- package/dist/realtime/api-stream-error.js +16 -0
- package/dist/realtime/api-stream-error.js.map +1 -0
- package/dist/realtime/watch-trackers.d.ts +10 -0
- package/dist/realtime/watch-trackers.d.ts.map +1 -0
- package/dist/realtime/watch-trackers.js +93 -0
- package/dist/realtime/watch-trackers.js.map +1 -0
- package/dist/transport.d.ts +4 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +84 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -4
- package/src/errors.ts +6 -0
- package/src/generated/client/client.gen.ts +300 -0
- package/src/generated/client/index.ts +27 -0
- package/src/generated/client/types.gen.ts +238 -0
- package/src/generated/client/utils.gen.ts +337 -0
- package/src/generated/client.gen.ts +24 -0
- package/src/generated/core/auth.gen.ts +49 -0
- package/src/generated/core/bodySerializer.gen.ts +96 -0
- package/src/generated/core/params.gen.ts +188 -0
- package/src/generated/core/pathSerializer.gen.ts +186 -0
- package/src/generated/core/queryKeySerializer.gen.ts +134 -0
- package/src/generated/core/serverSentEvents.gen.ts +265 -0
- package/src/generated/core/types.gen.ts +126 -0
- package/src/generated/core/utils.gen.ts +146 -0
- package/src/generated/index.ts +29 -0
- package/src/generated/sdk.gen.ts +165 -0
- package/src/generated/types.gen.ts +179 -0
- package/src/generated/zod.gen.ts +85 -0
- package/src/http-client.ts +31 -0
- package/src/index.ts +22 -0
- package/src/options.ts +61 -0
- package/src/realtime/api-stream-error.ts +20 -0
- package/src/realtime/watch-trackers.ts +114 -0
- package/src/transport.ts +99 -0
- package/src/types.ts +5 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type { BodySerializer, QuerySerializer } from "./bodySerializer.gen.js";
|
|
4
|
+
import {
|
|
5
|
+
type ArraySeparatorStyle,
|
|
6
|
+
serializeArrayParam,
|
|
7
|
+
serializeObjectParam,
|
|
8
|
+
serializePrimitiveParam,
|
|
9
|
+
} from "./pathSerializer.gen.js";
|
|
10
|
+
|
|
11
|
+
export interface PathSerializer {
|
|
12
|
+
path: Record<string, unknown>;
|
|
13
|
+
url: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const PATH_PARAM_RE: RegExp = /\{[^{}]+\}/g;
|
|
17
|
+
|
|
18
|
+
export const defaultPathSerializer = ({
|
|
19
|
+
path,
|
|
20
|
+
url: _url,
|
|
21
|
+
}: PathSerializer): string => {
|
|
22
|
+
let url = _url;
|
|
23
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
24
|
+
if (matches) {
|
|
25
|
+
for (const match of matches) {
|
|
26
|
+
let explode = false;
|
|
27
|
+
let name = match.substring(1, match.length - 1);
|
|
28
|
+
let style: ArraySeparatorStyle = "simple";
|
|
29
|
+
|
|
30
|
+
if (name.endsWith("*")) {
|
|
31
|
+
explode = true;
|
|
32
|
+
name = name.substring(0, name.length - 1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (name.startsWith(".")) {
|
|
36
|
+
name = name.substring(1);
|
|
37
|
+
style = "label";
|
|
38
|
+
} else if (name.startsWith(";")) {
|
|
39
|
+
name = name.substring(1);
|
|
40
|
+
style = "matrix";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const value = path[name];
|
|
44
|
+
|
|
45
|
+
if (value === undefined || value === null) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (Array.isArray(value)) {
|
|
50
|
+
url = url.replace(
|
|
51
|
+
match,
|
|
52
|
+
serializeArrayParam({ explode, name, style, value }),
|
|
53
|
+
);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (typeof value === "object") {
|
|
58
|
+
url = url.replace(
|
|
59
|
+
match,
|
|
60
|
+
serializeObjectParam({
|
|
61
|
+
explode,
|
|
62
|
+
name,
|
|
63
|
+
style,
|
|
64
|
+
value: value as Record<string, unknown>,
|
|
65
|
+
valueOnly: true,
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (style === "matrix") {
|
|
72
|
+
url = url.replace(
|
|
73
|
+
match,
|
|
74
|
+
`;${serializePrimitiveParam({
|
|
75
|
+
name,
|
|
76
|
+
value: value as string,
|
|
77
|
+
})}`,
|
|
78
|
+
);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const replaceValue = encodeURIComponent(
|
|
83
|
+
style === "label" ? `.${value as string}` : (value as string),
|
|
84
|
+
);
|
|
85
|
+
url = url.replace(match, replaceValue);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return url;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const getUrl = ({
|
|
92
|
+
baseUrl,
|
|
93
|
+
path,
|
|
94
|
+
query,
|
|
95
|
+
querySerializer,
|
|
96
|
+
url: _url,
|
|
97
|
+
}: {
|
|
98
|
+
baseUrl?: string;
|
|
99
|
+
path?: Record<string, unknown>;
|
|
100
|
+
query?: Record<string, unknown>;
|
|
101
|
+
querySerializer: QuerySerializer;
|
|
102
|
+
url: string;
|
|
103
|
+
}): string => {
|
|
104
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
105
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
106
|
+
if (path) {
|
|
107
|
+
url = defaultPathSerializer({ path, url });
|
|
108
|
+
}
|
|
109
|
+
let search = query ? querySerializer(query) : "";
|
|
110
|
+
if (search.startsWith("?")) {
|
|
111
|
+
search = search.substring(1);
|
|
112
|
+
}
|
|
113
|
+
if (search) {
|
|
114
|
+
url += `?${search}`;
|
|
115
|
+
}
|
|
116
|
+
return url;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export function getValidRequestBody(options: {
|
|
120
|
+
body?: unknown;
|
|
121
|
+
bodySerializer?: BodySerializer | null;
|
|
122
|
+
serializedBody?: unknown;
|
|
123
|
+
}): unknown {
|
|
124
|
+
const hasBody = options.body !== undefined;
|
|
125
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
126
|
+
|
|
127
|
+
if (isSerializedBody) {
|
|
128
|
+
if ("serializedBody" in options) {
|
|
129
|
+
const hasSerializedBody =
|
|
130
|
+
options.serializedBody !== undefined && options.serializedBody !== "";
|
|
131
|
+
|
|
132
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// not all clients implement a serializedBody property (i.e., client-axios)
|
|
136
|
+
return options.body !== "" ? options.body : null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// plain/text body
|
|
140
|
+
if (hasBody) {
|
|
141
|
+
return options.body;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// no body was provided
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
export { BikeFinderSdk, type Options } from "./sdk.gen.js";
|
|
4
|
+
export type {
|
|
5
|
+
ClientOptions,
|
|
6
|
+
GetHealthData,
|
|
7
|
+
GetHealthResponse,
|
|
8
|
+
GetHealthResponses,
|
|
9
|
+
GetTrackerData,
|
|
10
|
+
GetTrackerError,
|
|
11
|
+
GetTrackerErrors,
|
|
12
|
+
GetTrackerResponse,
|
|
13
|
+
GetTrackerResponses,
|
|
14
|
+
HealthStatus,
|
|
15
|
+
ListTrackersData,
|
|
16
|
+
ListTrackersError,
|
|
17
|
+
ListTrackersErrors,
|
|
18
|
+
ListTrackersResponse,
|
|
19
|
+
ListTrackersResponses,
|
|
20
|
+
ProblemDetails,
|
|
21
|
+
SubscribeTrackersData,
|
|
22
|
+
SubscribeTrackersError,
|
|
23
|
+
SubscribeTrackersErrors,
|
|
24
|
+
SubscribeTrackersResponse,
|
|
25
|
+
SubscribeTrackersResponses,
|
|
26
|
+
TrackerPage,
|
|
27
|
+
TrackerSummary,
|
|
28
|
+
TrackingMode,
|
|
29
|
+
} from "./types.gen.js";
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import { client } from "./client.gen.js";
|
|
4
|
+
import type {
|
|
5
|
+
Client,
|
|
6
|
+
ClientMeta,
|
|
7
|
+
Options as Options2,
|
|
8
|
+
RequestResult,
|
|
9
|
+
ServerSentEventsResult,
|
|
10
|
+
TDataShape,
|
|
11
|
+
} from "./client/index.js";
|
|
12
|
+
import type {
|
|
13
|
+
GetHealthData,
|
|
14
|
+
GetHealthResponses,
|
|
15
|
+
GetTrackerData,
|
|
16
|
+
GetTrackerErrors,
|
|
17
|
+
GetTrackerResponses,
|
|
18
|
+
ListTrackersData,
|
|
19
|
+
ListTrackersErrors,
|
|
20
|
+
ListTrackersResponses,
|
|
21
|
+
SubscribeTrackersData,
|
|
22
|
+
SubscribeTrackersErrors,
|
|
23
|
+
SubscribeTrackersResponse,
|
|
24
|
+
SubscribeTrackersResponses,
|
|
25
|
+
} from "./types.gen.js";
|
|
26
|
+
import {
|
|
27
|
+
zGetHealthResponse,
|
|
28
|
+
zGetTrackerResponse,
|
|
29
|
+
zListTrackersResponse,
|
|
30
|
+
zSubscribeTrackersResponse,
|
|
31
|
+
} from "./zod.gen.js";
|
|
32
|
+
|
|
33
|
+
export type Options<
|
|
34
|
+
TData extends TDataShape = TDataShape,
|
|
35
|
+
ThrowOnError extends boolean = boolean,
|
|
36
|
+
TResponse = unknown,
|
|
37
|
+
> = Options2<TData, ThrowOnError, TResponse> & {
|
|
38
|
+
/**
|
|
39
|
+
* You can provide a client instance returned by `createClient()` instead of
|
|
40
|
+
* individual options. This might be also useful if you want to implement a
|
|
41
|
+
* custom client.
|
|
42
|
+
*/
|
|
43
|
+
client?: Client;
|
|
44
|
+
/**
|
|
45
|
+
* You can pass arbitrary values through the `meta` object. This can be
|
|
46
|
+
* used to access values that aren't defined as part of the SDK function.
|
|
47
|
+
*/
|
|
48
|
+
meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
class HeyApiClient {
|
|
52
|
+
protected client: Client;
|
|
53
|
+
|
|
54
|
+
constructor(args?: { client?: Client }) {
|
|
55
|
+
this.client = args?.client ?? client;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
class HeyApiRegistry<T> {
|
|
60
|
+
private readonly defaultKey = "default";
|
|
61
|
+
|
|
62
|
+
private readonly instances: Map<string, T> = new Map();
|
|
63
|
+
|
|
64
|
+
get(key?: string): T {
|
|
65
|
+
const instance = this.instances.get(key ?? this.defaultKey);
|
|
66
|
+
if (!instance) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`No SDK client found. Create one with "new BikeFinderSdk()" to fix this error.`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return instance;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
set(value: T, key?: string): void {
|
|
75
|
+
this.instances.set(key ?? this.defaultKey, value);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export class BikeFinderSdk extends HeyApiClient {
|
|
80
|
+
public static readonly __registry: HeyApiRegistry<BikeFinderSdk> =
|
|
81
|
+
new HeyApiRegistry<BikeFinderSdk>();
|
|
82
|
+
|
|
83
|
+
constructor(args?: { client?: Client; key?: string }) {
|
|
84
|
+
super(args);
|
|
85
|
+
BikeFinderSdk.__registry.set(this, args?.key);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public getHealth<ThrowOnError extends boolean = false>(
|
|
89
|
+
options?: Options<GetHealthData, ThrowOnError>,
|
|
90
|
+
): RequestResult<GetHealthResponses, unknown, ThrowOnError> {
|
|
91
|
+
return (options?.client ?? this.client).get<
|
|
92
|
+
GetHealthResponses,
|
|
93
|
+
unknown,
|
|
94
|
+
ThrowOnError
|
|
95
|
+
>({
|
|
96
|
+
responseValidator: async (data) =>
|
|
97
|
+
await zGetHealthResponse.parseAsync(data),
|
|
98
|
+
url: "/health",
|
|
99
|
+
...options,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* List the caller's active trackers
|
|
105
|
+
*/
|
|
106
|
+
public listTrackers<ThrowOnError extends boolean = false>(
|
|
107
|
+
options?: Options<ListTrackersData, ThrowOnError>,
|
|
108
|
+
): RequestResult<ListTrackersResponses, ListTrackersErrors, ThrowOnError> {
|
|
109
|
+
return (options?.client ?? this.client).get<
|
|
110
|
+
ListTrackersResponses,
|
|
111
|
+
ListTrackersErrors,
|
|
112
|
+
ThrowOnError
|
|
113
|
+
>({
|
|
114
|
+
responseValidator: async (data) =>
|
|
115
|
+
await zListTrackersResponse.parseAsync(data),
|
|
116
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
117
|
+
url: "/v1/trackers",
|
|
118
|
+
...options,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Subscribe to the caller's tracker page
|
|
124
|
+
*
|
|
125
|
+
* SSE. snapshot events contain a TrackerPage JSON payload; keepalive events contain null. Reconnect with a fresh bearer token after closure. Each connection lasts at most 15 minutes and never beyond token expiry. Every reconnect starts with a complete snapshot; Last-Event-ID is not used.
|
|
126
|
+
*/
|
|
127
|
+
public subscribeTrackers<ThrowOnError extends boolean = false>(
|
|
128
|
+
options?: Options<
|
|
129
|
+
SubscribeTrackersData,
|
|
130
|
+
ThrowOnError,
|
|
131
|
+
SubscribeTrackersResponse
|
|
132
|
+
>,
|
|
133
|
+
): Promise<ServerSentEventsResult<SubscribeTrackersResponses>> {
|
|
134
|
+
return (options?.client ?? this.client).sse.get<
|
|
135
|
+
SubscribeTrackersResponses,
|
|
136
|
+
SubscribeTrackersErrors,
|
|
137
|
+
ThrowOnError
|
|
138
|
+
>({
|
|
139
|
+
responseValidator: async (data) =>
|
|
140
|
+
await zSubscribeTrackersResponse.parseAsync(data),
|
|
141
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
142
|
+
url: "/v1/trackers/stream",
|
|
143
|
+
...options,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Get an actively shared tracker
|
|
149
|
+
*/
|
|
150
|
+
public getTracker<ThrowOnError extends boolean = false>(
|
|
151
|
+
options: Options<GetTrackerData, ThrowOnError>,
|
|
152
|
+
): RequestResult<GetTrackerResponses, GetTrackerErrors, ThrowOnError> {
|
|
153
|
+
return (options.client ?? this.client).get<
|
|
154
|
+
GetTrackerResponses,
|
|
155
|
+
GetTrackerErrors,
|
|
156
|
+
ThrowOnError
|
|
157
|
+
>({
|
|
158
|
+
responseValidator: async (data) =>
|
|
159
|
+
await zGetTrackerResponse.parseAsync(data),
|
|
160
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
161
|
+
url: "/v1/trackers/{trackerId}",
|
|
162
|
+
...options,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
export type ClientOptions = {
|
|
4
|
+
baseUrl: `${string}://${string}` | (string & {});
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type HealthStatus = {
|
|
8
|
+
status: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type ProblemDetails = {
|
|
12
|
+
type?: null | string;
|
|
13
|
+
title?: null | string;
|
|
14
|
+
status?: null | number;
|
|
15
|
+
detail?: null | string;
|
|
16
|
+
instance?: null | string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type TrackerPage = {
|
|
20
|
+
items: Array<TrackerSummary>;
|
|
21
|
+
nextCursor: null | string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type TrackerSummary = {
|
|
25
|
+
id: string;
|
|
26
|
+
nickname: null | string;
|
|
27
|
+
requestedMode: null | TrackingMode;
|
|
28
|
+
subscriptionActive: null | boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type TrackingMode = "standard" | "security" | "tracking";
|
|
32
|
+
|
|
33
|
+
export type GetHealthData = {
|
|
34
|
+
body?: never;
|
|
35
|
+
path?: never;
|
|
36
|
+
query?: never;
|
|
37
|
+
url: "/health";
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type GetHealthResponses = {
|
|
41
|
+
/**
|
|
42
|
+
* OK
|
|
43
|
+
*/
|
|
44
|
+
200: HealthStatus;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type GetHealthResponse = GetHealthResponses[keyof GetHealthResponses];
|
|
48
|
+
|
|
49
|
+
export type ListTrackersData = {
|
|
50
|
+
body?: never;
|
|
51
|
+
path?: never;
|
|
52
|
+
query?: {
|
|
53
|
+
cursor?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Page size, from 1 to 100. Defaults to 50.
|
|
56
|
+
*/
|
|
57
|
+
limit?: number;
|
|
58
|
+
};
|
|
59
|
+
url: "/v1/trackers";
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type ListTrackersErrors = {
|
|
63
|
+
/**
|
|
64
|
+
* Bad Request
|
|
65
|
+
*/
|
|
66
|
+
400: ProblemDetails;
|
|
67
|
+
/**
|
|
68
|
+
* Unauthorized
|
|
69
|
+
*/
|
|
70
|
+
401: ProblemDetails;
|
|
71
|
+
/**
|
|
72
|
+
* Internal Server Error
|
|
73
|
+
*/
|
|
74
|
+
500: ProblemDetails;
|
|
75
|
+
/**
|
|
76
|
+
* Service Unavailable
|
|
77
|
+
*/
|
|
78
|
+
503: ProblemDetails;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type ListTrackersError = ListTrackersErrors[keyof ListTrackersErrors];
|
|
82
|
+
|
|
83
|
+
export type ListTrackersResponses = {
|
|
84
|
+
/**
|
|
85
|
+
* OK
|
|
86
|
+
*/
|
|
87
|
+
200: TrackerPage;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type ListTrackersResponse =
|
|
91
|
+
ListTrackersResponses[keyof ListTrackersResponses];
|
|
92
|
+
|
|
93
|
+
export type SubscribeTrackersData = {
|
|
94
|
+
body?: never;
|
|
95
|
+
path?: never;
|
|
96
|
+
query?: {
|
|
97
|
+
cursor?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Page size, from 1 to 100. Defaults to 50.
|
|
100
|
+
*/
|
|
101
|
+
limit?: number;
|
|
102
|
+
};
|
|
103
|
+
url: "/v1/trackers/stream";
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type SubscribeTrackersErrors = {
|
|
107
|
+
/**
|
|
108
|
+
* Bad Request
|
|
109
|
+
*/
|
|
110
|
+
400: ProblemDetails;
|
|
111
|
+
/**
|
|
112
|
+
* Unauthorized
|
|
113
|
+
*/
|
|
114
|
+
401: ProblemDetails;
|
|
115
|
+
/**
|
|
116
|
+
* Internal Server Error
|
|
117
|
+
*/
|
|
118
|
+
500: ProblemDetails;
|
|
119
|
+
/**
|
|
120
|
+
* Service Unavailable
|
|
121
|
+
*/
|
|
122
|
+
503: ProblemDetails;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type SubscribeTrackersError =
|
|
126
|
+
SubscribeTrackersErrors[keyof SubscribeTrackersErrors];
|
|
127
|
+
|
|
128
|
+
export type SubscribeTrackersResponses = {
|
|
129
|
+
/**
|
|
130
|
+
* OK
|
|
131
|
+
*/
|
|
132
|
+
200: TrackerPage | null;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export type SubscribeTrackersResponse =
|
|
136
|
+
SubscribeTrackersResponses[keyof SubscribeTrackersResponses];
|
|
137
|
+
|
|
138
|
+
export type GetTrackerData = {
|
|
139
|
+
body?: never;
|
|
140
|
+
path: {
|
|
141
|
+
trackerId: string;
|
|
142
|
+
};
|
|
143
|
+
query?: never;
|
|
144
|
+
url: "/v1/trackers/{trackerId}";
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export type GetTrackerErrors = {
|
|
148
|
+
/**
|
|
149
|
+
* Bad Request
|
|
150
|
+
*/
|
|
151
|
+
400: ProblemDetails;
|
|
152
|
+
/**
|
|
153
|
+
* Unauthorized
|
|
154
|
+
*/
|
|
155
|
+
401: ProblemDetails;
|
|
156
|
+
/**
|
|
157
|
+
* Not Found
|
|
158
|
+
*/
|
|
159
|
+
404: ProblemDetails;
|
|
160
|
+
/**
|
|
161
|
+
* Internal Server Error
|
|
162
|
+
*/
|
|
163
|
+
500: ProblemDetails;
|
|
164
|
+
/**
|
|
165
|
+
* Service Unavailable
|
|
166
|
+
*/
|
|
167
|
+
503: ProblemDetails;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export type GetTrackerError = GetTrackerErrors[keyof GetTrackerErrors];
|
|
171
|
+
|
|
172
|
+
export type GetTrackerResponses = {
|
|
173
|
+
/**
|
|
174
|
+
* OK
|
|
175
|
+
*/
|
|
176
|
+
200: TrackerSummary;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export type GetTrackerResponse = GetTrackerResponses[keyof GetTrackerResponses];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
|
|
5
|
+
export const zHealthStatus = z.object({
|
|
6
|
+
status: z.string(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const zProblemDetails = z.object({
|
|
10
|
+
type: z.string().nullish(),
|
|
11
|
+
title: z.string().nullish(),
|
|
12
|
+
status: z
|
|
13
|
+
.int()
|
|
14
|
+
.min(-2147483648, {
|
|
15
|
+
error: "Invalid value: Expected int32 to be >= -2147483648",
|
|
16
|
+
})
|
|
17
|
+
.max(2147483647, {
|
|
18
|
+
error: "Invalid value: Expected int32 to be <= 2147483647",
|
|
19
|
+
})
|
|
20
|
+
.nullish(),
|
|
21
|
+
detail: z.string().nullish(),
|
|
22
|
+
instance: z.string().nullish(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const zTrackingMode = z.enum(["standard", "security", "tracking"]);
|
|
26
|
+
|
|
27
|
+
export const zTrackerSummary = z.object({
|
|
28
|
+
id: z.string(),
|
|
29
|
+
nickname: z.string().nullable(),
|
|
30
|
+
requestedMode: zTrackingMode.nullable(),
|
|
31
|
+
subscriptionActive: z.boolean().nullable(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const zTrackerPage = z.object({
|
|
35
|
+
items: z.array(zTrackerSummary),
|
|
36
|
+
nextCursor: z.string().nullable(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* OK
|
|
41
|
+
*/
|
|
42
|
+
export const zGetHealthResponse = zHealthStatus;
|
|
43
|
+
|
|
44
|
+
export const zListTrackersQuery = z.object({
|
|
45
|
+
cursor: z
|
|
46
|
+
.string()
|
|
47
|
+
.min(1)
|
|
48
|
+
.max(128)
|
|
49
|
+
.regex(/^[A-Za-z0-9_-]+$/)
|
|
50
|
+
.optional(),
|
|
51
|
+
limit: z.int().gte(1).lte(100).optional().default(50),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* OK
|
|
56
|
+
*/
|
|
57
|
+
export const zListTrackersResponse = zTrackerPage;
|
|
58
|
+
|
|
59
|
+
export const zSubscribeTrackersQuery = z.object({
|
|
60
|
+
cursor: z
|
|
61
|
+
.string()
|
|
62
|
+
.min(1)
|
|
63
|
+
.max(128)
|
|
64
|
+
.regex(/^[A-Za-z0-9_-]+$/)
|
|
65
|
+
.optional(),
|
|
66
|
+
limit: z.int().gte(1).lte(100).optional().default(50),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* OK
|
|
71
|
+
*/
|
|
72
|
+
export const zSubscribeTrackersResponse = zTrackerPage.nullable();
|
|
73
|
+
|
|
74
|
+
export const zGetTrackerPath = z.object({
|
|
75
|
+
trackerId: z
|
|
76
|
+
.string()
|
|
77
|
+
.min(1)
|
|
78
|
+
.max(128)
|
|
79
|
+
.regex(/^[A-Za-z0-9_-]+$/),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* OK
|
|
84
|
+
*/
|
|
85
|
+
export const zGetTrackerResponse = zTrackerSummary;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createClient } from "./generated/client/index.js";
|
|
2
|
+
import type { ResolvedClientOptions } from "./options.js";
|
|
3
|
+
import { createAuthenticatedFetch } from "./transport.js";
|
|
4
|
+
|
|
5
|
+
export function createHttpClient(options: ResolvedClientOptions) {
|
|
6
|
+
const authenticatedFetch = createAuthenticatedFetch(options);
|
|
7
|
+
const client = createClient({
|
|
8
|
+
baseUrl: options.baseUrl,
|
|
9
|
+
redirect: "error",
|
|
10
|
+
credentials: "omit",
|
|
11
|
+
fetch: authenticatedFetch,
|
|
12
|
+
responseStyle: "fields",
|
|
13
|
+
});
|
|
14
|
+
client.interceptors.request.use((request, requestOptions) => {
|
|
15
|
+
// A per-call fetch would bypass authentication and transport policy.
|
|
16
|
+
if (requestOptions.fetch !== authenticatedFetch) {
|
|
17
|
+
throw new TypeError(
|
|
18
|
+
"Configure fetch on createBikeFinderClient, not individual requests.",
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
return request;
|
|
22
|
+
});
|
|
23
|
+
client.interceptors.error.use((error, response) => {
|
|
24
|
+
// Transport/auth/cancellation failures are exceptions, not HTTP Problem Details.
|
|
25
|
+
if (!response) throw error;
|
|
26
|
+
if (response.ok)
|
|
27
|
+
throw new TypeError("The API returned an invalid response.");
|
|
28
|
+
return error;
|
|
29
|
+
});
|
|
30
|
+
return client;
|
|
31
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { resolveClientOptions, type ApiClientOptions } from "./options.js";
|
|
2
|
+
import { BikeFinderSdk } from "./generated/sdk.gen.js";
|
|
3
|
+
import { createHttpClient } from "./http-client.js";
|
|
4
|
+
import { watchTrackers } from "./realtime/watch-trackers.js";
|
|
5
|
+
import type { TrackerPageQuery } from "./types.js";
|
|
6
|
+
|
|
7
|
+
export { AuthenticationError } from "./errors.js";
|
|
8
|
+
export { ApiStreamError } from "./realtime/api-stream-error.js";
|
|
9
|
+
export type { ApiClientOptions } from "./options.js";
|
|
10
|
+
export type * from "./types.js";
|
|
11
|
+
|
|
12
|
+
export function createBikeFinderClient(options: ApiClientOptions) {
|
|
13
|
+
const resolved = resolveClientOptions(options);
|
|
14
|
+
const requests = new BikeFinderSdk({ client: createHttpClient(resolved) });
|
|
15
|
+
return {
|
|
16
|
+
requests,
|
|
17
|
+
watchTrackers: (query: TrackerPageQuery = {}) =>
|
|
18
|
+
watchTrackers(requests, query),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type BikeFinderClient = ReturnType<typeof createBikeFinderClient>;
|