lucid-package 0.0.68 → 0.0.71

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-package",
3
- "version": "0.0.68",
3
+ "version": "0.0.71",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/cors.js CHANGED
@@ -2,8 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.corsAllowLucid = void 0;
4
4
  function corsAllowLucid(req, res, next) {
5
- var _a, _b;
6
- if ((_b = (_a = req.headers) === null || _a === void 0 ? void 0 : _a.origin) === null || _b === void 0 ? void 0 : _b.match(/.lucid(dev|staging|preprod|).app$/)) {
5
+ if (req.headers?.origin?.match(/.lucid(dev|staging|preprod|).app$/)) {
7
6
  res.header('Access-Control-Allow-Origin', req.headers.origin);
8
7
  res.header('Vary', 'Origin');
9
8
  res.header('Access-Control-Allow-Methods', 'GET, OPTIONS');
@@ -0,0 +1 @@
1
+ export declare function createDataConnector(name: string, isInternalTesting: boolean, skipSDKDependency: boolean): Promise<void>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDataConnector = void 0;
4
+ const filesystemutil_1 = require("./filesystemutil");
5
+ const installationutil_1 = require("./installationutil");
6
+ const package_1 = require("./package");
7
+ async function createDataConnector(name, isInternalTesting, skipSDKDependency) {
8
+ console.log('Creating data connector in dataconnectors/' + name);
9
+ (0, filesystemutil_1.copyFolderRecursiveSync)(__dirname + '/../templates/dataconnector', 'dataconnectors/' + name);
10
+ await (0, package_1.modifyManifest)((manifest) => {
11
+ if (!manifest['dataConnectors']) {
12
+ manifest['dataConnectors'] = [];
13
+ }
14
+ manifest['dataConnectors'].push({
15
+ 'name': name,
16
+ 'oauthProviderName': '',
17
+ 'callbackBaseUrl': '',
18
+ 'dataActions': {},
19
+ });
20
+ });
21
+ console.log(`Installing dependencies`);
22
+ process.chdir('dataconnectors/' + name);
23
+ (0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting, skipSDKDependency);
24
+ }
25
+ exports.createDataConnector = createDataConnector;
@@ -5,40 +5,15 @@ const child_process = require("child_process");
5
5
  const express = require("express");
6
6
  const oldFs = require("fs");
7
7
  const fs = require("fs/promises");
8
- const path = require("path");
9
8
  const cors_1 = require("./cors");
10
9
  const filesystemutil_1 = require("./filesystemutil");
10
+ const installationutil_1 = require("./installationutil");
11
11
  const package_1 = require("./package");
12
12
  const packagemanifest_1 = require("./packagemanifest");
13
13
  const shapelibrary_1 = require("./shapelibrary");
14
14
  const shellutil_1 = require("./shellutil");
15
15
  const supportedproduct_1 = require("./supportedproduct");
16
16
  const WebPackCLI = require('webpack-cli');
17
- function linkInternalTestingSDK() {
18
- if (!oldFs.existsSync('node_modules/lucid-extension-sdk')) {
19
- const cwd = process.cwd();
20
- const rootSearch = 'lucid/main/extensibility/';
21
- const pos = cwd.indexOf(rootSearch);
22
- const sdkPath = cwd.substr(0, pos + rootSearch.length) + 'lucid-extension-sdk';
23
- const relativePath = path.relative(cwd, sdkPath);
24
- console.log('Using symlink for dependency on SDK for internal testing');
25
- console.log((0, shellutil_1.execSyncLoggingOutputOnError)(`npm install --silent --save ${relativePath}`).toString());
26
- }
27
- }
28
- function installDependenciesIfNeeded(isInternalTesting, skipSDKDependency = false) {
29
- if (!oldFs.existsSync('node_modules')) {
30
- console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --silent').toString());
31
- }
32
- if (!oldFs.existsSync('node_modules/lucid-extension-sdk') && !skipSDKDependency) {
33
- if (isInternalTesting) {
34
- linkInternalTestingSDK();
35
- }
36
- else {
37
- console.log('Adding dependency on SDK');
38
- console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --save lucid-extension-sdk').toString());
39
- }
40
- }
41
- }
42
17
  async function createEditorExtension(name, isInternalTesting, skipSDKDependency) {
43
18
  console.log('Creating empty editor extension in editorextensions/' + name);
44
19
  (0, filesystemutil_1.copyFolderRecursiveSync)(__dirname + '/../templates/editorextension', 'editorextensions/' + name);
@@ -56,12 +31,12 @@ async function createEditorExtension(name, isInternalTesting, skipSDKDependency)
56
31
  });
57
32
  console.log(`Installing dependencies`);
58
33
  process.chdir('editorextensions/' + name);
59
- installDependenciesIfNeeded(isInternalTesting, skipSDKDependency);
34
+ (0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting, skipSDKDependency);
60
35
  }
61
36
  exports.createEditorExtension = createEditorExtension;
62
37
  async function buildEditorExtension(name, isInternalTesting, quiet = false) {
63
38
  process.chdir('editorextensions/' + (await getExtensionCodeDirectoryName(name)));
64
- installDependenciesIfNeeded(isInternalTesting);
39
+ (0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting);
65
40
  const cli = new WebPackCLI();
66
41
  await cli.run(['node', 'webpack', '--mode', 'production', ...(quiet ? ['--stats', 'errors-only'] : [])]);
67
42
  }
@@ -79,7 +54,7 @@ exports.updateExtensionSDK = updateExtensionSDK;
79
54
  */
80
55
  async function watchEditorExtension(name, isInternalTesting, quiet = false) {
81
56
  process.chdir('editorextensions/' + (await getExtensionCodeDirectoryName(name)));
82
- installDependenciesIfNeeded(isInternalTesting);
57
+ (0, installationutil_1.installDependenciesIfNeeded)(isInternalTesting);
83
58
  const cli = new WebPackCLI();
84
59
  cli.run(['node', 'webpack', '--watch', ...(quiet ? ['--stats', 'errors-only'] : [])]);
85
60
  }
@@ -101,8 +76,7 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
101
76
  const app = express();
102
77
  app.use(cors_1.corsAllowLucid);
103
78
  app.get(['/extension.js', '/editorextension/:name/extension.js'], async (req, res) => {
104
- var _a;
105
- const name = (_a = req.params['name']) !== null && _a !== void 0 ? _a : extensionNames[0];
79
+ const name = req.params['name'] ?? extensionNames[0];
106
80
  const directory = await getExtensionCodeDirectoryName(name);
107
81
  //Give it several seconds for the extension to finish generating before failing.
108
82
  const before = Date.now();
@@ -112,19 +86,16 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
112
86
  res.send((await fs.readFile(`editorextensions/${directory}/bin/extension.js`)).toString());
113
87
  });
114
88
  app.get(['/scopes', '/editorextension/:name/scopes'], async (req, res) => {
115
- var _a, _b, _c;
116
- const name = (_a = req.params['name']) !== null && _a !== void 0 ? _a : extensionNames[0];
89
+ const name = req.params['name'] ?? extensionNames[0];
117
90
  const manifest = await (0, packagemanifest_1.readManifest)('local');
118
- res.send(JSON.stringify((_c = (_b = manifest['extensions']) === null || _b === void 0 ? void 0 : _b.find((extension) => extension['name'] === name)) === null || _c === void 0 ? void 0 : _c.scopes));
91
+ res.send(JSON.stringify(manifest['extensions']?.find((extension) => extension['name'] === name)?.scopes));
119
92
  });
120
93
  app.get('/packageId', async (req, res) => {
121
- var _a;
122
94
  const manifest = await (0, packagemanifest_1.readManifest)('local');
123
- res.send((_a = manifest['id']) !== null && _a !== void 0 ? _a : '__local__');
95
+ res.send(manifest['id'] ?? '__local__');
124
96
  });
125
97
  app.get(['/editorextension', '/editorextension/:name'], async (req, res) => {
126
- var _a;
127
- const name = (_a = req.params['name']) !== null && _a !== void 0 ? _a : extensionNames[0];
98
+ const name = req.params['name'] ?? extensionNames[0];
128
99
  const rawExtension = await getRawEditorExtension(name, port);
129
100
  res.send(rawExtension);
130
101
  });
@@ -132,9 +103,8 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
132
103
  res.send(await Promise.all(extensionNames.map((name) => getRawEditorExtension(name, port))));
133
104
  });
134
105
  app.get('/settings', async (req, res) => {
135
- var _a;
136
106
  const manifest = await (0, packagemanifest_1.readManifest)('local');
137
- const settings = (_a = manifest.settings) !== null && _a !== void 0 ? _a : [];
107
+ const settings = manifest.settings ?? [];
138
108
  res.send(JSON.stringify(settings.map((setting, index) => {
139
109
  return {
140
110
  'Id': '__local__' + index,
@@ -148,11 +118,10 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
148
118
  })));
149
119
  });
150
120
  app.get('/dataConnector/:name', async (req, res) => {
151
- var _a;
152
121
  const name = req.params['name'];
153
122
  if (name) {
154
123
  const manifest = await (0, packagemanifest_1.readManifest)('local');
155
- const connector = (_a = manifest['dataConnectors']) === null || _a === void 0 ? void 0 : _a.find((one) => one.name === name);
124
+ const connector = manifest['dataConnectors']?.find((one) => one.name === name);
156
125
  if (connector) {
157
126
  res.send(JSON.stringify(connector));
158
127
  }
@@ -165,14 +134,13 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
165
134
  }
166
135
  });
167
136
  app.get('/oauthCredentials/:name', async (req, res) => {
168
- var _a;
169
137
  const name = req.params['name'];
170
138
  if (name) {
171
139
  const manifest = await (0, packagemanifest_1.readManifest)('local');
172
- const provider = (_a = manifest['oauthProviders']) === null || _a === void 0 ? void 0 : _a.find((one) => one.name === name);
140
+ const provider = manifest['oauthProviders']?.find((one) => one.name === name);
173
141
  if (provider && oldFs.existsSync(`${name}.credentials.local`)) {
174
142
  const credentials = JSON.parse((await fs.readFile(`${name}.credentials.local`)).toString());
175
- res.send(JSON.stringify(Object.assign(Object.assign({}, provider), credentials)));
143
+ res.send(JSON.stringify({ ...provider, ...credentials }));
176
144
  }
177
145
  else {
178
146
  res.sendStatus(404);
@@ -208,9 +176,8 @@ async function debugEditorExtension(extensionNames, quiet = false, pickAnyPort =
208
176
  }
209
177
  exports.debugEditorExtension = debugEditorExtension;
210
178
  async function getExtensionManifest(name) {
211
- var _a;
212
179
  const manifest = await (0, packagemanifest_1.readManifest)('local');
213
- return { manifest, extensionManifest: (_a = manifest['extensions']) === null || _a === void 0 ? void 0 : _a.find((one) => one['name'] === name) };
180
+ return { manifest, extensionManifest: manifest['extensions']?.find((one) => one['name'] === name) };
214
181
  }
215
182
  /**
216
183
  * We allow the creation of editor extensions that use the same code as a different editor extension in the same
@@ -219,40 +186,37 @@ async function getExtensionManifest(name) {
219
186
  * the same codePath for the chart extension as the spark extension.
220
187
  */
221
188
  async function getExtensionCodeDirectoryName(name) {
222
- var _a;
223
189
  const extensionManifest = (await getExtensionManifest(name)).extensionManifest;
224
- const codePath = extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest['codePath'];
225
- return codePath ? (_a = (await getExtensionCodeDirectoryNameFromCodePath(codePath))) !== null && _a !== void 0 ? _a : name : name;
190
+ const codePath = extensionManifest?.['codePath'];
191
+ return codePath ? (await getExtensionCodeDirectoryNameFromCodePath(codePath)) ?? name : name;
226
192
  }
227
193
  /**
228
194
  * Our codePath has the form '/editorextensions/{extensionName}/bin/extension.js'. This function returns the
229
195
  * extensionName.
230
196
  */
231
197
  async function getExtensionCodeDirectoryNameFromCodePath(codePath) {
232
- var _a;
233
- const parts = (_a = codePath.split('/')) !== null && _a !== void 0 ? _a : [];
198
+ const parts = codePath.split('/') ?? [];
234
199
  if (parts[0] === 'editorextensions' && parts[1]) {
235
200
  return `${parts[1]}`;
236
201
  }
237
202
  return undefined;
238
203
  }
239
204
  async function getRawEditorExtension(name, port) {
240
- var _a, _b, _c;
241
205
  const { manifest, extensionManifest } = await getExtensionManifest(name);
242
- const codePath = extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest['codePath'];
243
- const directory = codePath ? (_a = (await getExtensionCodeDirectoryNameFromCodePath(codePath))) !== null && _a !== void 0 ? _a : name : name;
206
+ const codePath = extensionManifest?.['codePath'];
207
+ const directory = codePath ? (await getExtensionCodeDirectoryNameFromCodePath(codePath)) ?? name : name;
244
208
  const products = extensionManifest
245
209
  ? getExtensionProducts(extensionManifest['product'], extensionManifest['products'])
246
210
  : [supportedproduct_1.SupportedProduct.Chart];
247
211
  return {
248
212
  id: '__local__',
249
- packageId: (_b = manifest['id']) !== null && _b !== void 0 ? _b : '__local__',
213
+ packageId: manifest['id'] ?? '__local__',
250
214
  packageVersionId: '__local__',
251
215
  version: manifest['version'],
252
216
  name: name,
253
- title: (_c = extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest['title']) !== null && _c !== void 0 ? _c : 'Local dev extension',
217
+ title: extensionManifest?.['title'] ?? 'Local dev extension',
254
218
  products: products,
255
- scopes: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest['scopes'],
219
+ scopes: extensionManifest?.['scopes'],
256
220
  codeUrl: `http://localhost:${port}/editorextension/${directory}/extension.js`,
257
221
  };
258
222
  }
package/src/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const argparse_1 = require("argparse");
4
+ const dataconnector_1 = require("./dataconnector");
4
5
  const editorextension_1 = require("./editorextension");
5
6
  const package_1 = require("./package");
6
7
  const shapelibrary_1 = require("./shapelibrary");
7
8
  class LucidSuiteExtensionCLI {
8
9
  async run(args) {
9
- var _a, _b;
10
10
  const parser = new argparse_1.ArgumentParser({
11
11
  description: 'Create and manage Lucid extension packages',
12
12
  });
@@ -102,6 +102,15 @@ class LucidSuiteExtensionCLI {
102
102
  action: 'store_true',
103
103
  help: 'Lock the aspect ratio of all images',
104
104
  });
105
+ const createDataConnectorParser = subparsers.add_parser('create-data-connector', {
106
+ help: 'Create a new data-connector as part of the current package',
107
+ });
108
+ createDataConnectorParser.add_argument('name');
109
+ createDataConnectorParser.add_argument('--skip-sdk', {
110
+ default: false,
111
+ action: 'store_true',
112
+ help: argparse_1.SUPPRESS,
113
+ });
105
114
  const parsed = parser.parse_args(args);
106
115
  //For internal development, creating and operating on a "test" package via bazel
107
116
  let isInternalTesting = !!parsed['chdir'];
@@ -125,87 +134,53 @@ class LucidSuiteExtensionCLI {
125
134
  case 'create':
126
135
  (0, package_1.createEmptyPackage)(parsed['name']);
127
136
  break;
128
- case 'bundle':
129
- if ((0, package_1.currentlyInPackage)()) {
130
- await (0, package_1.writePackage)(parsed['quiet'], parsed['env']);
131
- }
132
- else {
133
- console.error('Not currently in a Lucid extension package folder');
134
- }
135
- break;
136
- case 'update-sdk':
137
- if ((0, package_1.currentlyInPackage)()) {
138
- await (0, package_1.updateAllExtensionSDK)();
139
- }
140
- else {
141
- console.error('Not currently in a Lucid extension package folder');
142
- }
143
- break;
144
- case 'create-editor-extension':
145
- if ((0, package_1.currentlyInPackage)()) {
146
- await (0, editorextension_1.createEditorExtension)(parsed['name'], isInternalTesting, parsed['skip_sdk']);
147
- }
148
- else {
149
- console.error('Not currently in a Lucid extension package folder');
150
- }
151
- break;
152
- case 'build-editor-extension':
153
- if ((0, package_1.currentlyInPackage)()) {
154
- await (0, editorextension_1.buildEditorExtension)(parsed['name'], isInternalTesting, parsed['quiet']);
155
- }
156
- else {
157
- console.error('Not currently in a Lucid extension package folder');
158
- }
159
- break;
160
- case 'create-shape-library':
161
- if ((0, package_1.currentlyInPackage)()) {
162
- await (0, shapelibrary_1.createEmptyShapeLibrary)(parsed['name']);
163
- }
164
- else {
165
- console.error('Not currently in a Lucid extension package folder');
166
- }
167
- break;
168
- case 'create-image-shape-library':
169
- if ((0, package_1.currentlyInPackage)()) {
170
- const width = (_a = Number(parsed['width'])) !== null && _a !== void 0 ? _a : undefined;
171
- const height = (_b = Number(parsed['height'])) !== null && _b !== void 0 ? _b : undefined;
172
- const config = {
173
- width: width,
174
- height: height,
175
- lockAspect: parsed['aspectRatio'],
176
- };
177
- await (0, shapelibrary_1.createImageShapeLibrary)(parsed['name'], parsed['path'], config);
178
- }
179
- else {
180
- console.error('Not currently in a Lucid extension package folder');
181
- }
182
- break;
183
- case 'test-shape-libraries':
184
- if ((0, package_1.currentlyInPackage)()) {
185
- await (0, shapelibrary_1.debugShapeLibraries)();
186
- }
187
- else {
188
- console.error('Not currently in a Lucid extension package folder');
189
- }
190
- break;
191
- case 'test-editor-extension':
192
- if ((0, package_1.currentlyInPackage)()) {
193
- await (0, editorextension_1.debugEditorExtension)(parsed['name'], parsed['quiet'], parsed['anyport']);
194
- }
195
- else {
137
+ default:
138
+ // All the following commands can only be executed inside a Lucid extension package folder
139
+ if (!(0, package_1.currentlyInPackage)()) {
196
140
  console.error('Not currently in a Lucid extension package folder');
197
141
  }
198
- break;
199
- case 'watch-editor-extension':
200
- if ((0, package_1.currentlyInPackage)()) {
201
- await (0, editorextension_1.watchEditorExtension)(parsed['name'], isInternalTesting, parsed['quiet']);
202
- }
203
142
  else {
204
- console.error('Not currently in a Lucid extension package folder');
143
+ switch (parsed['command']) {
144
+ case 'bundle':
145
+ await (0, package_1.writePackage)(parsed['quiet'], parsed['env']);
146
+ case 'update-sdk':
147
+ await (0, package_1.updateAllExtensionSDK)();
148
+ break;
149
+ case 'create-editor-extension':
150
+ await (0, editorextension_1.createEditorExtension)(parsed['name'], isInternalTesting, parsed['skip_sdk']);
151
+ break;
152
+ case 'build-editor-extension':
153
+ await (0, editorextension_1.buildEditorExtension)(parsed['name'], isInternalTesting, parsed['quiet']);
154
+ break;
155
+ case 'create-shape-library':
156
+ await (0, shapelibrary_1.createEmptyShapeLibrary)(parsed['name']);
157
+ break;
158
+ case 'create-image-shape-library':
159
+ const width = Number(parsed['width']) ?? undefined;
160
+ const height = Number(parsed['height']) ?? undefined;
161
+ const config = {
162
+ width: width,
163
+ height: height,
164
+ lockAspect: parsed['aspectRatio'],
165
+ };
166
+ await (0, shapelibrary_1.createImageShapeLibrary)(parsed['name'], parsed['path'], config);
167
+ break;
168
+ case 'create-data-connector':
169
+ await (0, dataconnector_1.createDataConnector)(parsed['name'], isInternalTesting, parsed['skip_sdk']);
170
+ break;
171
+ case 'test-shape-libraries':
172
+ await (0, shapelibrary_1.debugShapeLibraries)();
173
+ break;
174
+ case 'test-editor-extension':
175
+ await (0, editorextension_1.debugEditorExtension)(parsed['name'], parsed['quiet'], parsed['anyport']);
176
+ break;
177
+ case 'watch-editor-extension':
178
+ await (0, editorextension_1.watchEditorExtension)(parsed['name'], isInternalTesting, parsed['quiet']);
179
+ break;
180
+ default:
181
+ parser.print_help();
182
+ }
205
183
  }
206
- break;
207
- default:
208
- parser.print_help();
209
184
  }
210
185
  }
211
186
  }
@@ -0,0 +1 @@
1
+ export declare function installDependenciesIfNeeded(isInternalTesting: boolean, skipSDKDependency?: boolean): void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.installDependenciesIfNeeded = void 0;
4
+ const oldFs = require("fs");
5
+ const path = require("path");
6
+ const shellutil_1 = require("./shellutil");
7
+ function installDependenciesIfNeeded(isInternalTesting, skipSDKDependency = false) {
8
+ if (!oldFs.existsSync('node_modules')) {
9
+ console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --silent').toString());
10
+ }
11
+ if (!oldFs.existsSync('node_modules/lucid-extension-sdk') && !skipSDKDependency) {
12
+ if (isInternalTesting) {
13
+ linkInternalTestingSDK();
14
+ }
15
+ else {
16
+ console.log('Adding dependency on SDK');
17
+ console.log((0, shellutil_1.execSyncLoggingOutputOnError)('npm install --save lucid-extension-sdk').toString());
18
+ }
19
+ }
20
+ }
21
+ exports.installDependenciesIfNeeded = installDependenciesIfNeeded;
22
+ function linkInternalTestingSDK() {
23
+ if (!oldFs.existsSync('node_modules/lucid-extension-sdk')) {
24
+ const cwd = process.cwd();
25
+ const rootSearch = 'lucid/main/extensibility/';
26
+ const pos = cwd.indexOf(rootSearch);
27
+ const sdkPath = cwd.substr(0, pos + rootSearch.length) + 'lucid-extension-sdk';
28
+ const relativePath = path.relative(cwd, sdkPath);
29
+ console.log('Using symlink for dependency on SDK for internal testing');
30
+ console.log((0, shellutil_1.execSyncLoggingOutputOnError)(`npm install --silent --save ${relativePath}`).toString());
31
+ }
32
+ }
@@ -36,8 +36,8 @@ export declare type PackageManifest = {
36
36
  'dataConnectors'?: {
37
37
  'name': string;
38
38
  'oauthProviderName': string;
39
- 'callbackUrl': string;
40
- 'dataActions': string[];
39
+ 'callbackBaseUrl': string;
40
+ 'dataActions': Record<string, string>;
41
41
  }[];
42
42
  'settings'?: {
43
43
  'name': string;
@@ -139,7 +139,6 @@ async function getShapeListJson(name, packagePath, port = 9901) {
139
139
  const manifest = hjson.parse(rawManifest.toString());
140
140
  const usedNames = new Set(manifest['shapes'].map((shape) => shape['key']).filter((key) => key !== undefined));
141
141
  return JSON.stringify(await Promise.all(manifest['shapes'].map(async (shapeManifest, index) => {
142
- var _a, _b, _c, _d;
143
142
  const rawShapeData = await fs.readFile(packagePath + `/shapelibraries/${name}/shapes/${shapeManifest['shape']}.shape`);
144
143
  const shapeData = hjson.parse(rawShapeData.toString());
145
144
  let shapeName = shapeManifest['key'];
@@ -170,7 +169,7 @@ async function getShapeListJson(name, packagePath, port = 9901) {
170
169
  'i18n': {},
171
170
  'locked': shapeData['locked'],
172
171
  'sourcePackage': {
173
- 'packageId': (_a = packageManifest['id']) !== null && _a !== void 0 ? _a : '__local__',
172
+ 'packageId': packageManifest['id'] ?? '__local__',
174
173
  'version': packageManifest['version'],
175
174
  'library': name,
176
175
  'shape': shapeManifest['shape'],
@@ -208,13 +207,13 @@ async function getShapeListJson(name, packagePath, port = 9901) {
208
207
  }
209
208
  for (var key in shapeManifest['defaults']) {
210
209
  if (key !== 'width' && key !== 'height') {
211
- const outName = (_b = defaultNameMap.get(key)) !== null && _b !== void 0 ? _b : key;
210
+ const outName = defaultNameMap.get(key) ?? key;
212
211
  properties[outName] = shapeManifest['defaults'][key];
213
212
  }
214
213
  }
215
- if (((_c = shapeData['locked']) === null || _c === void 0 ? void 0 : _c.includes('aspectRatio')) && !properties['AspectRatio']) {
214
+ if (shapeData['locked']?.includes('aspectRatio') && !properties['AspectRatio']) {
216
215
  properties['AspectRatio'] =
217
- (_d = shapeManifest['defaults']['width'] / shapeManifest['defaults']['height']) !== null && _d !== void 0 ? _d : 1;
216
+ shapeManifest['defaults']['width'] / shapeManifest['defaults']['height'] ?? 1;
218
217
  }
219
218
  return {
220
219
  'class': 'CustomBlock',
@@ -263,9 +262,8 @@ async function debugShapeLibraries(packagePath = '.', pickAnyPort = false) {
263
262
  //shape library, the toolbox doesn't update.
264
263
  let shapeLibraryVersion = Date.now();
265
264
  app.get('/shapeLibraries', async (req, res) => {
266
- var _a;
267
265
  const manifest = await (0, packagemanifest_1.readManifest)('local', packagePath + '/');
268
- const libraries = (_a = manifest['shapeLibraries']) !== null && _a !== void 0 ? _a : [];
266
+ const libraries = manifest['shapeLibraries'] ?? [];
269
267
  const output = await Promise.all(libraries.map(async (libraryManifest) => {
270
268
  const libraryDefinitionContent = await fs.readFile(packagePath + '/shapelibraries/' + libraryManifest['name'] + '/library.manifest');
271
269
  const libraryDefinition = JSON.parse(libraryDefinitionContent.toString());
@@ -0,0 +1 @@
1
+ This directory will contain actions performed by the data-connector
@@ -0,0 +1,7 @@
1
+ import * as crypto from 'crypto';
2
+ import * as express from 'express';
3
+ import {DataConnectorClient} from 'lucid-extension-sdk';
4
+ import {makeDataConnector} from './index';
5
+
6
+ const dataConnector = makeDataConnector(new DataConnectorClient({crypto, Buffer}));
7
+ dataConnector.runDebugServer({express});
@@ -0,0 +1,3 @@
1
+ import {DataConnector, DataConnectorClient} from 'lucid-extension-sdk';
2
+
3
+ export const makeDataConnector = (client: DataConnectorClient) => new DataConnector(client);
@@ -0,0 +1,16 @@
1
+ {
2
+ "devDependencies": {
3
+ "@types/express": "^4.17.13",
4
+ "@types/node": "^16.11.11",
5
+ "nodemon": "^2.0.19",
6
+ "ts-node": "^10.9.1",
7
+ "typescript": "^4.9.5"
8
+ },
9
+ "dependencies": {
10
+ "axios": "^0.27.2",
11
+ "express": "^4.18.1"
12
+ },
13
+ "engines": {
14
+ "node": ">=14.0.0"
15
+ }
16
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "emitDecoratorMetadata": true,
5
+ "experimentalDecorators": true,
6
+ "forceConsistentCasingInFileNames": true,
7
+ "module": "commonjs",
8
+ "moduleResolution": "node",
9
+ "newLine": "lf",
10
+ "noEmitOnError": false,
11
+ "noImplicitAny": true,
12
+ "noImplicitReturns": true,
13
+ "noImplicitThis": true,
14
+ "noUnusedLocals": false,
15
+ "pretty": true,
16
+ "removeComments": false,
17
+ "skipLibCheck": true,
18
+ "sourceMap": false,
19
+ "strictBindCallApply": true,
20
+ "strictFunctionTypes": true,
21
+ "strictNullChecks": true,
22
+ "strictPropertyInitialization": true,
23
+ "target": "ES2017",
24
+ "types": ["node"],
25
+ "lib": [
26
+ "es5",
27
+ "es6",
28
+ "ES2016.Array.Include",
29
+ "ES2017.String",
30
+ "ES2018.Promise",
31
+ "ES2017.Object",
32
+ "esnext.asynciterable"
33
+ ],
34
+ "outDir": "bin"
35
+ }
36
+ }