• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16export enum SdkProblem {
17  LimitedVoidType = 'LimitedVoidType',
18  ConstructorIface = 'ConstructorIface',
19  LiteralAsPropertyName = 'LiteralAsPropertyName',
20  OptionalMethod = 'OptionalMethod',
21  ConstructorFuncs = 'ConstructorFuncs',
22  IndexedAccessType = 'IndexedAccessType',
23  SendablePropType = 'SendablePropType',
24  TypeQuery = 'TypeQuery',
25  GlobalThisError = 'GlobalThisError',
26  InterfaceExtendsClass = 'InterfaceExtendsClass',
27  DeclWithDuplicateName = 'DeclWithDuplicateName',
28  ComputedPropertyName = 'ComputedPropertyName'
29}
30
31export enum SdkNameInfo {
32  ParentApiName = 'parent_api_name',
33  ImportPath = 'import_path'
34}
35
36export const ARKTS_WHITE_API_PATH_TEXTSTYLE = 'component/styled_string.d.ts';
37
38// Define function argument class
39export class ApiFuncArg {
40  name: string;
41  type: string;
42  is_optional: boolean;
43  has_default?: boolean;
44
45  constructor(data: Partial<ApiFuncArg>) {
46    this.name = data.name || '';
47    this.type = data.type || '';
48    this.is_optional = data.is_optional || false;
49    this.has_default = data.has_default || undefined;
50  }
51}
52
53// Define the parent API class (recursive structure)
54export class ParentApi {
55  api_name: string;
56  api_type: string;
57
58  constructor(data: Partial<ParentApi>) {
59    this.api_name = data.api_name || '';
60    this.api_type = data.api_type || '';
61  }
62}
63
64// Define the API information class
65export class ApiInfo {
66  problem: string;
67  api_name?: string;
68  api_type: string;
69  api_optional?: boolean;
70  api_auto_fix?: boolean;
71  api_auto_fix_context?: string;
72  api_func_args?: ApiFuncArg[];
73  parent_api: ParentApi[];
74  method_return_type?: string;
75  api_property_type?: string;
76  code_kind: number;
77
78  constructor(data: Partial<ApiInfo>) {
79    this.problem = data.problem || '';
80    this.api_name = data.api_name || undefined;
81    this.api_type = data.api_type || '';
82    this.api_optional = data.api_optional || undefined;
83    this.api_auto_fix = data.api_auto_fix || undefined;
84    this.api_auto_fix_context = data.api_auto_fix_context || undefined;
85    this.api_func_args =
86      (data.api_func_args || []).map((arg) => {
87        return new ApiFuncArg(arg);
88      }) || undefined;
89    this.parent_api = (data.parent_api || []).map((parent) => {
90      return new ParentApi(parent);
91    });
92    this.method_return_type = data.method_return_type || undefined;
93    this.api_property_type = data.api_property_type || undefined;
94    this.code_kind = data.code_kind || 0;
95  }
96}
97
98// Define the API list item class
99export class ApiListItem {
100  import_path: string[];
101  file_path: string;
102  api_info: ApiInfo;
103  is_global: boolean;
104
105  constructor(data: Partial<ApiListItem>) {
106    this.import_path = data.import_path || [];
107    this.file_path = data.file_path || '';
108    this.api_info = new ApiInfo(data.api_info || {});
109    this.is_global = data.is_global || false;
110  }
111}
112
113// Define the top-level API list class
114export class ApiList {
115  api_list: ApiListItem[];
116
117  constructor(data: Partial<ApiList>) {
118    this.api_list = (data.api_list || []).map((item) => {
119      return new ApiListItem(item);
120    });
121  }
122}
123