@paklo/core 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/dist/browser/defineProperty-ie4tC-F5.js +43 -0
- package/dist/browser/environment-DinhzwQn.js +139 -0
- package/dist/browser/environment-DinhzwQn.js.map +1 -0
- package/dist/browser/environment.d.ts +33 -0
- package/dist/browser/environment.js +3 -0
- package/dist/browser/github.d.ts +151 -0
- package/dist/browser/github.js +199 -0
- package/dist/browser/github.js.map +1 -0
- package/dist/browser/http.d.ts +121 -0
- package/dist/browser/http.js +248 -0
- package/dist/browser/http.js.map +1 -0
- package/dist/browser/logger-B7HLv660.js +31 -0
- package/dist/browser/logger-B7HLv660.js.map +1 -0
- package/dist/browser/logger.d.ts +23 -0
- package/dist/browser/logger.js +4 -0
- package/dist/browser/shared-data.d.ts +22 -0
- package/dist/browser/shared-data.js +23 -0
- package/dist/browser/shared-data.js.map +1 -0
- package/dist/browser/usage.d.ts +99 -0
- package/dist/browser/usage.js +383 -0
- package/dist/browser/usage.js.map +1 -0
- package/dist/node/azure.d.ts +338 -0
- package/dist/node/azure.js +735 -0
- package/dist/node/azure.js.map +1 -0
- package/dist/node/dependabot-BteoKZVy.js +547 -0
- package/dist/node/dependabot-BteoKZVy.js.map +1 -0
- package/dist/node/dependabot.d.ts +3 -0
- package/dist/node/dependabot.js +6 -0
- package/dist/node/environment-DX5CD-dD.js +138 -0
- package/dist/node/environment-DX5CD-dD.js.map +1 -0
- package/dist/node/environment.d.ts +33 -0
- package/dist/node/environment.js +3 -0
- package/dist/node/github.d.ts +2 -0
- package/dist/node/github.js +198 -0
- package/dist/node/github.js.map +1 -0
- package/dist/node/http-BG_-s47I.js +245 -0
- package/dist/node/http-BG_-s47I.js.map +1 -0
- package/dist/node/http.d.ts +121 -0
- package/dist/node/http.js +4 -0
- package/dist/node/index-3wZw74Ah.d.ts +151 -0
- package/dist/node/index-DP9JfUPG.d.ts +1761 -0
- package/dist/node/job-Crr4kh3e.js +451 -0
- package/dist/node/job-Crr4kh3e.js.map +1 -0
- package/dist/node/logger-bWnHxtAf.js +31 -0
- package/dist/node/logger-bWnHxtAf.js.map +1 -0
- package/dist/node/logger.d.ts +23 -0
- package/dist/node/logger.js +4 -0
- package/dist/node/shared-data.d.ts +22 -0
- package/dist/node/shared-data.js +23 -0
- package/dist/node/shared-data.js.map +1 -0
- package/dist/node/usage.d.ts +99 -0
- package/dist/node/usage.js +48 -0
- package/dist/node/usage.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ZodType } from "zod/v4";
|
|
2
|
+
|
|
3
|
+
//#region src/http/headers.d.ts
|
|
4
|
+
declare const HEADER_NAME_CONTENT_DISPOSITION = "Content-Disposition";
|
|
5
|
+
declare const HEADER_NAME_CONTENT_TYPE = "Content-Type";
|
|
6
|
+
declare const HEADER_NAME_ACCEPT = "Accept";
|
|
7
|
+
declare const HEADER_NAME_USER_AGENT = "User-Agent";
|
|
8
|
+
declare const HEADER_NAME_AUTHORIZATION = "Authorization";
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/http/multipart.d.ts
|
|
11
|
+
declare class MultipartFormDataBody {
|
|
12
|
+
private type;
|
|
13
|
+
private boundary;
|
|
14
|
+
private parts;
|
|
15
|
+
encode(): Promise<Buffer>;
|
|
16
|
+
getBoundary(): string;
|
|
17
|
+
getContentType(): string;
|
|
18
|
+
add(name: string, value: string): void;
|
|
19
|
+
addFile(name: string, file: File): void;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/http/problem.d.ts
|
|
23
|
+
interface ProblemDetails {
|
|
24
|
+
type?: string;
|
|
25
|
+
/** The name/title of the error.*/
|
|
26
|
+
title: string;
|
|
27
|
+
/** A brief explanation/definition into the nature of the error. */
|
|
28
|
+
detail?: string | null;
|
|
29
|
+
/** Any additional error arguments passed to the client. */
|
|
30
|
+
extras?: unknown;
|
|
31
|
+
/** The HTTP status code */
|
|
32
|
+
status?: number;
|
|
33
|
+
statusText?: string;
|
|
34
|
+
errors?: Record<string, string[] | undefined>;
|
|
35
|
+
traceId?: string;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/http/inner.d.ts
|
|
39
|
+
type CreateInnerApiClientOptions = {
|
|
40
|
+
/**
|
|
41
|
+
* The base URL to use for the API.
|
|
42
|
+
* @example 'https://api.paklo.app'
|
|
43
|
+
*/
|
|
44
|
+
baseUrl: string;
|
|
45
|
+
/** The token to use for authentication. This can be a JWT or specialized key. */
|
|
46
|
+
token?: string;
|
|
47
|
+
};
|
|
48
|
+
type RequestOptions = {
|
|
49
|
+
/**
|
|
50
|
+
* Value for the `User-Agent` header.
|
|
51
|
+
* This prepends the default value (e.g. `paklo/ab26320`)
|
|
52
|
+
* which is important when we need to propagate the browser information to the server.
|
|
53
|
+
*/
|
|
54
|
+
userAgent?: string;
|
|
55
|
+
};
|
|
56
|
+
type ResourceResponse<T$1 = Record<string, unknown>> = {
|
|
57
|
+
/** The headers of the response. */
|
|
58
|
+
headers: Headers;
|
|
59
|
+
/** Whether the request was successful. */
|
|
60
|
+
successful: boolean;
|
|
61
|
+
/** The status code of the response. */
|
|
62
|
+
status: number;
|
|
63
|
+
/** The status text of the response. */
|
|
64
|
+
statusText: string;
|
|
65
|
+
/** The data of the response. */
|
|
66
|
+
data?: T$1;
|
|
67
|
+
/** The error of the response. */
|
|
68
|
+
error?: ProblemDetails;
|
|
69
|
+
};
|
|
70
|
+
type InnerRequestOptions<T$1> = RequestOptions & {
|
|
71
|
+
/**
|
|
72
|
+
* The base URL to use for the request.
|
|
73
|
+
* This overrides the default base URL.
|
|
74
|
+
* @example 'https://api.paklo.app'
|
|
75
|
+
*/
|
|
76
|
+
baseUrl?: string;
|
|
77
|
+
/** Additional headers to use for the request. */
|
|
78
|
+
headers?: HeadersInit;
|
|
79
|
+
/** The payload to use for the request. */
|
|
80
|
+
payload?: Record<string, unknown> | MultipartFormDataBody | ReadableStream | XMLHttpRequestBodyInit;
|
|
81
|
+
/** The schema to use when parsing the response. */
|
|
82
|
+
schema?: ZodType<T$1>;
|
|
83
|
+
};
|
|
84
|
+
type InnerRequestOptionsComplete<T$1> = InnerRequestOptions<T$1> & {
|
|
85
|
+
/** The method to use for the request. */
|
|
86
|
+
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
87
|
+
/** The URL to use for the request. */
|
|
88
|
+
url: string;
|
|
89
|
+
};
|
|
90
|
+
declare class InnerApiClient {
|
|
91
|
+
private readonly baseUrl;
|
|
92
|
+
private readonly headers;
|
|
93
|
+
private readonly token?;
|
|
94
|
+
/**
|
|
95
|
+
* Create a new API client.
|
|
96
|
+
* @param options The options to use for the client.
|
|
97
|
+
*/
|
|
98
|
+
constructor({
|
|
99
|
+
baseUrl,
|
|
100
|
+
token
|
|
101
|
+
}: CreateInnerApiClientOptions);
|
|
102
|
+
get<T>(url: string, options?: InnerRequestOptions<T>): Promise<ResourceResponse<T>>;
|
|
103
|
+
post<T>(url: string, options?: InnerRequestOptions<T>): Promise<ResourceResponse<T>>;
|
|
104
|
+
put<T>(url: string, options?: InnerRequestOptions<T>): Promise<ResourceResponse<T>>;
|
|
105
|
+
patch<T>(url: string, options?: InnerRequestOptions<T>): Promise<ResourceResponse<T>>;
|
|
106
|
+
delete<T>(url: string, options?: InnerRequestOptions<T>): Promise<ResourceResponse<T>>;
|
|
107
|
+
request<T>(options: InnerRequestOptionsComplete<T>): Promise<ResourceResponse<T>>;
|
|
108
|
+
private makeUrl;
|
|
109
|
+
}
|
|
110
|
+
/** Http request error */
|
|
111
|
+
declare class HttpRequestError extends Error {
|
|
112
|
+
code: number;
|
|
113
|
+
constructor(message: string, code: number);
|
|
114
|
+
}
|
|
115
|
+
declare function isErrorTemporaryFailure(e?: {
|
|
116
|
+
code?: string | number;
|
|
117
|
+
message?: string;
|
|
118
|
+
} | null): boolean;
|
|
119
|
+
//#endregion
|
|
120
|
+
export { CreateInnerApiClientOptions, HEADER_NAME_ACCEPT, HEADER_NAME_AUTHORIZATION, HEADER_NAME_CONTENT_DISPOSITION, HEADER_NAME_CONTENT_TYPE, HEADER_NAME_USER_AGENT, HttpRequestError, InnerApiClient, InnerRequestOptions, ProblemDetails, RequestOptions, ResourceResponse, isErrorTemporaryFailure };
|
|
121
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { t as environment } from "./environment-DinhzwQn.js";
|
|
2
|
+
import { t as _defineProperty } from "./defineProperty-ie4tC-F5.js";
|
|
3
|
+
|
|
4
|
+
//#region src/http/headers.ts
|
|
5
|
+
const HEADER_NAME_CONTENT_DISPOSITION = "Content-Disposition";
|
|
6
|
+
const HEADER_NAME_CONTENT_TYPE = "Content-Type";
|
|
7
|
+
const HEADER_NAME_ACCEPT = "Accept";
|
|
8
|
+
const HEADER_NAME_USER_AGENT = "User-Agent";
|
|
9
|
+
const HEADER_NAME_AUTHORIZATION = "Authorization";
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/http/multipart.ts
|
|
13
|
+
var MultipartFormDataBody = class {
|
|
14
|
+
constructor() {
|
|
15
|
+
_defineProperty(this, "type", "multipart/form-data");
|
|
16
|
+
_defineProperty(this, "boundary", `${Math.random().toString(36).substring(2)}`);
|
|
17
|
+
_defineProperty(this, "parts", []);
|
|
18
|
+
}
|
|
19
|
+
async encode() {
|
|
20
|
+
if (this.parts.length === 0) throw new Error("MultipartFormDataBody must have at least one part");
|
|
21
|
+
const data = [];
|
|
22
|
+
for (const part of this.parts) {
|
|
23
|
+
data.push(`--${this.boundary}\r\n`);
|
|
24
|
+
for (const [key, value] of Object.entries(part.headers)) data.push(`${key}: ${value}\r\n`);
|
|
25
|
+
data.push("\r\n");
|
|
26
|
+
data.push(part.body);
|
|
27
|
+
data.push("\r\n");
|
|
28
|
+
}
|
|
29
|
+
data.push(`--${this.boundary}--\r\n`);
|
|
30
|
+
const list = [];
|
|
31
|
+
for (const item of data) if (item instanceof File) list.push(Buffer.from(await item.arrayBuffer()));
|
|
32
|
+
else if (typeof item === "string") list.push(Buffer.from(item, "utf8"));
|
|
33
|
+
else list.push(item);
|
|
34
|
+
return Buffer.concat(list);
|
|
35
|
+
}
|
|
36
|
+
getBoundary() {
|
|
37
|
+
return this.boundary;
|
|
38
|
+
}
|
|
39
|
+
getContentType() {
|
|
40
|
+
return `${this.type}; boundary=${this.boundary}`;
|
|
41
|
+
}
|
|
42
|
+
add(name, value) {
|
|
43
|
+
const part = createPart(name, value);
|
|
44
|
+
this.parts.push(part);
|
|
45
|
+
}
|
|
46
|
+
addFile(name, file) {
|
|
47
|
+
const part = createPart(name, file, file.name, file.type);
|
|
48
|
+
this.parts.push(part);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
function createPart(name, body, filename, contentType) {
|
|
52
|
+
const headers = {};
|
|
53
|
+
headers[HEADER_NAME_CONTENT_DISPOSITION] = `form-data; name="${name}"${filename ? `; filename="${filename}"` : ""}`;
|
|
54
|
+
if (contentType) headers[HEADER_NAME_CONTENT_TYPE] = contentType;
|
|
55
|
+
return {
|
|
56
|
+
name,
|
|
57
|
+
headers,
|
|
58
|
+
body
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/http/inner.ts
|
|
64
|
+
const defaultUserAgent = `paklo/${environment.sha?.substring(0, 7) ?? "dogfood"}`;
|
|
65
|
+
var InnerApiClient = class {
|
|
66
|
+
/**
|
|
67
|
+
* Create a new API client.
|
|
68
|
+
* @param options The options to use for the client.
|
|
69
|
+
*/
|
|
70
|
+
constructor({ baseUrl, token }) {
|
|
71
|
+
_defineProperty(this, "baseUrl", void 0);
|
|
72
|
+
_defineProperty(this, "headers", void 0);
|
|
73
|
+
_defineProperty(this, "token", void 0);
|
|
74
|
+
this.baseUrl = baseUrl;
|
|
75
|
+
this.headers = new Headers({ [HEADER_NAME_ACCEPT]: "application/json" });
|
|
76
|
+
this.token = token;
|
|
77
|
+
}
|
|
78
|
+
async get(url, options) {
|
|
79
|
+
return this.request({
|
|
80
|
+
url: this.makeUrl(url, options),
|
|
81
|
+
method: "GET",
|
|
82
|
+
...options
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async post(url, options) {
|
|
86
|
+
return this.request({
|
|
87
|
+
method: "POST",
|
|
88
|
+
url: this.makeUrl(url, options),
|
|
89
|
+
...options
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async put(url, options) {
|
|
93
|
+
return this.request({
|
|
94
|
+
method: "PUT",
|
|
95
|
+
url: this.makeUrl(url, options),
|
|
96
|
+
...options
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
async patch(url, options) {
|
|
100
|
+
return this.request({
|
|
101
|
+
method: "PATCH",
|
|
102
|
+
url: this.makeUrl(url, options),
|
|
103
|
+
...options
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async delete(url, options) {
|
|
107
|
+
return this.request({
|
|
108
|
+
method: "DELETE",
|
|
109
|
+
url: this.makeUrl(url, options),
|
|
110
|
+
...options
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async request(options) {
|
|
114
|
+
const { method, url, payload, userAgent, headers: additionalHeaders, schema } = options;
|
|
115
|
+
const headers = new Headers(this.headers);
|
|
116
|
+
const finalUserAgent = userAgent && userAgent.length > 0 ? `${userAgent} (${defaultUserAgent})` : defaultUserAgent;
|
|
117
|
+
headers.set(HEADER_NAME_USER_AGENT, finalUserAgent);
|
|
118
|
+
if (this.token) headers.set(HEADER_NAME_AUTHORIZATION, `Bearer ${this.token}`);
|
|
119
|
+
if (additionalHeaders) if (additionalHeaders instanceof Headers) additionalHeaders.forEach((value, key) => headers.set(key, value));
|
|
120
|
+
else if (Array.isArray(additionalHeaders)) additionalHeaders.forEach(([key, value]) => headers.set(key, value));
|
|
121
|
+
else Object.entries(additionalHeaders).forEach(([key, value]) => headers.set(key, value));
|
|
122
|
+
let body;
|
|
123
|
+
if (skipSerialization(payload)) body = payload;
|
|
124
|
+
else if (payload instanceof MultipartFormDataBody) {
|
|
125
|
+
body = new Uint8Array(await payload.encode());
|
|
126
|
+
headers.set(HEADER_NAME_CONTENT_TYPE, payload.getContentType());
|
|
127
|
+
} else {
|
|
128
|
+
body = JSON.stringify(payload);
|
|
129
|
+
headers.set(HEADER_NAME_CONTENT_TYPE, "application/json");
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
const response = await fetch(url, {
|
|
133
|
+
method,
|
|
134
|
+
headers,
|
|
135
|
+
body
|
|
136
|
+
});
|
|
137
|
+
const { ok: successful, status, statusText } = response;
|
|
138
|
+
if (!successful) try {
|
|
139
|
+
const rawError = await response.text();
|
|
140
|
+
return {
|
|
141
|
+
headers: response.headers,
|
|
142
|
+
successful,
|
|
143
|
+
status,
|
|
144
|
+
statusText,
|
|
145
|
+
error: JSON.parse(rawError)
|
|
146
|
+
};
|
|
147
|
+
} catch (err) {
|
|
148
|
+
if (err instanceof SyntaxError) return {
|
|
149
|
+
headers: response.headers,
|
|
150
|
+
successful,
|
|
151
|
+
status,
|
|
152
|
+
statusText,
|
|
153
|
+
error: {
|
|
154
|
+
title: "Unknown error",
|
|
155
|
+
status,
|
|
156
|
+
statusText: response.statusText
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const error = {
|
|
160
|
+
title: (err instanceof Error ? err.message : void 0) ?? "Unknown error",
|
|
161
|
+
status: response.status,
|
|
162
|
+
statusText: response.statusText
|
|
163
|
+
};
|
|
164
|
+
return {
|
|
165
|
+
headers: response.headers,
|
|
166
|
+
successful,
|
|
167
|
+
status,
|
|
168
|
+
statusText,
|
|
169
|
+
error
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const contentLength = response.headers.get("content-length");
|
|
173
|
+
let data = contentLength && contentLength !== "0" ? await response.json() : void 0;
|
|
174
|
+
if (data && schema) {
|
|
175
|
+
const result = await schema.safeParseAsync(data);
|
|
176
|
+
if (!result.success) return {
|
|
177
|
+
headers: response.headers,
|
|
178
|
+
successful: false,
|
|
179
|
+
status,
|
|
180
|
+
statusText,
|
|
181
|
+
data,
|
|
182
|
+
error: {
|
|
183
|
+
title: "application_error",
|
|
184
|
+
detail: "Schema validation error",
|
|
185
|
+
errors: result.error.flatten().fieldErrors,
|
|
186
|
+
status: response.status,
|
|
187
|
+
statusText: response.statusText
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
data = result.data;
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
headers: response.headers,
|
|
194
|
+
data,
|
|
195
|
+
successful,
|
|
196
|
+
status,
|
|
197
|
+
statusText
|
|
198
|
+
};
|
|
199
|
+
} catch (err) {
|
|
200
|
+
return {
|
|
201
|
+
headers: new Headers(),
|
|
202
|
+
successful: false,
|
|
203
|
+
status: -1,
|
|
204
|
+
statusText: "Application Error",
|
|
205
|
+
error: {
|
|
206
|
+
title: "application_error",
|
|
207
|
+
detail: `Unable to fetch data. The request could not be resolved. ${err}`
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
makeUrl(url, options) {
|
|
213
|
+
if (url.startsWith("http://") || url.startsWith("https://")) return url;
|
|
214
|
+
return `${options?.baseUrl ?? this.baseUrl}${url}`;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Whether to skip serialization of the payload.
|
|
219
|
+
* @param payload The payload to check.
|
|
220
|
+
* @returns true if the payload should not be serialized; otherwise, false.
|
|
221
|
+
*/
|
|
222
|
+
function skipSerialization(payload) {
|
|
223
|
+
return payload instanceof FormData || payload instanceof URLSearchParams || payload instanceof ReadableStream || payload instanceof Blob || payload instanceof ArrayBuffer || payload instanceof Buffer || typeof payload === "string" || !payload;
|
|
224
|
+
}
|
|
225
|
+
/** Http request error */
|
|
226
|
+
var HttpRequestError = class extends Error {
|
|
227
|
+
constructor(message, code) {
|
|
228
|
+
super(message);
|
|
229
|
+
this.code = code;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
function isErrorTemporaryFailure(e) {
|
|
233
|
+
if (e instanceof HttpRequestError) switch (e.code) {
|
|
234
|
+
case 502: return true;
|
|
235
|
+
case 503: return true;
|
|
236
|
+
case 504: return true;
|
|
237
|
+
default: return false;
|
|
238
|
+
}
|
|
239
|
+
else if (e?.code) switch (e.code) {
|
|
240
|
+
case "ETIMEDOUT": return true;
|
|
241
|
+
default: return false;
|
|
242
|
+
}
|
|
243
|
+
else return false;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
//#endregion
|
|
247
|
+
export { HEADER_NAME_ACCEPT, HEADER_NAME_AUTHORIZATION, HEADER_NAME_CONTENT_DISPOSITION, HEADER_NAME_CONTENT_TYPE, HEADER_NAME_USER_AGENT, HttpRequestError, InnerApiClient, isErrorTemporaryFailure };
|
|
248
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","names":["data: Array<MultipartFormDataBodyPart['body']>","list: Buffer[]","headers: Record<string, string>","body: BodyInit | undefined","error: ProblemDetails","code: number"],"sources":["../../src/http/headers.ts","../../src/http/multipart.ts","../../src/http/inner.ts"],"sourcesContent":["export const HEADER_NAME_CONTENT_DISPOSITION = 'Content-Disposition';\nexport const HEADER_NAME_CONTENT_TYPE = 'Content-Type';\nexport const HEADER_NAME_ACCEPT = 'Accept';\nexport const HEADER_NAME_USER_AGENT = 'User-Agent';\nexport const HEADER_NAME_AUTHORIZATION = 'Authorization';\n","import { HEADER_NAME_CONTENT_DISPOSITION, HEADER_NAME_CONTENT_TYPE } from './headers';\n\nexport class MultipartFormDataBody {\n private type = 'multipart/form-data';\n private boundary: string = `${Math.random().toString(36).substring(2)}`;\n private parts: Array<MultipartFormDataBodyPart> = [];\n\n public async encode(): Promise<Buffer> {\n if (this.parts.length === 0) {\n throw new Error('MultipartFormDataBody must have at least one part');\n }\n\n const data: Array<MultipartFormDataBodyPart['body']> = [];\n\n for (const part of this.parts) {\n // write boundary\n data.push(`--${this.boundary}\\r\\n`);\n\n // write headers\n for (const [key, value] of Object.entries(part.headers)) {\n data.push(`${key}: ${value}\\r\\n`);\n }\n data.push('\\r\\n');\n\n // write body\n data.push(part.body);\n data.push('\\r\\n');\n }\n\n data.push(`--${this.boundary}--\\r\\n`);\n\n const list: Buffer[] = [];\n for (const item of data) {\n if (item instanceof File) list.push(Buffer.from(await item.arrayBuffer()));\n else if (typeof item === 'string') list.push(Buffer.from(item, 'utf8'));\n else list.push(item);\n }\n return Buffer.concat(list);\n }\n\n public getBoundary(): string {\n return this.boundary;\n }\n\n public getContentType(): string {\n return `${this.type}; boundary=${this.boundary}`;\n }\n\n public add(name: string, value: string) {\n const part = createPart(name, value);\n this.parts.push(part);\n }\n\n public addFile(name: string, file: File) {\n const part = createPart(name, file, file.name, file.type);\n this.parts.push(part);\n }\n}\n\ntype MultipartFormDataBodyPart = {\n name: string;\n headers: Record<string, string>;\n body: Buffer | File | string;\n};\n\nfunction createPart(\n name: string,\n body: MultipartFormDataBodyPart['body'],\n filename?: string,\n contentType?: string,\n): MultipartFormDataBodyPart {\n const headers: Record<string, string> = {};\n headers[HEADER_NAME_CONTENT_DISPOSITION] = `form-data; name=\"${name}\"${filename ? `; filename=\"${filename}\"` : ''}`;\n if (contentType) headers[HEADER_NAME_CONTENT_TYPE] = contentType;\n return { name, headers, body };\n}\n","import type { ZodType } from 'zod/v4';\n\nimport { environment } from '@/environment';\n\nimport {\n HEADER_NAME_ACCEPT,\n HEADER_NAME_AUTHORIZATION,\n HEADER_NAME_CONTENT_TYPE,\n HEADER_NAME_USER_AGENT,\n} from './headers';\nimport { MultipartFormDataBody } from './multipart';\nimport type { ProblemDetails } from './problem';\n\nconst defaultUserAgent = `paklo/${environment.sha?.substring(0, 7) ?? 'dogfood'}`;\n\nexport type CreateInnerApiClientOptions = {\n /**\n * The base URL to use for the API.\n * @example 'https://api.paklo.app'\n */\n baseUrl: string;\n\n /** The token to use for authentication. This can be a JWT or specialized key. */\n token?: string;\n};\n\nexport type RequestOptions = {\n /**\n * Value for the `User-Agent` header.\n * This prepends the default value (e.g. `paklo/ab26320`)\n * which is important when we need to propagate the browser information to the server.\n */\n userAgent?: string;\n};\n\nexport type ResourceResponse<T = Record<string, unknown>> = {\n /** The headers of the response. */\n headers: Headers;\n\n /** Whether the request was successful. */\n successful: boolean;\n\n /** The status code of the response. */\n status: number;\n\n /** The status text of the response. */\n statusText: string;\n\n /** The data of the response. */\n data?: T;\n\n /** The error of the response. */\n error?: ProblemDetails;\n};\n\nexport type InnerRequestOptions<T> = RequestOptions & {\n /**\n * The base URL to use for the request.\n * This overrides the default base URL.\n * @example 'https://api.paklo.app'\n */\n baseUrl?: string;\n\n /** Additional headers to use for the request. */\n headers?: HeadersInit;\n\n /** The payload to use for the request. */\n payload?: Record<string, unknown> | MultipartFormDataBody | ReadableStream | XMLHttpRequestBodyInit;\n\n /** The schema to use when parsing the response. */\n schema?: ZodType<T>;\n};\n\ntype InnerRequestOptionsComplete<T> = InnerRequestOptions<T> & {\n /** The method to use for the request. */\n method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\n\n /** The URL to use for the request. */\n url: string;\n};\n\nexport class InnerApiClient {\n private readonly baseUrl: string;\n private readonly headers: Headers;\n private readonly token?: string;\n\n /**\n * Create a new API client.\n * @param options The options to use for the client.\n */\n constructor({ baseUrl, token }: CreateInnerApiClientOptions) {\n this.baseUrl = baseUrl;\n\n this.headers = new Headers({\n [HEADER_NAME_ACCEPT]: 'application/json',\n });\n\n this.token = token;\n }\n\n async get<T>(url: string, options?: InnerRequestOptions<T>) {\n return this.request<T>({\n url: this.makeUrl(url, options),\n method: 'GET',\n ...options,\n });\n }\n\n async post<T>(url: string, options?: InnerRequestOptions<T>) {\n return this.request<T>({\n method: 'POST',\n url: this.makeUrl(url, options),\n ...options,\n });\n }\n\n async put<T>(url: string, options?: InnerRequestOptions<T>) {\n return this.request<T>({\n method: 'PUT',\n url: this.makeUrl(url, options),\n ...options,\n });\n }\n\n async patch<T>(url: string, options?: InnerRequestOptions<T>) {\n return this.request<T>({\n method: 'PATCH',\n url: this.makeUrl(url, options),\n ...options,\n });\n }\n\n async delete<T>(url: string, options?: InnerRequestOptions<T>) {\n return this.request<T>({\n method: 'DELETE',\n url: this.makeUrl(url, options),\n ...options,\n });\n }\n\n async request<T>(options: InnerRequestOptionsComplete<T>): Promise<ResourceResponse<T>> {\n const { method, url, payload, userAgent, headers: additionalHeaders, schema } = options;\n\n // create headers for the request\n const headers = new Headers(this.headers);\n const finalUserAgent = userAgent && userAgent.length > 0 ? `${userAgent} (${defaultUserAgent})` : defaultUserAgent;\n headers.set(HEADER_NAME_USER_AGENT, finalUserAgent);\n\n // populate authorization header\n if (this.token) {\n headers.set(HEADER_NAME_AUTHORIZATION, `Bearer ${this.token}`);\n }\n\n // populate additional headers\n // biome-ignore-start lint/suspicious/useIterableCallbackReturn: not used\n if (additionalHeaders) {\n if (additionalHeaders instanceof Headers) {\n additionalHeaders.forEach((value, key) => headers.set(key, value as string));\n } else if (Array.isArray(additionalHeaders)) {\n additionalHeaders.forEach(([key, value]) => headers.set(key, value));\n } else {\n Object.entries(additionalHeaders).forEach(([key, value]) => headers.set(key, value as string));\n }\n }\n // biome-ignore-end lint/suspicious/useIterableCallbackReturn: not used\n\n // prepare body\n let body: BodyInit | undefined;\n if (skipSerialization(payload)) body = payload;\n else if (payload instanceof MultipartFormDataBody) {\n body = new Uint8Array(await payload.encode());\n headers.set(HEADER_NAME_CONTENT_TYPE, payload.getContentType());\n } else {\n body = JSON.stringify(payload);\n headers.set(HEADER_NAME_CONTENT_TYPE, 'application/json');\n }\n\n // make request\n try {\n const response = await fetch(url, { method, headers, body });\n const { ok: successful, status, statusText } = response;\n\n if (!successful) {\n try {\n const rawError = await response.text();\n return { headers: response.headers, successful, status, statusText, error: JSON.parse(rawError) };\n } catch (err) {\n if (err instanceof SyntaxError) {\n return {\n headers: response.headers,\n successful,\n status,\n statusText,\n error: {\n title: 'Unknown error',\n status,\n statusText: response.statusText,\n },\n };\n }\n\n const error: ProblemDetails = {\n title: (err instanceof Error ? err.message : undefined) ?? 'Unknown error',\n status: response.status,\n statusText: response.statusText,\n };\n\n return { headers: response.headers, successful, status, statusText, error };\n }\n }\n\n const contentLength = response.headers.get('content-length');\n let data = contentLength && contentLength !== '0' ? ((await response.json()) as T) : undefined;\n if (data && schema) {\n const result = await schema.safeParseAsync(data);\n if (!result.success) {\n return {\n headers: response.headers,\n successful: false,\n status,\n statusText,\n data,\n error: {\n title: 'application_error',\n detail: 'Schema validation error',\n errors: result.error.flatten().fieldErrors,\n status: response.status,\n statusText: response.statusText,\n },\n };\n }\n data = result.data;\n }\n\n return { headers: response.headers, data, successful, status, statusText };\n } catch (err) {\n return {\n headers: new Headers(),\n successful: false,\n status: -1,\n statusText: 'Application Error',\n error: {\n title: 'application_error',\n detail: `Unable to fetch data. The request could not be resolved. ${err}`,\n },\n };\n }\n }\n\n private makeUrl<T>(url: string, options?: InnerRequestOptions<T>): string {\n if (url.startsWith('http://') || url.startsWith('https://')) return url;\n const baseUrl = options?.baseUrl ?? this.baseUrl;\n return `${baseUrl}${url}`;\n }\n}\n\n/**\n * Whether to skip serialization of the payload.\n * @param payload The payload to check.\n * @returns true if the payload should not be serialized; otherwise, false.\n */\nfunction skipSerialization(\n payload: InnerRequestOptions<never>['payload'],\n): payload is FormData | URLSearchParams | ReadableStream | Blob | ArrayBuffer | string | undefined {\n return (\n payload instanceof FormData ||\n payload instanceof URLSearchParams ||\n payload instanceof ReadableStream ||\n payload instanceof Blob ||\n payload instanceof ArrayBuffer ||\n payload instanceof Buffer ||\n typeof payload === 'string' ||\n !payload\n );\n}\n\n/** Http request error */\nexport class HttpRequestError extends Error {\n constructor(\n message: string,\n public code: number,\n ) {\n super(message);\n }\n}\n\nexport function isErrorTemporaryFailure(e?: { code?: string | number; message?: string } | null): boolean {\n if (e instanceof HttpRequestError) {\n // Check for common HTTP status codes that indicate a temporary failure\n // See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status\n switch (e.code) {\n case 502:\n return true; // 502 Bad Gateway\n case 503:\n return true; // 503 Service Unavailable\n case 504:\n return true; // 504 Gateway Timeout\n default:\n return false;\n }\n } else if (e?.code) {\n // Check for Node.js system errors that indicate a temporary failure\n // See: https://nodejs.org/api/errors.html#errors_common_system_errors\n switch (e.code) {\n case 'ETIMEDOUT':\n return true; // Operation timed out\n default:\n return false;\n }\n } else {\n return false;\n }\n}\n"],"mappings":";;;;AAAA,MAAa,kCAAkC;AAC/C,MAAa,2BAA2B;AACxC,MAAa,qBAAqB;AAClC,MAAa,yBAAyB;AACtC,MAAa,4BAA4B;;;;ACFzC,IAAa,wBAAb,MAAmC;;wBACzB,QAAO;wBACP,YAAmB,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,UAAU,EAAE;wBAC7D,SAA0C,EAAE;;CAEpD,MAAa,SAA0B;AACrC,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI,MAAM,oDAAoD;EAGtE,MAAMA,OAAiD,EAAE;AAEzD,OAAK,MAAM,QAAQ,KAAK,OAAO;AAE7B,QAAK,KAAK,KAAK,KAAK,SAAS,MAAM;AAGnC,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,QAAQ,CACrD,MAAK,KAAK,GAAG,IAAI,IAAI,MAAM,MAAM;AAEnC,QAAK,KAAK,OAAO;AAGjB,QAAK,KAAK,KAAK,KAAK;AACpB,QAAK,KAAK,OAAO;;AAGnB,OAAK,KAAK,KAAK,KAAK,SAAS,QAAQ;EAErC,MAAMC,OAAiB,EAAE;AACzB,OAAK,MAAM,QAAQ,KACjB,KAAI,gBAAgB,KAAM,MAAK,KAAK,OAAO,KAAK,MAAM,KAAK,aAAa,CAAC,CAAC;WACjE,OAAO,SAAS,SAAU,MAAK,KAAK,OAAO,KAA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AAS,WAAW,KAAK,UACrB;;;;;;;;AASxB,SAAS,kBACP,SACkG;AAClG,QACE,mBAAmB,YACnB,mBAAmB,mBACnB,mBAAmB,kBACnB,mBAAmB,QACnB,mBAAmB,eACnB,mBAAmB,UACnB,OAAO,YAAY,YACnB,CAAC;;;AAKL,IAAa,mBAAb,cAAsC,MAAM;CAC1C,YACE,SACA,AAAOC,MACP;AACA,QAAM,QAAQ;EAFP;;;AAMX,SAAgB,wBAAwB,GAAkE;AACxG,KAAI,aAAa,iBAGf,SAAQ,EAAE,MAAV;EACE,KAAK,IACH,QAAO;EACT,KAAK,IACH,QAAO;EACT,KAAK,IACH,QAAO;EACT,QACE,QAAO;;UAEF,GAAG,KAGZ,SAAQ,EAAE,MAAV;EACE,KAAK,YACH,QAAO;EACT,QACE,QAAO;;KAGX,QAAO"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { t as environment } from "./environment-DinhzwQn.js";
|
|
2
|
+
import pino from "pino";
|
|
3
|
+
import { PinoPretty } from "pino-pretty";
|
|
4
|
+
|
|
5
|
+
//#region src/logger.ts
|
|
6
|
+
const options = {
|
|
7
|
+
level: process.env.LOG_LEVEL || (environment.production ? "warn" : "debug"),
|
|
8
|
+
base: {
|
|
9
|
+
env: environment.name,
|
|
10
|
+
sha: environment.sha,
|
|
11
|
+
branch: environment.branch
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const destination = environment.production ? void 0 : PinoPretty({
|
|
15
|
+
colorize: true,
|
|
16
|
+
sync: environment.test
|
|
17
|
+
});
|
|
18
|
+
const logger = pino(options, destination);
|
|
19
|
+
/**
|
|
20
|
+
* Creates a logger for the application.
|
|
21
|
+
* @param options - The options for creating the logger.
|
|
22
|
+
* @returns The created logger.
|
|
23
|
+
*/
|
|
24
|
+
function create({ name }) {
|
|
25
|
+
const application = `paklo-${name}`;
|
|
26
|
+
return logger.child({ application }, { level: environment.production ? "warn" : "debug" });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { logger as n, create as t };
|
|
31
|
+
//# sourceMappingURL=logger-B7HLv660.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-B7HLv660.js","names":["options: LoggerOptions","destination: DestinationStream | undefined"],"sources":["../../src/logger.ts"],"sourcesContent":["import pino, { type DestinationStream, type Logger, type LoggerOptions } from 'pino';\nimport { PinoPretty } from 'pino-pretty';\n\nimport { environment } from '@/environment';\n\nconst options: LoggerOptions = {\n level: process.env.LOG_LEVEL || (environment.production ? 'warn' : 'debug'),\n base: {\n env: environment.name,\n sha: environment.sha,\n branch: environment.branch,\n },\n};\n\n// pino-pretty has issues with nextjs and we cannot fix in webpack because we are moving to turbopack\n// https://github.com/pinojs/pino/issues/1841#issuecomment-1815284760\n// https://github.com/vercel/next.js/discussions/46987\nconst destination: DestinationStream | undefined = environment.production\n ? undefined\n : PinoPretty({\n colorize: true,\n // https://github.com/pinojs/pino-pretty#usage-with-jest\n sync: environment.test,\n });\nexport const logger = pino(options, destination);\n\n/** Options for creating a logger. */\nexport type CreateOptions = {\n /**\n * The name of the application.\n * @example `website`\n */\n name: string;\n};\n\n/**\n * Creates a logger for the application.\n * @param options - The options for creating the logger.\n * @returns The created logger.\n */\nexport function create({ name }: CreateOptions): Logger {\n const application = `paklo-${name}`;\n return logger.child({ application }, { level: environment.production ? 'warn' : 'debug' });\n}\n"],"mappings":";;;;;AAKA,MAAMA,UAAyB;CAC7B,OAAO,QAAQ,IAAI,cAAc,YAAY,aAAa,SAAS;CACnE,MAAM;EACJ,KAAK,YAAY;EACjB,KAAK,YAAY;EACjB,QAAQ,YAAY;EACrB;CACF;AAKD,MAAMC,cAA6C,YAAY,aAC3D,SACA,WAAW;CACT,UAAU;CAEV,MAAM,YAAY;CACnB,CAAC;AACN,MAAa,SAAS,KAAK,SAAS,YAAY;;;;;;AAgBhD,SAAgB,OAAO,EAAE,QAA+B;CACtD,MAAM,cAAc,SAAS;AAC7B,QAAO,OAAO,MAAM,EAAE,aAAa,EAAE,EAAE,OAAO,YAAY,aAAa,SAAS,SAAS,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import pino, { Logger } from "pino";
|
|
2
|
+
|
|
3
|
+
//#region src/logger.d.ts
|
|
4
|
+
declare const logger: pino.Logger<never, boolean>;
|
|
5
|
+
/** Options for creating a logger. */
|
|
6
|
+
type CreateOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the application.
|
|
9
|
+
* @example `website`
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Creates a logger for the application.
|
|
15
|
+
* @param options - The options for creating the logger.
|
|
16
|
+
* @returns The created logger.
|
|
17
|
+
*/
|
|
18
|
+
declare function create({
|
|
19
|
+
name
|
|
20
|
+
}: CreateOptions): Logger;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { CreateOptions, create, logger };
|
|
23
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/shared-data/social-media.d.ts
|
|
2
|
+
declare const socials: {
|
|
3
|
+
twitter: {
|
|
4
|
+
username: string;
|
|
5
|
+
url: string;
|
|
6
|
+
};
|
|
7
|
+
linkedin: {
|
|
8
|
+
username: string;
|
|
9
|
+
url: string;
|
|
10
|
+
};
|
|
11
|
+
youtube: {
|
|
12
|
+
channel: string;
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
github: {
|
|
16
|
+
username: string;
|
|
17
|
+
url: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { socials };
|
|
22
|
+
//# sourceMappingURL=shared-data.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/shared-data/social-media.ts
|
|
2
|
+
const socials = {
|
|
3
|
+
twitter: {
|
|
4
|
+
username: "maxwellweru",
|
|
5
|
+
url: "https://twitter.com/maxwellweru"
|
|
6
|
+
},
|
|
7
|
+
linkedin: {
|
|
8
|
+
username: "maxwellweru",
|
|
9
|
+
url: "https://www.linkedin.com/in/maxwellweru"
|
|
10
|
+
},
|
|
11
|
+
youtube: {
|
|
12
|
+
channel: "mburumaxwell",
|
|
13
|
+
url: "https://youtube.com/c/mburumaxwell"
|
|
14
|
+
},
|
|
15
|
+
github: {
|
|
16
|
+
username: "mburumaxwell",
|
|
17
|
+
url: "https://github.com/mburumaxwell"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { socials };
|
|
23
|
+
//# sourceMappingURL=shared-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-data.js","names":[],"sources":["../../src/shared-data/social-media.ts"],"sourcesContent":["// just me, for now\nexport const socials = {\n twitter: {\n username: 'maxwellweru',\n url: 'https://twitter.com/maxwellweru',\n },\n linkedin: {\n username: 'maxwellweru',\n url: 'https://www.linkedin.com/in/maxwellweru',\n },\n youtube: {\n channel: 'mburumaxwell',\n url: 'https://youtube.com/c/mburumaxwell',\n },\n github: {\n username: 'mburumaxwell',\n url: 'https://github.com/mburumaxwell',\n },\n};\n"],"mappings":";AACA,MAAa,UAAU;CACrB,SAAS;EACP,UAAU;EACV,KAAK;EACN;CACD,UAAU;EACR,UAAU;EACV,KAAK;EACN;CACD,SAAS;EACP,SAAS;EACT,KAAK;EACN;CACD,QAAQ;EACN,UAAU;EACV,KAAK;EACN;CACF"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
|
|
3
|
+
//#region src/usage.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* ```json
|
|
8
|
+
* {
|
|
9
|
+
* "host": {
|
|
10
|
+
* "platform": "darwin",
|
|
11
|
+
* "os": "25.0.0",
|
|
12
|
+
* "arch": "arm64",
|
|
13
|
+
* "machine-hash": "d3bbb66be2ad9dfab10af69b450f7e7e814ef7bbf1277a6d0df9e1db44ba4f5c"
|
|
14
|
+
* },
|
|
15
|
+
* "trigger": "user",
|
|
16
|
+
* "provider": "azure",
|
|
17
|
+
* "owner": "https://dev.azure.com/tingle/",
|
|
18
|
+
* "package-manager": "terraform",
|
|
19
|
+
* "version": "0.9.0",
|
|
20
|
+
* "id": 2850677077,
|
|
21
|
+
* "started": "2025-10-03T14:44:00.191Z",
|
|
22
|
+
* "duration": 31812,
|
|
23
|
+
* "success": true
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare const UsageTelemetryRequestDataSchema: z.ZodObject<{
|
|
28
|
+
host: z.ZodObject<{
|
|
29
|
+
platform: z.ZodString;
|
|
30
|
+
release: z.ZodString;
|
|
31
|
+
arch: z.ZodString;
|
|
32
|
+
'machine-hash': z.ZodString;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
version: z.ZodString;
|
|
35
|
+
trigger: z.ZodEnum<{
|
|
36
|
+
user: "user";
|
|
37
|
+
service: "service";
|
|
38
|
+
}>;
|
|
39
|
+
provider: z.ZodEnum<{
|
|
40
|
+
azure: "azure";
|
|
41
|
+
}>;
|
|
42
|
+
owner: z.ZodURL;
|
|
43
|
+
project: z.ZodOptional<z.ZodURL>;
|
|
44
|
+
'package-manager': z.ZodEnum<{
|
|
45
|
+
hex: "hex";
|
|
46
|
+
bun: "bun";
|
|
47
|
+
bundler: "bundler";
|
|
48
|
+
cargo: "cargo";
|
|
49
|
+
composer: "composer";
|
|
50
|
+
devcontainers: "devcontainers";
|
|
51
|
+
docker: "docker";
|
|
52
|
+
docker_compose: "docker_compose";
|
|
53
|
+
dotnet_sdk: "dotnet_sdk";
|
|
54
|
+
helm: "helm";
|
|
55
|
+
elm: "elm";
|
|
56
|
+
submodules: "submodules";
|
|
57
|
+
github_actions: "github_actions";
|
|
58
|
+
go_modules: "go_modules";
|
|
59
|
+
gradle: "gradle";
|
|
60
|
+
maven: "maven";
|
|
61
|
+
npm_and_yarn: "npm_and_yarn";
|
|
62
|
+
nuget: "nuget";
|
|
63
|
+
pip: "pip";
|
|
64
|
+
pub: "pub";
|
|
65
|
+
swift: "swift";
|
|
66
|
+
terraform: "terraform";
|
|
67
|
+
uv: "uv";
|
|
68
|
+
}>;
|
|
69
|
+
id: z.ZodNumber;
|
|
70
|
+
started: z.ZodCoercedDate<unknown>;
|
|
71
|
+
duration: z.ZodNumber;
|
|
72
|
+
success: z.ZodBoolean;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
/**
|
|
75
|
+
* @example
|
|
76
|
+
* ```json
|
|
77
|
+
* {
|
|
78
|
+
* "host": {
|
|
79
|
+
* "platform": "darwin",
|
|
80
|
+
* "os": "25.0.0",
|
|
81
|
+
* "arch": "arm64",
|
|
82
|
+
* "machine-hash": "d3bbb66be2ad9dfab10af69b450f7e7e814ef7bbf1277a6d0df9e1db44ba4f5c"
|
|
83
|
+
* },
|
|
84
|
+
* "trigger": "user",
|
|
85
|
+
* "provider": "azure",
|
|
86
|
+
* "owner": "https://dev.azure.com/tingle/",
|
|
87
|
+
* "package-manager": "terraform",
|
|
88
|
+
* "version": "0.9.0",
|
|
89
|
+
* "id": 2850677077,
|
|
90
|
+
* "started": "2025-10-03T14:44:00.191Z",
|
|
91
|
+
* "duration": 31812,
|
|
92
|
+
* "success": true
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
type UsageTelemetryRequestData = z.infer<typeof UsageTelemetryRequestDataSchema>;
|
|
97
|
+
//#endregion
|
|
98
|
+
export { UsageTelemetryRequestData, UsageTelemetryRequestDataSchema };
|
|
99
|
+
//# sourceMappingURL=usage.d.ts.map
|