@contrail/extensions-sdk 1.0.25 → 1.0.27
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 +42 -2
- package/lib/apps/plan.js +64 -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,13 @@
|
|
|
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",
|
|
10
|
+
ASSIGN_ITEMS = "plan:assign_items"
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* A row on a plan. Beyond the item linkage below, properties are the org-configured
|
|
@@ -33,6 +35,13 @@ export interface AddPlaceholdersOptions {
|
|
|
33
35
|
* - `selected` — only the currently selected rows
|
|
34
36
|
*/
|
|
35
37
|
export declare type PlanPlaceholderScope = 'all' | 'filtered' | 'displayed' | 'selected';
|
|
38
|
+
/** Assigns one existing item to one existing placeholder row. */
|
|
39
|
+
export interface PlaceholderItemAssignment {
|
|
40
|
+
/** The row to assign onto. */
|
|
41
|
+
placeholderId: string;
|
|
42
|
+
/** The item to assign — an item family or an item option. */
|
|
43
|
+
itemId: string;
|
|
44
|
+
}
|
|
36
45
|
export interface GetPlaceholdersOptions {
|
|
37
46
|
/** Defaults to `all`. */
|
|
38
47
|
scope?: PlanPlaceholderScope;
|
|
@@ -90,6 +99,37 @@ export declare class PlanApp {
|
|
|
90
99
|
* Reading is always permitted, including on a view-only plan.
|
|
91
100
|
*/
|
|
92
101
|
static getPlaceholders(options?: GetPlaceholdersOptions): Promise<Array<PlanPlaceholder>>;
|
|
102
|
+
/**
|
|
103
|
+
* The filter and sorts in effect **right now**.
|
|
104
|
+
*
|
|
105
|
+
* Use this to scope an extension the way the grid is scoped. If the user has filtered the plan to
|
|
106
|
+
* `gender = mens`, a goals tool can hide goals for other genders rather than reporting them as
|
|
107
|
+
* unmet, and can avoid offering to create rows that would immediately fall out of that filter.
|
|
108
|
+
*
|
|
109
|
+
* ### How this differs from the launch context
|
|
110
|
+
*
|
|
111
|
+
* `getCurrentPlan().viewState` is the state captured when the extension opened — synchronous and
|
|
112
|
+
* free, but blind to any filter change since. This method round-trips to the host for current
|
|
113
|
+
* state, and refreshes `viewState` on the cached context so the synchronous read agrees with it
|
|
114
|
+
* afterwards.
|
|
115
|
+
*
|
|
116
|
+
* Reading is always permitted, including on a view-only plan.
|
|
117
|
+
*/
|
|
118
|
+
static getViewState(): Promise<PlanViewState>;
|
|
119
|
+
/**
|
|
120
|
+
* Assigns existing items to existing placeholder rows.
|
|
121
|
+
*
|
|
122
|
+
* Runs the plan's own item-assignment pipeline, so the item's properties are mapped onto the
|
|
123
|
+
* row, the project item is created if needed, and carryover is applied — the same work the grid
|
|
124
|
+
* does when a user drops an item onto a row. Rows appear updated immediately and the change is
|
|
125
|
+
* broadcast to other users.
|
|
126
|
+
*
|
|
127
|
+
* Use this to fill placeholders that already carry attribution; to create new rows instead, see
|
|
128
|
+
* {@link addPlaceholders}.
|
|
129
|
+
*
|
|
130
|
+
* Requires the plan to be editable.
|
|
131
|
+
*/
|
|
132
|
+
static assignItems(assignments: Array<PlaceholderItemAssignment>): Promise<void>;
|
|
93
133
|
/**
|
|
94
134
|
* Creates new rows on the plan from property data, and returns them.
|
|
95
135
|
*
|
package/lib/apps/plan.js
CHANGED
|
@@ -20,6 +20,8 @@ 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";
|
|
24
|
+
PlanCommand["ASSIGN_ITEMS"] = "plan:assign_items";
|
|
23
25
|
})(PlanCommand = exports.PlanCommand || (exports.PlanCommand = {}));
|
|
24
26
|
class PlanApp {
|
|
25
27
|
static getCurrentPlan() {
|
|
@@ -107,6 +109,68 @@ class PlanApp {
|
|
|
107
109
|
return placeholders;
|
|
108
110
|
});
|
|
109
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* The filter and sorts in effect **right now**.
|
|
114
|
+
*
|
|
115
|
+
* Use this to scope an extension the way the grid is scoped. If the user has filtered the plan to
|
|
116
|
+
* `gender = mens`, a goals tool can hide goals for other genders rather than reporting them as
|
|
117
|
+
* unmet, and can avoid offering to create rows that would immediately fall out of that filter.
|
|
118
|
+
*
|
|
119
|
+
* ### How this differs from the launch context
|
|
120
|
+
*
|
|
121
|
+
* `getCurrentPlan().viewState` is the state captured when the extension opened — synchronous and
|
|
122
|
+
* free, but blind to any filter change since. This method round-trips to the host for current
|
|
123
|
+
* state, and refreshes `viewState` on the cached context so the synchronous read agrees with it
|
|
124
|
+
* afterwards.
|
|
125
|
+
*
|
|
126
|
+
* Reading is always permitted, including on a view-only plan.
|
|
127
|
+
*/
|
|
128
|
+
static getViewState() {
|
|
129
|
+
var _a, _b;
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
PlanApp.validatePlanContext();
|
|
132
|
+
const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({
|
|
133
|
+
command: PlanCommand.GET_VIEW_STATE,
|
|
134
|
+
});
|
|
135
|
+
const viewState = (_a = PlanApp.validateAndReturnResults(results)) !== null && _a !== void 0 ? _a : {
|
|
136
|
+
hasFilter: false,
|
|
137
|
+
filters: [],
|
|
138
|
+
sorts: [],
|
|
139
|
+
};
|
|
140
|
+
// getAppContext() hands back the live singleton, so this updates what getCurrentPlan() sees.
|
|
141
|
+
const plan = (_b = (0, app_context_1.getAppContext)().appContext) === null || _b === void 0 ? void 0 : _b.plan;
|
|
142
|
+
if (plan) {
|
|
143
|
+
plan.viewState = viewState;
|
|
144
|
+
}
|
|
145
|
+
return viewState;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Assigns existing items to existing placeholder rows.
|
|
150
|
+
*
|
|
151
|
+
* Runs the plan's own item-assignment pipeline, so the item's properties are mapped onto the
|
|
152
|
+
* row, the project item is created if needed, and carryover is applied — the same work the grid
|
|
153
|
+
* does when a user drops an item onto a row. Rows appear updated immediately and the change is
|
|
154
|
+
* broadcast to other users.
|
|
155
|
+
*
|
|
156
|
+
* Use this to fill placeholders that already carry attribution; to create new rows instead, see
|
|
157
|
+
* {@link addPlaceholders}.
|
|
158
|
+
*
|
|
159
|
+
* Requires the plan to be editable.
|
|
160
|
+
*/
|
|
161
|
+
static assignItems(assignments) {
|
|
162
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
PlanApp.validatePlanContext();
|
|
164
|
+
if (!(assignments === null || assignments === void 0 ? void 0 : assignments.length)) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({
|
|
168
|
+
command: PlanCommand.ASSIGN_ITEMS,
|
|
169
|
+
data: { assignments },
|
|
170
|
+
});
|
|
171
|
+
PlanApp.validateAndReturnResults(results);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
110
174
|
/**
|
|
111
175
|
* Creates new rows on the plan from property data, and returns them.
|
|
112
176
|
*
|
package/package.json
CHANGED