-
Notifications
You must be signed in to change notification settings - Fork 0
/
detect-if-single-drawing-needs-update.ts
35 lines (29 loc) · 1.25 KB
/
detect-if-single-drawing-needs-update.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
import { mainLog } from './utils/logger.js';
import { ApiClient } from './utils/apiclient.js';
import { usage, DrawingScriptArgs, parseDrawingScriptArgs, validateBaseURLs, getIfDrawingNeedsUpdate } from './utils/drawingutils.js';
const LOG = mainLog();
let drawingScriptArgs: DrawingScriptArgs = null;
let validArgs: boolean = true;
let apiClient: ApiClient = null;
try {
drawingScriptArgs = parseDrawingScriptArgs();
apiClient = await ApiClient.createApiClient(drawingScriptArgs.stackToUse);
validateBaseURLs(apiClient.getBaseURL(), drawingScriptArgs.baseURL);
} catch (error) {
validArgs = false;
usage('detect-if-single-drawing-needs-update');
}
if (validArgs) {
try {
LOG.info(`documentId=${drawingScriptArgs.documentId}, workspaceId=${drawingScriptArgs.workspaceId}, elementId=${drawingScriptArgs.elementId}`);
const drawingNeedsUpdate: boolean = await getIfDrawingNeedsUpdate(apiClient, drawingScriptArgs.documentId, drawingScriptArgs.workspaceId, drawingScriptArgs.elementId)
if (drawingNeedsUpdate) {
console.log('Drawing needs an update!');
} else {
console.log('Drawing does NOT need an update.');
}
} catch (error) {
console.error(error);
LOG.error('Detecting if a drawing needs an update failed', error);
}
}