@glassly/cloud-client 0.4.3-dev.1207 → 0.4.3
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/package.json +2 -2
- package/src/http.ts +5 -0
- package/src/index.ts +1 -0
- package/src/modules/core/core.ts +4 -0
- package/src/modules/core/reports.ts +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glassly/cloud-client",
|
|
3
|
-
"version": "0.4.3
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"test": "bun test"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@glassly/cloud-protocol": "0.4.3
|
|
15
|
+
"@glassly/cloud-protocol": "0.4.3",
|
|
16
16
|
"tweetnacl": "^1.0.3"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
package/src/http.ts
CHANGED
|
@@ -25,12 +25,16 @@ import type { HttpTransport } from "./transports";
|
|
|
25
25
|
* presents the refresh token, so they pass `bearer` explicitly rather than going
|
|
26
26
|
* through `cloud.auth`.
|
|
27
27
|
*
|
|
28
|
+
* `anonymous` sends no Bearer and never calls the token source, so the call
|
|
29
|
+
* still goes out while the stored credentials are dead.
|
|
30
|
+
*
|
|
28
31
|
* `idempotent` marks a call as safe to retry on a transient network error. GET
|
|
29
32
|
* is always treated as idempotent; the full-replace PUT opts in via this flag.
|
|
30
33
|
* POST is never retried by default because it may not be safe to repeat.
|
|
31
34
|
*/
|
|
32
35
|
export interface ReqOpts {
|
|
33
36
|
bearer?: string;
|
|
37
|
+
anonymous?: boolean;
|
|
34
38
|
idempotent?: boolean;
|
|
35
39
|
/**
|
|
36
40
|
* Extra request headers. For per-call values that must not be logged with the
|
|
@@ -98,6 +102,7 @@ export function createHttpClient(deps: CreateHttpClientDeps): HttpClient {
|
|
|
98
102
|
* logs everywhere in this library.
|
|
99
103
|
*/
|
|
100
104
|
async function resolveBearer(opts?: ReqOpts): Promise<string | undefined> {
|
|
105
|
+
if (opts?.anonymous) return undefined;
|
|
101
106
|
if (opts?.bearer) return opts.bearer;
|
|
102
107
|
if (getToken) return await getToken();
|
|
103
108
|
return undefined;
|
package/src/index.ts
CHANGED
package/src/modules/core/core.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type ReportAttachmentInput,
|
|
24
24
|
type ReportLogEntry,
|
|
25
25
|
type ReportStatus,
|
|
26
|
+
type SubmitAnonymousReportInput,
|
|
26
27
|
type SubmitReportInput,
|
|
27
28
|
type SubmitReportResult,
|
|
28
29
|
} from "./reports";
|
|
@@ -42,6 +43,7 @@ export type {
|
|
|
42
43
|
ReportStatus,
|
|
43
44
|
ReportSystemPriority,
|
|
44
45
|
ReportTrigger,
|
|
46
|
+
SubmitAnonymousReportInput,
|
|
45
47
|
SubmitReportInput,
|
|
46
48
|
SubmitReportResult,
|
|
47
49
|
} from "./reports";
|
|
@@ -192,6 +194,7 @@ export class Core {
|
|
|
192
194
|
};
|
|
193
195
|
readonly reports: {
|
|
194
196
|
submit(input: SubmitReportInput): Promise<SubmitReportResult>;
|
|
197
|
+
submitAnonymous(input: SubmitAnonymousReportInput): Promise<SubmitReportResult>;
|
|
195
198
|
addLogs(
|
|
196
199
|
reportId: string,
|
|
197
200
|
source: string,
|
|
@@ -259,6 +262,7 @@ export class Core {
|
|
|
259
262
|
};
|
|
260
263
|
this.reports = {
|
|
261
264
|
submit: reports.submit.bind(reports),
|
|
265
|
+
submitAnonymous: reports.submitAnonymous.bind(reports),
|
|
262
266
|
addLogs: reports.addLogs.bind(reports),
|
|
263
267
|
addScreenshots: reports.addScreenshots.bind(reports),
|
|
264
268
|
complete: reports.complete.bind(reports),
|
|
@@ -61,6 +61,20 @@ export type SubmitReportInput =
|
|
|
61
61
|
context: ReportContext;
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
export type SubmitAnonymousReportInput =
|
|
65
|
+
| {
|
|
66
|
+
kind: "bug";
|
|
67
|
+
trigger: ReportTrigger;
|
|
68
|
+
report: ReportDetails;
|
|
69
|
+
context: ReportContext;
|
|
70
|
+
logs?: ReportLogEntry[];
|
|
71
|
+
}
|
|
72
|
+
| {
|
|
73
|
+
kind: "feedback";
|
|
74
|
+
feedback: string | Record<string, unknown>;
|
|
75
|
+
context: ReportContext;
|
|
76
|
+
};
|
|
77
|
+
|
|
64
78
|
export interface SubmitReportResult {
|
|
65
79
|
reportId: string;
|
|
66
80
|
status: ReportStatus;
|
|
@@ -99,6 +113,10 @@ export class Reports {
|
|
|
99
113
|
return this.http.post<SubmitReportResult>(REPORTS_PATH, input);
|
|
100
114
|
}
|
|
101
115
|
|
|
116
|
+
submitAnonymous(input: SubmitAnonymousReportInput): Promise<SubmitReportResult> {
|
|
117
|
+
return this.http.post<SubmitReportResult>(`${REPORTS_PATH}/anonymous`, input, { anonymous: true });
|
|
118
|
+
}
|
|
119
|
+
|
|
102
120
|
/** `replace` swaps out the report's earlier log bundles from `source`. */
|
|
103
121
|
async addLogs(
|
|
104
122
|
reportId: string,
|