@antcde/connect-ts 0.0.48
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.
- package/README.md +129 -0
- package/build/AntConnect.d.ts +69 -0
- package/build/AntConnect.d.ts.map +1 -0
- package/build/AntConnect.js +65 -0
- package/build/AntHttpClient.d.ts +34 -0
- package/build/AntHttpClient.d.ts.map +1 -0
- package/build/AntHttpClient.js +101 -0
- package/build/ResponseStatusCodes.d.ts +64 -0
- package/build/ResponseStatusCodes.d.ts.map +1 -0
- package/build/ResponseStatusCodes.js +63 -0
- package/build/comms/client.d.ts +33 -0
- package/build/comms/client.d.ts.map +1 -0
- package/build/comms/client.js +121 -0
- package/build/comms/host.d.ts +29 -0
- package/build/comms/host.d.ts.map +1 -0
- package/build/comms/host.js +129 -0
- package/build/comms/models.d.ts +57 -0
- package/build/comms/models.d.ts.map +1 -0
- package/build/comms/models.js +1 -0
- package/build/comms/utils.d.ts +45 -0
- package/build/comms/utils.d.ts.map +1 -0
- package/build/comms/utils.js +75 -0
- package/build/index.d.ts +18 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +8 -0
- package/build/services/AppService.d.ts +95 -0
- package/build/services/AppService.d.ts.map +1 -0
- package/build/services/AppService.js +24 -0
- package/build/services/ClientService.d.ts +19 -0
- package/build/services/ClientService.d.ts.map +1 -0
- package/build/services/ClientService.js +7 -0
- package/build/services/ColumnService.d.ts +38 -0
- package/build/services/ColumnService.d.ts.map +1 -0
- package/build/services/ColumnService.js +9 -0
- package/build/services/DmsService.d.ts +46 -0
- package/build/services/DmsService.d.ts.map +1 -0
- package/build/services/DmsService.js +21 -0
- package/build/services/DownloadService.d.ts +16 -0
- package/build/services/DownloadService.d.ts.map +1 -0
- package/build/services/DownloadService.js +6 -0
- package/build/services/LabelService.d.ts +35 -0
- package/build/services/LabelService.d.ts.map +1 -0
- package/build/services/LabelService.js +9 -0
- package/build/services/LaravelQueueService.d.ts +8 -0
- package/build/services/LaravelQueueService.d.ts.map +1 -0
- package/build/services/LaravelQueueService.js +6 -0
- package/build/services/LicenseService.d.ts +27 -0
- package/build/services/LicenseService.d.ts.map +1 -0
- package/build/services/LicenseService.js +10 -0
- package/build/services/LinkService.d.ts +17 -0
- package/build/services/LinkService.d.ts.map +1 -0
- package/build/services/LinkService.js +8 -0
- package/build/services/ModuleService.d.ts +45 -0
- package/build/services/ModuleService.d.ts.map +1 -0
- package/build/services/ModuleService.js +16 -0
- package/build/services/NewsService.d.ts +19 -0
- package/build/services/NewsService.d.ts.map +1 -0
- package/build/services/NewsService.js +6 -0
- package/build/services/PermissionService.d.ts +28 -0
- package/build/services/PermissionService.d.ts.map +1 -0
- package/build/services/PermissionService.js +9 -0
- package/build/services/Project/ProjectUserService.d.ts +17 -0
- package/build/services/Project/ProjectUserService.d.ts.map +1 -0
- package/build/services/Project/ProjectUserService.js +7 -0
- package/build/services/ProjectMemberService.d.ts +24 -0
- package/build/services/ProjectMemberService.d.ts.map +1 -0
- package/build/services/ProjectMemberService.js +7 -0
- package/build/services/ProjectRoleService.d.ts +77 -0
- package/build/services/ProjectRoleService.d.ts.map +1 -0
- package/build/services/ProjectRoleService.js +13 -0
- package/build/services/ProjectService.d.ts +69 -0
- package/build/services/ProjectService.d.ts.map +1 -0
- package/build/services/ProjectService.js +12 -0
- package/build/services/RBAC/PermissionService.d.ts +49 -0
- package/build/services/RBAC/PermissionService.d.ts.map +1 -0
- package/build/services/RBAC/PermissionService.js +8 -0
- package/build/services/RBAC/RoleService.d.ts +36 -0
- package/build/services/RBAC/RoleService.d.ts.map +1 -0
- package/build/services/RBAC/RoleService.js +15 -0
- package/build/services/RecordService.d.ts +50 -0
- package/build/services/RecordService.d.ts.map +1 -0
- package/build/services/RecordService.js +34 -0
- package/build/services/RevisionService.d.ts +29 -0
- package/build/services/RevisionService.d.ts.map +1 -0
- package/build/services/RevisionService.js +9 -0
- package/build/services/SbsService.d.ts +34 -0
- package/build/services/SbsService.d.ts.map +1 -0
- package/build/services/SbsService.js +10 -0
- package/build/services/ScriptsService.d.ts +45 -0
- package/build/services/ScriptsService.d.ts.map +1 -0
- package/build/services/ScriptsService.js +20 -0
- package/build/services/SignService.d.ts +8 -0
- package/build/services/SignService.d.ts.map +1 -0
- package/build/services/SignService.js +5 -0
- package/build/services/TableQueryService.d.ts +46 -0
- package/build/services/TableQueryService.d.ts.map +1 -0
- package/build/services/TableQueryService.js +10 -0
- package/build/services/TableService.d.ts +79 -0
- package/build/services/TableService.d.ts.map +1 -0
- package/build/services/TableService.js +16 -0
- package/build/services/TaskQueryService.d.ts +12 -0
- package/build/services/TaskQueryService.d.ts.map +1 -0
- package/build/services/TaskQueryService.js +8 -0
- package/build/services/TaskService.d.ts +249 -0
- package/build/services/TaskService.d.ts.map +1 -0
- package/build/services/TaskService.js +138 -0
- package/build/services/TokenService.d.ts +32 -0
- package/build/services/TokenService.d.ts.map +1 -0
- package/build/services/TokenService.js +9 -0
- package/build/services/UserService.d.ts +98 -0
- package/build/services/UserService.d.ts.map +1 -0
- package/build/services/UserService.js +41 -0
- package/build/services/WorkflowService.d.ts +112 -0
- package/build/services/WorkflowService.d.ts.map +1 -0
- package/build/services/WorkflowService.js +181 -0
- package/build/types.d.ts +21 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { send } from 'post-robot';
|
|
11
|
+
import { BehaviorSubject, combineLatest, concatMap, firstValueFrom, identity, map, shareReplay, switchMap, take, tap, } from 'rxjs';
|
|
12
|
+
import { notificationTypes } from './models';
|
|
13
|
+
import { clone, newScope, takeUntilClosed } from './utils';
|
|
14
|
+
export function newCommsClient(params) {
|
|
15
|
+
var _a;
|
|
16
|
+
const scope = newScope();
|
|
17
|
+
const clientIdChanges = scope
|
|
18
|
+
.once('ant/comms/init', (_a) => __awaiter(this, [_a], void 0, function* ({ data }) { return data; }))
|
|
19
|
+
.pipe(concatMap(({ data: { clientId } }) => clientId ? [clientId] : []), shareReplay(1));
|
|
20
|
+
const box = {
|
|
21
|
+
clientIdChanges,
|
|
22
|
+
scope,
|
|
23
|
+
parent: params.parent,
|
|
24
|
+
};
|
|
25
|
+
return Object.assign(scope, {
|
|
26
|
+
notepad: newNotepad(box),
|
|
27
|
+
notifications: newNotifications(box),
|
|
28
|
+
connect: (_a = params.connect) !== null && _a !== void 0 ? _a : newAntConnectFacade(box),
|
|
29
|
+
context: newContextObservable(box),
|
|
30
|
+
toolbar: handleToolbarChanges(box),
|
|
31
|
+
appState: handleAppStateChanges(box),
|
|
32
|
+
locales: handleLocalesChange(box),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function handleAppStateChanges({ scope, clientIdChanges, parent }) {
|
|
36
|
+
const changes = clientIdChanges.pipe(switchMap(clientId => scope.on(`ant/${clientId}/state`)), map(e => e.data.state));
|
|
37
|
+
return Object.assign(changes, {
|
|
38
|
+
get: () => firstValueFrom(clientIdChanges.pipe(take(1), concatMap(clientId => scope.send(parent, `ant/${clientId}/state/get`, {}, { fireAndForget: false })), map(e => e.data.state))),
|
|
39
|
+
set: (state) => clientIdChanges
|
|
40
|
+
.pipe(take(1), concatMap(clientId => scope.send(parent, `ant/${clientId}/state`, { timestamp: Date.now(), state })))
|
|
41
|
+
.forEach(identity),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function handleLocalesChange({ clientIdChanges, scope }) {
|
|
45
|
+
return clientIdChanges.pipe(switchMap(clientId => scope.on(`ant/${clientId}/locales`)), map(e => e.data));
|
|
46
|
+
}
|
|
47
|
+
function handleToolbarChanges({ scope, parent, clientIdChanges }) {
|
|
48
|
+
const toolbar = new BehaviorSubject({ menu: [], search: { enabled: false, input: '' } });
|
|
49
|
+
const set = (value) => {
|
|
50
|
+
if (typeof value === 'function') {
|
|
51
|
+
toolbar.next(value(toolbar.value));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
toolbar.next(value);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
combineLatest([
|
|
58
|
+
toolbar.asObservable(),
|
|
59
|
+
clientIdChanges,
|
|
60
|
+
])
|
|
61
|
+
.pipe(tap(([toolbar, clientId]) => send(parent, `ant/${clientId}/toolbar`, { toolbar })), switchMap(([toolbar, clientId]) => combineLatest([
|
|
62
|
+
scope.on(`ant/${clientId}/toolbar/click`).pipe(tap(({ data }) => {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
(_c = (_b = [toolbar.start, ...(_a = toolbar.menu) !== null && _a !== void 0 ? _a : []][data.index]) === null || _b === void 0 ? void 0 : _b.onClick) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
65
|
+
})),
|
|
66
|
+
scope.on(`ant/${clientId}/toolbar/search`).pipe(tap(({ data }) => {
|
|
67
|
+
set((t) => {
|
|
68
|
+
const toolbar = Object.assign(Object.assign({}, t), { search: Object.assign(Object.assign({}, t.search), { input: data.value }) });
|
|
69
|
+
console.log('aaa', Object.assign(Object.assign({}, data), { toolbar }));
|
|
70
|
+
return toolbar;
|
|
71
|
+
});
|
|
72
|
+
})),
|
|
73
|
+
])), takeUntilClosed(scope))
|
|
74
|
+
.subscribe();
|
|
75
|
+
return Object.assign(toolbar.asObservable().pipe(takeUntilClosed(scope)), { set, get: () => toolbar.value });
|
|
76
|
+
}
|
|
77
|
+
export function newNotepad({ scope, parent, clientIdChanges }) {
|
|
78
|
+
const post = (name, data) => __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
clientIdChanges
|
|
80
|
+
.pipe(concatMap(clientId => scope.send(parent, `ant/${clientId}/notepad`, { name, data })))
|
|
81
|
+
.subscribe();
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
show: tab => post('show/tab', { tab }),
|
|
85
|
+
showTask: (task, select) => post(`show/task`, { task, select }),
|
|
86
|
+
hide: () => post(`hide`, undefined),
|
|
87
|
+
selectSbs: item => post(`sbs/select`, { item }),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export function newNotifications({ parent, scope, clientIdChanges }) {
|
|
91
|
+
return notificationTypes.reduce((result, type) => Object.assign(result, {
|
|
92
|
+
[type]: (message) => {
|
|
93
|
+
return clientIdChanges
|
|
94
|
+
.pipe(take(1), concatMap(clientId => scope.send(parent, `ant/${clientId}/notifications`, { type, message })), map(({ data }) => data))
|
|
95
|
+
.forEach(identity);
|
|
96
|
+
},
|
|
97
|
+
}), {});
|
|
98
|
+
}
|
|
99
|
+
function newContextObservable({ scope, clientIdChanges }) {
|
|
100
|
+
return clientIdChanges.pipe(switchMap(clientId => scope.on(`ant/${clientId}/context`)), map(e => clone(e.data.context)));
|
|
101
|
+
}
|
|
102
|
+
function newAntConnectFacade({ scope, parent, clientIdChanges }) {
|
|
103
|
+
return new Proxy({}, {
|
|
104
|
+
get: (_, service) => new Proxy({}, {
|
|
105
|
+
get: (_, name) => {
|
|
106
|
+
if (typeof service === 'string' && typeof name === 'string') {
|
|
107
|
+
return (...args) => {
|
|
108
|
+
const observable = clientIdChanges.pipe(concatMap((clientId) => {
|
|
109
|
+
return scope.send(parent, `ant/${clientId}/connect`, {
|
|
110
|
+
service,
|
|
111
|
+
name,
|
|
112
|
+
args,
|
|
113
|
+
});
|
|
114
|
+
}));
|
|
115
|
+
return firstValueFrom(observable).then(({ data }) => data);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
}),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AntConnect } from "../AntConnect";
|
|
2
|
+
import type { Observable, SubscriptionLike } from 'rxjs';
|
|
3
|
+
import type { Context, LocaleData, Notepad, Notification, Toolbar } from './models';
|
|
4
|
+
interface HostParams {
|
|
5
|
+
windowChanges: Observable<Window>;
|
|
6
|
+
contextChanges: Observable<Context>;
|
|
7
|
+
addNotification: (notification: Notification) => void;
|
|
8
|
+
connect: AntConnect;
|
|
9
|
+
notepad: Notepad;
|
|
10
|
+
locales: Observable<LocaleData>;
|
|
11
|
+
appState?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Host extends SubscriptionLike {
|
|
14
|
+
toolbar: Observable<Toolbar> & {
|
|
15
|
+
get: () => Toolbar;
|
|
16
|
+
set: {
|
|
17
|
+
search: (value: string) => Promise<unknown>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
isConnectionInitialized: Observable<boolean>;
|
|
21
|
+
appState: {
|
|
22
|
+
changes: Observable<string>;
|
|
23
|
+
get: () => string;
|
|
24
|
+
set: (state: string) => void;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare function newCommsHost(params: HostParams): Host;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/comms/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAoB;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAW,gBAAgB,EAAE,MAAM,MAAM,CAAA;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAuBnF,UAAU,UAAU;IAClB,aAAa,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;IACjC,cAAc,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IACnC,eAAe,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAA;IACrD,OAAO,EAAE,UAAU,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AASD,MAAM,WAAW,IAAK,SAAQ,gBAAgB;IAC5C,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG;QAAE,GAAG,EAAE,MAAM,OAAO,CAAC;QAAC,GAAG,EAAE;YAAE,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;SAAE,CAAA;KAAE,CAAA;IAC3G,uBAAuB,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC5C,QAAQ,EAAE;QACR,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;QAC3B,GAAG,EAAE,MAAM,MAAM,CAAA;QACjB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;KAC7B,CAAA;CACF;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CA+BrD"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { on, send } from 'post-robot';
|
|
11
|
+
import { BehaviorSubject, combineLatest, concatMap, delay, distinctUntilChanged, filter, identity, map, of, ReplaySubject, retry, startWith, switchMap, take, tap, } from 'rxjs';
|
|
12
|
+
import { fromArrayLike } from 'rxjs/internal/observable/innerFrom';
|
|
13
|
+
import { newId, newScope, takeUntilClosed } from './utils';
|
|
14
|
+
export function newCommsHost(params) {
|
|
15
|
+
const scope = newScope();
|
|
16
|
+
const clientId = newId();
|
|
17
|
+
const connectionInitialized = new ReplaySubject(1);
|
|
18
|
+
const box = { scope, params, clientId, connectionInitialized };
|
|
19
|
+
const toolbar = handleToolbarChanges(box);
|
|
20
|
+
const appState = handleAppStateChanges(box);
|
|
21
|
+
handleInit(box);
|
|
22
|
+
handleContextChanges(box);
|
|
23
|
+
handleNotificationChanges(box);
|
|
24
|
+
handleConnectChanges(box);
|
|
25
|
+
handleNotepadChanges(box);
|
|
26
|
+
params.locales
|
|
27
|
+
.pipe(switchMap(locales => combineLatest([fromArrayLike([locales]), params.windowChanges, connectionInitialized])), concatMap(([locales, window]) => send(window, `ant/${clientId}/locales`, { locales })), takeUntilClosed(scope))
|
|
28
|
+
.subscribe();
|
|
29
|
+
scope.add(connectionInitialized);
|
|
30
|
+
return Object.assign(scope, {
|
|
31
|
+
toolbar,
|
|
32
|
+
appState,
|
|
33
|
+
isConnectionInitialized: connectionInitialized
|
|
34
|
+
.asObservable()
|
|
35
|
+
.pipe(map(() => true), startWith(false), takeUntilClosed(scope)),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function handleInit({ scope, params, clientId, connectionInitialized }) {
|
|
39
|
+
// tried all the forms I can think of to catch the error of `send` when timeout. None of them succeeded, so second best thing was to add loggers to know that is solved after retrying.
|
|
40
|
+
params.windowChanges
|
|
41
|
+
.pipe(switchMap(window => send(window, 'ant/comms/init', { clientId }, { fireAndForget: false })), retry({
|
|
42
|
+
delay: (error, attempt) => of(error).pipe(delay(3000), tap(error => console.info('retrying connection initialization', { attempt, error }))),
|
|
43
|
+
}), tap(() => console.info('connection initialized')), takeUntilClosed(scope))
|
|
44
|
+
.subscribe({ next: () => connectionInitialized.next(undefined) });
|
|
45
|
+
}
|
|
46
|
+
function handleNotificationChanges({ scope, params, clientId }) {
|
|
47
|
+
scope
|
|
48
|
+
.resolve(on(`ant/${clientId}/notifications`, (_a) => __awaiter(this, [_a], void 0, function* ({ data }) {
|
|
49
|
+
const notification = data;
|
|
50
|
+
params.addNotification(notification);
|
|
51
|
+
return notification;
|
|
52
|
+
})))
|
|
53
|
+
.catch(identity); // consume the cancellation error
|
|
54
|
+
}
|
|
55
|
+
function handleConnectChanges({ scope, params, clientId }) {
|
|
56
|
+
scope
|
|
57
|
+
.resolve(on(`ant/${clientId}/connect`, ({ data }) => {
|
|
58
|
+
const { service, name, args } = data;
|
|
59
|
+
return params.connect[service][name](...args);
|
|
60
|
+
}))
|
|
61
|
+
.catch(identity); // consume the cancellation error
|
|
62
|
+
}
|
|
63
|
+
function handleNotepadChanges({ scope, params, clientId }) {
|
|
64
|
+
scope
|
|
65
|
+
.resolve(on(`ant/${clientId}/notepad`, (e) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const { name, data } = e.data;
|
|
67
|
+
switch (name) {
|
|
68
|
+
case 'hide':
|
|
69
|
+
return params.notepad.hide();
|
|
70
|
+
case 'show/tab':
|
|
71
|
+
return params.notepad.show(data.tab);
|
|
72
|
+
case 'show/task':
|
|
73
|
+
return params.notepad.showTask(data.task, data.select);
|
|
74
|
+
case 'sbs/select':
|
|
75
|
+
return params.notepad.selectSbs(data.item);
|
|
76
|
+
}
|
|
77
|
+
})))
|
|
78
|
+
.catch(identity); // consume the cancellation error
|
|
79
|
+
}
|
|
80
|
+
function handleContextChanges({ params, clientId, scope, connectionInitialized }) {
|
|
81
|
+
const { contextChanges, windowChanges } = params;
|
|
82
|
+
combineLatest([windowChanges, contextChanges, connectionInitialized])
|
|
83
|
+
.pipe(filter(([window]) => !window.closed), concatMap(([window, context]) => send(window, `ant/${clientId}/context`, { context }, { fireAndForget: true })), takeUntilClosed(scope))
|
|
84
|
+
.subscribe();
|
|
85
|
+
}
|
|
86
|
+
function handleToolbarChanges({ scope, clientId, connectionInitialized, params }) {
|
|
87
|
+
const toolbar = new BehaviorSubject({ menu: [], search: { enabled: false, input: '' } });
|
|
88
|
+
scope.on(`ant/${clientId}/toolbar`)
|
|
89
|
+
.pipe(tap(({ data, source }) => {
|
|
90
|
+
var _a;
|
|
91
|
+
const toolbar = data.toolbar;
|
|
92
|
+
const emit = (name, data) => connectionInitialized
|
|
93
|
+
.pipe(take(1), concatMap(() => send(source, name, data)))
|
|
94
|
+
.forEach(identity);
|
|
95
|
+
[toolbar === null || toolbar === void 0 ? void 0 : toolbar.start, ...(_a = toolbar.menu) !== null && _a !== void 0 ? _a : []]
|
|
96
|
+
.flatMap((item, index) => item ? [{ item, index }] : [])
|
|
97
|
+
.forEach(({ item, index }) => item.onClick = () => emit(`ant/${clientId}/toolbar/click`, { index }));
|
|
98
|
+
}), map(({ data }) => data.toolbar))
|
|
99
|
+
.subscribe(value => toolbar.next(value));
|
|
100
|
+
return Object.assign(toolbar.asObservable(), {
|
|
101
|
+
get: () => toolbar.value,
|
|
102
|
+
set: {
|
|
103
|
+
search: (value) => {
|
|
104
|
+
return combineLatest([params.windowChanges, connectionInitialized])
|
|
105
|
+
.pipe(take(1), concatMap(([source]) => send(source, `ant/${clientId}/toolbar/search`, { value })), tap(() => console.log('aaa', { value })))
|
|
106
|
+
.forEach(identity);
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function handleAppStateChanges({ scope, params, clientId, connectionInitialized }) {
|
|
112
|
+
var _a;
|
|
113
|
+
const appState = new BehaviorSubject({ timestamp: 0, state: (_a = params.appState) !== null && _a !== void 0 ? _a : '' });
|
|
114
|
+
scope
|
|
115
|
+
.on(`ant/${clientId}/state`)
|
|
116
|
+
.subscribe(({ data }) => { var _a; return data.timestamp > ((_a = appState.value) === null || _a === void 0 ? void 0 : _a.timestamp) && appState.next(data); });
|
|
117
|
+
scope
|
|
118
|
+
.on(`ant/${clientId}/state/get`, () => appState.value)
|
|
119
|
+
.subscribe();
|
|
120
|
+
appState
|
|
121
|
+
.asObservable()
|
|
122
|
+
.pipe(concatMap(state => combineLatest([fromArrayLike([state]), params.windowChanges, connectionInitialized])), concatMap(([state, window]) => send(window, `ant/${clientId}/state`, state, { fireAndForget: true })), takeUntilClosed(scope))
|
|
123
|
+
.subscribe();
|
|
124
|
+
return {
|
|
125
|
+
changes: appState.asObservable().pipe(map(e => e.state), distinctUntilChanged(), takeUntilClosed(scope)),
|
|
126
|
+
get: () => appState.value.state,
|
|
127
|
+
set: (state) => appState.next({ timestamp: Date.now(), state }),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { License } from "../services/LicenseService";
|
|
2
|
+
import type { ProjectShort } from "../services/ProjectService";
|
|
3
|
+
import type { Task } from "../services/TaskService";
|
|
4
|
+
import type { User } from "../services/UserService";
|
|
5
|
+
import type { Subscription } from 'rxjs';
|
|
6
|
+
export interface Context {
|
|
7
|
+
user?: User | null;
|
|
8
|
+
license?: License | null;
|
|
9
|
+
task?: Task | null;
|
|
10
|
+
project?: ProjectShort | null;
|
|
11
|
+
sbs?: {
|
|
12
|
+
code: string;
|
|
13
|
+
} | null;
|
|
14
|
+
locale?: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface ToolbarItem {
|
|
17
|
+
icon: string;
|
|
18
|
+
title: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
onClick?: () => void;
|
|
21
|
+
}
|
|
22
|
+
export interface Toolbar {
|
|
23
|
+
start?: ToolbarItem;
|
|
24
|
+
title?: string;
|
|
25
|
+
search: {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
input: string;
|
|
28
|
+
};
|
|
29
|
+
menu: ToolbarItem[];
|
|
30
|
+
}
|
|
31
|
+
export type NotepadVisibility = boolean | 'task' | 'apps' | 'tasks' | 'sbs';
|
|
32
|
+
export interface Notepad {
|
|
33
|
+
show: (tab?: NotepadVisibility) => PromiseLike<unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Show a task in the notepad. Optionally it can be selected as the current Task.
|
|
36
|
+
* @param task
|
|
37
|
+
* @param select
|
|
38
|
+
*/
|
|
39
|
+
showTask: (task: {
|
|
40
|
+
id: string;
|
|
41
|
+
}, select?: true) => PromiseLike<unknown>;
|
|
42
|
+
hide: () => PromiseLike<unknown>;
|
|
43
|
+
selectSbs: (item: {
|
|
44
|
+
code: string;
|
|
45
|
+
}) => PromiseLike<unknown>;
|
|
46
|
+
}
|
|
47
|
+
export declare const notificationTypes: readonly ["success", "error", "warning", "info"];
|
|
48
|
+
export type Notifications = Record<typeof notificationTypes[number], (message: string) => Promise<unknown> & Subscription>;
|
|
49
|
+
export interface Notification {
|
|
50
|
+
type: typeof notificationTypes[number];
|
|
51
|
+
message: string;
|
|
52
|
+
}
|
|
53
|
+
export interface LocaleData {
|
|
54
|
+
locale?: string;
|
|
55
|
+
availableLocales: string[];
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/comms/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,mCAAiC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,mCAAiC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,gCAA8B;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,gCAA8B;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,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AAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,CAAA;AAE1H,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAA;IACtC,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const notificationTypes = ['success', 'error', 'warning', 'info'];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { MonoTypeOperatorFunction } from 'rxjs';
|
|
2
|
+
import { Observable, Subscription } from 'rxjs';
|
|
3
|
+
/**
|
|
4
|
+
* Ensures a stream is closed whenever the parent subscription is closed.
|
|
5
|
+
*
|
|
6
|
+
* This will make sure the stream is not sending results after a UI component is destroyed.
|
|
7
|
+
* @param subscription
|
|
8
|
+
*/
|
|
9
|
+
export declare function takeUntilClosed<T>(subscription: Subscription): MonoTypeOperatorFunction<T>;
|
|
10
|
+
export interface Message<T extends object = any, R = unknown> {
|
|
11
|
+
data: T;
|
|
12
|
+
origin: string;
|
|
13
|
+
source: Window;
|
|
14
|
+
response?: R;
|
|
15
|
+
}
|
|
16
|
+
type HandlerType<T, R> = (event: {
|
|
17
|
+
source: Window;
|
|
18
|
+
origin: string;
|
|
19
|
+
data: T;
|
|
20
|
+
}) => Promise<R> | R;
|
|
21
|
+
export declare function newScope(parent?: Subscription): Subscription & {
|
|
22
|
+
resolve: <T>(value: PromiseLike<T> | {
|
|
23
|
+
cancel: () => void;
|
|
24
|
+
}) => Promise<T> & Subscription;
|
|
25
|
+
newScope: () => Subscription & any;
|
|
26
|
+
on: <T extends object = any, R extends object = any>(name: string, handler?: HandlerType<T, R>) => Observable<Message<T, unknown>>;
|
|
27
|
+
once: <T extends object = any, R extends object = any>(name: string, handler?: (message: Message<T>) => Promise<R>) => Observable<Message<T, unknown>>;
|
|
28
|
+
send: <T extends object = any, R extends object = any>(window: Window, name: string, data: T, options?: {
|
|
29
|
+
fireAndForget?: boolean;
|
|
30
|
+
timeout?: number;
|
|
31
|
+
}) => Observable<Message<R, unknown>>;
|
|
32
|
+
};
|
|
33
|
+
export type Scope = ReturnType<typeof newScope>;
|
|
34
|
+
export declare const newId: () => string;
|
|
35
|
+
/**
|
|
36
|
+
* The toRaw and structuredClonew are failing under certain conditions, but this good old one not.
|
|
37
|
+
* @param value
|
|
38
|
+
*/
|
|
39
|
+
export declare function clone<T>(value: T): T;
|
|
40
|
+
export interface AppStateData {
|
|
41
|
+
timestamp: number;
|
|
42
|
+
state: string;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/comms/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,MAAM,CAAA;AAEpD,OAAO,EAAqC,UAAU,EAAW,YAAY,EAAwB,MAAM,MAAM,CAAA;AAIjH;;;;;GAKG;AAEH,wBAAgB,eAAe,CAAC,CAAC,EAAE,YAAY,EAAE,YAAY,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAW1F;AA0BD,MAAM,WAAW,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,EAAE,CAAC,GAAG,OAAO;IAC1D,IAAI,EAAE,CAAC,CAAA;IACP,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,CAAA;CACb;AAED,KAAK,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,CAAC,CAAA;CACR,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAEpB,wBAAgB,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY;cA9BpC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,GAAG;QAAE,MAAM,EAAE,MAAM,IAAI,CAAA;KAAE,KAAG,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY;;SAsC9E,CAAC,SAAS,MAAM,QAAQ,CAAC,SAAS,MAAM,cAAc,MAAM,YAAY,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC;WAUvF,CAAC,SAAS,MAAM,QAAQ,CAAC,SAAS,MAAM,cAAc,MAAM,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;WAI3G,CAAC,SAAS,MAAM,QAAQ,CAAC,SAAS,MAAM,gBACrC,MAAM,QACR,MAAM,QACN,CAAC,YACG;QAAE,aAAa,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;EAM5D;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE/C,eAAO,MAAM,KAAK,cAAuE,CAAA;AAEzF;;;GAGG;AAEH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEpC;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { on, once, send } from 'post-robot';
|
|
11
|
+
import { EMPTY, first, firstValueFrom, map, Observable, Subject, Subscription, takeUntil, takeWhile } from 'rxjs';
|
|
12
|
+
import { fromPromise } from 'rxjs/internal/observable/innerFrom';
|
|
13
|
+
import { isPromise } from 'rxjs/internal/util/isPromise';
|
|
14
|
+
/**
|
|
15
|
+
* Ensures a stream is closed whenever the parent subscription is closed.
|
|
16
|
+
*
|
|
17
|
+
* This will make sure the stream is not sending results after a UI component is destroyed.
|
|
18
|
+
* @param subscription
|
|
19
|
+
*/
|
|
20
|
+
export function takeUntilClosed(subscription) {
|
|
21
|
+
return (observable) => {
|
|
22
|
+
const subject = new Subject();
|
|
23
|
+
subscription.add(() => {
|
|
24
|
+
subject.next();
|
|
25
|
+
subject.complete();
|
|
26
|
+
});
|
|
27
|
+
return observable.pipe(takeUntil(subject), takeWhile(() => !subscription.closed));
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Helper function that can process all the `post-robot` functions. It will wrap the `post-robot` function in a Observable to make it cancellable.
|
|
32
|
+
*
|
|
33
|
+
* Cancelling the scope will result in all the ongoing `post-robot` functions to be cancelled.
|
|
34
|
+
*/
|
|
35
|
+
function newResolve(parent) {
|
|
36
|
+
return (value) => {
|
|
37
|
+
const subscription = new Subscription();
|
|
38
|
+
const promise = isPromise(value)
|
|
39
|
+
? firstValueFrom(fromPromise(value).pipe(takeUntilClosed(subscription)))
|
|
40
|
+
: new Promise((_, error) => {
|
|
41
|
+
subscription.add(() => {
|
|
42
|
+
value.cancel();
|
|
43
|
+
EMPTY.pipe(first()).subscribe({ error }); // send error, because it is default behavior to either a success or an error
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
parent.add(subscription);
|
|
47
|
+
return Object.assign(promise, subscription);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function newScope(parent) {
|
|
51
|
+
const subscription = new Subscription();
|
|
52
|
+
parent === null || parent === void 0 ? void 0 : parent.add(subscription);
|
|
53
|
+
return Object.assign(subscription, {
|
|
54
|
+
resolve: newResolve(subscription),
|
|
55
|
+
newScope: () => newScope(subscription),
|
|
56
|
+
on: (name, handler) => new Observable((subscriber) => {
|
|
57
|
+
const cancellable = on(name, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const response = yield Promise.resolve().then(() => handler === null || handler === void 0 ? void 0 : handler(params));
|
|
59
|
+
subscriber.next(Object.assign(Object.assign({}, params), { response }));
|
|
60
|
+
return response;
|
|
61
|
+
}));
|
|
62
|
+
subscriber.add(() => cancellable.cancel());
|
|
63
|
+
}).pipe(takeUntilClosed(subscription)),
|
|
64
|
+
once: (name, handler) => fromPromise(once(name, handler)).pipe(takeUntilClosed(subscription), map(e => e)),
|
|
65
|
+
send: (window, name, data, options) => fromPromise(send(window, name, data, options)).pipe(takeUntilClosed(subscription), map(e => e)),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export const newId = () => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString();
|
|
69
|
+
/**
|
|
70
|
+
* The toRaw and structuredClonew are failing under certain conditions, but this good old one not.
|
|
71
|
+
* @param value
|
|
72
|
+
*/
|
|
73
|
+
export function clone(value) {
|
|
74
|
+
return JSON.parse(JSON.stringify(value));
|
|
75
|
+
}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './AntConnect';
|
|
2
|
+
export { type AntConnect } from './AntConnect';
|
|
3
|
+
export { AntHttpClient, newAntHttpClient, type NewAntHttpClientArgs } from './AntHttpClient';
|
|
4
|
+
export { type Client, newCommsClient } from './comms/client';
|
|
5
|
+
export { newNotepad } from './comms/client';
|
|
6
|
+
export { type Host, newCommsHost } from './comms/host';
|
|
7
|
+
export type { Context, LocaleData, Notepad, NotepadVisibility, Notification, Notifications, Toolbar, ToolbarItem } from './comms/models';
|
|
8
|
+
export { clone, newScope, type Scope } from './comms/utils';
|
|
9
|
+
export type { App } from './services/AppService';
|
|
10
|
+
export { type License } from './services/LicenseService';
|
|
11
|
+
export { type Project, type ProjectRequestBody, type ProjectShort } from './services/ProjectService';
|
|
12
|
+
export type { SbsRecord } from './services/SbsService';
|
|
13
|
+
export type { TableQueryService, TableQueryShort } from './services/TableQueryService';
|
|
14
|
+
export { type Task } from './services/TaskService';
|
|
15
|
+
export { defaultGetTaskQuery, defaultGetTasksQuery } from './services/TaskService';
|
|
16
|
+
export type { FileInRequest, User, UserShort } from './services/UserService';
|
|
17
|
+
export * from './types';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAC5F,OAAO,EAAE,KAAK,MAAM,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,KAAK,IAAI,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACtD,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAExI,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,KAAK,EAAE,MAAM,eAAe,CAAA;AAC3D,YAAY,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACpG,YAAY,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACtF,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAClF,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAE5E,cAAc,SAAS,CAAA"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './AntConnect';
|
|
2
|
+
export { AntHttpClient, newAntHttpClient } from './AntHttpClient';
|
|
3
|
+
export { newCommsClient } from './comms/client';
|
|
4
|
+
export { newNotepad } from './comms/client';
|
|
5
|
+
export { newCommsHost } from './comms/host';
|
|
6
|
+
export { clone, newScope } from './comms/utils';
|
|
7
|
+
export { defaultGetTaskQuery, defaultGetTasksQuery } from './services/TaskService';
|
|
8
|
+
export * from './types';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { MessageResponse } from "../AntConnect";
|
|
2
|
+
import type { AntHttpClient } from "../AntHttpClient";
|
|
3
|
+
import type { DataWrapper } from '../types';
|
|
4
|
+
import type { Project } from './ProjectService';
|
|
5
|
+
export interface ResourceApp {
|
|
6
|
+
id: number;
|
|
7
|
+
app_id: number;
|
|
8
|
+
app_version_id: number;
|
|
9
|
+
resource_id: string;
|
|
10
|
+
resource_type: string;
|
|
11
|
+
project_id: string;
|
|
12
|
+
created_at: string;
|
|
13
|
+
updated_at: string;
|
|
14
|
+
deleted_at: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface App {
|
|
17
|
+
id: number;
|
|
18
|
+
title: string;
|
|
19
|
+
description: string | null;
|
|
20
|
+
color: string;
|
|
21
|
+
is_published: boolean;
|
|
22
|
+
is_system: boolean;
|
|
23
|
+
is_private: boolean;
|
|
24
|
+
project_required: boolean;
|
|
25
|
+
icon: string;
|
|
26
|
+
url: string;
|
|
27
|
+
image: string | null;
|
|
28
|
+
created_at: string;
|
|
29
|
+
versions: AppVersion[];
|
|
30
|
+
updated_at: string;
|
|
31
|
+
loading?: boolean;
|
|
32
|
+
enabled?: boolean;
|
|
33
|
+
enabled_in_license: boolean;
|
|
34
|
+
latest_version: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface AppVersion {
|
|
37
|
+
id: number;
|
|
38
|
+
app_id: number;
|
|
39
|
+
version: string;
|
|
40
|
+
release_type: string;
|
|
41
|
+
release_notes: string | null;
|
|
42
|
+
resources: ResourceApp[];
|
|
43
|
+
url: string;
|
|
44
|
+
created_at: string;
|
|
45
|
+
updated_at: string;
|
|
46
|
+
loading?: boolean;
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
enabled_in_license?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface AppVersionFormData {
|
|
51
|
+
app_id: number;
|
|
52
|
+
app_version_id: number;
|
|
53
|
+
}
|
|
54
|
+
export interface AppFormData {
|
|
55
|
+
title?: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
color?: string;
|
|
58
|
+
icon?: string;
|
|
59
|
+
image?: File | null;
|
|
60
|
+
build?: File | null;
|
|
61
|
+
image64?: string;
|
|
62
|
+
build64?: string;
|
|
63
|
+
release_type?: string;
|
|
64
|
+
release_notes?: string;
|
|
65
|
+
is_system: boolean;
|
|
66
|
+
is_private: boolean;
|
|
67
|
+
project_required: boolean;
|
|
68
|
+
license_id: string | null;
|
|
69
|
+
}
|
|
70
|
+
export interface AllLicenseAppsParams {
|
|
71
|
+
licenseId: string;
|
|
72
|
+
type: 'all' | 'installed' | 'available';
|
|
73
|
+
search: string;
|
|
74
|
+
}
|
|
75
|
+
export interface AppService {
|
|
76
|
+
fetchApps: () => Promise<DataWrapper<App[]>>;
|
|
77
|
+
fetchSystemApps: (licenseId: string) => Promise<DataWrapper<App[]>>;
|
|
78
|
+
fetchApp: (resource: string, resourceId: string, appId: number) => Promise<DataWrapper<App>>;
|
|
79
|
+
createApp: (appData: AppFormData) => Promise<App>;
|
|
80
|
+
updateApp: (appId: number, appData: Partial<AppFormData>) => Promise<App>;
|
|
81
|
+
deleteApp: (appId: number) => Promise<MessageResponse>;
|
|
82
|
+
fetchAppProjects: (licenseId: number, appId: number) => Promise<Project[]>;
|
|
83
|
+
fetchAppDetails: (appId: number) => Promise<Partial<App>>;
|
|
84
|
+
fetchLicenseApps: (licenseId: string) => Promise<DataWrapper<App[]>>;
|
|
85
|
+
fetchAllLicenseApps: (licenseId: AllLicenseAppsParams['licenseId'], type: AllLicenseAppsParams['type'], search?: AllLicenseAppsParams['search']) => Promise<DataWrapper<App[]>>;
|
|
86
|
+
addAppToLicense: (licenseId: string, appId: number, appVersionId: number) => Promise<any>;
|
|
87
|
+
removeAppFromLicense: (licenseId: string, appId: number, appVersionId: number | null) => Promise<any>;
|
|
88
|
+
fetchProjectApps: (projectId: string) => Promise<DataWrapper<App[]>>;
|
|
89
|
+
addAppToProject: (projectId: string, appId: number, appVersionId: number) => Promise<any>;
|
|
90
|
+
removeAppFromProject: (projectId: string, appId: number, appVersionId: number | null) => Promise<any>;
|
|
91
|
+
fetchUserApps: (licenseId: string) => Promise<DataWrapper<App[]>>;
|
|
92
|
+
}
|
|
93
|
+
export declare function newAppService(client: AntHttpClient): AppService;
|
|
94
|
+
export default AppService;
|
|
95
|
+
//# sourceMappingURL=AppService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppService.d.ts","sourceRoot":"","sources":["../../src/services/AppService.ts"],"names":[],"mappings":"AAAA,O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b,YAAY,EAAE,MAAM,GAAG,IAAI,KACxB,OAAO,CAAC,GAAG,CAAC,CAAA;IAEjB,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IACpE,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IACzF,oBAAoB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IACrG,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;CAClE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CA+B/D;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function newAppService(client) {
|
|
2
|
+
return {
|
|
3
|
+
fetchApps: () => client.get('/apps'),
|
|
4
|
+
fetchApp: (resource, resourceId, appId) => client.get(`/${resource}/${resourceId}/apps/${appId}`),
|
|
5
|
+
fetchAppDetails: appId => client.get(`/apps/${appId}`),
|
|
6
|
+
createApp: appData => client.post(`/apps`, appData),
|
|
7
|
+
updateApp: (appId, appData) => client.put(`/apps/${appId}`, appData), // Workaround to make Laravel FormData PATCH/PUT requests work
|
|
8
|
+
deleteApp: appId => client.delete(`/apps/${appId}`),
|
|
9
|
+
fetchAppProjects: (licenseId, appId) => client.get(`/licenses/${licenseId}/apps/${appId}/projects`),
|
|
10
|
+
fetchSystemApps: licenseId => client.get(`/licenses/${licenseId}/systemApps`),
|
|
11
|
+
fetchLicenseApps: licenseId => client.get(`/licenses/${licenseId}/apps`),
|
|
12
|
+
fetchAllLicenseApps: (licenseId, type, search = '') => client.get(`/licenses/${licenseId}/all-apps`, { params: { type, search } }),
|
|
13
|
+
addAppToLicense: (licenseId, appId, appVersionId) => client.post(`/licenses/${licenseId}/apps`, { app_id: appId, app_version_id: appVersionId }),
|
|
14
|
+
removeAppFromLicense: (licenseId, appId, appVersionId) => client.delete(`/licenses/${licenseId}/apps`, {
|
|
15
|
+
data: { app_id: appId, app_version_id: appVersionId !== null && appVersionId !== void 0 ? appVersionId : null },
|
|
16
|
+
}),
|
|
17
|
+
fetchProjectApps: projectId => client.get(`/projects/${projectId}/apps`),
|
|
18
|
+
addAppToProject: (projectId, appId, appVersionId) => client.post(`/projects/${projectId}/apps`, { app_id: appId, app_version_id: appVersionId }),
|
|
19
|
+
removeAppFromProject: (projectId, appId, appVersionId) => client.delete(`/projects/${projectId}/apps`, {
|
|
20
|
+
data: { app_id: appId, app_version_id: appVersionId },
|
|
21
|
+
}),
|
|
22
|
+
fetchUserApps: licenseId => client.get(`/licenses/${licenseId}/user-apps`),
|
|
23
|
+
};
|
|
24
|
+
}
|