forked from SAP/webide-client-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.d.ts
326 lines (280 loc) · 11.1 KB
/
api.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
// ----------------------------------------------------------------
// -------------------------- Dev Server --------------------------
// ----------------------------------------------------------------
/**
* A configuration of Connect Middleware functions.
* NOTE: The <path> property is optional
* and the middleware property may be an array.
*/
import {Server} from "http";
import {Configuration as WebpackConfiguration} from "webpack"
export type MiddlewareOptions = {
path?: string
middleware: Function | Array<Function>
}[]
export type DefaultMiddlewareOptions = {
diHost?: string,
diPort?: number,
minikubeIp? :string
}
export interface DevServerAPI {
/**
* Starts a static connect web server serving the CWD.
*/
startConnect: (
options?: {
port?: number
customMiddlewares?: MiddlewareOptions[]
builtInMiddlewareOpts?: DefaultMiddlewareOptions
}
) => Server
/**
* Returns the default middleware required to run SAP Web IDE locally on a connect webserver.
* This means redirects for "env.json" files with "local" configurations
* and reverse proxies for DI.
*/
getDefaultMiddleware: (
options?: DefaultMiddlewareOptions
) => MiddlewareOptions
}
export declare const devServer: DevServerAPI
// ----------------------------------------------------------------
// -------------------------- Karma -------------------------------
// ----------------------------------------------------------------
export interface KarmaAPI {
/**
* Returns the default properties to be used in SAP Web IDE Karma configuration.
* This can be used directly; however, @see "buildKarmaConfig"
* for a convenience utility to assist building Karma configurations.
*
* See @link http://karma-runner.github.io/1.0/config/configuration-file.html
* for details.
*/
defaultProps: () => Object
/**
* @param version - SAPUI5 version.
* @param baseUrl - URL where SAPUI5 is hosted.
*
* @returns a full URL to "sap-ui-core.js".
*/
getUi5VersionUrl: (version: string, baseUrl: string) => string
}
export declare const karma: KarmaAPI
// ----------------------------------------------------------------
// -------------------------- Bundling ----------------------------
// ----------------------------------------------------------------
export interface BundlingAPI {
/**
* Bundles an SAP Web IDE feature, including JS sources, “i18n” files, and JSON metadata.
* It does not include the bundling of any SAPUI5 resources. Use tools provided by SAPUI5 to bundle those.
*
* Returns a promise with an object. The object properties:
* outDir: output directory containing the bundled files. The output directory's name may not be known
* in advance as it may include a timestamp when the caching option is enabled. By exposing the
* exact name, custom post-processing steps may be more easily implemented by the user.
*
*/
bundleFeature: (
target: string,
options?: {
/**
* Which JavaScript bundler to use.
* Note that each of the bundlers have their configuration key.
* - "javascriptOpts" for requirejs.
* - "webpackConfiguration" for webpack.
*/
bundler?: "webpack" | "requirejs"
/**
* Output directory for the bundle.
* Default value is "dist".
*/
outDir?: string
/**
* Bundle into "outDir/[VERSION]_[TIMESTAMP]/" instead of "outDir/"
* and create a wrapper "package.json" file in the "outDir/package.json" file to enable caching support.
* Default value is "true".
*/
enableCaching?: boolean
/**
* Should the output directory be cleaned prior to the bundling?
* This is enabled by default. If you have custom code that creates additional
* packaged artifacts in this directory, disabling this option should be considered.
* Default value is "true".
*/
cleanOutDir?: boolean
/**
* SubOptions for the javaScript bundling phase.
* The are only relevant when using the require.js optimizer for bundling.
*/
javaScriptOpts?: {
/**
* Custom configurations for the "require.js" optimizer.
* For details, @link http://requirejs.org/docs/optimization.html#options.
*/
optimizeOptions?: Object
/**
* Will only log validation errors on the bundled artifacts
* instead of throwing an error that rejects the promise.
* Enable it only if you are an advanced user and understand
* the ramifications.
* @link {https://github.com/SAP/webide-client-tools/blob/master/FAQ.md#VALIDATE
*/
ignoreValidations?: boolean
/**
* Ignored glob patterns, by default all JS resources (recursively)
* in the directory of the "plugin.json" file are bundled. However,
* some special edge cases may require exclusion.
* For details about valid pattern syntax, @link https://github.com/isaacs/node-glob.
*/
ignore?: string | string[]
},
/**
* The webpack configuration
* - Mutually exclusive with providing javaScriptOpts.
* - For details see:
* @link {https://webpack.js.org/concepts/}
* @link {https://www.npmjs.com/package/@types/webpack}
*/
webpackConfig?: WebpackConfiguration
/**
* SubOptions for the JSON file metadata bundling phase.
*/
metadataOpts?: {
/**
* Prefix to apply to all plugin paths, such as "quickstart" --> "prefix/quickstart".
*/
pluginsPrefix?: string
}
}
) => Promise<{ outDir: string }>
/**
* Returns the default configuration for bundling webide JavaScript resources
* Using webpack. Use this as the starting point in creating your own
* webpack.config.js file.
*/
getDefaultWebpackConfig: ( target?: string) => WebpackConfiguration
/**
* Internal utilities to construct the "bundleFeature" flow.
* These are exposed as unofficial APIs to enable the creation of advanced flows by end users.
* However, they receive the same level of support as the official APIs.
*/
internal: any
}
export declare const bundling: BundlingAPI
// ----------------------------------------------------------------
// -------------------------- STF ---------------------------------
// ----------------------------------------------------------------
export type PluginDescription = {
pluginName: string
sURI: string
required?: boolean
}
export type PluginsTransformDef = {
remove?: (string | RegExp)[]
add?: PluginDescription[]
}
export type MockPresets = "IN_MEMORY_BACKEND"
export type WebIDEServiceProxy = Object
export type AMDModule = Object
export interface STF_API {
/**
*
* @param [options.urlParams] {Object.<string, string>} -
* Additional url params, for example:
* {
* user:"TECHNICAL_USER",
* myKey:"myValue"
* }
*
*
* @return {Promise<Window>} For the window where SAP Web Ide is running.
* This is resolved when the SAP Web IDE core has finished loading (all_plugins_started).
*/
startWebIDE: (
/**
* Unique ID for this SAP Web IDE instance.
*/
id: string,
options?: {
/**
* An SAP Web IDE feature configuration to be used as
* the root configuration when starting SAP Web IDE.
*/
featureConfig?: Object
/**
* An SAP Web IDE "env.json" object (NOT a URL link to one).
*/
env?: Object
/**
* Definition of SAP Web IDE plugin transformation that happens BEFORE
* any plugins are registered in the "pluginRegistry". This allows using mock
* plugins or adding plugins to the SAP Web IDE instance that starts during tests.
*/
pluginsTransformDef?: PluginsTransformDef
/**
* Common presets for using "pluginsTransformDef" to mock (i.e., replace) SAP Web IDE capabilities.
* Most commonly used to mock the back-end service to allow testing with an "in-memory"
* fake file system.
*/
mocks?: MockPresets[]
/**
* Default value is: "/base/node_modules/webide/src/main/webapp/index.html".
*/
html?: string
/**
* Path to load SAPUI5 from this instance of SAP Web IDE.
*/
ui5Root?: string
/**
* Flag to enable or disable the use of the "sap-ui-debug=true" flag in the SAP Web IDE URL.
*/
ui5Debug?: boolean
/**
* Flag to enable or disable the use of the "sap-ide-debug=true" flag in the SAP Web IDE URL.
*/
ideDebug?: boolean
/**
* Additional url params passed to the webide instance for example:
* {
* user: "TECHNICAL_USER",
* myFlag: "myValue"
* }
*/
urlParams?: { [key: string]: string }
}
) => Promise<void>
shutdownWebIde(
/**
* ID of the SAP Web IDE instance to shut down.
*/
id: string
): void
/**
* Exposes a service from the SAP Web IDE instance.
*/
getService(
/**
* ID of the SAP Web IDE instance to shut down.
*/
id: string,
serviceName: string
): Promise<WebIDEServiceProxy>
/**
* Utility to get a partial <getService> function with a bound "suiteName" argument.
* This can be used to reduce verbosity and mistakes coming from copying pasting.
*/
getServicePartial(
id: string
): (serviceName: string) => Promise<WebIDEServiceProxy>
/**
* Exposes the "require.js" AMD modules from the "iframe" of the SAP Web IDE instance.
*/
require(id: string, depPaths: string[]): Promise<AMDModule>
/**
* Exposes the original AMD module of an SAP Web IDE service proxy.
* This can allow accessing "private" methods on a service.
*/
getServicePrivateImpl(Service: WebIDEServiceProxy): Promise<AMDModule>
}
export declare const STF: STF_API
export as namespace webideClientTools