@api-client/ui 0.0.12 → 0.0.14

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.
Files changed (194) hide show
  1. package/demo/elements/authorization/cc.ts +56 -27
  2. package/dist/bindings/base/FileBindings.d.ts +4 -0
  3. package/dist/bindings/base/FileBindings.d.ts.map +1 -1
  4. package/dist/bindings/base/FileBindings.js +21 -1
  5. package/dist/bindings/base/FileBindings.js.map +1 -1
  6. package/dist/bindings/base/StoreBindings.d.ts +1 -17
  7. package/dist/bindings/base/StoreBindings.d.ts.map +1 -1
  8. package/dist/bindings/base/StoreBindings.js +0 -59
  9. package/dist/bindings/base/StoreBindings.js.map +1 -1
  10. package/dist/bindings/web/WebFileBindings.js +1 -1
  11. package/dist/bindings/web/WebFileBindings.js.map +1 -1
  12. package/dist/define/http/certificate-add.d.ts +9 -0
  13. package/dist/define/http/certificate-add.d.ts.map +1 -0
  14. package/dist/define/http/certificate-add.js +10 -0
  15. package/dist/define/http/certificate-add.js.map +1 -0
  16. package/dist/define/http/http-body-editor.d.ts.map +1 -1
  17. package/dist/define/http/http-body-editor.js +1 -1
  18. package/dist/define/http/http-body-editor.js.map +1 -1
  19. package/dist/define/ui/ui-segmented-button-set.d.ts +1 -1
  20. package/dist/define/ui/ui-segmented-button-set.d.ts.map +1 -1
  21. package/dist/define/ui/ui-segmented-button-set.js.map +1 -1
  22. package/dist/elements/authorization/ui/CC.styles.d.ts.map +1 -1
  23. package/dist/elements/authorization/ui/CC.styles.js +4 -9
  24. package/dist/elements/authorization/ui/CC.styles.js.map +1 -1
  25. package/dist/elements/authorization/ui/CcAuthorization.d.ts +14 -29
  26. package/dist/elements/authorization/ui/CcAuthorization.d.ts.map +1 -1
  27. package/dist/elements/authorization/ui/CcAuthorization.js +67 -158
  28. package/dist/elements/authorization/ui/CcAuthorization.js.map +1 -1
  29. package/dist/elements/http/BodyEditor.js +5 -5
  30. package/dist/elements/http/BodyEditor.js.map +1 -1
  31. package/dist/elements/http/BodyEditor.styles.d.ts +1 -1
  32. package/dist/elements/http/BodyEditor.styles.d.ts.map +1 -1
  33. package/dist/elements/http/BodyEditor.styles.js +5 -19
  34. package/dist/elements/http/BodyEditor.styles.js.map +1 -1
  35. package/dist/elements/http/CertificateAdd.element.d.ts +91 -0
  36. package/dist/elements/http/CertificateAdd.element.d.ts.map +1 -0
  37. package/dist/elements/http/CertificateAdd.element.js +389 -0
  38. package/dist/elements/http/CertificateAdd.element.js.map +1 -0
  39. package/dist/elements/http/CertificateAdd.styles.d.ts +3 -0
  40. package/dist/elements/http/CertificateAdd.styles.d.ts.map +1 -0
  41. package/dist/elements/http/CertificateAdd.styles.js +61 -0
  42. package/dist/elements/http/CertificateAdd.styles.js.map +1 -0
  43. package/dist/elements/project/ProjectRunReport.d.ts +2 -1
  44. package/dist/elements/project/ProjectRunReport.d.ts.map +1 -1
  45. package/dist/elements/project/ProjectRunReport.js.map +1 -1
  46. package/dist/elements/store/FilePicker.styles.d.ts.map +1 -1
  47. package/dist/elements/store/FilePicker.styles.js +1 -0
  48. package/dist/elements/store/FilePicker.styles.js.map +1 -1
  49. package/dist/elements/store/FilesLib.d.ts +2 -2
  50. package/dist/elements/store/FilesLib.d.ts.map +1 -1
  51. package/dist/elements/store/FilesLib.js.map +1 -1
  52. package/dist/events/EventTypes.d.ts +6 -7
  53. package/dist/events/EventTypes.d.ts.map +1 -1
  54. package/dist/events/EventTypes.js +7 -7
  55. package/dist/events/EventTypes.js.map +1 -1
  56. package/dist/events/Events.d.ts +6 -1
  57. package/dist/events/Events.d.ts.map +1 -1
  58. package/dist/events/Events.js +2 -0
  59. package/dist/events/Events.js.map +1 -1
  60. package/dist/events/FilesystemEvents.d.ts +8 -0
  61. package/dist/events/FilesystemEvents.d.ts.map +1 -0
  62. package/dist/events/FilesystemEvents.js +59 -0
  63. package/dist/events/FilesystemEvents.js.map +1 -0
  64. package/dist/events/HttpClientEvents.d.ts +0 -2
  65. package/dist/events/HttpClientEvents.d.ts.map +1 -1
  66. package/dist/events/HttpClientEvents.js +0 -2
  67. package/dist/events/HttpClientEvents.js.map +1 -1
  68. package/dist/http-client/idb/Arc18DataUpgrade.d.ts +0 -8
  69. package/dist/http-client/idb/Arc18DataUpgrade.d.ts.map +1 -1
  70. package/dist/http-client/idb/Arc18DataUpgrade.js +11 -206
  71. package/dist/http-client/idb/Arc18DataUpgrade.js.map +1 -1
  72. package/dist/http-client/store/Cursor.js +2 -2
  73. package/dist/http-client/store/Cursor.js.map +1 -1
  74. package/dist/http-client/store/HttpClientIdbDatabase.d.ts.map +1 -1
  75. package/dist/http-client/store/HttpClientIdbDatabase.js +2 -6
  76. package/dist/http-client/store/HttpClientIdbDatabase.js.map +1 -1
  77. package/dist/http-client/store/State.d.ts +1 -3
  78. package/dist/http-client/store/State.d.ts.map +1 -1
  79. package/dist/http-client/store/State.js.map +1 -1
  80. package/dist/http-client/store/StoreBroadcast.d.ts +0 -5
  81. package/dist/http-client/store/StoreBroadcast.d.ts.map +1 -1
  82. package/dist/http-client/store/StoreBroadcast.js +0 -7
  83. package/dist/http-client/store/StoreBroadcast.js.map +1 -1
  84. package/dist/http-client/store/idb/IdbStore.d.ts +1 -10
  85. package/dist/http-client/store/idb/IdbStore.d.ts.map +1 -1
  86. package/dist/http-client/store/idb/IdbStore.js +0 -48
  87. package/dist/http-client/store/idb/IdbStore.js.map +1 -1
  88. package/dist/http-client/store/types.d.ts +2 -56
  89. package/dist/http-client/store/types.d.ts.map +1 -1
  90. package/dist/http-client/store/types.js.map +1 -1
  91. package/dist/index.d.ts +1 -0
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +2 -0
  94. package/dist/index.js.map +1 -1
  95. package/dist/lib/files/FileUtils.d.ts +9 -0
  96. package/dist/lib/files/FileUtils.d.ts.map +1 -0
  97. package/dist/lib/files/FileUtils.js +13 -0
  98. package/dist/lib/files/FileUtils.js.map +1 -0
  99. package/dist/mixins/RouteMixin.d.ts +4 -0
  100. package/dist/mixins/RouteMixin.d.ts.map +1 -1
  101. package/dist/mixins/RouteMixin.js +1 -0
  102. package/dist/mixins/RouteMixin.js.map +1 -1
  103. package/dist/pages/api-client/ApiClient.screen.d.ts +8 -4
  104. package/dist/pages/api-client/ApiClient.screen.d.ts.map +1 -1
  105. package/dist/pages/api-client/ApiClient.screen.js +25 -4
  106. package/dist/pages/api-client/ApiClient.screen.js.map +1 -1
  107. package/dist/pages/api-client/ApiClient.styles.d.ts.map +1 -1
  108. package/dist/pages/api-client/ApiClient.styles.js +0 -12
  109. package/dist/pages/api-client/ApiClient.styles.js.map +1 -1
  110. package/dist/pages/api-client/pages/Files.page.d.ts.map +1 -1
  111. package/dist/pages/api-client/pages/Files.page.js +13 -0
  112. package/dist/pages/api-client/pages/Files.page.js.map +1 -1
  113. package/dist/pages/api-client/pages/Trash.page.d.ts.map +1 -1
  114. package/dist/pages/api-client/pages/Trash.page.js +3 -11
  115. package/dist/pages/api-client/pages/Trash.page.js.map +1 -1
  116. package/dist/ui/button/SegmentedButtonsSet.d.ts +14 -0
  117. package/dist/ui/button/SegmentedButtonsSet.d.ts.map +1 -1
  118. package/dist/ui/button/SegmentedButtonsSet.js.map +1 -1
  119. package/dist/ui/list/UiDropdownList.js +1 -1
  120. package/dist/ui/list/UiDropdownList.js.map +1 -1
  121. package/dist/ui/notification/SnackNotifications.d.ts +1 -0
  122. package/dist/ui/notification/SnackNotifications.d.ts.map +1 -1
  123. package/dist/ui/notification/SnackNotifications.js +7 -0
  124. package/dist/ui/notification/SnackNotifications.js.map +1 -1
  125. package/package.json +2 -2
  126. package/src/bindings/base/FileBindings.ts +25 -1
  127. package/src/bindings/base/StoreBindings.ts +1 -73
  128. package/src/bindings/web/WebFileBindings.ts +1 -1
  129. package/src/define/http/certificate-add.ts +12 -0
  130. package/src/define/http/http-body-editor.ts +1 -1
  131. package/src/define/ui/ui-segmented-button-set.ts +1 -1
  132. package/src/elements/authorization/ui/CC.styles.ts +4 -9
  133. package/src/elements/authorization/ui/CcAuthorization.ts +67 -167
  134. package/src/elements/http/BodyEditor.styles.ts +5 -19
  135. package/src/elements/http/BodyEditor.ts +5 -5
  136. package/src/elements/http/CertificateAdd.element.ts +443 -0
  137. package/src/elements/http/CertificateAdd.styles.ts +61 -0
  138. package/src/elements/project/ProjectRunReport.ts +2 -1
  139. package/src/elements/store/FilePicker.styles.ts +1 -0
  140. package/src/elements/store/FilesLib.ts +2 -2
  141. package/src/events/EventTypes.ts +7 -7
  142. package/src/events/Events.ts +2 -0
  143. package/src/events/FilesystemEvents.ts +63 -0
  144. package/src/events/HttpClientEvents.ts +0 -2
  145. package/src/http-client/idb/Arc18DataUpgrade.ts +84 -84
  146. package/src/http-client/store/Cursor.ts +2 -2
  147. package/src/http-client/store/HttpClientIdbDatabase.ts +5 -9
  148. package/src/http-client/store/State.ts +1 -5
  149. package/src/http-client/store/StoreBroadcast.ts +0 -8
  150. package/src/http-client/store/idb/IdbStore.ts +1 -51
  151. package/src/http-client/store/types.ts +2 -57
  152. package/src/index.ts +3 -0
  153. package/src/lib/files/FileUtils.ts +12 -0
  154. package/src/mixins/RouteMixin.ts +8 -1
  155. package/src/pages/api-client/ApiClient.screen.ts +33 -9
  156. package/src/pages/api-client/ApiClient.styles.ts +0 -12
  157. package/src/pages/api-client/pages/Files.page.ts +11 -0
  158. package/src/pages/api-client/pages/Trash.page.ts +3 -10
  159. package/src/ui/button/SegmentedButtonsSet.ts +16 -1
  160. package/src/ui/list/UiDropdownList.ts +1 -1
  161. package/src/ui/notification/SnackNotifications.ts +8 -0
  162. package/test/elements/http/BodyFormdataEditorElement.test.ts +458 -454
  163. package/test/elements/http/BodyMultipartEditorElement.test.ts +609 -605
  164. package/test/elements/http/BodyRawEditorElement.test.ts +60 -56
  165. package/test/elements/http/CertificateAdd.test.ts +430 -0
  166. package/test/events/EventTypes.test.ts +0 -22
  167. package/test/helpers/UiMock.ts +19 -2
  168. package/web-test-runner.config.mjs +6 -5
  169. package/dist/events/http-client/models/CertificatesEvents.d.ts +0 -12
  170. package/dist/events/http-client/models/CertificatesEvents.d.ts.map +0 -1
  171. package/dist/events/http-client/models/CertificatesEvents.js +0 -18
  172. package/dist/events/http-client/models/CertificatesEvents.js.map +0 -1
  173. package/dist/http-client/idb/AuthDataModel.d.ts +0 -60
  174. package/dist/http-client/idb/AuthDataModel.d.ts.map +0 -1
  175. package/dist/http-client/idb/AuthDataModel.js +0 -150
  176. package/dist/http-client/idb/AuthDataModel.js.map +0 -1
  177. package/dist/http-client/idb/HostsModel.d.ts +0 -25
  178. package/dist/http-client/idb/HostsModel.d.ts.map +0 -1
  179. package/dist/http-client/idb/HostsModel.js +0 -82
  180. package/dist/http-client/idb/HostsModel.js.map +0 -1
  181. package/dist/http-client/idb/LegacyMockedStore.d.ts +0 -214
  182. package/dist/http-client/idb/LegacyMockedStore.d.ts.map +0 -1
  183. package/dist/http-client/idb/LegacyMockedStore.js +0 -486
  184. package/dist/http-client/idb/LegacyMockedStore.js.map +0 -1
  185. package/dist/http-client/store/Validator.d.ts +0 -4
  186. package/dist/http-client/store/Validator.d.ts.map +0 -1
  187. package/dist/http-client/store/Validator.js +0 -32
  188. package/dist/http-client/store/Validator.js.map +0 -1
  189. package/src/events/http-client/models/CertificatesEvents.ts +0 -23
  190. package/src/http-client/idb/AuthDataModel.ts +0 -175
  191. package/src/http-client/idb/HostsModel.ts +0 -125
  192. package/src/http-client/idb/LegacyMockedStore.ts +0 -544
  193. package/src/http-client/store/Validator.ts +0 -33
  194. package/test/apic-ui.test.ts +0 -31
@@ -1,14 +1,14 @@
1
1
  /* eslint-disable class-methods-use-this */
2
2
  import 'pouchdb/dist/pouchdb.js';
3
- import { get, set } from 'idb-keyval';
4
- import { IAuthorizationData, IHostRule, HostRuleKind, } from '@api-client/core/build/browser.js'; // Certificate, HttpProject
5
- import { ARCAuthData, HostRule as LegacyHostRule } from '@api-client/core/build/legacy.js'; // Normalizer, ARCProject, ARCSavedRequest, ARCCertificateIndex, ARCRequestCertificate,
3
+ import { get } from 'idb-keyval';
4
+ // import { IAuthorizationData, IHostRule, HostRuleKind, } from '@api-client/core/build/browser.js'; // Certificate, HttpProject
5
+ // import { ARCAuthData, HostRule as LegacyHostRule } from '@api-client/core/build/legacy.js'; // Normalizer, ARCProject, ARCSavedRequest, ARCCertificateIndex, ARCRequestCertificate,
6
6
  // import { LegacyBodyProcessor } from './LegacyBodyProcessor.js';
7
7
  // import { HistoryModel } from './HistoryModel.js';
8
8
  // import { ProjectModel } from './ProjectModel.js';
9
- import { AuthDataModel } from './AuthDataModel.js';
9
+ // import { AuthDataModel } from './AuthDataModel.js';
10
10
  // import { CertificateModel } from './CertificateModel.js';
11
- import { HostsModel } from './HostsModel.js';
11
+ // import { HostsModel } from './HostsModel.js';
12
12
 
13
13
  const upgradeKey = 'CHL5v3fUMx';
14
14
 
@@ -27,38 +27,38 @@ export default class Arc18DataUpgrade {
27
27
  }
28
28
 
29
29
  static async runIfNeeded(): Promise<void> {
30
- const needed = await Arc18DataUpgrade.needsUpgrade();
31
- if (!needed) {
32
- return undefined;
33
- }
34
- const instance = new Arc18DataUpgrade();
35
- return instance.run();
30
+ // const needed = await Arc18DataUpgrade.needsUpgrade();
31
+ // if (!needed) {
32
+ // return undefined;
33
+ // }
34
+ // const instance = new Arc18DataUpgrade();
35
+ // return instance.run();
36
36
  }
37
37
 
38
- /**
39
- * Sets a flag sealing the upgrade. Next call to the `run()` will result with no operation.
40
- */
41
- async seal(): Promise<void> {
42
- await set(upgradeKey, true);
43
- }
38
+ // /**
39
+ // * Sets a flag sealing the upgrade. Next call to the `run()` will result with no operation.
40
+ // */
41
+ // async seal(): Promise<void> {
42
+ // await set(upgradeKey, true);
43
+ // }
44
44
 
45
- async run(): Promise<void> {
46
- await this.upgradeHistory();
47
- // await this.upgradeProjects();
48
- // await this.upgradeSaved();
49
- await this.upgradeAuthData();
50
- // await this.upgradeCertificates();
51
- await this.hostRules();
45
+ // async run(): Promise<void> {
46
+ // await this.upgradeHistory();
47
+ // await this.upgradeProjects();
48
+ // await this.upgradeSaved();
49
+ // await this.upgradeAuthData();
50
+ // await this.upgradeCertificates();
51
+ // await this.hostRules();
52
52
 
53
- await this.seal();
54
- }
53
+ // await this.seal();
54
+ // }
55
55
 
56
- async upgradeHistory(): Promise<void> {
57
- const sourceDb = new PouchDB('history-requests');
58
- await sourceDb.compact();
59
- // const targetDb = new HistoryModel();
60
- // await this._upgradeHistoryPage(sourceDb, targetDb);
61
- }
56
+ // async upgradeHistory(): Promise<void> {
57
+ // const sourceDb = new PouchDB('history-requests');
58
+ // await sourceDb.compact();
59
+ // const targetDb = new HistoryModel();
60
+ // await this._upgradeHistoryPage(sourceDb, targetDb);
61
+ // }
62
62
 
63
63
  // async upgradeProjects(): Promise<void> {
64
64
  // const projectsDb = new PouchDB<ARCProject>('legacy-projects');
@@ -128,32 +128,32 @@ export default class Arc18DataUpgrade {
128
128
  // await targetDb.put(project.toJSON());
129
129
  // }
130
130
 
131
- async upgradeAuthData(): Promise<void> {
132
- const src = new PouchDB<ARCAuthData>('auth-data');
133
- const response = await src.allDocs({ include_docs: true });
134
- const items: IAuthorizationData[] = [];
135
- response.rows.forEach(item => {
136
- const { doc } = item;
137
- if (!doc) {
138
- return;
139
- }
140
- const transformed: IAuthorizationData = {
141
- key: doc._id,
142
- };
143
- if (doc.domain) {
144
- transformed.domain = doc.domain;
145
- }
146
- if (doc.password) {
147
- transformed.password = doc.password;
148
- }
149
- if (doc.password) {
150
- transformed.password = doc.password;
151
- }
152
- items.push(transformed);
153
- });
154
- const model = new AuthDataModel();
155
- await model.putBulk(items);
156
- }
131
+ // async upgradeAuthData(): Promise<void> {
132
+ // const src = new PouchDB<ARCAuthData>('auth-data');
133
+ // const response = await src.allDocs({ include_docs: true });
134
+ // const items: IAuthorizationData[] = [];
135
+ // response.rows.forEach(item => {
136
+ // const { doc } = item;
137
+ // if (!doc) {
138
+ // return;
139
+ // }
140
+ // const transformed: IAuthorizationData = {
141
+ // key: doc._id,
142
+ // };
143
+ // if (doc.domain) {
144
+ // transformed.domain = doc.domain;
145
+ // }
146
+ // if (doc.password) {
147
+ // transformed.password = doc.password;
148
+ // }
149
+ // if (doc.password) {
150
+ // transformed.password = doc.password;
151
+ // }
152
+ // items.push(transformed);
153
+ // });
154
+ // const model = new AuthDataModel();
155
+ // await model.putBulk(items);
156
+ // }
157
157
 
158
158
  // protected async _upgradeHistoryPage(sourceDb: PouchDB.Database, targetDb: HistoryModel, lastKey?: string): Promise<void> {
159
159
  // const opts: PouchDB.Core.AllDocsOptions | PouchDB.Core.AllDocsWithinRangeOptions = {
@@ -216,30 +216,30 @@ export default class Arc18DataUpgrade {
216
216
  // await model.putBulk(upgrades);
217
217
  // }
218
218
 
219
- async hostRules(): Promise<void> {
220
- const srcDb = new PouchDB<LegacyHostRule>('host-rules');
221
- const response = await srcDb.allDocs({ include_docs: true });
222
- const items: IHostRule[] = [];
223
- response.rows.forEach(item => {
224
- const { doc } = item;
225
- if (!doc) {
226
- return;
227
- }
228
- const transformed: IHostRule = {
229
- kind: HostRuleKind,
230
- from: doc.from,
231
- to: doc.to,
232
- key: doc._id,
233
- };
234
- if (doc.comment) {
235
- transformed.comment = doc.comment;
236
- }
237
- if (typeof doc.enabled === 'boolean') {
238
- transformed.enabled = doc.enabled;
239
- }
240
- items.push(transformed);
241
- });
242
- const model = new HostsModel();
243
- await model.putBulk(items);
244
- }
219
+ // async hostRules(): Promise<void> {
220
+ // const srcDb = new PouchDB<LegacyHostRule>('host-rules');
221
+ // const response = await srcDb.allDocs({ include_docs: true });
222
+ // const items: IHostRule[] = [];
223
+ // response.rows.forEach(item => {
224
+ // const { doc } = item;
225
+ // if (!doc) {
226
+ // return;
227
+ // }
228
+ // const transformed: IHostRule = {
229
+ // kind: HostRuleKind,
230
+ // from: doc.from,
231
+ // to: doc.to,
232
+ // key: doc._id,
233
+ // };
234
+ // if (doc.comment) {
235
+ // transformed.comment = doc.comment;
236
+ // }
237
+ // if (typeof doc.enabled === 'boolean') {
238
+ // transformed.enabled = doc.enabled;
239
+ // }
240
+ // items.push(transformed);
241
+ // });
242
+ // const model = new HostsModel();
243
+ // await model.putBulk(items);
244
+ // }
245
245
  }
@@ -12,7 +12,7 @@ export class Cursor {
12
12
  async decodeCursor(cursor: string): Promise<IListState> {
13
13
  let result: IListState;
14
14
  try {
15
- const decoded = atob(cursor);
15
+ const decoded = window.atob(cursor);
16
16
  result = JSON.parse(decoded);
17
17
  } catch (e) {
18
18
  throw new ApiError(`Invalid page cursor.`, 400);
@@ -27,6 +27,6 @@ export class Cursor {
27
27
  */
28
28
  async encodeCursor(state: object): Promise<string> {
29
29
  const str = JSON.stringify(state);
30
- return btoa(str);
30
+ return window.btoa(str);
31
31
  }
32
32
  }
@@ -3,7 +3,7 @@ import { ContextListOptions } from '@api-client/core/build/browser.js';
3
3
  import { HttpClientPersistance } from "./HttpClientPersistance.js";
4
4
  import { Cursor } from './Cursor.js';
5
5
  import { IListState } from './State.js';
6
- import { HttpClientDB, SpaceStoreNames, StoreName } from './types.js';
6
+ import { HttpClientDB, StoreName } from './types.js';
7
7
  import { IdbUrlHistory } from './idb/IdbUrlHistory.js';
8
8
  import { IdbWsHistory } from './idb/IdbWsHistory.js';
9
9
  import { IdbProjectUi } from './idb/IdbProjectUi.js';
@@ -132,9 +132,7 @@ export class HttpClientIdbDatabase implements HttpClientPersistance {
132
132
  const dbResult = await openDB<HttpClientDB>('HttpClient', 1, {
133
133
  upgrade: (db) => {
134
134
  const stores: StoreName[] = [
135
- 'UrlHistory', 'WsHistory',
136
- 'AuthCache', 'Hosts', 'Environments',
137
- 'ProjectUi',
135
+ 'UrlHistory', 'WsHistory', 'ProjectUi',
138
136
  ];
139
137
  const names = db.objectStoreNames;
140
138
  for (const name of stores) {
@@ -143,7 +141,7 @@ export class HttpClientIdbDatabase implements HttpClientPersistance {
143
141
  if (typeof this[fnName] === 'function') {
144
142
  this[fnName](db, exists);
145
143
  } else if (!exists) {
146
- this._defaultUpgradeHandler(name as SpaceStoreNames, db, exists);
144
+ this._defaultUpgradeHandler(name as StoreName, db, exists);
147
145
  }
148
146
  }
149
147
  },
@@ -157,13 +155,11 @@ export class HttpClientIdbDatabase implements HttpClientPersistance {
157
155
  * @param name The store name to create
158
156
  * @param db The handler to the database
159
157
  */
160
- private _defaultUpgradeHandler(name: SpaceStoreNames, db: IDBPDatabase<HttpClientDB>, storeExists: boolean): void {
158
+ private _defaultUpgradeHandler(name: StoreName, db: IDBPDatabase<HttpClientDB>, storeExists: boolean): void {
161
159
  if (storeExists) {
162
160
  return;
163
161
  }
164
- const store = db.createObjectStore(name, { keyPath: 'data.key' });
165
- const typed = store as IDBPObjectStore<HttpClientDB, SpaceStoreNames[], SpaceStoreNames, 'versionchange'>;
166
- typed.createIndex('space', 'meta.space', { unique: false });
162
+ db.createObjectStore(name, { keyPath: 'data.key' });
167
163
  }
168
164
 
169
165
  private _UrlHistoryUpgradeHandler(db: IDBPDatabase<HttpClientDB>, storeExists: boolean): void {
@@ -1,4 +1,4 @@
1
- import { ContextSpaceListOptions, HistoryListOptions, IProjectExecutionListOptions } from "@api-client/core/build/browser.js";
1
+ import { ContextSpaceListOptions } from "@api-client/core/build/browser.js";
2
2
 
3
3
  export interface CursorState {
4
4
  /**
@@ -14,7 +14,3 @@ export interface CursorState {
14
14
  }
15
15
 
16
16
  export type IListState = ContextSpaceListOptions & CursorState;
17
-
18
- export type HistoryState = HistoryListOptions & CursorState;
19
-
20
- export type ProjectRunsState = IProjectExecutionListOptions & CursorState;
@@ -55,14 +55,6 @@ export class StoreBroadcast {
55
55
  return '/store/history/ws';
56
56
  }
57
57
 
58
- /**
59
- * The path used to construct a `BroadcastChannel` (or similar)
60
- * to communicate changes between contexts for the Certificates store.
61
- */
62
- static get certificates(): string {
63
- return '/store/certificates';
64
- }
65
-
66
58
  /**
67
59
  * The path used to construct a `BroadcastChannel` (or similar)
68
60
  * to communicate changes between contexts for the History store.
@@ -1,6 +1,5 @@
1
1
  import { IDBPDatabase } from "idb";
2
- import { HttpClientDB, IStoredEntity, StoreName } from "../types.js";
3
- import { IListState } from "../State.js";
2
+ import { HttpClientDB } from "../types.js";
4
3
  import { HttpClientIdbDatabase } from "../HttpClientIdbDatabase.js";
5
4
 
6
5
  export abstract class IdbStore {
@@ -24,53 +23,4 @@ export abstract class IdbStore {
24
23
  async cleanup(): Promise<void> {
25
24
  //
26
25
  }
27
-
28
- /**
29
- * Lists entities that uses `IStoredEntity` format.
30
- * @param db A reference to the database
31
- * @param storeName The name of the store to query.
32
- * @param opts Query options.
33
- * @returns The list of listed objects.
34
- */
35
- protected async listStoredEntities(db: IDBPDatabase<HttpClientDB>, storeName: StoreName, opts: IListState): Promise<unknown[]> {
36
- let adv = opts.skip || 0;
37
- const { descending, limit = this.parent.defaultLimit, lastKey, space } = opts;
38
- const tx = db.transaction(storeName, 'readonly');
39
- const dir = descending === true ? 'prev' : 'next';
40
- let keyFound = false;
41
- const items: unknown[] = [];
42
- for await (const cursor of tx.store.iterate(null, dir)) {
43
- const info = cursor.value as IStoredEntity;
44
- if (!info.meta || !info.data) {
45
- continue;
46
- }
47
- const { meta, data } = info;
48
- if (space && meta.space !== space) {
49
- continue;
50
- }
51
- const { key } = data as { key: string };
52
- if (!key) {
53
- continue;
54
- }
55
- if (lastKey && !keyFound) {
56
- if (key !== lastKey) {
57
- continue;
58
- }
59
- keyFound = true;
60
- }
61
- if (adv) {
62
- cursor.advance(adv);
63
- adv = 0;
64
- continue;
65
- }
66
- if (meta.deleted) {
67
- continue;
68
- }
69
- items.push(data);
70
- if (items.length >= limit) {
71
- break;
72
- }
73
- }
74
- return items;
75
- }
76
26
  }
@@ -1,52 +1,12 @@
1
- import {
2
- IAuthorizationData, IEnvironment, IHostRule,
3
- IRequestUiMeta, IUrl,
4
- } from '@api-client/core/build/browser.js';
1
+ import { IRequestUiMeta, IUrl } from '@api-client/core/build/browser.js';
5
2
  import { DBSchema } from 'idb/with-async-ittr';
6
3
 
7
- export interface IEntityMeta {
8
- /**
9
- * The space this object belongs to.
10
- */
11
- space: string;
12
- /**
13
- * Whether the entity is deleted.
14
- */
15
- deleted?: boolean;
16
- /**
17
- * A timestamp when the entity was deleted.
18
- * Can be used to cleanup the store after some time.
19
- */
20
- deleteTime?: number;
21
- }
22
-
23
- export interface IStoredEntity<T = unknown> {
24
- meta: IEntityMeta;
25
- data: T;
26
- }
27
-
28
- export interface IGetOptions {
29
- /**
30
- * Whether to return a deleted document.
31
- */
32
- deleted?: boolean;
33
- }
34
-
35
- export interface IStoredMedia<T = unknown> {
36
- key: string;
37
- value: T;
38
- mime: string;
39
- deleted?: boolean;
40
- }
41
-
42
4
  export interface IStoredRequestUi {
43
5
  data: IRequestUiMeta;
44
6
  meta: { key: string; project: string; }
45
7
  }
46
8
 
47
- export type SpaceStoreNames = 'AuthCache' | 'Hosts' | 'Environments';
48
- export type GeneralStoreNames = 'UrlHistory' | 'WsHistory' | 'ProjectUi';
49
- export type StoreName = GeneralStoreNames | SpaceStoreNames;
9
+ export type StoreName = 'UrlHistory' | 'WsHistory' | 'ProjectUi';
50
10
 
51
11
  export interface HttpClientDB extends DBSchema {
52
12
  UrlHistory: {
@@ -57,21 +17,6 @@ export interface HttpClientDB extends DBSchema {
57
17
  key: string;
58
18
  value: IUrl;
59
19
  }
60
- AuthCache: {
61
- key: string;
62
- value: IStoredEntity<IAuthorizationData>;
63
- indexes: { 'space': string };
64
- }
65
- Hosts: {
66
- key: string;
67
- value: IStoredEntity<IHostRule>;
68
- indexes: { 'space': string };
69
- }
70
- Environments: {
71
- key: string;
72
- value: IStoredEntity<IEnvironment>;
73
- indexes: { 'space': string };
74
- }
75
20
  ProjectUi: {
76
21
  key: string[];
77
22
  value: IStoredRequestUi;
package/src/index.ts CHANGED
@@ -31,6 +31,9 @@ export * from './bindings/base/ProxyBindings.js';
31
31
  export * from './bindings/base/SharedWorkerThread.js';
32
32
  export * from './bindings/base/StoreBindings.js';
33
33
 
34
+ // HTTP Client IDB
35
+ export * from './http-client/store/HttpClientIdbDatabase.js';
36
+
34
37
  // Events
35
38
 
36
39
  export { Events } from './events/Events.js';
@@ -0,0 +1,12 @@
1
+ export class FileUtils {
2
+ /**
3
+ * Reads the last segment of the file path and returns it as a file name.
4
+ *
5
+ * @param path THe file path.
6
+ */
7
+ static getFileName(path: string): string {
8
+ const delimiter = path.includes('/') ? '/' : '\\';
9
+ const last = path.split(delimiter).pop();
10
+ return last || '';
11
+ }
12
+ }
@@ -101,6 +101,11 @@ export declare class RouteMixinInterface {
101
101
  */
102
102
  static get routes(): IRoute[];
103
103
 
104
+ /**
105
+ * The current route parameters. This is the same what is passed to the route handler.
106
+ */
107
+ protected currentRoute?: IRouteResult;
108
+
104
109
  /**
105
110
  * Initializes the routing.
106
111
  */
@@ -119,6 +124,8 @@ export function RouteMixin<T extends Constructor<Object>>(superClass: T): Constr
119
124
  return []
120
125
  }
121
126
 
127
+ protected currentRoute?: IRouteResult;
128
+
122
129
  constructor(...args: any[]) {
123
130
  super(...args);
124
131
  this._routeHandler = this._routeHandler.bind(this);
@@ -159,7 +166,7 @@ export function RouteMixin<T extends Constructor<Object>>(superClass: T): Constr
159
166
  argument.params = params;
160
167
  }
161
168
  }
162
-
169
+ this.currentRoute = argument;
163
170
  this._callRoute(activeRoute, argument);
164
171
  if (activeRoute.title) {
165
172
  document.title = activeRoute.title;
@@ -2,23 +2,24 @@
2
2
  import { html, TemplateResult, CSSResult, nothing } from 'lit';
3
3
  import { BroadcastCreatedEvent, BroadcastEvent, IFile, ISpace, uuidV4 } from '@api-client/core/build/browser.js';
4
4
  import { ApplicationInit, ApplicationScreen } from '../ApplicationScreen.js';
5
- import { IRoute, IRouteResult } from '../../mixins/RouteMixin.js';
6
5
  import pageStyles from './ApiClient.styles.js';
7
6
  import globalStyles from '../../styles/global-styles.js';
8
7
  import typography from '../../styles/m3/typography.module.js';
8
+ import surface from '../../styles/m3/surface.module.js';
9
9
  import dialogStyles from '../../styles/m3/dialog.module.js';
10
10
  import { navigate } from '../../lib/route.js';
11
11
  import { reactive } from '../../lib/decorators.js';
12
12
  import { DataTable } from '../../ui/table/DataTable.js';
13
- import Input from '../../ui/input/Input.js';
14
13
  import { FilesPage } from './pages/Files.page.js';
15
14
  import { SharedPage } from './pages/Shared.page.js';
16
15
  import { TrashPage } from './pages/Trash.page.js';
17
16
  import { SettingsPage } from './pages/Settings.page.js';
18
- import { HttpClientStoreBindings } from '../../bindings/base/HttpClientStoreBindings.js';
17
+ import type { IRoute, IRouteResult } from '../../mixins/RouteMixin.js';
18
+ import type Input from '../../ui/input/Input.js';
19
+ import type { HttpClientStoreBindings } from '../../bindings/base/HttpClientStoreBindings.js';
20
+ import type { NavigationBindings } from '../../bindings/base/NavigationBindings.js';
21
+ import type { FileBindings } from '../../bindings/base/FileBindings.js';
19
22
  import { StoreBroadcast } from '../../http-client/store/StoreBroadcast.js';
20
- import { NavigationBindings } from '../../bindings/base/NavigationBindings.js';
21
- import { FileBindings } from '../../bindings/base/FileBindings.js';
22
23
  import AppInfo from './AppInfo.js';
23
24
  import '../../define/ui/ui-button.js';
24
25
  import '../../define/app-navigation-item.js';
@@ -27,6 +28,7 @@ import '../../define/ui/ui-icon-button.js';
27
28
  import '../../define/ui/ui-text-field.js';
28
29
  import '../../define/ui/ui-dropdown-list.js';
29
30
  import '../../define/ui/ui-divider.js';
31
+ import '../../define/http/certificate-add.js';
30
32
 
31
33
  export interface PageInit extends ApplicationInit {
32
34
  idb: HttpClientStoreBindings;
@@ -48,11 +50,12 @@ export default class ApiClientScreen extends ApplicationScreen {
48
50
  { pattern: '/shared/(?<key>.*)', method: 'sharedRoute', name: 'Shares', title: 'Shared with you' },
49
51
  { pattern: '/trash', method: 'trashRoute', name: 'Trash', title: 'Trash' },
50
52
  { pattern: '/settings', method: 'settingsRoute', name: 'Settings', title: 'Settings' },
53
+ { pattern: '/certificates/add/?(?<parent>.*)', method: 'addCertRoute', name: 'Add certificate', title: 'Add certificate' },
51
54
  ];
52
55
  }
53
56
 
54
57
  static get styles(): CSSResult[] {
55
- return [globalStyles, pageStyles, typography, dialogStyles, DataTable.styles];
58
+ return [globalStyles, pageStyles, typography, dialogStyles, DataTable.styles, surface];
56
59
  }
57
60
 
58
61
  /**
@@ -193,7 +196,7 @@ export default class ApiClientScreen extends ApplicationScreen {
193
196
  protected async createLastSpaceStoreKey(): Promise<string | undefined> {
194
197
  try {
195
198
  const env = await this.bindings.store.global.get();
196
- return `http-client.latest.space.${env.key}`;
199
+ return `api-client.latest.space.${env.key}`;
197
200
  } catch (_) {
198
201
  return undefined;
199
202
  }
@@ -365,6 +368,15 @@ export default class ApiClientScreen extends ApplicationScreen {
365
368
  this.page = 'settings';
366
369
  }
367
370
 
371
+ protected addCertRoute(): void {
372
+ this.resetRoute();
373
+ this.page = 'add-cert';
374
+ }
375
+
376
+ protected handleCertificateClose(): void {
377
+ window.history.back();
378
+ }
379
+
368
380
  protected mainNavHandler(e: Event): void {
369
381
  const target = e.target as HTMLElement;
370
382
  const { page } = target.dataset;
@@ -535,7 +547,7 @@ export default class ApiClientScreen extends ApplicationScreen {
535
547
  const { page, isSingleUser } = this;
536
548
  return html`
537
549
  <nav aria-label="Main">
538
- <h1 class="title-small nav-title">HTTP Client</h1>
550
+ <h1 class="title-small nav-title">API Client</h1>
539
551
  <ol class="nav-list">
540
552
  <li>
541
553
  <app-navigation-item data-page="files" .selected=${page === 'files'} @click="${this.mainNavHandler}">
@@ -622,7 +634,7 @@ export default class ApiClientScreen extends ApplicationScreen {
622
634
  protected override mainTemplate(): TemplateResult {
623
635
  return html`
624
636
  <main class="body-medium">
625
- <div class="content">
637
+ <div class="content surface1">
626
638
  ${this.renderPage()}
627
639
  </div>
628
640
  </main>
@@ -638,6 +650,7 @@ export default class ApiClientScreen extends ApplicationScreen {
638
650
  case 'shared': return this.shared.render();
639
651
  case 'trash': return this.trash.render();
640
652
  case 'settings': return this.settings.render();
653
+ case 'add-cert': return this.renderAddCertificate();
641
654
  default: return this.render404();
642
655
  }
643
656
  }
@@ -724,4 +737,15 @@ export default class ApiClientScreen extends ApplicationScreen {
724
737
  </dialog>
725
738
  `;
726
739
  }
740
+
741
+ protected renderAddCertificate(): TemplateResult {
742
+ const { currentRoute, currentSpace } = this;
743
+ const parent = currentRoute && currentRoute.params && currentRoute.params.parent as string | undefined;
744
+ const space = currentSpace && currentSpace.key;
745
+ return html`
746
+ <h2 class="headline-small">Add Certificate</h2>
747
+ <p class="body-medium">Import a certificate to use it in your HTTP projects. Note, imported certificate cannot be changed.</p>
748
+ <certificate-add .folder="${parent}" .space="${space}" @close="${this.handleCertificateClose}"></certificate-add>
749
+ `;
750
+ }
727
751
  }
@@ -174,8 +174,6 @@ main {
174
174
 
175
175
  main .content {
176
176
  padding: 20px;
177
- position: relative;
178
- z-index: 0;
179
177
  border-radius: inherit;
180
178
 
181
179
  flex: 1;
@@ -184,16 +182,6 @@ main .content {
184
182
 
185
183
  overflow: hidden;
186
184
  }
187
-
188
- main .content::before {
189
- content: '';
190
- background-color: var(--md-sys-color-primary);
191
- opacity: .05;
192
- position: absolute;
193
- inset: 0;
194
- border-radius: inherit;
195
- }
196
-
197
185
  main .content > * {
198
186
  position: relative;
199
187
  z-index: 1;
@@ -241,6 +241,13 @@ export class FilesPage {
241
241
  this.screen.openDialog('createProjectDialog');
242
242
  } else if (option === 'schema') {
243
243
  this.screen.openDialog('createSchemaDialog');
244
+ } else if (option === 'certificate') {
245
+ const { parent } = this.fs;
246
+ if (parent) {
247
+ navigate('certificates', 'add', parent);
248
+ } else {
249
+ navigate('certificates', 'add');
250
+ }
244
251
  }
245
252
  }
246
253
 
@@ -573,6 +580,10 @@ export class FilesPage {
573
580
  <ui-icon icon="schema" slot="start"></ui-icon>
574
581
  Data schema
575
582
  </ui-list-item>
583
+ <ui-list-item image="icon" data-option="certificate" role="menuitem">
584
+ <ui-icon icon="certificate" slot="start"></ui-icon>
585
+ Certificate
586
+ </ui-list-item>
576
587
  <ui-divider></ui-divider>
577
588
  <ui-list-item image="icon" data-option="folder" role="menuitem">
578
589
  <ui-icon icon="folder" slot="start"></ui-icon>