@contrail/extensions-sdk 1.0.23 → 1.0.25
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/boards.d.ts +3 -0
- package/lib/apps/boards.js +2 -0
- package/lib/apps/plan.d.ts +118 -1
- package/lib/apps/plan.js +142 -1
- package/lib/apps/showcase.d.ts +23 -0
- package/lib/apps/showcase.js +20 -0
- package/package.json +1 -1
- package/lib/extensions/connection-timeout.d.ts +0 -7
- package/lib/extensions/connection-timeout.js +0 -34
package/lib/apps/boards.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare enum BoardCommand {
|
|
|
10
10
|
ADD_FRAMES_FROM_TEMPLATE = "board:add_frames_from_template",
|
|
11
11
|
ADD_ITEMS_TO_CLIPBOARD = "board:add_items_to_clipboard"
|
|
12
12
|
}
|
|
13
|
+
/** Payload for bulk-add items to clipboard (Board and Showcase). */
|
|
13
14
|
export interface ClipboardItemsPayload {
|
|
14
15
|
clipboardItems: Array<{
|
|
15
16
|
itemId: string;
|
|
@@ -56,8 +57,10 @@ export declare class BoardsApp {
|
|
|
56
57
|
static deleteElements(elements: Array<BoardDocumentElement>): void;
|
|
57
58
|
static modifyElements(changeObjects: Array<BoardDocumentElementChanges>): void;
|
|
58
59
|
static getElements(criteria: object): Promise<Array<DocumentElement>>;
|
|
60
|
+
/** Creates new content from a set of elements and assigns to an entity (item, etc) as a viewable */
|
|
59
61
|
static createNewContentAndAssignToEntity(assignmentOptions: any, entity: any, elements: Array<DocumentElement>): Promise<Array<DocumentElement>>;
|
|
60
62
|
static recolorImages(imageElements: Array<DocumentElement>, hexCode: string, hexMap?: {}): Promise<Array<DocumentElement>>;
|
|
63
|
+
/** Request the host to bulk-add items to the user's clipboard. */
|
|
61
64
|
static addItemsToClipboard(clipboardItems: Array<{
|
|
62
65
|
itemId: string;
|
|
63
66
|
projectItemId?: string | null;
|
package/lib/apps/boards.js
CHANGED
|
@@ -76,6 +76,7 @@ class BoardsApp {
|
|
|
76
76
|
return this.validateAndReturnResults(results);
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
+
/** Creates new content from a set of elements and assigns to an entity (item, etc) as a viewable */
|
|
79
80
|
static createNewContentAndAssignToEntity(assignmentOptions, entity, elements) {
|
|
80
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
82
|
BoardsApp.validateBoardContext();
|
|
@@ -101,6 +102,7 @@ class BoardsApp {
|
|
|
101
102
|
return this.validateAndReturnResults(results);
|
|
102
103
|
});
|
|
103
104
|
}
|
|
105
|
+
/** Request the host to bulk-add items to the user's clipboard. */
|
|
104
106
|
static addItemsToClipboard(clipboardItems) {
|
|
105
107
|
BoardsApp.validateBoardContext();
|
|
106
108
|
if (clipboardItems === null || clipboardItems === void 0 ? void 0 : clipboardItems.length) {
|
package/lib/apps/plan.d.ts
CHANGED
|
@@ -2,14 +2,131 @@ import { PlanContext } from './app-context';
|
|
|
2
2
|
export declare enum PlanCommand {
|
|
3
3
|
ADD_ROWS = "plan:add_rows",
|
|
4
4
|
SHOW_MESSAGE = "plan:show_message",
|
|
5
|
-
CLEAR_SELECTED_ROWS = "plan:clear_selected_rows"
|
|
5
|
+
CLEAR_SELECTED_ROWS = "plan:clear_selected_rows",
|
|
6
|
+
ADD_PLACEHOLDERS = "plan:add_placeholders",
|
|
7
|
+
ADD_PLACEHOLDERS_WITH_ITEMS = "plan:add_placeholders_with_items",
|
|
8
|
+
GET_PLACEHOLDERS = "plan:get_placeholders"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A row on a plan. Beyond the item linkage below, properties are the org-configured
|
|
12
|
+
* type-property slugs of the `plan-placeholder` type (`gender`, `targetVolume`, ...).
|
|
13
|
+
*/
|
|
14
|
+
export interface PlanPlaceholder {
|
|
15
|
+
id?: string;
|
|
16
|
+
itemFamilyId?: string;
|
|
17
|
+
itemOptionId?: string;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
/** Optional placement and history behavior for the add-placeholder commands. */
|
|
21
|
+
export interface AddPlaceholdersOptions {
|
|
22
|
+
/** Row index to insert at. Omit to append to the end of the plan. */
|
|
23
|
+
targetRowIndex?: number;
|
|
24
|
+
/** Skip the undo/redo entry. Intended for bulk programmatic writes. */
|
|
25
|
+
skipRecordingUndoRedo?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Which rows {@link PlanApp.getPlaceholders} should return. Mirrors the plan's own data scopes.
|
|
29
|
+
*
|
|
30
|
+
* - `all` — every row on the plan, ignoring filters (the default)
|
|
31
|
+
* - `filtered` — the user's active filter applied
|
|
32
|
+
* - `displayed` — filter plus focused item family, i.e. what the grid is actually showing
|
|
33
|
+
* - `selected` — only the currently selected rows
|
|
34
|
+
*/
|
|
35
|
+
export declare type PlanPlaceholderScope = 'all' | 'filtered' | 'displayed' | 'selected';
|
|
36
|
+
export interface GetPlaceholdersOptions {
|
|
37
|
+
/** Defaults to `all`. */
|
|
38
|
+
scope?: PlanPlaceholderScope;
|
|
39
|
+
/**
|
|
40
|
+
* Return only these property slugs, to keep the payload small on large plans.
|
|
41
|
+
* `id`, `itemFamilyId` and `itemOptionId` are always included.
|
|
42
|
+
*/
|
|
43
|
+
propertySlugs?: Array<string>;
|
|
6
44
|
}
|
|
7
45
|
export declare class PlanApp {
|
|
8
46
|
static getCurrentPlan(): PlanContext;
|
|
47
|
+
/**
|
|
48
|
+
* The plan's rows **as they were when this extension opened**.
|
|
49
|
+
*
|
|
50
|
+
* Synchronous and free, because it reads the context snapshot the host sent at startup. That
|
|
51
|
+
* snapshot is never re-sent, so it will not contain rows created since (including ones this
|
|
52
|
+
* extension created itself), edits made in the grid, or other users' changes.
|
|
53
|
+
*
|
|
54
|
+
* Use this for a one-shot read on open. For current state, `await` {@link getPlaceholders} —
|
|
55
|
+
* which also refreshes what this method returns.
|
|
56
|
+
*/
|
|
9
57
|
static getAllPlanPlaceholders(): any[];
|
|
58
|
+
/**
|
|
59
|
+
* The snapshot narrowed to the user's active filter — the same startup snapshot as
|
|
60
|
+
* {@link getAllPlanPlaceholders}, and equally subject to going stale.
|
|
61
|
+
*
|
|
62
|
+
* Note this filters the snapshot by the `filteredPlanPlaceholderIds` captured at startup, so it
|
|
63
|
+
* reflects the filter *at open time*. If the user changes the filter while the extension is open,
|
|
64
|
+
* use `getPlaceholders({ scope: 'filtered' })` instead.
|
|
65
|
+
*/
|
|
10
66
|
static getFilteredPlanPlaceholders(): any[];
|
|
67
|
+
/**
|
|
68
|
+
* The plan's rows **as they are right now**, read from the host on demand.
|
|
69
|
+
*
|
|
70
|
+
* Asynchronous, because it round-trips to the plan. Returns fully hydrated rows — property
|
|
71
|
+
* defaults applied and formulas evaluated — so it is the only way to see the real state of rows
|
|
72
|
+
* created during this session, or edits the user has made in the grid since it opened.
|
|
73
|
+
*
|
|
74
|
+
* ### How this differs from {@link getAllPlanPlaceholders}
|
|
75
|
+
*
|
|
76
|
+
* | | `getAllPlanPlaceholders()` | `getPlaceholders()` |
|
|
77
|
+
* | --- | --- | --- |
|
|
78
|
+
* | Source | startup context snapshot | live host state |
|
|
79
|
+
* | Call | synchronous | `await` |
|
|
80
|
+
* | Sees later changes | no | yes |
|
|
81
|
+
* | Scope | all, or filter-at-open-time | `all` / `filtered` / `displayed` / `selected` |
|
|
82
|
+
*
|
|
83
|
+
* ### Side effect
|
|
84
|
+
*
|
|
85
|
+
* A **full, unprojected** read (no `scope`, or `scope: 'all'`, and no `propertySlugs`) replaces
|
|
86
|
+
* the cached snapshot, so `getAllPlanPlaceholders()` returns the fresh rows afterwards. A
|
|
87
|
+
* filtered or projected read deliberately does not, since a partial result is not a valid
|
|
88
|
+
* substitute for the snapshot.
|
|
89
|
+
*
|
|
90
|
+
* Reading is always permitted, including on a view-only plan.
|
|
91
|
+
*/
|
|
92
|
+
static getPlaceholders(options?: GetPlaceholdersOptions): Promise<Array<PlanPlaceholder>>;
|
|
93
|
+
/**
|
|
94
|
+
* Creates new rows on the plan from property data, and returns them.
|
|
95
|
+
*
|
|
96
|
+
* The rows are created through the plan's own row-creation path, so they appear in the grid
|
|
97
|
+
* immediately, are undoable, and are broadcast to other users viewing the plan. The property
|
|
98
|
+
* values supplied on each placeholder are set on the created row.
|
|
99
|
+
*
|
|
100
|
+
* Any placeholder carrying an `itemFamilyId`/`itemOptionId` is routed through item assignment,
|
|
101
|
+
* exactly as {@link addPlaceholdersWithItems} would handle it.
|
|
102
|
+
*
|
|
103
|
+
* Note that {@link getAllPlanPlaceholders} continues to return the snapshot taken when the
|
|
104
|
+
* extension was opened — it will not include these rows. Use the returned array instead.
|
|
105
|
+
*/
|
|
106
|
+
static addPlaceholders(placeholders: Array<PlanPlaceholder>, options?: AddPlaceholdersOptions): Promise<Array<PlanPlaceholder>>;
|
|
107
|
+
/**
|
|
108
|
+
* Creates new rows on the plan for existing items, and returns them.
|
|
109
|
+
*
|
|
110
|
+
* Each placeholder must carry an `itemFamilyId` or `itemOptionId`. The plan resolves the item,
|
|
111
|
+
* creates the project item, and applies carryover — the behavior the deprecated
|
|
112
|
+
* {@link addRows} provides, under a name that says what it does.
|
|
113
|
+
*
|
|
114
|
+
* To create rows that are not backed by an item, use {@link addPlaceholders}.
|
|
115
|
+
*/
|
|
116
|
+
static addPlaceholdersWithItems(placeholders: Array<PlanPlaceholder>, options?: AddPlaceholdersOptions): Promise<Array<PlanPlaceholder>>;
|
|
117
|
+
/**
|
|
118
|
+
* Adds rows to the plan for existing items.
|
|
119
|
+
*
|
|
120
|
+
* @deprecated The name is misleading: this only adds rows for existing **items**, and property
|
|
121
|
+
* values on a placeholder without an `itemFamilyId`/`itemOptionId` are silently discarded. It
|
|
122
|
+
* also returns nothing, so the created rows are not available to the caller.
|
|
123
|
+
*
|
|
124
|
+
* Use {@link addPlaceholdersWithItems} for item-backed rows, or {@link addPlaceholders} to
|
|
125
|
+
* create rows from property data. Retained for existing extensions.
|
|
126
|
+
*/
|
|
11
127
|
static addRows(collectionElements: Array<any>): void;
|
|
12
128
|
static clearSelectedRows(): void;
|
|
13
129
|
static showMessage(message: string): void;
|
|
14
130
|
private static validatePlanContext;
|
|
131
|
+
private static validateAndReturnResults;
|
|
15
132
|
}
|
package/lib/apps/plan.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.PlanApp = exports.PlanCommand = void 0;
|
|
4
13
|
const actions_1 = require("../actions/actions");
|
|
@@ -8,18 +17,39 @@ var PlanCommand;
|
|
|
8
17
|
PlanCommand["ADD_ROWS"] = "plan:add_rows";
|
|
9
18
|
PlanCommand["SHOW_MESSAGE"] = "plan:show_message";
|
|
10
19
|
PlanCommand["CLEAR_SELECTED_ROWS"] = "plan:clear_selected_rows";
|
|
20
|
+
PlanCommand["ADD_PLACEHOLDERS"] = "plan:add_placeholders";
|
|
21
|
+
PlanCommand["ADD_PLACEHOLDERS_WITH_ITEMS"] = "plan:add_placeholders_with_items";
|
|
22
|
+
PlanCommand["GET_PLACEHOLDERS"] = "plan:get_placeholders";
|
|
11
23
|
})(PlanCommand = exports.PlanCommand || (exports.PlanCommand = {}));
|
|
12
24
|
class PlanApp {
|
|
13
25
|
static getCurrentPlan() {
|
|
14
26
|
PlanApp.validatePlanContext();
|
|
15
27
|
return (0, app_context_1.getAppContext)().appContext.plan;
|
|
16
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The plan's rows **as they were when this extension opened**.
|
|
31
|
+
*
|
|
32
|
+
* Synchronous and free, because it reads the context snapshot the host sent at startup. That
|
|
33
|
+
* snapshot is never re-sent, so it will not contain rows created since (including ones this
|
|
34
|
+
* extension created itself), edits made in the grid, or other users' changes.
|
|
35
|
+
*
|
|
36
|
+
* Use this for a one-shot read on open. For current state, `await` {@link getPlaceholders} —
|
|
37
|
+
* which also refreshes what this method returns.
|
|
38
|
+
*/
|
|
17
39
|
static getAllPlanPlaceholders() {
|
|
18
40
|
var _a;
|
|
19
41
|
PlanApp.validatePlanContext();
|
|
20
42
|
const plan = PlanApp.getCurrentPlan();
|
|
21
43
|
return (_a = plan === null || plan === void 0 ? void 0 : plan.planPlaceholders) !== null && _a !== void 0 ? _a : [];
|
|
22
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The snapshot narrowed to the user's active filter — the same startup snapshot as
|
|
47
|
+
* {@link getAllPlanPlaceholders}, and equally subject to going stale.
|
|
48
|
+
*
|
|
49
|
+
* Note this filters the snapshot by the `filteredPlanPlaceholderIds` captured at startup, so it
|
|
50
|
+
* reflects the filter *at open time*. If the user changes the filter while the extension is open,
|
|
51
|
+
* use `getPlaceholders({ scope: 'filtered' })` instead.
|
|
52
|
+
*/
|
|
23
53
|
static getFilteredPlanPlaceholders() {
|
|
24
54
|
var _a;
|
|
25
55
|
PlanApp.validatePlanContext();
|
|
@@ -32,6 +62,109 @@ class PlanApp {
|
|
|
32
62
|
const filteredResults = allPlanPlaceholders.filter((placeholder) => filteredPlanPlaceholderIds.includes(placeholder.id));
|
|
33
63
|
return filteredResults;
|
|
34
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* The plan's rows **as they are right now**, read from the host on demand.
|
|
67
|
+
*
|
|
68
|
+
* Asynchronous, because it round-trips to the plan. Returns fully hydrated rows — property
|
|
69
|
+
* defaults applied and formulas evaluated — so it is the only way to see the real state of rows
|
|
70
|
+
* created during this session, or edits the user has made in the grid since it opened.
|
|
71
|
+
*
|
|
72
|
+
* ### How this differs from {@link getAllPlanPlaceholders}
|
|
73
|
+
*
|
|
74
|
+
* | | `getAllPlanPlaceholders()` | `getPlaceholders()` |
|
|
75
|
+
* | --- | --- | --- |
|
|
76
|
+
* | Source | startup context snapshot | live host state |
|
|
77
|
+
* | Call | synchronous | `await` |
|
|
78
|
+
* | Sees later changes | no | yes |
|
|
79
|
+
* | Scope | all, or filter-at-open-time | `all` / `filtered` / `displayed` / `selected` |
|
|
80
|
+
*
|
|
81
|
+
* ### Side effect
|
|
82
|
+
*
|
|
83
|
+
* A **full, unprojected** read (no `scope`, or `scope: 'all'`, and no `propertySlugs`) replaces
|
|
84
|
+
* the cached snapshot, so `getAllPlanPlaceholders()` returns the fresh rows afterwards. A
|
|
85
|
+
* filtered or projected read deliberately does not, since a partial result is not a valid
|
|
86
|
+
* substitute for the snapshot.
|
|
87
|
+
*
|
|
88
|
+
* Reading is always permitted, including on a view-only plan.
|
|
89
|
+
*/
|
|
90
|
+
static getPlaceholders(options) {
|
|
91
|
+
var _a, _b, _c;
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
PlanApp.validatePlanContext();
|
|
94
|
+
const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({
|
|
95
|
+
command: PlanCommand.GET_PLACEHOLDERS,
|
|
96
|
+
data: { options },
|
|
97
|
+
});
|
|
98
|
+
const placeholders = (_a = PlanApp.validateAndReturnResults(results)) !== null && _a !== void 0 ? _a : [];
|
|
99
|
+
const isFullRead = (!(options === null || options === void 0 ? void 0 : options.scope) || options.scope === 'all') && !((_b = options === null || options === void 0 ? void 0 : options.propertySlugs) === null || _b === void 0 ? void 0 : _b.length);
|
|
100
|
+
if (isFullRead) {
|
|
101
|
+
// getAppContext() hands back the live singleton, so this updates what the sync getters see.
|
|
102
|
+
const plan = (_c = (0, app_context_1.getAppContext)().appContext) === null || _c === void 0 ? void 0 : _c.plan;
|
|
103
|
+
if (plan) {
|
|
104
|
+
plan.planPlaceholders = placeholders;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return placeholders;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Creates new rows on the plan from property data, and returns them.
|
|
112
|
+
*
|
|
113
|
+
* The rows are created through the plan's own row-creation path, so they appear in the grid
|
|
114
|
+
* immediately, are undoable, and are broadcast to other users viewing the plan. The property
|
|
115
|
+
* values supplied on each placeholder are set on the created row.
|
|
116
|
+
*
|
|
117
|
+
* Any placeholder carrying an `itemFamilyId`/`itemOptionId` is routed through item assignment,
|
|
118
|
+
* exactly as {@link addPlaceholdersWithItems} would handle it.
|
|
119
|
+
*
|
|
120
|
+
* Note that {@link getAllPlanPlaceholders} continues to return the snapshot taken when the
|
|
121
|
+
* extension was opened — it will not include these rows. Use the returned array instead.
|
|
122
|
+
*/
|
|
123
|
+
static addPlaceholders(placeholders, options) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
PlanApp.validatePlanContext();
|
|
126
|
+
if (!(placeholders === null || placeholders === void 0 ? void 0 : placeholders.length)) {
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({
|
|
130
|
+
command: PlanCommand.ADD_PLACEHOLDERS,
|
|
131
|
+
data: { placeholders, options },
|
|
132
|
+
});
|
|
133
|
+
return PlanApp.validateAndReturnResults(results);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Creates new rows on the plan for existing items, and returns them.
|
|
138
|
+
*
|
|
139
|
+
* Each placeholder must carry an `itemFamilyId` or `itemOptionId`. The plan resolves the item,
|
|
140
|
+
* creates the project item, and applies carryover — the behavior the deprecated
|
|
141
|
+
* {@link addRows} provides, under a name that says what it does.
|
|
142
|
+
*
|
|
143
|
+
* To create rows that are not backed by an item, use {@link addPlaceholders}.
|
|
144
|
+
*/
|
|
145
|
+
static addPlaceholdersWithItems(placeholders, options) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
PlanApp.validatePlanContext();
|
|
148
|
+
if (!(placeholders === null || placeholders === void 0 ? void 0 : placeholders.length)) {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({
|
|
152
|
+
command: PlanCommand.ADD_PLACEHOLDERS_WITH_ITEMS,
|
|
153
|
+
data: { placeholders, options },
|
|
154
|
+
});
|
|
155
|
+
return PlanApp.validateAndReturnResults(results);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Adds rows to the plan for existing items.
|
|
160
|
+
*
|
|
161
|
+
* @deprecated The name is misleading: this only adds rows for existing **items**, and property
|
|
162
|
+
* values on a placeholder without an `itemFamilyId`/`itemOptionId` are silently discarded. It
|
|
163
|
+
* also returns nothing, so the created rows are not available to the caller.
|
|
164
|
+
*
|
|
165
|
+
* Use {@link addPlaceholdersWithItems} for item-backed rows, or {@link addPlaceholders} to
|
|
166
|
+
* create rows from property data. Retained for existing extensions.
|
|
167
|
+
*/
|
|
35
168
|
static addRows(collectionElements) {
|
|
36
169
|
PlanApp.validatePlanContext();
|
|
37
170
|
if (collectionElements === null || collectionElements === void 0 ? void 0 : collectionElements.length) {
|
|
@@ -50,10 +183,18 @@ class PlanApp {
|
|
|
50
183
|
actions.sendMessageToHost({ command: PlanCommand.SHOW_MESSAGE, data: message });
|
|
51
184
|
}
|
|
52
185
|
static validatePlanContext() {
|
|
186
|
+
var _a, _b;
|
|
53
187
|
const context = (0, app_context_1.getAppContext)();
|
|
54
|
-
if (context.appContext.vibeIQApp !== app_context_1.VibeIQAppType.PLAN || !context.appContext.plan) {
|
|
188
|
+
if (((_a = context.appContext) === null || _a === void 0 ? void 0 : _a.vibeIQApp) !== app_context_1.VibeIQAppType.PLAN || !((_b = context.appContext) === null || _b === void 0 ? void 0 : _b.plan)) {
|
|
55
189
|
throw new Error('App extension has not been initialized with Plan context.');
|
|
56
190
|
}
|
|
57
191
|
}
|
|
192
|
+
static validateAndReturnResults(results) {
|
|
193
|
+
var _a;
|
|
194
|
+
if (!results.success) {
|
|
195
|
+
throw new Error((_a = results.error) !== null && _a !== void 0 ? _a : 'App operation failed.');
|
|
196
|
+
}
|
|
197
|
+
return results.data;
|
|
198
|
+
}
|
|
58
199
|
}
|
|
59
200
|
exports.PlanApp = PlanApp;
|
package/lib/apps/showcase.d.ts
CHANGED
|
@@ -15,10 +15,12 @@ export interface ShowcaseDocumentElementChanges {
|
|
|
15
15
|
}
|
|
16
16
|
export interface AddElementsToShowcasePayload {
|
|
17
17
|
elements: Array<ShowcaseDocumentElement>;
|
|
18
|
+
/** If omitted, elements are added to the currently active frame. */
|
|
18
19
|
frameId?: string;
|
|
19
20
|
}
|
|
20
21
|
export interface ModifyElementsInShowcasePayload {
|
|
21
22
|
changeObjects: Array<ShowcaseDocumentElementChanges>;
|
|
23
|
+
/** If omitted, elements are modified on the currently active frame. */
|
|
22
24
|
frameId?: string;
|
|
23
25
|
}
|
|
24
26
|
export interface AddCanvasFrameToShowcasePayload {
|
|
@@ -40,11 +42,21 @@ export declare type NavigateToFrameInShowcasePayload = {
|
|
|
40
42
|
};
|
|
41
43
|
export interface NavigateToFrameResult {
|
|
42
44
|
frameId: string;
|
|
45
|
+
/** 0-based position of the frame within the showcase's frames. */
|
|
43
46
|
frameIndex: number;
|
|
44
47
|
}
|
|
45
48
|
export declare class ShowcaseApp {
|
|
46
49
|
static getCurrentShowcase(): any;
|
|
50
|
+
/**
|
|
51
|
+
* Adds elements to a frame in the showcase.
|
|
52
|
+
* If `frameId` is omitted, elements are added to the currently active frame.
|
|
53
|
+
* Otherwise, elements are added to the frame matching `frameId`.
|
|
54
|
+
*/
|
|
47
55
|
static addElements(elements: Array<ShowcaseDocumentElement>, frameId?: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Adds a new canvas frame (lineboard page) containing the given elements
|
|
58
|
+
* and returns the created frame.
|
|
59
|
+
*/
|
|
48
60
|
static addCanvasFrame(elements: Array<ShowcaseDocumentElement>, frameOptions?: {
|
|
49
61
|
name?: string;
|
|
50
62
|
size?: {
|
|
@@ -52,8 +64,19 @@ export declare class ShowcaseApp {
|
|
|
52
64
|
height: number;
|
|
53
65
|
};
|
|
54
66
|
}): Promise<any>;
|
|
67
|
+
/**
|
|
68
|
+
* Modifies existing elements in a frame in the showcase.
|
|
69
|
+
* If `frameId` is omitted, elements are modified on the currently active frame.
|
|
70
|
+
* Otherwise, elements are modified on the frame matching `frameId`.
|
|
71
|
+
*/
|
|
55
72
|
static modifyElements(changeObjects: Array<ShowcaseDocumentElementChanges>, frameId?: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Changes the showcase's current (visible) frame and resolves with the frame that is now active.
|
|
75
|
+
* Target the frame either by `frameId` or by its 0-based `frameIndex` within `showcase.frames`.
|
|
76
|
+
* The returned promise rejects if the id or index does not match a frame.
|
|
77
|
+
*/
|
|
56
78
|
static navigateToFrame(target: NavigateToFrameInShowcasePayload): Promise<NavigateToFrameResult>;
|
|
79
|
+
/** Request the host to bulk-add items to the user's clipboard. */
|
|
57
80
|
static addItemsToClipboard(clipboardItems: Array<{
|
|
58
81
|
itemId: string;
|
|
59
82
|
projectItemId?: string | null;
|
package/lib/apps/showcase.js
CHANGED
|
@@ -26,6 +26,11 @@ class ShowcaseApp {
|
|
|
26
26
|
ShowcaseApp.validateShowcaseContext();
|
|
27
27
|
return (_a = (0, app_context_1.getAppContext)().appContext) === null || _a === void 0 ? void 0 : _a.showcase;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Adds elements to a frame in the showcase.
|
|
31
|
+
* If `frameId` is omitted, elements are added to the currently active frame.
|
|
32
|
+
* Otherwise, elements are added to the frame matching `frameId`.
|
|
33
|
+
*/
|
|
29
34
|
static addElements(elements, frameId) {
|
|
30
35
|
ShowcaseApp.validateShowcaseContext();
|
|
31
36
|
if (elements === null || elements === void 0 ? void 0 : elements.length) {
|
|
@@ -33,6 +38,10 @@ class ShowcaseApp {
|
|
|
33
38
|
(0, actions_1.getExtensionActions)().sendMessageToHost({ command: ShowcaseCommand.ADD_ELEMENTS, data });
|
|
34
39
|
}
|
|
35
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Adds a new canvas frame (lineboard page) containing the given elements
|
|
43
|
+
* and returns the created frame.
|
|
44
|
+
*/
|
|
36
45
|
static addCanvasFrame(elements, frameOptions) {
|
|
37
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
47
|
ShowcaseApp.validateShowcaseContext();
|
|
@@ -46,6 +55,11 @@ class ShowcaseApp {
|
|
|
46
55
|
}
|
|
47
56
|
});
|
|
48
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Modifies existing elements in a frame in the showcase.
|
|
60
|
+
* If `frameId` is omitted, elements are modified on the currently active frame.
|
|
61
|
+
* Otherwise, elements are modified on the frame matching `frameId`.
|
|
62
|
+
*/
|
|
49
63
|
static modifyElements(changeObjects, frameId) {
|
|
50
64
|
ShowcaseApp.validateShowcaseContext();
|
|
51
65
|
if (changeObjects === null || changeObjects === void 0 ? void 0 : changeObjects.length) {
|
|
@@ -53,6 +67,11 @@ class ShowcaseApp {
|
|
|
53
67
|
(0, actions_1.getExtensionActions)().sendMessageToHost({ command: ShowcaseCommand.MODIFY_ELEMENTS, data });
|
|
54
68
|
}
|
|
55
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Changes the showcase's current (visible) frame and resolves with the frame that is now active.
|
|
72
|
+
* Target the frame either by `frameId` or by its 0-based `frameIndex` within `showcase.frames`.
|
|
73
|
+
* The returned promise rejects if the id or index does not match a frame.
|
|
74
|
+
*/
|
|
56
75
|
static navigateToFrame(target) {
|
|
57
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
77
|
ShowcaseApp.validateShowcaseContext();
|
|
@@ -66,6 +85,7 @@ class ShowcaseApp {
|
|
|
66
85
|
return ShowcaseApp.validateAndReturnResults(results);
|
|
67
86
|
});
|
|
68
87
|
}
|
|
88
|
+
/** Request the host to bulk-add items to the user's clipboard. */
|
|
69
89
|
static addItemsToClipboard(clipboardItems) {
|
|
70
90
|
ShowcaseApp.validateShowcaseContext();
|
|
71
91
|
if (clipboardItems === null || clipboardItems === void 0 ? void 0 : clipboardItems.length) {
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare class ExtensionConnectionTimeoutError extends Error {
|
|
2
|
-
constructor(timeoutMs: number);
|
|
3
|
-
}
|
|
4
|
-
export declare class HostConnectionTimeoutError extends Error {
|
|
5
|
-
constructor(timeoutMs: number);
|
|
6
|
-
}
|
|
7
|
-
export declare function withConnectionTimeout<T>(promise: Promise<T>, timeoutMs: number, createError: () => Error): Promise<T>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withConnectionTimeout = exports.HostConnectionTimeoutError = exports.ExtensionConnectionTimeoutError = void 0;
|
|
4
|
-
class ExtensionConnectionTimeoutError extends Error {
|
|
5
|
-
constructor(timeoutMs) {
|
|
6
|
-
super(`Extension connection to host timed out after ${timeoutMs}ms. Ensure the host calls registerHostWithAppExtension after the extension iframe has loaded.`);
|
|
7
|
-
this.name = 'ExtensionConnectionTimeoutError';
|
|
8
|
-
Object.setPrototypeOf(this, ExtensionConnectionTimeoutError.prototype);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.ExtensionConnectionTimeoutError = ExtensionConnectionTimeoutError;
|
|
12
|
-
class HostConnectionTimeoutError extends Error {
|
|
13
|
-
constructor(timeoutMs) {
|
|
14
|
-
super(`Host connection to extension timed out after ${timeoutMs}ms. Ensure the extension calls registerAppExtension() on load and the iframe has loaded.`);
|
|
15
|
-
this.name = 'HostConnectionTimeoutError';
|
|
16
|
-
Object.setPrototypeOf(this, HostConnectionTimeoutError.prototype);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.HostConnectionTimeoutError = HostConnectionTimeoutError;
|
|
20
|
-
function withConnectionTimeout(promise, timeoutMs, createError) {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
const timer = setTimeout(() => reject(createError()), timeoutMs);
|
|
23
|
-
promise
|
|
24
|
-
.then((value) => {
|
|
25
|
-
clearTimeout(timer);
|
|
26
|
-
resolve(value);
|
|
27
|
-
})
|
|
28
|
-
.catch((err) => {
|
|
29
|
-
clearTimeout(timer);
|
|
30
|
-
reject(err);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
exports.withConnectionTimeout = withConnectionTimeout;
|