1/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// TODO (b/262667224):
18//  deduplicate all the type definitions in this file when we move Winscope to google3.
19//  The definitions were duplicated from these source files:
20//  - google3/wireless/android/tools/android_bug_tool/app/platform/web/interface/command.ts
21//  - google3/wireless/android/tools/android_bug_tool/app/platform/web/interface/attachment_metadata.ts
22//  - google3/wireless/android/tools/android_bug_tool/app/platform/web/interface/bug_report_metadata.ts
23
24/** Describes the type of message enclosed in a {@code WebCommandMessage}. */
25export enum MessageType {
26  UNKNOWN,
27  OPEN_REQUEST,
28  OPEN_BUGANIZER_RESPONSE,
29  OPEN_WEB_RESPONSE,
30  OPEN_URL_REQUEST,
31  OPEN_URL_RESPONSE,
32  CHECK_ISSUE_METADATA_REQUEST,
33  CHECK_ISSUE_METADATA_RESPONSE,
34  OPEN_TOOL_WEB_REQUEST,
35}
36
37/** Base of all messages sent between the web and extension. */
38export declare interface WebCommandMessage {
39  action: MessageType;
40}
41
42/** Request from web to background to download the file. */
43export interface OpenRequest extends WebCommandMessage {
44  action: MessageType.OPEN_REQUEST;
45}
46
47/** Response of download the issue's attachment from background. */
48export declare interface OpenBuganizerResponse extends WebCommandMessage {
49  action: MessageType.OPEN_BUGANIZER_RESPONSE;
50
51  /** issue id */
52  issueId: string;
53
54  /** issue title */
55  issueTitle: string | undefined;
56
57  /** issue access level */
58  issueAccessLevel: IssueAccessLimit | undefined;
59
60  /** Attachment list. */
61  attachments: AttachmentMetadata[];
62}
63
64/** Attachment metadata. */
65export interface AttachmentMetadata {
66  bugReportMetadata?: BugReportMetadata;
67  author: string;
68  name: string;
69  objectUrl: string;
70  restrictionSeverity: RestrictionSeverity;
71  resourceName: string;
72  entityStatus: EntityStatus;
73  attachmentId: string;
74  fileSize: number;
75  commentTimestamp?: DateTime;
76}
77
78/**
79 * Incorporates all of the metadata that can be retrieved from a bugreport
80 * file name.
81 */
82export interface BugReportMetadata {
83  uuid?: string;
84  hasWinscope: boolean;
85  hasTrace: boolean;
86  isRedacted: boolean;
87  device: string;
88  build: string;
89  // The date parsed from the bug report filename is only used for
90  // grouping common files together.  It is not used for display purposes.
91  timestamp: DateTime;
92}
93
94/**
95 * Defines of the issue access limit. See:
96 * http://go/buganizer/concepts/access-control#accesslimit
97 */
98export enum IssueAccessLimit {
99  INTERNAL = '',
100  VISIBLE_TO_PARTNERS = 'Visible to Partners',
101  VISIBLE_TO_PUBLIC = 'Visible to Public',
102}
103
104/**
105 * Types of issue content restriction verdicts. See:
106 * http://google3/google/devtools/issuetracker/v1/issuetracker.proto?l=1858&rcl=278024740
107 */
108export enum RestrictionSeverity {
109  /** Unspecified restricted content severity */
110  RESTRICTION_SEVERITY_UNSPECIFIED = 0,
111  /** No restricted content was detected/flagged in the content */
112  NONE_DETECTED = 1,
113  /** Restricted content was detected/flagged in the content */
114  RESTRICTED = 2,
115  /** RESTRICTED_PLUS content was detected/flagged in the content */
116  RESTRICTED_PLUS = 3,
117}
118
119/**
120 * Types of entity statuses for issue tracker attachments. See:
121 * https:google3/google/devtools/issuetracker/v1/issuetracker.proto;rcl=448855448;l=58
122 */
123export enum EntityStatus {
124  // Default value. Entity exists and is available for use.
125  ACTIVE = 0,
126  // Entity is invisible except for administrative actions, i.e. undelete.
127  DELETED = 1,
128  // Entity is irretrievably wiped.
129  PURGED = 2,
130}
131
132// Actual definition is in google3/third_party/javascript/closure/date/date
133export type DateTime = object;
134