@hubspot/ui-extensions-dev-server 1.0.2 → 1.1.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.
Files changed (95) hide show
  1. package/package.json +1 -1
  2. package/dist/index.d.ts +0 -4
  3. package/dist/index.js +0 -4
  4. package/dist/lib/DevModeInterface.d.ts +0 -9
  5. package/dist/lib/DevModeInterface.js +0 -36
  6. package/dist/lib/DevModeParentInterface.d.ts +0 -19
  7. package/dist/lib/DevModeParentInterface.js +0 -181
  8. package/dist/lib/DevModeUnifiedInterface.d.ts +0 -9
  9. package/dist/lib/DevModeUnifiedInterface.js +0 -118
  10. package/dist/lib/DevServerState.d.ts +0 -44
  11. package/dist/lib/DevServerState.js +0 -95
  12. package/dist/lib/ExtensionsWebSocket.d.ts +0 -25
  13. package/dist/lib/ExtensionsWebSocket.js +0 -110
  14. package/dist/lib/__mocks__/config.d.ts +0 -2
  15. package/dist/lib/__mocks__/config.js +0 -5
  16. package/dist/lib/__mocks__/isExtensionFile.d.ts +0 -5
  17. package/dist/lib/__mocks__/isExtensionFile.js +0 -11
  18. package/dist/lib/__tests__/DevModeInterface.spec.d.ts +0 -1
  19. package/dist/lib/__tests__/DevModeInterface.spec.js +0 -155
  20. package/dist/lib/__tests__/DevModeParentInterface.spec.d.ts +0 -1
  21. package/dist/lib/__tests__/DevModeParentInterface.spec.js +0 -179
  22. package/dist/lib/__tests__/DevModeUnifiedInterface.spec.d.ts +0 -1
  23. package/dist/lib/__tests__/DevModeUnifiedInterface.spec.js +0 -236
  24. package/dist/lib/__tests__/ExtensionsWebSocket.spec.d.ts +0 -1
  25. package/dist/lib/__tests__/ExtensionsWebSocket.spec.js +0 -304
  26. package/dist/lib/__tests__/ast.spec.d.ts +0 -1
  27. package/dist/lib/__tests__/ast.spec.js +0 -737
  28. package/dist/lib/__tests__/build.spec.d.ts +0 -1
  29. package/dist/lib/__tests__/build.spec.js +0 -159
  30. package/dist/lib/__tests__/config.spec.d.ts +0 -1
  31. package/dist/lib/__tests__/config.spec.js +0 -291
  32. package/dist/lib/__tests__/dev.spec.d.ts +0 -1
  33. package/dist/lib/__tests__/dev.spec.js +0 -80
  34. package/dist/lib/__tests__/extensionsService.spec.d.ts +0 -1
  35. package/dist/lib/__tests__/extensionsService.spec.js +0 -150
  36. package/dist/lib/__tests__/factories.d.ts +0 -48
  37. package/dist/lib/__tests__/factories.js +0 -32
  38. package/dist/lib/__tests__/fixtures/extensionConfig.d.ts +0 -182
  39. package/dist/lib/__tests__/fixtures/extensionConfig.js +0 -304
  40. package/dist/lib/__tests__/fixtures/urls.d.ts +0 -4
  41. package/dist/lib/__tests__/fixtures/urls.js +0 -4
  42. package/dist/lib/__tests__/parsing-utils.spec.d.ts +0 -1
  43. package/dist/lib/__tests__/parsing-utils.spec.js +0 -467
  44. package/dist/lib/__tests__/plugins/codeBlockingPlugin.spec.d.ts +0 -1
  45. package/dist/lib/__tests__/plugins/codeBlockingPlugin.spec.js +0 -112
  46. package/dist/lib/__tests__/plugins/codeCheckingPlugin.spec.d.ts +0 -1
  47. package/dist/lib/__tests__/plugins/codeCheckingPlugin.spec.js +0 -111
  48. package/dist/lib/__tests__/plugins/devBuildPlugin.spec.d.ts +0 -1
  49. package/dist/lib/__tests__/plugins/devBuildPlugin.spec.js +0 -256
  50. package/dist/lib/__tests__/plugins/friendlyLoggingPlugin.spec.d.ts +0 -1
  51. package/dist/lib/__tests__/plugins/friendlyLoggingPlugin.spec.js +0 -65
  52. package/dist/lib/__tests__/plugins/manifestPlugin.spec.d.ts +0 -1
  53. package/dist/lib/__tests__/plugins/manifestPlugin.spec.js +0 -455
  54. package/dist/lib/__tests__/plugins/relevantModulesPlugin.spec.d.ts +0 -1
  55. package/dist/lib/__tests__/plugins/relevantModulesPlugin.spec.js +0 -81
  56. package/dist/lib/__tests__/server.spec.d.ts +0 -1
  57. package/dist/lib/__tests__/server.spec.js +0 -152
  58. package/dist/lib/__tests__/test-utils/ast.d.ts +0 -1
  59. package/dist/lib/__tests__/test-utils/ast.js +0 -4
  60. package/dist/lib/__tests__/utils.spec.d.ts +0 -1
  61. package/dist/lib/__tests__/utils.spec.js +0 -176
  62. package/dist/lib/ast.d.ts +0 -16
  63. package/dist/lib/ast.js +0 -281
  64. package/dist/lib/bin/cli.d.ts +0 -2
  65. package/dist/lib/bin/cli.js +0 -143
  66. package/dist/lib/build.d.ts +0 -24
  67. package/dist/lib/build.js +0 -73
  68. package/dist/lib/config.d.ts +0 -7
  69. package/dist/lib/config.js +0 -124
  70. package/dist/lib/constants.d.ts +0 -32
  71. package/dist/lib/constants.js +0 -43
  72. package/dist/lib/dev.d.ts +0 -2
  73. package/dist/lib/dev.js +0 -58
  74. package/dist/lib/extensionsService.d.ts +0 -10
  75. package/dist/lib/extensionsService.js +0 -45
  76. package/dist/lib/parsing-utils.d.ts +0 -31
  77. package/dist/lib/parsing-utils.js +0 -289
  78. package/dist/lib/plugins/codeBlockingPlugin.d.ts +0 -8
  79. package/dist/lib/plugins/codeBlockingPlugin.js +0 -45
  80. package/dist/lib/plugins/codeCheckingPlugin.d.ts +0 -8
  81. package/dist/lib/plugins/codeCheckingPlugin.js +0 -89
  82. package/dist/lib/plugins/devBuildPlugin.d.ts +0 -8
  83. package/dist/lib/plugins/devBuildPlugin.js +0 -201
  84. package/dist/lib/plugins/friendlyLoggingPlugin.d.ts +0 -14
  85. package/dist/lib/plugins/friendlyLoggingPlugin.js +0 -36
  86. package/dist/lib/plugins/manifestPlugin.d.ts +0 -12
  87. package/dist/lib/plugins/manifestPlugin.js +0 -158
  88. package/dist/lib/plugins/relevantModulesPlugin.d.ts +0 -13
  89. package/dist/lib/plugins/relevantModulesPlugin.js +0 -25
  90. package/dist/lib/server.d.ts +0 -13
  91. package/dist/lib/server.js +0 -99
  92. package/dist/lib/types.d.ts +0 -290
  93. package/dist/lib/types.js +0 -12
  94. package/dist/lib/utils.d.ts +0 -25
  95. package/dist/lib/utils.js +0 -113
@@ -1,150 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import path from 'path';
3
- vi.mock('../utils', () => ({
4
- loadManifest: vi.fn(() => {
5
- return {
6
- name: 'fake manifest file',
7
- };
8
- }),
9
- }));
10
- import { EXTENSIONS_MESSAGE_VERSION, PLATFORM_VERSION } from "../constants.js";
11
- import extensionsService from "../extensionsService.js";
12
- import { loadManifest } from "../utils.js";
13
- import { DevServerState } from "../DevServerState.js";
14
- import { createMockLogger, createDevServerConfig } from "./factories.js";
15
- describe('extensionsService', () => {
16
- let devServerState;
17
- let logger;
18
- beforeEach(() => {
19
- logger = createMockLogger();
20
- devServerState = new DevServerState(createDevServerConfig(logger));
21
- });
22
- describe('add', () => {
23
- it('should add a GET endpoint to /extensions', () => {
24
- const server = {
25
- get: vi.fn(),
26
- };
27
- extensionsService.add(
28
- // TypeScript wants us to mock the entire Express Application object which is excessive
29
- server, devServerState, []);
30
- expect(server.get).toHaveBeenCalledTimes(1);
31
- expect(server.get).toHaveBeenCalledWith('/extensions', expect.any(Function));
32
- });
33
- });
34
- describe('generateExtensionsHandler', () => {
35
- it('should return a handler method', () => {
36
- const result = extensionsService.generateExtensionsHandler(devServerState);
37
- expect(result).toStrictEqual(expect.any(Function));
38
- });
39
- it('should return a handler that returns data about which extensions are running', () => {
40
- const capabilities = ['capability-1', 'capability-2'];
41
- const handler = extensionsService.generateExtensionsHandler(devServerState, capabilities);
42
- const jsonMethod = vi.fn();
43
- const response = {
44
- status: vi.fn(() => {
45
- return {
46
- json: jsonMethod,
47
- };
48
- }),
49
- };
50
- // Don't want to mock full express types because they are huge, so type assert
51
- handler({}, response);
52
- const { outputDir, expressPort, portalId, extensionsMetadata } = devServerState;
53
- expect(loadManifest).toHaveBeenCalledTimes(1);
54
- expect(loadManifest).toHaveBeenCalledWith(outputDir, path.parse(extensionsMetadata[0].config.output).name);
55
- expect(response.status).toHaveBeenCalledTimes(1);
56
- expect(response.status).toBeCalledWith(200);
57
- expect(jsonMethod).toHaveBeenCalledTimes(1);
58
- expect(jsonMethod).toBeCalledWith({
59
- extensions: [
60
- {
61
- manifest: {
62
- name: 'fake manifest file',
63
- },
64
- ...extensionsMetadata[0].baseMessage,
65
- },
66
- ],
67
- portalId,
68
- version: EXTENSIONS_MESSAGE_VERSION,
69
- websocket: `ws://localhost:${expressPort}`,
70
- capabilities,
71
- platformVersion: PLATFORM_VERSION.V20231,
72
- });
73
- });
74
- it('should return a handler that includes platform version in response', () => {
75
- const capabilities = ['capability-1', 'capability-2'];
76
- const handler = extensionsService.generateExtensionsHandler(devServerState, capabilities);
77
- const jsonMethod = vi.fn();
78
- const response = {
79
- status: vi.fn(() => {
80
- return {
81
- json: jsonMethod,
82
- };
83
- }),
84
- };
85
- handler({}, response);
86
- expect(jsonMethod).toHaveBeenCalledWith(expect.objectContaining({
87
- platformVersion: PLATFORM_VERSION.V20231,
88
- }));
89
- });
90
- it('should work when platform version is undefined', () => {
91
- const mockDevServerState = {
92
- extensionsMetadata: [
93
- {
94
- baseMessage: {
95
- appName: 'Test App',
96
- title: 'Test Extension',
97
- callback: 'test.js',
98
- },
99
- },
100
- ],
101
- outputDir: '/test/output',
102
- webSocketPort: 2345,
103
- portalId: 12345,
104
- functionsConfig: {
105
- platformVersion: undefined,
106
- },
107
- };
108
- const capabilities = ['capability-1', 'capability-2'];
109
- const handler = extensionsService.generateExtensionsHandler(
110
- // @ts-expect-error - we need to test the undefined state
111
- mockDevServerState, capabilities);
112
- const jsonMethod = vi.fn();
113
- const response = {
114
- status: vi.fn(() => {
115
- return {
116
- json: jsonMethod,
117
- };
118
- }),
119
- };
120
- handler({}, response);
121
- const callArgs = jsonMethod.mock.calls[0][0];
122
- expect(callArgs).not.toHaveProperty('platformVersion');
123
- });
124
- it('should return a handler that sends error responses when something goes wrong', () => {
125
- const handler = extensionsService.generateExtensionsHandler(devServerState);
126
- const jsonMethod = vi.fn();
127
- const response = {
128
- status: vi.fn(() => {
129
- return {
130
- json: jsonMethod,
131
- };
132
- }),
133
- };
134
- // @ts-expect-error TS thinks mockImplementationOnce doesn't exist
135
- loadManifest.mockImplementationOnce(() => {
136
- throw new Error('YOU SHALL NOT PASS');
137
- });
138
- // Don't want to mock full express types because they are huge, so type assert
139
- handler({}, response);
140
- expect(response.status).toHaveBeenCalledTimes(1);
141
- expect(response.status).toBeCalledWith(500);
142
- expect(jsonMethod).toHaveBeenCalledTimes(1);
143
- expect(jsonMethod).toBeCalledWith({
144
- message: 'Unable to determine which extensions are running',
145
- });
146
- expect(logger.error).toHaveBeenCalledTimes(1);
147
- expect(logger.error).toHaveBeenCalledWith(expect.stringContaining('Error in /extensions endpoint:'));
148
- });
149
- });
150
- });
@@ -1,48 +0,0 @@
1
- import { Logger } from '../types.ts';
2
- import { ViteDevServer } from 'vite';
3
- export declare function createMockLogger(): Logger;
4
- export declare function createMockViteDevServer(): ViteDevServer;
5
- export declare function createDevServerConfig(logger: Logger, overrides?: {}): {
6
- urls: {
7
- api: string;
8
- web: string;
9
- };
10
- logger: Logger;
11
- accountId: number;
12
- platformVersion: "2023.1";
13
- expressPort: number;
14
- extensionConfigs: {
15
- type: string;
16
- data: {
17
- title: string;
18
- uid: string;
19
- location: string;
20
- module: {
21
- file: string;
22
- };
23
- objectTypes: {
24
- name: string;
25
- }[];
26
- appName: string;
27
- sourceId: string;
28
- };
29
- output: string;
30
- path: string;
31
- extensionPath: string;
32
- extensionConfigPath: string;
33
- appConfig: {
34
- name: string;
35
- description: string;
36
- uid: string;
37
- scopes: string[];
38
- public: boolean;
39
- extensions: {
40
- crm: {
41
- cards: {
42
- file: string;
43
- }[];
44
- };
45
- };
46
- };
47
- }[];
48
- };
@@ -1,32 +0,0 @@
1
- import { vi } from 'vitest';
2
- import { PLATFORM_VERSION } from "../constants.js";
3
- import { urls } from "../__tests__/fixtures/urls.js";
4
- import { cardConfig } from "../__tests__/fixtures/extensionConfig.js";
5
- export function createMockLogger() {
6
- return {
7
- info: vi.fn(),
8
- debug: vi.fn(),
9
- warn: vi.fn(),
10
- error: vi.fn(),
11
- };
12
- }
13
- export function createMockViteDevServer() {
14
- return {
15
- middlewares: vi.fn(),
16
- pluginContainer: {
17
- close: vi.fn(async () => { }),
18
- },
19
- close: vi.fn(async () => { }),
20
- };
21
- }
22
- export function createDevServerConfig(logger, overrides = {}) {
23
- return {
24
- urls,
25
- logger,
26
- accountId: 12345,
27
- platformVersion: PLATFORM_VERSION.V20231,
28
- expressPort: 1234,
29
- extensionConfigs: [cardConfig],
30
- ...overrides,
31
- };
32
- }
@@ -1,182 +0,0 @@
1
- import { UnifiedAppComponent, UnifiedAppConfig, UnifiedExtensionComponent } from '../../types.ts';
2
- export declare const appComponent: {
3
- config: {
4
- name: string;
5
- public: boolean;
6
- scopes: never[];
7
- description: string;
8
- extensions: {
9
- crm: {
10
- cards: {
11
- file: string;
12
- }[];
13
- };
14
- };
15
- };
16
- type: "private-app";
17
- path: string;
18
- };
19
- export declare const appComponentTwoCards: any;
20
- export declare const appConfig: {
21
- name: string;
22
- description: string;
23
- uid: string;
24
- scopes: string[];
25
- public: boolean;
26
- extensions: {
27
- crm: {
28
- cards: {
29
- file: string;
30
- }[];
31
- };
32
- };
33
- };
34
- export declare const unifiedAppConfig: UnifiedAppComponent;
35
- export declare const transformedUnifiedAppConfig: UnifiedAppConfig;
36
- export declare const transformedUnifiedAppConfigTwoCards: UnifiedAppConfig;
37
- export declare const cardConfig: {
38
- type: string;
39
- data: {
40
- title: string;
41
- uid: string;
42
- location: string;
43
- module: {
44
- file: string;
45
- };
46
- objectTypes: {
47
- name: string;
48
- }[];
49
- appName: string;
50
- sourceId: string;
51
- };
52
- output: string;
53
- path: string;
54
- extensionPath: string;
55
- extensionConfigPath: string;
56
- appConfig: {
57
- name: string;
58
- description: string;
59
- uid: string;
60
- scopes: string[];
61
- public: boolean;
62
- extensions: {
63
- crm: {
64
- cards: {
65
- file: string;
66
- }[];
67
- };
68
- };
69
- };
70
- };
71
- export declare const cardConfigTwo: {
72
- type: string;
73
- data: {
74
- title: string;
75
- uid: string;
76
- location: string;
77
- module: {
78
- file: string;
79
- };
80
- objectTypes: {
81
- name: string;
82
- }[];
83
- appName: string;
84
- sourceId: string;
85
- };
86
- output: string;
87
- path: string;
88
- extensionPath: string;
89
- extensionConfigPath: string;
90
- appConfig: {
91
- name: string;
92
- description: string;
93
- uid: string;
94
- scopes: string[];
95
- public: boolean;
96
- extensions: {
97
- crm: {
98
- cards: {
99
- file: string;
100
- }[];
101
- };
102
- };
103
- };
104
- };
105
- export declare const unifiedCardOneConfig: UnifiedExtensionComponent;
106
- export declare const transformedUnifiedCardOneConfig: {
107
- type: string;
108
- data: {
109
- title: string;
110
- uid: string;
111
- location: string;
112
- module: {
113
- file: string;
114
- };
115
- objectTypes: {
116
- name: string;
117
- }[];
118
- appName: string;
119
- sourceId: string;
120
- };
121
- output: string;
122
- path: string;
123
- extensionPath: string;
124
- extensionConfigPath: string;
125
- };
126
- export declare const unifiedCardTwoConfig: UnifiedExtensionComponent;
127
- export declare const transformedUnifiedCardTwoConfig: {
128
- type: string;
129
- data: {
130
- title: string;
131
- uid: string;
132
- location: string;
133
- module: {
134
- file: string;
135
- };
136
- objectTypes: {
137
- name: string;
138
- }[];
139
- appName: string;
140
- sourceId: string;
141
- };
142
- output: string;
143
- path: string;
144
- extensionPath: string;
145
- extensionConfigPath: string;
146
- };
147
- export declare const settingsExtensionConfig: UnifiedExtensionComponent;
148
- export declare const settingsExtensionTransformedData: {
149
- type: string;
150
- data: {
151
- title: string;
152
- uid: string;
153
- location: string;
154
- module: {
155
- file: string;
156
- };
157
- appName: string;
158
- sourceId: string;
159
- };
160
- output: string;
161
- path: string;
162
- extensionPath: string;
163
- extensionConfigPath: string;
164
- };
165
- export declare const appHomesConfig: UnifiedExtensionComponent;
166
- export declare const appHomesTransformedData: {
167
- type: string;
168
- data: {
169
- title: string;
170
- uid: string;
171
- location: string;
172
- module: {
173
- file: string;
174
- };
175
- appName: string;
176
- sourceId: string;
177
- };
178
- output: string;
179
- path: string;
180
- extensionPath: string;
181
- extensionConfigPath: string;
182
- };