lucid-package 0.0.38 → 0.0.39

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.38",
3
+ "version": "0.0.39",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -11,6 +11,7 @@ const package_1 = require("./package");
11
11
  const packagemanifest_1 = require("./packagemanifest");
12
12
  const shapelibrary_1 = require("./shapelibrary");
13
13
  const shellutil_1 = require("./shellutil");
14
+ const supportedproduct_1 = require("./supportedproduct");
14
15
  const WebPackCLI = require('webpack-cli');
15
16
  function linkInternalTestingSDK() {
16
17
  if (!oldFs.existsSync('node_modules/lucid-extension-sdk')) {
@@ -47,7 +48,7 @@ async function createEditorExtension(name, isInternalTesting) {
47
48
  manifest['extensions'].push({
48
49
  'name': name,
49
50
  'title': name,
50
- 'product': 'chart',
51
+ 'products': [supportedproduct_1.SupportedProduct.Chart],
51
52
  'codePath': `editorextensions/${name}/bin/extension.js`,
52
53
  'scopes': ['READ', 'WRITE', 'DOWNLOAD', 'SHOW_MODAL', 'CUSTOM_UI', 'NETWORK'],
53
54
  });
@@ -186,10 +187,13 @@ async function getExtensionCodeDirectoryNameFromCodePath(codePath) {
186
187
  return undefined;
187
188
  }
188
189
  async function getRawEditorExtension(name) {
189
- var _a, _b, _c, _d;
190
+ var _a, _b, _c;
190
191
  const { manifest, extensionManifest } = await getExtensionManifest(name);
191
192
  const codePath = extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest['codePath'];
192
193
  const directory = codePath ? (_a = (await getExtensionCodeDirectoryNameFromCodePath(codePath))) !== null && _a !== void 0 ? _a : name : name;
194
+ const products = extensionManifest
195
+ ? getExtensionProducts(extensionManifest['product'], extensionManifest['products'])
196
+ : [supportedproduct_1.SupportedProduct.Chart];
193
197
  return {
194
198
  id: '__local__',
195
199
  packageId: (_b = manifest['id']) !== null && _b !== void 0 ? _b : '__local__',
@@ -197,8 +201,17 @@ async function getRawEditorExtension(name) {
197
201
  version: manifest['version'],
198
202
  name: name,
199
203
  title: (_c = extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest['title']) !== null && _c !== void 0 ? _c : 'Local dev extension',
200
- product: (_d = extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest['product']) !== null && _d !== void 0 ? _d : 'chart',
204
+ products: products,
201
205
  scopes: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest['scopes'],
202
206
  codeUrl: `http://localhost:9900/editorextension/${directory}/extension.js`,
203
207
  };
204
208
  }
209
+ function getExtensionProducts(product, products) {
210
+ if (products && products.length !== 0) {
211
+ return products;
212
+ }
213
+ if (product) {
214
+ return [product];
215
+ }
216
+ throw new Error('Either "product" or "products" must be spcified for the editor extension in the package manifest');
217
+ }
@@ -1,3 +1,4 @@
1
+ import { SupportedProduct } from './supportedproduct';
1
2
  export declare enum SettingType {
2
3
  STRING = "string"
3
4
  }
@@ -9,7 +10,8 @@ export declare type PackageManifest = {
9
10
  'title': string;
10
11
  'codePath': string;
11
12
  'scopes': string[];
12
- 'product': 'chart' | 'spark' | 'teamspaces';
13
+ 'product'?: SupportedProduct;
14
+ 'products'?: SupportedProduct[];
13
15
  }[];
14
16
  'shapeLibraries'?: {
15
17
  'name': string;
@@ -5,6 +5,7 @@ const fs = require("fs");
5
5
  const fsPromises = require("fs/promises");
6
6
  const checks_1 = require("lucid-extension-sdk/sdk/core/checks");
7
7
  const validators_1 = require("lucid-extension-sdk/sdk/core/validators/validators");
8
+ const supportedproduct_1 = require("./supportedproduct");
8
9
  var SettingType;
9
10
  (function (SettingType) {
10
11
  SettingType["STRING"] = "string";
@@ -60,10 +61,21 @@ function validateManifestOrThrow(manifest) {
60
61
  if (!(0, checks_1.isTypedArray)(checks_1.isString)(extension['scopes'])) {
61
62
  throw new Error('manifest.json: extension "scopes" must be a string array');
62
63
  }
63
- if (extension['product'] !== 'chart' &&
64
- extension['product'] !== 'spark' &&
65
- extension['product'] !== 'teamspaces') {
66
- throw new Error(`manifest.json: found ${extension['product']}. extension "product" must be "chart" or "spark" or "teamspaces"`);
64
+ if ((extension['product'] && extension['products']) ||
65
+ (!(0, checks_1.isDef)(extension['product']) && !(0, checks_1.isDef)(extension['products']))) {
66
+ throw new Error('either the "product" or "products" field must be specified and not both');
67
+ }
68
+ const supportedProducts = Object.values(supportedproduct_1.SupportedProduct);
69
+ if (extension['product']) {
70
+ if (!(0, validators_1.enumValidator)(supportedproduct_1.SupportedProduct)(extension['product'])) {
71
+ throw new Error(`manifest.json: found ${extension['product']}. extension "product" must be one of ${supportedProducts}`);
72
+ }
73
+ }
74
+ if (extension['products']) {
75
+ if (!(0, checks_1.isTypedArray)((0, validators_1.enumValidator)(supportedproduct_1.SupportedProduct))(extension['products']) ||
76
+ extension['products'].length === 0) {
77
+ throw new Error(`manifest.json: found ${extension['products']}. extension "products" must be an array containing values from ${supportedProducts}`);
78
+ }
67
79
  }
68
80
  }
69
81
  }
@@ -0,0 +1,5 @@
1
+ export declare enum SupportedProduct {
2
+ Chart = "chart",
3
+ Spark = "spark",
4
+ TeamSpaces = "teamspaces"
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SupportedProduct = void 0;
4
+ var SupportedProduct;
5
+ (function (SupportedProduct) {
6
+ SupportedProduct["Chart"] = "chart";
7
+ SupportedProduct["Spark"] = "spark";
8
+ SupportedProduct["TeamSpaces"] = "teamspaces";
9
+ })(SupportedProduct = exports.SupportedProduct || (exports.SupportedProduct = {}));