-
Notifications
You must be signed in to change notification settings - Fork 208
/
NativeAppProps.ts
152 lines (127 loc) · 5.12 KB
/
NativeAppProps.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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module NativeApp
*/
import { AccessToken, GuidString } from "@itwin/core-bentley";
import { BriefcaseProps, LocalBriefcaseProps, RequestNewBriefcaseProps } from "./BriefcaseTypes";
/** @internal */
export const nativeAppIpcStrings = {
channelName: "itwinjs-core/nativeApp",
notifyChannel: "itwinjs-core/nativeApp-notify",
} as const;
/**
* Type of value for storage values
* @beta
*/
export type StorageValue = string | number | boolean | undefined | Uint8Array;
/** Indicates whether or not the computer is currently connected to the internet.
* @beta
*/
export enum InternetConnectivityStatus {
Online,
Offline,
}
/** Describes whether the user or the browser overrode the internet connectivity status.
* @beta
*/
export enum OverriddenBy {
Browser,
User,
}
/**
* Interface implemented by the frontend [NotificationHandler]($common) to be notified of events from NativeApp backend.
* @internal
*/
export interface NativeAppNotifications {
notifyInternetConnectivityChanged(status: InternetConnectivityStatus): void;
}
/**
* The methods that may be invoked via Ipc from the frontend of a Native App and are implemented on its backend.
* @internal
*/
export interface NativeAppFunctions {
/** If the user is signed in a valid access token will be returned. */
getAccessToken: () => Promise<AccessToken | undefined>;
/** Check if the internet is reachable. */
checkInternetConnectivity(): Promise<InternetConnectivityStatus>;
/** Manually override internet reachability for testing purposes.
* @param _status New status to set on backend.
*/
overrideInternetConnectivity(_overriddenBy: OverriddenBy, _status: InternetConnectivityStatus): Promise<void>;
/** Acquire a new BriefcaseId for the supplied iModelId from iModelHub */
acquireNewBriefcaseId(_iModelId: GuidString): Promise<number>;
/** Get the filename in the briefcase cache for the supplied BriefcaseId and iModelId.
* @note this merely returns the full path fileName. It does not test for the existence of the file.
*/
getBriefcaseFileName(_props: BriefcaseProps): Promise<string>;
/** Download a briefcase file for the supplied briefcase properties. */
downloadBriefcase(_requestProps: RequestNewBriefcaseProps, _reportProgress: boolean, _interval?: number): Promise<LocalBriefcaseProps>;
/**
* Cancels the previously requested download of a briefcase
* @param _key Key to locate the briefcase in the disk cache
* @note returns true if the cancel request was acknowledged. false otherwise
*/
requestCancelDownloadBriefcase(_fileName: string): Promise<boolean>;
/**
* Delete a previously downloaded briefcase. The briefcase must be closed.
* @param _fileName the Briefcase to delete
*/
deleteBriefcaseFiles(_fileName: string): Promise<void>;
/**
* Gets a list of all briefcases that were previously downloaded to the system briefcase cache.
* @note returns array of LocalBriefcaseProps.
*/
getCachedBriefcases(_iModelId?: GuidString): Promise<LocalBriefcaseProps[]>;
/**
* Open a key/value pair base storage
* @param _storageId string identifier of storage
*/
storageMgrOpen(_storageId: string): Promise<string>;
/**
* Close a key/value pair base storage
* @param _storageId string identifier of storage
* @param _deleteOnClose delete the storage on close
*/
storageMgrClose(_storageId: string, _deleteOnClose: boolean): Promise<void>;
/**
* Get the names of available storages
* @note returns list of storage names
*/
storageMgrNames(): Promise<string[]>;
/**
* Get the value associated with a key.
* @param _storageId string identifier of storage
* @param _key key identifier for value
* @note returns key value or undefined
*/
storageGet(_storageId: string, _key: string): Promise<StorageValue | undefined>;
/**
* Set a value for a key.
* @param _storageId string identifier of storage
* @param _key key identifier for value
* @param _value value to be set
*/
storageSet(_storageId: string, _key: string, _value: StorageValue): Promise<void>;
/**
* Remove a key/value pair.
* @param _storageId string identifier of storage
* @param _key key identifier for value
*/
storageRemove(_storageId: string, _key: string): Promise<void>;
/**
* Get list of keys in a storage.
* @param _storageId string identifier of storage
* @note returns list of storage ids
*/
storageKeys(_storageId: string): Promise<string[]>;
/**
* Delete all key/value pairs.
* @param _storageId string identifier of storage
*/
storageRemoveAll(_storageId: string): Promise<void>;
/** get the type of a value for a key, or undefined if not present. */
storageGetValueType(_storageId: string, _key: string): Promise<"number" | "string" | "boolean" | "Uint8Array" | "null" | undefined>;
}