@contrail/extensions-sdk 1.0.2 → 1.0.3
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/lib/apps/app-context.d.ts +41 -5
- package/lib/apps/app-context.js +3 -3
- package/lib/apps/boards.js +1 -1
- package/lib/apps/plan.d.ts +4 -1
- package/lib/apps/plan.js +19 -1
- package/package.json +1 -1
|
@@ -1,18 +1,54 @@
|
|
|
1
1
|
import { User } from "@contrail/entity-types";
|
|
2
2
|
export declare enum VibeIQAppType {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
BOARDS = "boards",
|
|
4
|
+
PLAN = "plan",
|
|
5
|
+
SHOWCASE = "showcase"
|
|
6
6
|
}
|
|
7
7
|
export interface AppContext {
|
|
8
8
|
appContext?: {
|
|
9
|
-
plan?:
|
|
10
|
-
board?:
|
|
9
|
+
plan?: PlanContext;
|
|
10
|
+
board?: BoardContext;
|
|
11
11
|
selectedElements?: any[];
|
|
12
12
|
vibeIQApp?: VibeIQAppType;
|
|
13
13
|
};
|
|
14
14
|
user?: User;
|
|
15
15
|
}
|
|
16
|
+
export interface PlanContext {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
orgId: string;
|
|
20
|
+
targetAssortmentId: string;
|
|
21
|
+
workspaceId: string;
|
|
22
|
+
itemIds?: string[];
|
|
23
|
+
planPlaceholders?: any[];
|
|
24
|
+
filteredPlanPlaceholderIds?: string[];
|
|
25
|
+
hasFilter: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface BoardContext {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
orgId: string;
|
|
31
|
+
backingAssortmentId: string;
|
|
32
|
+
documentId: string;
|
|
33
|
+
document: {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
orgId: string;
|
|
37
|
+
ownedByReference: string;
|
|
38
|
+
size: {
|
|
39
|
+
width: string;
|
|
40
|
+
height: string;
|
|
41
|
+
};
|
|
42
|
+
elements: any[];
|
|
43
|
+
documentElementSortOrder: any;
|
|
44
|
+
modelBindings: any;
|
|
45
|
+
workspaceId: string;
|
|
46
|
+
};
|
|
47
|
+
previewFileId: string;
|
|
48
|
+
rootWorkspaceId: string;
|
|
49
|
+
typeId: string;
|
|
50
|
+
workspaceId: string;
|
|
51
|
+
}
|
|
16
52
|
export declare const CONTEXT: AppContext;
|
|
17
53
|
export declare function setAppContext(context: AppContext): void;
|
|
18
54
|
export declare function getAppContext(): AppContext;
|
package/lib/apps/app-context.js
CHANGED
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getAppContext = exports.setAppContext = exports.CONTEXT = exports.VibeIQAppType = void 0;
|
|
4
4
|
var VibeIQAppType;
|
|
5
5
|
(function (VibeIQAppType) {
|
|
6
|
-
VibeIQAppType["
|
|
7
|
-
VibeIQAppType["
|
|
8
|
-
VibeIQAppType["
|
|
6
|
+
VibeIQAppType["BOARDS"] = "boards";
|
|
7
|
+
VibeIQAppType["PLAN"] = "plan";
|
|
8
|
+
VibeIQAppType["SHOWCASE"] = "showcase";
|
|
9
9
|
})(VibeIQAppType = exports.VibeIQAppType || (exports.VibeIQAppType = {}));
|
|
10
10
|
exports.CONTEXT = {};
|
|
11
11
|
function setAppContext(context) {
|
package/lib/apps/boards.js
CHANGED
|
@@ -15,7 +15,7 @@ class BoardsApp {
|
|
|
15
15
|
}
|
|
16
16
|
static validateBoardContext() {
|
|
17
17
|
const context = (0, app_context_1.getAppContext)();
|
|
18
|
-
if (context.appContext.vibeIQApp !== app_context_1.VibeIQAppType.
|
|
18
|
+
if (context.appContext.vibeIQApp !== app_context_1.VibeIQAppType.BOARDS || !context.appContext.board) {
|
|
19
19
|
throw new Error("App extension has not been initialized with Board context.");
|
|
20
20
|
}
|
|
21
21
|
}
|
package/lib/apps/plan.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { PlanContext } from "./app-context";
|
|
1
2
|
export declare class PlanApp {
|
|
2
|
-
static getCurrentPlan():
|
|
3
|
+
static getCurrentPlan(): PlanContext;
|
|
4
|
+
static getAllPlanPlaceholders(): any[];
|
|
5
|
+
static getFilteredPlanPlaceholders(): any[];
|
|
3
6
|
static addRows(collectionElements: Array<any>): void;
|
|
4
7
|
static clearSelectedRows(): void;
|
|
5
8
|
static showMessage(message: string): void;
|
package/lib/apps/plan.js
CHANGED
|
@@ -8,6 +8,24 @@ class PlanApp {
|
|
|
8
8
|
PlanApp.validatePlanContext();
|
|
9
9
|
return (0, app_context_1.getAppContext)().appContext.plan;
|
|
10
10
|
}
|
|
11
|
+
static getAllPlanPlaceholders() {
|
|
12
|
+
var _a;
|
|
13
|
+
PlanApp.validatePlanContext();
|
|
14
|
+
const plan = PlanApp.getCurrentPlan();
|
|
15
|
+
return (_a = plan === null || plan === void 0 ? void 0 : plan.planPlaceholders) !== null && _a !== void 0 ? _a : [];
|
|
16
|
+
}
|
|
17
|
+
static getFilteredPlanPlaceholders() {
|
|
18
|
+
var _a;
|
|
19
|
+
PlanApp.validatePlanContext();
|
|
20
|
+
const plan = PlanApp.getCurrentPlan();
|
|
21
|
+
const allPlanPlaceholders = PlanApp.getAllPlanPlaceholders();
|
|
22
|
+
if (!(plan === null || plan === void 0 ? void 0 : plan.hasFilter)) {
|
|
23
|
+
return allPlanPlaceholders;
|
|
24
|
+
}
|
|
25
|
+
const filteredPlanPlaceholderIds = (_a = plan.filteredPlanPlaceholderIds) !== null && _a !== void 0 ? _a : [];
|
|
26
|
+
const filteredResults = allPlanPlaceholders.filter((placeholder) => filteredPlanPlaceholderIds.includes(placeholder.id));
|
|
27
|
+
return filteredResults;
|
|
28
|
+
}
|
|
11
29
|
static addRows(collectionElements) {
|
|
12
30
|
PlanApp.validatePlanContext();
|
|
13
31
|
const actions = (0, actions_1.getExtensionActions)();
|
|
@@ -25,7 +43,7 @@ class PlanApp {
|
|
|
25
43
|
}
|
|
26
44
|
static validatePlanContext() {
|
|
27
45
|
const context = (0, app_context_1.getAppContext)();
|
|
28
|
-
if (context.appContext.vibeIQApp !== app_context_1.VibeIQAppType.
|
|
46
|
+
if (context.appContext.vibeIQApp !== app_context_1.VibeIQAppType.PLAN || !context.appContext.plan) {
|
|
29
47
|
throw new Error("App extension has not been initialized with Plan context.");
|
|
30
48
|
}
|
|
31
49
|
}
|
package/package.json
CHANGED