@contrail/extensions-sdk 1.0.14 → 1.0.16-0

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.
@@ -1,9 +1,11 @@
1
1
  ## What
2
+
2
3
  - [ ] Bugfix
3
4
  - [ ] Feature
4
5
  - [ ] Enhancement
5
6
 
6
- Description:
7
+ Description:
8
+
7
9
  <!--
8
10
  Describe the functional changes of the PR.
9
11
 
@@ -15,16 +17,15 @@ is sufficient.
15
17
  -->
16
18
 
17
19
  ## Why
18
- <!--
20
+
21
+ <!--
19
22
  why is this change needed? Same rules as with #What
20
23
  -->
21
24
 
22
-
23
25
  ## Testing added
24
- <!--
26
+
27
+ <!--
25
28
  Describe the testing you added to this PR
26
29
  -->
27
30
 
28
-
29
31
  ## Link to Jira ticket(s)
30
-
@@ -0,0 +1,34 @@
1
+ name: Check Code Formatting
2
+ on:
3
+ pull_request:
4
+ paths:
5
+ - '**'
6
+ workflow_dispatch: # allow running in github actions manually
7
+ jobs:
8
+ check-formatting:
9
+ runs-on: ubuntu-24.04
10
+ steps:
11
+ - name: Node.js
12
+ uses: actions/setup-node@v3
13
+ with:
14
+ node-version: 18.13.0
15
+ - uses: actions/checkout@v3
16
+ with:
17
+ lfs: true
18
+ - name: Checkout LFS objects
19
+ run: git lfs checkout
20
+ - name: NPM Install
21
+ env:
22
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
23
+ run: npm ci
24
+ - name: Check Format
25
+ working-directory: ./
26
+ run: npx prettier --check .
27
+ - name: Fail On Warnings
28
+ run: |
29
+ if [ $? -eq 0 ]; then
30
+ echo "No formatting issues found"
31
+ else
32
+ echo "Formatting issues found. Run 'npx prettier --write .' to fix them."
33
+ exit 1
34
+ fi
@@ -1,6 +1,5 @@
1
1
  name: empty-passing-test
2
- on:
3
- pull_request
2
+ on: pull_request
4
3
  jobs:
5
4
  test:
6
5
  runs-on: ubuntu-20.04
@@ -3,7 +3,7 @@ on:
3
3
  pull_request:
4
4
  # run this workflow when files these files change
5
5
  paths:
6
- - "**"
6
+ - '**'
7
7
  workflow_dispatch: # allow running in github actions manually
8
8
  jobs:
9
9
  test:
@@ -0,0 +1,13 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ if [ "$BYPASS_FORMATTING_CHECK" = "true" ]; then
5
+ echo ""
6
+ echo "⚠️ ======== WARNING ======== ⚠️"
7
+ echo " Formatting Check Bypassed" # This looks off-center but prints correctly
8
+ echo "⚠️ ========================= ⚠️"
9
+ echo ""
10
+ exit 0
11
+ fi
12
+
13
+ npm run lint-staged:check
@@ -0,0 +1,3 @@
1
+ {
2
+ "*.{js,ts,html,css,json,yml,yaml}": "prettier --check"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "*.{ts,js,html,css,yml,yaml}": "prettier --write"
3
+ }
@@ -0,0 +1,9 @@
1
+ **/.git
2
+ **/.svn
3
+ **/.hg
4
+ **/node_modules
5
+ **/.angular
6
+ **/.nyc_output
7
+ **/build
8
+ **/coverage
9
+ **/*.svg
@@ -0,0 +1,2 @@
1
+ singleQuote: true
2
+ printWidth: 120
package/README.md CHANGED
@@ -1,2 +1,3 @@
1
1
  # Contrail Extensions SDK
2
+
2
3
  Client library for interfacing with VibeIQ's services and apps from an extension.
@@ -1,7 +1,7 @@
1
- import { AppContext } from "../apps/app-context";
2
- import { EntitiesClientAction } from "../entities/entities-action-handler";
3
- import { AppExtensionMessage } from "../extensions/app-extension-message-handler";
4
- import { TypesClientAction } from "../types/types-action-handler";
1
+ import { AppContext } from '../apps/app-context';
2
+ import { EntitiesClientAction } from '../entities/entities-action-handler';
3
+ import { AppExtensionMessage } from '../extensions/app-extension-message-handler';
4
+ import { TypesClientAction } from '../types/types-action-handler';
5
5
  export interface RegisterExtensionActions {
6
6
  init(context: AppContext): void;
7
7
  }
@@ -1,4 +1,4 @@
1
- import { User } from "@contrail/entity-types";
1
+ import { User } from '@contrail/entity-types';
2
2
  export declare enum VibeIQAppType {
3
3
  BOARDS = "boards",
4
4
  PLAN = "plan",
@@ -1,11 +1,13 @@
1
1
  import { DocumentElement } from '@contrail/documents';
2
+ import { FrameDocumentTemplate } from '@contrail/document-generation';
2
3
  export declare enum BoardCommand {
3
4
  ADD_ELEMENTS = "board:add_elements",
4
5
  DELETE_ELEMENTS = "board:delete_elements",
5
6
  MODIFY_ELEMENTS = "board:modify_elements",
6
7
  GET_ELEMENTS = "board:get_elements",
7
8
  RECOLOR_IMAGES = "board:recolor_images",
8
- ADD_CONTENT_TO_ENTITY_FROM_ELEMENTS = "board:add_content_to_entity_from_elements"
9
+ ADD_CONTENT_TO_ENTITY_FROM_ELEMENTS = "board:add_content_to_entity_from_elements",
10
+ ADD_FRAMES_FROM_TEMPLATE = "board:add_frames_from_template"
9
11
  }
10
12
  export interface BoardDocumentElement extends DocumentElement {
11
13
  [key: string]: any;
@@ -19,9 +21,29 @@ export interface AppClientResults {
19
21
  data?: any;
20
22
  error?: string;
21
23
  }
24
+ export declare type FrameFromTemplateParams = {
25
+ frameTemplate: FrameDocumentTemplate;
26
+ frameOptions?: {
27
+ position: {
28
+ x: number;
29
+ y: number;
30
+ };
31
+ };
32
+ frameTemplateId?: never;
33
+ } | {
34
+ frameTemplateId: string;
35
+ frameOptions?: {
36
+ position: {
37
+ x: number;
38
+ y: number;
39
+ };
40
+ };
41
+ frameTemplate?: never;
42
+ };
22
43
  export declare class BoardsApp {
23
44
  static getCurrentBoard(): any;
24
45
  static addElements(elements: Array<BoardDocumentElement>): void;
46
+ static addFramesFromTemplate(frames: Array<FrameFromTemplateParams>): Promise<Array<DocumentElement>>;
25
47
  static deleteElements(elements: Array<BoardDocumentElement>): void;
26
48
  static modifyElements(changeObjects: Array<BoardDocumentElementChanges>): void;
27
49
  static getElements(criteria: object): Promise<Array<DocumentElement>>;
@@ -20,6 +20,7 @@ var BoardCommand;
20
20
  BoardCommand["GET_ELEMENTS"] = "board:get_elements";
21
21
  BoardCommand["RECOLOR_IMAGES"] = "board:recolor_images";
22
22
  BoardCommand["ADD_CONTENT_TO_ENTITY_FROM_ELEMENTS"] = "board:add_content_to_entity_from_elements";
23
+ BoardCommand["ADD_FRAMES_FROM_TEMPLATE"] = "board:add_frames_from_template";
23
24
  })(BoardCommand = exports.BoardCommand || (exports.BoardCommand = {}));
24
25
  class BoardsApp {
25
26
  static getCurrentBoard() {
@@ -29,9 +30,25 @@ class BoardsApp {
29
30
  static addElements(elements) {
30
31
  BoardsApp.validateBoardContext();
31
32
  if (elements === null || elements === void 0 ? void 0 : elements.length) {
32
- (0, actions_1.getExtensionActions)().sendMessageToHost({ command: BoardCommand.ADD_ELEMENTS, data: elements });
33
+ (0, actions_1.getExtensionActions)().sendMessageToHost({
34
+ command: BoardCommand.ADD_ELEMENTS,
35
+ data: elements,
36
+ });
33
37
  }
34
38
  }
39
+ static addFramesFromTemplate(frames) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ BoardsApp.validateBoardContext();
42
+ if (frames === null || frames === void 0 ? void 0 : frames.length) {
43
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({
44
+ command: BoardCommand.ADD_FRAMES_FROM_TEMPLATE,
45
+ data: frames,
46
+ });
47
+ return this.validateAndReturnResults(results);
48
+ }
49
+ return [];
50
+ });
51
+ }
35
52
  static deleteElements(elements) {
36
53
  BoardsApp.validateBoardContext();
37
54
  const elementsWithIds = elements.filter((element) => !!element.id);
@@ -42,13 +59,19 @@ class BoardsApp {
42
59
  static modifyElements(changeObjects) {
43
60
  BoardsApp.validateBoardContext();
44
61
  if (changeObjects === null || changeObjects === void 0 ? void 0 : changeObjects.length) {
45
- (0, actions_1.getExtensionActions)().sendMessageToHost({ command: BoardCommand.MODIFY_ELEMENTS, data: changeObjects });
62
+ (0, actions_1.getExtensionActions)().sendMessageToHost({
63
+ command: BoardCommand.MODIFY_ELEMENTS,
64
+ data: changeObjects,
65
+ });
46
66
  }
47
67
  }
48
68
  static getElements(criteria) {
49
69
  return __awaiter(this, void 0, void 0, function* () {
50
70
  BoardsApp.validateBoardContext();
51
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({ command: BoardCommand.GET_ELEMENTS, data: criteria });
71
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({
72
+ command: BoardCommand.GET_ELEMENTS,
73
+ data: criteria,
74
+ });
52
75
  return this.validateAndReturnResults(results);
53
76
  });
54
77
  }
@@ -58,23 +81,29 @@ class BoardsApp {
58
81
  const data = {
59
82
  assignmentOptions,
60
83
  entity,
61
- elements
84
+ elements,
62
85
  };
63
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({ command: BoardCommand.ADD_CONTENT_TO_ENTITY_FROM_ELEMENTS, data });
86
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({
87
+ command: BoardCommand.ADD_CONTENT_TO_ENTITY_FROM_ELEMENTS,
88
+ data,
89
+ });
64
90
  return this.validateAndReturnResults(results);
65
91
  });
66
92
  }
67
93
  static recolorImages(imageElements, hexCode, hexMap = {}) {
68
94
  return __awaiter(this, void 0, void 0, function* () {
69
95
  BoardsApp.validateBoardContext();
70
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({ command: BoardCommand.RECOLOR_IMAGES, data: { imageElements, hexCode, hexMap } });
96
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToHost({
97
+ command: BoardCommand.RECOLOR_IMAGES,
98
+ data: { imageElements, hexCode, hexMap },
99
+ });
71
100
  return this.validateAndReturnResults(results);
72
101
  });
73
102
  }
74
103
  static validateBoardContext() {
75
104
  const context = (0, app_context_1.getAppContext)();
76
105
  if (context.appContext.vibeIQApp !== app_context_1.VibeIQAppType.BOARDS || !context.appContext.board) {
77
- throw new Error("App extension has not been initialized with Board context.");
106
+ throw new Error('App extension has not been initialized with Board context.');
78
107
  }
79
108
  }
80
109
  static validateAndReturnResults(results) {
@@ -1,4 +1,4 @@
1
- import { PlanContext } from "./app-context";
1
+ 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",
package/lib/apps/plan.js CHANGED
@@ -52,7 +52,7 @@ class PlanApp {
52
52
  static validatePlanContext() {
53
53
  const context = (0, app_context_1.getAppContext)();
54
54
  if (context.appContext.vibeIQApp !== app_context_1.VibeIQAppType.PLAN || !context.appContext.plan) {
55
- throw new Error("App extension has not been initialized with Plan context.");
55
+ throw new Error('App extension has not been initialized with Plan context.');
56
56
  }
57
57
  }
58
58
  }
@@ -1,4 +1,4 @@
1
- import { EntitiesClientBatchCreateOptions, EntitiesClientBatchDeleteOptions, EntitiesClientBatchUpdateOptions, EntitiesClientCreateOptions, EntitiesClientDeleteOptions, EntitiesClientGetOptions, API_VERSION } from "@contrail/sdk";
1
+ import { EntitiesClientBatchCreateOptions, EntitiesClientBatchDeleteOptions, EntitiesClientBatchUpdateOptions, EntitiesClientCreateOptions, EntitiesClientDeleteOptions, EntitiesClientGetOptions, API_VERSION } from '@contrail/sdk';
2
2
  declare class EntitiesClientUpdateOptions {
3
3
  entityName?: string;
4
4
  object: any;
@@ -17,43 +17,64 @@ class EntitiesClientUpdateOptions {
17
17
  class EntitiesClient {
18
18
  get(options) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({ method: entities_action_handler_1.EntitiesClientMethods.GET, options });
20
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({
21
+ method: entities_action_handler_1.EntitiesClientMethods.GET,
22
+ options,
23
+ });
21
24
  return this.validateAndReturnEntityClientResults(results);
22
25
  });
23
26
  }
24
27
  create(options) {
25
28
  return __awaiter(this, void 0, void 0, function* () {
26
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({ method: entities_action_handler_1.EntitiesClientMethods.CREATE, options });
29
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({
30
+ method: entities_action_handler_1.EntitiesClientMethods.CREATE,
31
+ options,
32
+ });
27
33
  return this.validateAndReturnEntityClientResults(results);
28
34
  });
29
35
  }
30
36
  batchCreate(options) {
31
37
  return __awaiter(this, void 0, void 0, function* () {
32
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({ method: entities_action_handler_1.EntitiesClientMethods.BATCH_CREATE, options });
38
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({
39
+ method: entities_action_handler_1.EntitiesClientMethods.BATCH_CREATE,
40
+ options,
41
+ });
33
42
  return this.validateAndReturnEntityClientResults(results);
34
43
  });
35
44
  }
36
45
  update(options) {
37
46
  return __awaiter(this, void 0, void 0, function* () {
38
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({ method: entities_action_handler_1.EntitiesClientMethods.UPDATE, options });
47
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({
48
+ method: entities_action_handler_1.EntitiesClientMethods.UPDATE,
49
+ options,
50
+ });
39
51
  return this.validateAndReturnEntityClientResults(results);
40
52
  });
41
53
  }
42
54
  batchUpdate(options) {
43
55
  return __awaiter(this, void 0, void 0, function* () {
44
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({ method: entities_action_handler_1.EntitiesClientMethods.BATCH_UPDATE, options });
56
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({
57
+ method: entities_action_handler_1.EntitiesClientMethods.BATCH_UPDATE,
58
+ options,
59
+ });
45
60
  return this.validateAndReturnEntityClientResults(results);
46
61
  });
47
62
  }
48
63
  delete(options) {
49
64
  return __awaiter(this, void 0, void 0, function* () {
50
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({ method: entities_action_handler_1.EntitiesClientMethods.DELETE, options });
65
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({
66
+ method: entities_action_handler_1.EntitiesClientMethods.DELETE,
67
+ options,
68
+ });
51
69
  return this.validateAndReturnEntityClientResults(results);
52
70
  });
53
71
  }
54
72
  batchDelete(options) {
55
73
  return __awaiter(this, void 0, void 0, function* () {
56
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({ method: entities_action_handler_1.EntitiesClientMethods.BATCH_DELETE, options });
74
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToEntitiesClient({
75
+ method: entities_action_handler_1.EntitiesClientMethods.BATCH_DELETE,
76
+ options,
77
+ });
57
78
  return this.validateAndReturnEntityClientResults(results);
58
79
  });
59
80
  }
@@ -27,7 +27,7 @@ class AppExtensionHost {
27
27
  appExtension.init(context);
28
28
  }
29
29
  catch (error) {
30
- console.error("Failed to connect host app with app extension:", error);
30
+ console.error('Failed to connect host app with app extension:', error);
31
31
  throw error;
32
32
  }
33
33
  });
@@ -45,7 +45,7 @@ class AppExtensionHost {
45
45
  },
46
46
  sendMessageToHost(message) {
47
47
  return customMessageHandler.handleMessage(message);
48
- }
48
+ },
49
49
  };
50
50
  }
51
51
  }
@@ -28,7 +28,7 @@ class AppExtension {
28
28
  });
29
29
  }
30
30
  catch (error) {
31
- console.error("Failed to connect app extension with host application:", error);
31
+ console.error('Failed to connect app extension with host application:', error);
32
32
  throw error;
33
33
  }
34
34
  });
@@ -37,19 +37,18 @@ class AppExtension {
37
37
  return {
38
38
  init(context) {
39
39
  return AppExtension.initAppExtension(context);
40
- }
40
+ },
41
41
  };
42
42
  }
43
43
  static initAppExtension(context) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
- console.log("[AppExtension]: Initialized: Received context: ", context);
45
+ console.log('[AppExtension]: Initialized: Received context: ', context);
46
46
  (0, app_context_1.setAppContext)(context);
47
47
  if (AppExtension.initPromiseResolver) {
48
48
  AppExtension.initPromiseResolver();
49
49
  }
50
50
  });
51
51
  }
52
- ;
53
52
  static close() {
54
53
  (0, actions_1.getExtensionActions)().close();
55
54
  }
@@ -1,4 +1,4 @@
1
- import { TypeClientOptions } from "@contrail/sdk";
1
+ import { TypeClientOptions } from '@contrail/sdk';
2
2
  import { Type, TypeProperty } from '@contrail/types';
3
3
  export declare class TypesClient {
4
4
  getType(options: TypeClientOptions): Promise<Type>;
@@ -15,20 +15,29 @@ const types_action_handler_1 = require("./types-action-handler");
15
15
  class TypesClient {
16
16
  getType(options) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToTypesClient({ method: types_action_handler_1.TypesClientMethods.GET_TYPE, options });
18
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToTypesClient({
19
+ method: types_action_handler_1.TypesClientMethods.GET_TYPE,
20
+ options,
21
+ });
19
22
  return this.validateAndReturnTypeClientResults(results);
20
23
  });
21
24
  }
22
25
  getByRootAndPath(options) {
23
26
  return __awaiter(this, void 0, void 0, function* () {
24
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToTypesClient({ method: types_action_handler_1.TypesClientMethods.GET_BY_ROOT_AND_PATH, options });
27
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToTypesClient({
28
+ method: types_action_handler_1.TypesClientMethods.GET_BY_ROOT_AND_PATH,
29
+ options,
30
+ });
25
31
  return this.validateAndReturnTypeClientResults(results);
26
32
  });
27
33
  }
28
34
  getProperty(typeId, propertySlug) {
29
35
  return __awaiter(this, void 0, void 0, function* () {
30
36
  const getPropertyOptions = { typeId, propertySlug };
31
- const results = yield (0, actions_1.getExtensionActions)().sendMessageToTypesClient({ method: types_action_handler_1.TypesClientMethods.GET_PROPERTY, options: getPropertyOptions });
37
+ const results = yield (0, actions_1.getExtensionActions)().sendMessageToTypesClient({
38
+ method: types_action_handler_1.TypesClientMethods.GET_PROPERTY,
39
+ options: getPropertyOptions,
40
+ });
32
41
  return this.validateAndReturnTypeClientResults(results);
33
42
  });
34
43
  }
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@contrail/extensions-sdk",
3
- "version": "1.0.14",
3
+ "version": "1.0.16-0",
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",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
10
- "lint": "tslint -p tsconfig.json",
9
+ "prepare": "husky install",
10
+ "lint-staged:check": "lint-staged --config .lintstagedrc-check.json",
11
+ "lint-staged:format": "lint-staged --allow-empty --config .lintstagedrc-format.json",
11
12
  "generate-docs": "npx typedoc src/index.ts --disableSources --excludeInternal --plugin typedoc-plugin-extras --favicon home-hero.svg",
12
13
  "test": "jest"
13
14
  },
@@ -15,22 +16,26 @@
15
16
  "author": "",
16
17
  "license": "ISC",
17
18
  "dependencies": {
18
- "@contrail/documents": "^1.0.86",
19
+ "@contrail/documents": "^1.1.3",
20
+ "@contrail/document-generation": "^2.1.26",
19
21
  "@contrail/entity-types": "^1.1.35",
20
22
  "penpal": "^6.2.2"
21
23
  },
22
24
  "devDependencies": {
23
25
  "@types/jest": "^29.5.2",
24
26
  "@types/node": "^14.10.1",
27
+ "husky": "^9.0.11",
25
28
  "jest": "^29.5.0",
26
- "prettier": "^1.19.1",
29
+ "lint-staged": "^15.2.5",
30
+ "prettier": "^3.2.5",
27
31
  "ts-jest": "^29.1.1",
28
- "tslint": "^5.11.0",
29
- "tslint-config-prettier": "^1.18.0",
30
32
  "typedoc": "^0.25.7",
31
33
  "typedoc-plugin-extras": "^3.0.0",
32
34
  "typescript": "^4.0.0"
33
35
  },
36
+ "lint-staged": {
37
+ "*.{js,css,md}": "prettier --write"
38
+ },
34
39
  "peerDependencies": {
35
40
  "@contrail/sdk": "^1.3.7"
36
41
  },