@contrail/extensions-sdk 1.0.26 → 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.
@@ -6,7 +6,8 @@ export declare enum PlanCommand {
6
6
  ADD_PLACEHOLDERS = "plan:add_placeholders",
7
7
  ADD_PLACEHOLDERS_WITH_ITEMS = "plan:add_placeholders_with_items",
8
8
  GET_PLACEHOLDERS = "plan:get_placeholders",
9
- GET_VIEW_STATE = "plan:get_view_state"
9
+ GET_VIEW_STATE = "plan:get_view_state",
10
+ ASSIGN_ITEMS = "plan:assign_items"
10
11
  }
11
12
  /**
12
13
  * A row on a plan. Beyond the item linkage below, properties are the org-configured
@@ -34,6 +35,13 @@ export interface AddPlaceholdersOptions {
34
35
  * - `selected` — only the currently selected rows
35
36
  */
36
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
+ }
37
45
  export interface GetPlaceholdersOptions {
38
46
  /** Defaults to `all`. */
39
47
  scope?: PlanPlaceholderScope;
@@ -108,6 +116,20 @@ export declare class PlanApp {
108
116
  * Reading is always permitted, including on a view-only plan.
109
117
  */
110
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>;
111
133
  /**
112
134
  * Creates new rows on the plan from property data, and returns them.
113
135
  *
package/lib/apps/plan.js CHANGED
@@ -21,6 +21,7 @@ var PlanCommand;
21
21
  PlanCommand["ADD_PLACEHOLDERS_WITH_ITEMS"] = "plan:add_placeholders_with_items";
22
22
  PlanCommand["GET_PLACEHOLDERS"] = "plan:get_placeholders";
23
23
  PlanCommand["GET_VIEW_STATE"] = "plan:get_view_state";
24
+ PlanCommand["ASSIGN_ITEMS"] = "plan:assign_items";
24
25
  })(PlanCommand = exports.PlanCommand || (exports.PlanCommand = {}));
25
26
  class PlanApp {
26
27
  static getCurrentPlan() {
@@ -144,6 +145,32 @@ class PlanApp {
144
145
  return viewState;
145
146
  });
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
+ }
147
174
  /**
148
175
  * Creates new rows on the plan from property data, and returns them.
149
176
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/extensions-sdk",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "description": "Client library for interfacing with VibeIQ's services and apps from an extension.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",