dochub-sdk 0.1.264 → 0.1.267

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
+
@@ -328,8 +328,9 @@ export interface IDocHubDataLake {
328
328
  /**
329
329
  * Отправляет транзакцию в DataLake
330
330
  * @param transaction - Объект транзакции
331
+ * @param comment - Комментарий к фиксируемой транзакции
331
332
  */
332
- commitTransaction(transaction: IDocHubTransaction): Promise<IDocHubTransaction>;
333
+ commitTransaction(transaction: IDocHubTransaction, comment?: string): Promise<IDocHubTransaction>;
333
334
 
334
335
  /**
335
336
  * Отменяет транзакцию
@@ -1,5 +1,6 @@
1
1
  import { AxiosResponse, AxiosRequestConfig, ResponseType, Method } from 'axios';
2
2
  import { IDocHubContext } from './contexts';
3
+ import { IDocHubTransactionFileHeaders } from './datalake';
3
4
 
4
5
  export enum ProtocolOptionsResponseTypes {
5
6
  arraybuffer = 'arraybuffer',
@@ -91,14 +92,16 @@ export interface IDocHubResourceVersion {
91
92
  */
92
93
  export interface IDocHubCommitFile {
93
94
  uri: string;
95
+ headers?: IDocHubTransactionFileHeaders;
94
96
  content: string | ArrayBuffer | (() => string | ArrayBuffer);
95
- encoded?: 'plain' | 'base64' | 'ArrayBuffer';
97
+ encoded?: 'plain' | 'base64' | 'ArrayBuffer'; // default: plain
96
98
  }
97
99
 
98
100
  /**
99
101
  * Данные для создания коммита
100
102
  */
101
- export interface IDocHubCommitBatch extends AxiosRequestConfig {
103
+ export interface IDocHubCommitBatch extends IDocHubProtocolRequestConfig {
104
+ method: DocHubProtocolMethods.COMMIT,
102
105
  comment: string;
103
106
  data: IDocHubCommitFile[];
104
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dochub-sdk",
3
- "version": "0.1.264",
3
+ "version": "0.1.267",
4
4
  "description": "The DocHub System Development Kit.",
5
5
  "private": false,
6
6
  "main": "index.ts",