@contrail/extensions-sdk 1.0.25 → 1.0.26
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 +50 -0
- package/lib/apps/index.d.ts +1 -1
- package/lib/apps/plan.d.ts +20 -2
- package/lib/apps/plan.js +37 -0
- package/package.json +1 -1
|
@@ -37,6 +37,43 @@ export interface AppContext {
|
|
|
37
37
|
};
|
|
38
38
|
user?: User;
|
|
39
39
|
}
|
|
40
|
+
/** One active filter condition on the plan. */
|
|
41
|
+
export interface PlanFilterCriterion {
|
|
42
|
+
/** The property being filtered, e.g. `gender`. */
|
|
43
|
+
slug: string;
|
|
44
|
+
label?: string;
|
|
45
|
+
propertyType?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The condition, as a FilterConditionType value: `equals`, `not_equal_to`, `is_any_of`,
|
|
48
|
+
* `is_none_of`, `contains`, `starts_with`, `ends_with`, `less_than`, `greater_than`,
|
|
49
|
+
* `greater_than_or_equal`, `less_than_or_equal`, `is_empty`, `is_not_empty`, `is_in_list`,
|
|
50
|
+
* `are_any_empty`.
|
|
51
|
+
*/
|
|
52
|
+
conditionType: string;
|
|
53
|
+
/** The value compared against. An array for the `is_any_of` / `is_none_of` conditions. */
|
|
54
|
+
value?: any;
|
|
55
|
+
/** How this condition joins the previous one. Absent on the first criterion. */
|
|
56
|
+
conjunction?: 'and' | 'or';
|
|
57
|
+
includeEmptyValues?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface PlanSortCriterion {
|
|
60
|
+
slug: string;
|
|
61
|
+
label?: string;
|
|
62
|
+
/** A SortDirection value: `ASC`, `DESC`, `LIST_ORDER_ASC` or `LIST_ORDER_DESC`. */
|
|
63
|
+
direction: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* What the user is currently looking at, beyond the rows themselves.
|
|
67
|
+
*
|
|
68
|
+
* Lets an extension scope itself the way the grid is scoped — e.g. a goals tool can hide goals for
|
|
69
|
+
* a gender the user has filtered out, rather than reporting them as unmet.
|
|
70
|
+
*/
|
|
71
|
+
export interface PlanViewState {
|
|
72
|
+
/** True when at least one filter condition is active. */
|
|
73
|
+
hasFilter: boolean;
|
|
74
|
+
filters: Array<PlanFilterCriterion>;
|
|
75
|
+
sorts: Array<PlanSortCriterion>;
|
|
76
|
+
}
|
|
40
77
|
export interface PlanContext {
|
|
41
78
|
id: string;
|
|
42
79
|
name: string;
|
|
@@ -46,7 +83,20 @@ export interface PlanContext {
|
|
|
46
83
|
itemIds?: string[];
|
|
47
84
|
planPlaceholders?: any[];
|
|
48
85
|
filteredPlanPlaceholderIds?: string[];
|
|
86
|
+
/**
|
|
87
|
+
* Whether a filter is active.
|
|
88
|
+
*
|
|
89
|
+
* @deprecated Superseded by `viewState`, which also says *what* the filter is. Retained because
|
|
90
|
+
* existing extensions read it; equivalent to `viewState.hasFilter`.
|
|
91
|
+
*/
|
|
49
92
|
hasFilter: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* The filter and sorts in effect **when this extension opened**.
|
|
95
|
+
*
|
|
96
|
+
* Absent on hosts that predate this field, so guard before reading. For current state — after
|
|
97
|
+
* the user has changed the filter — `await` {@link PlanApp.getViewState}.
|
|
98
|
+
*/
|
|
99
|
+
viewState?: PlanViewState;
|
|
50
100
|
}
|
|
51
101
|
export interface BoardContext {
|
|
52
102
|
id: string;
|
package/lib/apps/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getAppContext, AppContext, BoardContext, PlanContext, ShowcaseContext, VibeIQAppType } from './app-context';
|
|
1
|
+
export { getAppContext, AppContext, BoardContext, PlanContext, PlanFilterCriterion, PlanSortCriterion, PlanViewState, ShowcaseContext, VibeIQAppType, } from './app-context';
|
|
2
2
|
export * from './boards';
|
|
3
3
|
export * from './plan';
|
|
4
4
|
export * from './showcase';
|
package/lib/apps/plan.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { PlanContext } from './app-context';
|
|
1
|
+
import { PlanContext, PlanViewState } from './app-context';
|
|
2
2
|
export declare enum PlanCommand {
|
|
3
3
|
ADD_ROWS = "plan:add_rows",
|
|
4
4
|
SHOW_MESSAGE = "plan:show_message",
|
|
5
5
|
CLEAR_SELECTED_ROWS = "plan:clear_selected_rows",
|
|
6
6
|
ADD_PLACEHOLDERS = "plan:add_placeholders",
|
|
7
7
|
ADD_PLACEHOLDERS_WITH_ITEMS = "plan:add_placeholders_with_items",
|
|
8
|
-
GET_PLACEHOLDERS = "plan:get_placeholders"
|
|
8
|
+
GET_PLACEHOLDERS = "plan:get_placeholders",
|
|
9
|
+
GET_VIEW_STATE = "plan:get_view_state"
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* A row on a plan. Beyond the item linkage below, properties are the org-configured
|
|
@@ -90,6 +91,23 @@ export declare class PlanApp {
|
|
|
90
91
|
* Reading is always permitted, including on a view-only plan.
|
|
91
92
|
*/
|
|
92
93
|
static getPlaceholders(options?: GetPlaceholdersOptions): Promise<Array<PlanPlaceholder>>;
|
|
94
|
+
/**
|
|
95
|
+
* The filter and sorts in effect **right now**.
|
|
96
|
+
*
|
|
97
|
+
* Use this to scope an extension the way the grid is scoped. If the user has filtered the plan to
|
|
98
|
+
* `gender = mens`, a goals tool can hide goals for other genders rather than reporting them as
|
|
99
|
+
* unmet, and can avoid offering to create rows that would immediately fall out of that filter.
|
|
100
|
+
*
|
|
101
|
+
* ### How this differs from the launch context
|
|
102
|
+
*
|
|
103
|
+
* `getCurrentPlan().viewState` is the state captured when the extension opened — synchronous and
|
|
104
|
+
* free, but blind to any filter change since. This method round-trips to the host for current
|
|
105
|
+
* state, and refreshes `viewState` on the cached context so the synchronous read agrees with it
|
|
106
|
+
* afterwards.
|
|
107
|
+
*
|
|
108
|
+
* Reading is always permitted, including on a view-only plan.
|
|
109
|
+
*/
|
|
110
|
+
static getViewState(): Promise<PlanViewState>;
|
|
93
111
|
/**
|
|
94
112
|
* Creates new rows on the plan from property data, and returns them.
|
|
95
113
|
*
|
package/lib/apps/plan.js
CHANGED
|
@@ -20,6 +20,7 @@ var PlanCommand;
|
|
|
20
20
|
PlanCommand["ADD_PLACEHOLDERS"] = "plan:add_placeholders";
|
|
21
21
|
PlanCommand["ADD_PLACEHOLDERS_WITH_ITEMS"] = "plan:add_placeholders_with_items";
|
|
22
22
|
PlanCommand["GET_PLACEHOLDERS"] = "plan:get_placeholders";
|
|
23
|
+
PlanCommand["GET_VIEW_STATE"] = "plan:get_view_state";
|
|
23
24
|
})(PlanCommand = exports.PlanCommand || (exports.PlanCommand = {}));
|
|
24
25
|
class PlanApp {
|
|
25
26
|
static getCurrentPlan() {
|
|
@@ -107,6 +108,42 @@ class PlanApp {
|
|
|
107
108
|
return placeholders;
|
|
108
109
|
});
|
|
109
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* The filter and sorts in effect **right now**.
|
|
113
|
+
*
|
|
114
|
+
* Use this to scope an extension the way the grid is scoped. If the user has filtered the plan to
|
|
115
|
+
* `gender = mens`, a goals tool can hide goals for other genders rather than reporting them as
|
|
116
|
+
* unmet, and can avoid offering to create rows that would immediately fall out of that filter.
|
|
117
|
+
*
|
|
118
|
+
* ### How this differs from the launch context
|
|
119
|
+
*
|
|
120
|
+
* `getCurrentPlan().viewState` is the state captured when the extension opened — synchronous and
|
|
121
|
+
* free, but blind to any filter change since. This method round-trips to the host for current
|
|
122
|
+
* state, and refreshes `viewState` on the cached context so the synchronous read agrees with it
|
|
123
|
+
* afterwards.
|
|
124
|
+
*
|
|
125
|
+
* Reading is always permitted, including on a view-only plan.
|
|
126
|
+
*/
|
|
127
|
+
static getViewState() {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
PlanApp.validatePlanContext();
|
|
131
|
+
const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({
|
|
132
|
+
command: PlanCommand.GET_VIEW_STATE,
|
|
133
|
+
});
|
|
134
|
+
const viewState = (_a = PlanApp.validateAndReturnResults(results)) !== null && _a !== void 0 ? _a : {
|
|
135
|
+
hasFilter: false,
|
|
136
|
+
filters: [],
|
|
137
|
+
sorts: [],
|
|
138
|
+
};
|
|
139
|
+
// getAppContext() hands back the live singleton, so this updates what getCurrentPlan() sees.
|
|
140
|
+
const plan = (_b = (0, app_context_1.getAppContext)().appContext) === null || _b === void 0 ? void 0 : _b.plan;
|
|
141
|
+
if (plan) {
|
|
142
|
+
plan.viewState = viewState;
|
|
143
|
+
}
|
|
144
|
+
return viewState;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
110
147
|
/**
|
|
111
148
|
* Creates new rows on the plan from property data, and returns them.
|
|
112
149
|
*
|
package/package.json
CHANGED