@hubspot/ui-extensions-dev-server 0.10.2 → 1.0.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/README.md +23 -4
  2. package/dist/index.d.ts +3 -3
  3. package/dist/index.js +4 -45
  4. package/dist/lib/DevModeInterface.d.ts +2 -2
  5. package/dist/lib/DevModeInterface.js +12 -28
  6. package/dist/lib/DevModeParentInterface.d.ts +2 -2
  7. package/dist/lib/DevModeParentInterface.js +138 -154
  8. package/dist/lib/DevModeUnifiedInterface.d.ts +2 -2
  9. package/dist/lib/DevModeUnifiedInterface.js +28 -49
  10. package/dist/lib/DevServerState.d.ts +9 -5
  11. package/dist/lib/DevServerState.js +37 -18
  12. package/dist/lib/ExtensionsWebSocket.d.ts +25 -0
  13. package/dist/lib/ExtensionsWebSocket.js +110 -0
  14. package/dist/lib/__mocks__/config.d.ts +2 -0
  15. package/dist/lib/__mocks__/config.js +5 -0
  16. package/dist/lib/__mocks__/isExtensionFile.d.ts +5 -0
  17. package/dist/lib/__mocks__/isExtensionFile.js +11 -0
  18. package/dist/lib/__tests__/DevModeInterface.spec.d.ts +1 -0
  19. package/dist/lib/__tests__/DevModeInterface.spec.js +155 -0
  20. package/dist/lib/__tests__/DevModeParentInterface.spec.d.ts +1 -0
  21. package/dist/lib/__tests__/DevModeParentInterface.spec.js +179 -0
  22. package/dist/lib/__tests__/DevModeUnifiedInterface.spec.d.ts +1 -0
  23. package/dist/lib/__tests__/DevModeUnifiedInterface.spec.js +236 -0
  24. package/dist/lib/__tests__/ExtensionsWebSocket.spec.d.ts +1 -0
  25. package/dist/lib/__tests__/ExtensionsWebSocket.spec.js +304 -0
  26. package/dist/lib/__tests__/ast.spec.d.ts +1 -0
  27. package/dist/lib/__tests__/ast.spec.js +737 -0
  28. package/dist/lib/__tests__/build.spec.d.ts +1 -0
  29. package/dist/lib/__tests__/build.spec.js +159 -0
  30. package/dist/lib/__tests__/config.spec.d.ts +1 -0
  31. package/dist/lib/__tests__/config.spec.js +291 -0
  32. package/dist/lib/__tests__/dev.spec.d.ts +1 -0
  33. package/dist/lib/__tests__/dev.spec.js +80 -0
  34. package/dist/lib/__tests__/extensionsService.spec.d.ts +1 -0
  35. package/dist/lib/__tests__/extensionsService.spec.js +150 -0
  36. package/dist/lib/__tests__/factories.d.ts +48 -0
  37. package/dist/lib/__tests__/factories.js +32 -0
  38. package/dist/lib/__tests__/fixtures/extensionConfig.d.ts +182 -0
  39. package/dist/lib/__tests__/fixtures/extensionConfig.js +304 -0
  40. package/dist/lib/__tests__/fixtures/urls.d.ts +4 -0
  41. package/dist/lib/__tests__/fixtures/urls.js +4 -0
  42. package/dist/lib/__tests__/parsing-utils.spec.d.ts +1 -0
  43. package/dist/lib/__tests__/parsing-utils.spec.js +467 -0
  44. package/dist/lib/__tests__/plugins/codeBlockingPlugin.spec.d.ts +1 -0
  45. package/dist/lib/__tests__/plugins/codeBlockingPlugin.spec.js +112 -0
  46. package/dist/lib/__tests__/plugins/codeCheckingPlugin.spec.d.ts +1 -0
  47. package/dist/lib/__tests__/plugins/codeCheckingPlugin.spec.js +73 -0
  48. package/dist/lib/__tests__/plugins/devBuildPlugin.spec.d.ts +1 -0
  49. package/dist/lib/__tests__/plugins/devBuildPlugin.spec.js +256 -0
  50. package/dist/lib/__tests__/plugins/friendlyLoggingPlugin.spec.d.ts +1 -0
  51. package/dist/lib/__tests__/plugins/friendlyLoggingPlugin.spec.js +65 -0
  52. package/dist/lib/__tests__/plugins/manifestPlugin.spec.d.ts +1 -0
  53. package/dist/lib/__tests__/plugins/manifestPlugin.spec.js +455 -0
  54. package/dist/lib/__tests__/plugins/relevantModulesPlugin.spec.d.ts +1 -0
  55. package/dist/lib/__tests__/plugins/relevantModulesPlugin.spec.js +81 -0
  56. package/dist/lib/__tests__/server.spec.d.ts +1 -0
  57. package/dist/lib/__tests__/server.spec.js +152 -0
  58. package/dist/lib/__tests__/test-utils/ast.d.ts +1 -0
  59. package/dist/lib/__tests__/test-utils/ast.js +4 -0
  60. package/dist/lib/__tests__/utils.spec.d.ts +1 -0
  61. package/dist/lib/__tests__/utils.spec.js +176 -0
  62. package/dist/lib/ast.d.ts +1 -1
  63. package/dist/lib/ast.js +22 -29
  64. package/dist/lib/bin/cli.js +52 -72
  65. package/dist/lib/build.d.ts +1 -1
  66. package/dist/lib/build.js +60 -78
  67. package/dist/lib/config.d.ts +1 -1
  68. package/dist/lib/config.js +31 -34
  69. package/dist/lib/constants.d.ts +0 -2
  70. package/dist/lib/constants.js +20 -27
  71. package/dist/lib/dev.d.ts +1 -1
  72. package/dist/lib/dev.js +52 -69
  73. package/dist/lib/extensionsService.d.ts +1 -1
  74. package/dist/lib/extensionsService.js +21 -15
  75. package/dist/lib/parsing-utils.d.ts +1 -1
  76. package/dist/lib/parsing-utils.js +7 -11
  77. package/dist/lib/plugins/codeBlockingPlugin.d.ts +1 -1
  78. package/dist/lib/plugins/codeBlockingPlugin.js +5 -8
  79. package/dist/lib/plugins/codeCheckingPlugin.d.ts +1 -1
  80. package/dist/lib/plugins/codeCheckingPlugin.js +4 -9
  81. package/dist/lib/plugins/devBuildPlugin.d.ts +2 -2
  82. package/dist/lib/plugins/devBuildPlugin.js +74 -99
  83. package/dist/lib/plugins/friendlyLoggingPlugin.d.ts +2 -2
  84. package/dist/lib/plugins/friendlyLoggingPlugin.js +4 -12
  85. package/dist/lib/plugins/manifestPlugin.d.ts +1 -1
  86. package/dist/lib/plugins/manifestPlugin.js +46 -26
  87. package/dist/lib/plugins/relevantModulesPlugin.d.ts +2 -2
  88. package/dist/lib/plugins/relevantModulesPlugin.js +4 -7
  89. package/dist/lib/server.d.ts +7 -2
  90. package/dist/lib/server.js +85 -84
  91. package/dist/lib/types.d.ts +1 -1
  92. package/dist/lib/types.js +4 -7
  93. package/dist/lib/utils.d.ts +1 -1
  94. package/dist/lib/utils.js +23 -40
  95. package/package.json +44 -31
@@ -0,0 +1,304 @@
1
+ import { UnifiedAppAuthTypes, UnifiedComponentTypes, } from "../../types.js";
2
+ const addCard = (component, cardFile) => ({
3
+ ...component,
4
+ config: {
5
+ ...component.config,
6
+ extensions: {
7
+ ...component.config.extensions,
8
+ crm: {
9
+ ...component.config.extensions.crm,
10
+ cards: [...component.config.extensions.crm.cards, { file: cardFile }],
11
+ },
12
+ },
13
+ },
14
+ });
15
+ const addUnifiedCard = (component, cardFile) => ({
16
+ ...component,
17
+ extensions: {
18
+ ...component.extensions,
19
+ crm: {
20
+ ...component.extensions.crm,
21
+ cards: [...component.extensions.crm.cards, { file: cardFile }],
22
+ },
23
+ },
24
+ });
25
+ export const appComponent = {
26
+ config: {
27
+ name: 'Meme generator',
28
+ public: false,
29
+ scopes: [],
30
+ description: 'make some dope memes',
31
+ extensions: {
32
+ crm: {
33
+ cards: [
34
+ {
35
+ file: 'extensions/meme-card.json',
36
+ },
37
+ ],
38
+ },
39
+ },
40
+ },
41
+ type: 'private-app',
42
+ path: 'path/to/my/application',
43
+ };
44
+ export const appComponentTwoCards = addCard(appComponent, 'extensions/another-meme-card.json');
45
+ export const appConfig = {
46
+ name: 'Meme generator',
47
+ description: 'make some dope memes',
48
+ uid: 'meme_generator',
49
+ scopes: ['crm.objects.contacts.read'],
50
+ public: false,
51
+ extensions: {
52
+ crm: {
53
+ cards: [
54
+ {
55
+ file: 'extensions/meme-card.json',
56
+ },
57
+ ],
58
+ },
59
+ },
60
+ };
61
+ export const unifiedAppConfig = {
62
+ uid: 'application-uid',
63
+ config: {
64
+ description: 'Generate dope memes',
65
+ name: 'Meme generator',
66
+ auth: {
67
+ type: UnifiedAppAuthTypes.OAUTH,
68
+ redirectUrls: ['http://localhost:3000/oauth-callback'],
69
+ requiredScopes: [
70
+ 'crm.objects.contacts.read',
71
+ 'crm.objects.contacts.write',
72
+ 'media_bridge.read',
73
+ 'media_bridge.write',
74
+ ],
75
+ optionalScopes: [],
76
+ conditionallyRequiredScopes: [],
77
+ },
78
+ permittedUrls: {
79
+ fetch: ['https://api.hubapi.com'],
80
+ iframe: [],
81
+ img: [],
82
+ },
83
+ },
84
+ componentType: UnifiedComponentTypes.APPLICATION,
85
+ componentDeps: {},
86
+ metaFilePath: 'app/app-hsmeta.json',
87
+ files: {},
88
+ localDev: {
89
+ componentRoot: '/some/path/to/app',
90
+ componentConfigPath: '/some/path/to/app/app-hsmeta.json',
91
+ },
92
+ };
93
+ export const transformedUnifiedAppConfig = {
94
+ name: unifiedAppConfig.config.name,
95
+ description: unifiedAppConfig.config.description,
96
+ uid: unifiedAppConfig.uid,
97
+ extensions: {
98
+ crm: {
99
+ cards: [
100
+ {
101
+ file: './CardOne.jsx',
102
+ },
103
+ ],
104
+ },
105
+ },
106
+ auth: unifiedAppConfig.config.auth,
107
+ support: undefined,
108
+ isPublicApp: true,
109
+ allowedUrls: ['https://api.hubapi.com'],
110
+ variables: {},
111
+ };
112
+ export const transformedUnifiedAppConfigTwoCards = addUnifiedCard(transformedUnifiedAppConfig, './CardTwo.jsx');
113
+ export const cardConfig = {
114
+ type: 'crm-card',
115
+ data: {
116
+ title: 'Meme Card',
117
+ uid: 'meme_card',
118
+ location: 'crm.record.sidebar',
119
+ module: { file: 'MemeCard.jsx' },
120
+ objectTypes: [{ name: 'CONTACT' }],
121
+ appName: appConfig.name,
122
+ sourceId: `${appConfig.uid}::meme_card`,
123
+ },
124
+ output: 'MemeCard.js',
125
+ path: 'path/to/my/application',
126
+ extensionPath: 'path/to/my/application/extensions',
127
+ extensionConfigPath: 'path/to/my/application/extensions/meme-card.json',
128
+ appConfig,
129
+ };
130
+ export const cardConfigTwo = {
131
+ type: 'crm-card',
132
+ data: {
133
+ title: 'Another Meme Card',
134
+ uid: 'another_meme_card',
135
+ location: 'crm.record.sidebar',
136
+ module: { file: 'AnotherMemeCard.jsx' },
137
+ objectTypes: [{ name: 'CONTACT' }],
138
+ appName: appConfig.name,
139
+ sourceId: `${appConfig.uid}::another_meme_card`,
140
+ },
141
+ output: 'AnotherMemeCard.js',
142
+ path: 'path/to/my/application',
143
+ extensionPath: 'path/to/my/application/extensions',
144
+ extensionConfigPath: 'path/to/my/application/extensions/another-meme-card.json',
145
+ appConfig,
146
+ };
147
+ export const unifiedCardOneConfig = {
148
+ uid: 'card-one',
149
+ config: {
150
+ name: 'Card One',
151
+ description: 'This is card one',
152
+ location: 'crm.record.tab',
153
+ entrypoint: '/app/cards/CardOne.jsx',
154
+ objectTypes: ['CONTACT'],
155
+ },
156
+ componentType: UnifiedComponentTypes.CARD,
157
+ componentDeps: {
158
+ app: 'application-uid',
159
+ },
160
+ metaFilePath: 'app/cards/card-hsmeta.json',
161
+ files: {},
162
+ localDev: {
163
+ componentRoot: '/some/path/to/app/cards',
164
+ componentConfigPath: '/some/path/to/app/cards/card-hsmeta.json',
165
+ },
166
+ };
167
+ export const transformedUnifiedCardOneConfig = {
168
+ type: 'card',
169
+ data: {
170
+ title: 'Card One',
171
+ uid: 'card-one',
172
+ location: 'crm.record.tab',
173
+ module: {
174
+ file: '/some/path/to/app/cards/CardOne.jsx',
175
+ },
176
+ objectTypes: [
177
+ {
178
+ name: 'CONTACT',
179
+ },
180
+ ],
181
+ appName: 'Meme generator',
182
+ sourceId: 'application-uid::card-one',
183
+ },
184
+ output: 'CardOne.js',
185
+ path: '/some/path/to/app',
186
+ extensionPath: '/some/path/to/app/cards',
187
+ extensionConfigPath: '/some/path/to/app/cards/card-hsmeta.json',
188
+ };
189
+ export const unifiedCardTwoConfig = {
190
+ uid: 'card-two',
191
+ config: {
192
+ name: 'Card Two',
193
+ description: 'This is card two',
194
+ location: 'crm.record.tab',
195
+ entrypoint: '/app/cards/CardTwo.jsx',
196
+ objectTypes: ['CONTACT'],
197
+ },
198
+ componentType: UnifiedComponentTypes.CARD,
199
+ componentDeps: {
200
+ app: 'application-uid',
201
+ },
202
+ metaFilePath: 'app/cards/card-two-hsmeta.json',
203
+ files: {},
204
+ localDev: {
205
+ componentRoot: '/some/path/to/app/cards',
206
+ componentConfigPath: '/some/path/to/app/cards/card-two-hsmeta.json',
207
+ },
208
+ };
209
+ export const transformedUnifiedCardTwoConfig = {
210
+ type: 'card',
211
+ data: {
212
+ title: 'Card Two',
213
+ uid: 'card-two',
214
+ location: 'crm.record.tab',
215
+ module: {
216
+ file: '/some/path/to/app/cards/CardTwo.jsx',
217
+ },
218
+ objectTypes: [
219
+ {
220
+ name: 'CONTACT',
221
+ },
222
+ ],
223
+ appName: 'Meme generator',
224
+ sourceId: 'application-uid::card-two',
225
+ },
226
+ output: 'CardTwo.js',
227
+ path: '/some/path/to/app',
228
+ extensionPath: '/some/path/to/app/cards',
229
+ extensionConfigPath: '/some/path/to/app/cards/card-two-hsmeta.json',
230
+ };
231
+ export const settingsExtensionConfig = {
232
+ uid: 'card-settings',
233
+ config: {
234
+ // @ts-expect-error The developer does not provide a name for App Settings
235
+ name: undefined,
236
+ description: 'This is the card for settings',
237
+ location: 'settings',
238
+ entrypoint: '/app/cards/CardSettings.jsx',
239
+ },
240
+ componentType: UnifiedComponentTypes.SETTINGS,
241
+ componentDeps: {
242
+ app: 'application-uid',
243
+ },
244
+ metaFilePath: 'app/cards/card-settings-hsmeta.json',
245
+ files: {},
246
+ localDev: {
247
+ componentRoot: '/some/path/to/app/cards',
248
+ componentConfigPath: '/some/path/to/app/cards/card-settings-hsmeta.json',
249
+ },
250
+ };
251
+ export const settingsExtensionTransformedData = {
252
+ type: 'card',
253
+ data: {
254
+ title: 'Settings',
255
+ uid: 'card-settings',
256
+ location: 'settings',
257
+ module: {
258
+ file: '/some/path/to/app/cards/CardSettings.jsx',
259
+ },
260
+ appName: 'Meme generator',
261
+ sourceId: 'application-uid::card-settings',
262
+ },
263
+ output: 'CardSettings.js',
264
+ path: '/some/path/to/app',
265
+ extensionPath: '/some/path/to/app/cards',
266
+ extensionConfigPath: '/some/path/to/app/cards/card-settings-hsmeta.json',
267
+ };
268
+ export const appHomesConfig = {
269
+ uid: 'app-home-pages',
270
+ config: {
271
+ // @ts-expect-error The developer does not provide a name for App Homes
272
+ name: undefined,
273
+ description: 'This is the page for app homes',
274
+ location: 'home',
275
+ entrypoint: '/app/pages/AppHome.jsx',
276
+ },
277
+ componentType: UnifiedComponentTypes.PAGE,
278
+ componentDeps: {
279
+ app: 'application-uid',
280
+ },
281
+ metaFilePath: 'app/pages/app-home-hsmeta.json',
282
+ files: {},
283
+ localDev: {
284
+ componentRoot: '/some/path/to/app/pages',
285
+ componentConfigPath: '/some/path/to/app/pages/app-home-hsmeta.json',
286
+ },
287
+ };
288
+ export const appHomesTransformedData = {
289
+ type: 'page',
290
+ data: {
291
+ title: 'App Home',
292
+ uid: 'app-home-pages',
293
+ location: 'home',
294
+ module: {
295
+ file: '/some/path/to/app/pages/AppHome.jsx',
296
+ },
297
+ appName: 'Meme generator',
298
+ sourceId: 'application-uid::app-home-pages',
299
+ },
300
+ output: 'AppHome.js',
301
+ path: '/some/path/to/app',
302
+ extensionPath: '/some/path/to/app/pages',
303
+ extensionConfigPath: '/some/path/to/app/pages/app-home-hsmeta.json',
304
+ };
@@ -0,0 +1,4 @@
1
+ export declare const urls: {
2
+ api: string;
3
+ web: string;
4
+ };
@@ -0,0 +1,4 @@
1
+ export const urls = {
2
+ api: 'https://api.inbound.com',
3
+ web: 'https://app.inbound.com',
4
+ };
@@ -0,0 +1 @@
1
+ export {};