dochub-sdk 0.1.266 → 0.1.268

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.
@@ -0,0 +1,19 @@
1
+ export type DynamicProxyHandler = () => any;
2
+ /**
3
+ * Проксирует обращения к динамическому объекту в режиме "только для чтения"
4
+ * @param handler - Функция, которая должна возвращать реальный объект источник
5
+ * @returns
6
+ */
7
+ export function dynamicProxy(handler: DynamicProxyHandler) {
8
+ const resolver = {
9
+ get(target, prop, receiver) {
10
+ const subject = handler();
11
+ if (!subject) throw new Error('Proxy subject is empty');
12
+ return handler()[prop];
13
+ },
14
+ set() {
15
+ throw new Error('Changing the proxy object is prohibited!');
16
+ }
17
+ };
18
+ return new Proxy({}, resolver);
19
+ }
package/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { IDocHubCore } from './interfaces/core';
2
+ import { dynamicProxy } from './helpers/proxy';
2
3
 
3
4
  export * from './interfaces/core';
4
5
  export * from './interfaces/contexts';
@@ -24,8 +25,8 @@ export * from './interfaces/datasets';
24
25
  export * from './schemas/basetypes';
25
26
  export * from './schemas/dochub-yaml';
26
27
 
27
- export const DocHub: IDocHubCore = window['DocHub'];
28
+ export const DocHub: IDocHubCore = dynamicProxy(() => window['DocHub']);
28
29
  export const Vue2 = () => window['Vue'];
29
30
  export const Vuetify2 = () => window['Vuetify'];
30
31
 
31
- if (!DocHub) throw new Error('!!!!!!!! No found DocHub core! !!!!!!!!!');
32
+
@@ -151,6 +151,11 @@ export interface IDocHubProtocol {
151
151
  * @returns - Результирующий URI в формате протокола
152
152
  */
153
153
  resolveURL(...args: string[]): string;
154
+ /**
155
+ * Выделяет хост из URI ресурса. Для систем управления версиями в хост могут входить данные репозитория, ветки, коммита и т.п.
156
+ * @param uri - идентификатор ресурса
157
+ */
158
+ extractHost(uri: string): string | null;
154
159
  /**
155
160
  * Выполняет запрос к ресурсу по аналогии с axios
156
161
  * @param config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dochub-sdk",
3
- "version": "0.1.266",
3
+ "version": "0.1.268",
4
4
  "description": "The DocHub System Development Kit.",
5
5
  "private": false,
6
6
  "main": "index.ts",