lucid-package 0.0.37 → 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.37",
3
+ "version": "0.0.39",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -23,7 +23,7 @@
23
23
  "express": "^4.17.1",
24
24
  "hjson": "^3.2.2",
25
25
  "jszip": "^3.7.1",
26
- "lucid-extension-sdk": "^0.0.8",
26
+ "lucid-extension-sdk": "^0.0.73",
27
27
  "password-prompt": "^1.1.2",
28
28
  "ts-loader": "^9.2.6",
29
29
  "webpack": "^5.64.4",
@@ -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,7 @@
1
+ import { SupportedProduct } from './supportedproduct';
2
+ export declare enum SettingType {
3
+ STRING = "string"
4
+ }
1
5
  export declare type PackageManifest = {
2
6
  'id'?: string;
3
7
  'version': string;
@@ -6,7 +10,8 @@ export declare type PackageManifest = {
6
10
  'title': string;
7
11
  'codePath': string;
8
12
  'scopes': string[];
9
- 'product': 'chart' | 'spark' | 'teamspaces';
13
+ 'product'?: SupportedProduct;
14
+ 'products'?: SupportedProduct[];
10
15
  }[];
11
16
  'shapeLibraries'?: {
12
17
  'name': string;
@@ -33,6 +38,12 @@ export declare type PackageManifest = {
33
38
  'callbackUrl': string;
34
39
  'callbackEvents': string[];
35
40
  }[];
41
+ 'settings'?: {
42
+ 'name': string;
43
+ 'label': string;
44
+ 'description': string;
45
+ 'type': SettingType;
46
+ }[];
36
47
  };
37
48
  /**
38
49
  * @param manifestOverrideEnv The environment to override the manifest with
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readManifest = void 0;
3
+ exports.readManifest = exports.SettingType = void 0;
4
4
  const fs = require("fs");
5
5
  const fsPromises = require("fs/promises");
6
6
  const checks_1 = require("lucid-extension-sdk/sdk/core/checks");
7
+ const validators_1 = require("lucid-extension-sdk/sdk/core/validators/validators");
8
+ const supportedproduct_1 = require("./supportedproduct");
9
+ var SettingType;
10
+ (function (SettingType) {
11
+ SettingType["STRING"] = "string";
12
+ })(SettingType = exports.SettingType || (exports.SettingType = {}));
7
13
  const versionRegex = /^\d+\.\d+\.\d+$/;
8
14
  function validateManifestOrThrow(manifest) {
9
15
  if (!(0, checks_1.isObject)(manifest)) {
@@ -12,10 +18,36 @@ function validateManifestOrThrow(manifest) {
12
18
  if (!(0, checks_1.isString)(manifest['version']) || !versionRegex.test(manifest['version'])) {
13
19
  throw new Error('manifest.json: "version" must be a string in the format <major>.<minor>.<patch>');
14
20
  }
21
+ function validateUniqueNames(kindOfThings, things) {
22
+ if (new Set(things.map((one) => one['name'])).size !== things.length) {
23
+ throw new Error(kindOfThings + ' must have unique named');
24
+ }
25
+ }
26
+ if (manifest['settings']) {
27
+ if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['settings'])) {
28
+ throw new Error('manifest.json: "settings" must be an array of objects');
29
+ }
30
+ validateUniqueNames('settings', manifest['settings']);
31
+ for (const setting of manifest['settings']) {
32
+ if (!(0, checks_1.isString)(setting['name'])) {
33
+ throw new Error('manifest.json: setting "name" must be a string');
34
+ }
35
+ if (!(0, checks_1.isString)(setting['label'])) {
36
+ throw new Error('manifest.json: setting "label" must be a string');
37
+ }
38
+ if (!(0, checks_1.isString)(setting['description'])) {
39
+ throw new Error('manifest.json: setting "description" must be a string');
40
+ }
41
+ if (!(0, validators_1.enumValidator)(SettingType)(setting['type'])) {
42
+ throw new Error('manifest.json: setting "type" must be "string"');
43
+ }
44
+ }
45
+ }
15
46
  if (manifest['extensions']) {
16
47
  if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['extensions'])) {
17
48
  throw new Error('manifest.json: "extensions" must be an array of objects');
18
49
  }
50
+ validateUniqueNames('extensions', manifest['extensions']);
19
51
  for (const extension of manifest['extensions']) {
20
52
  if (!(0, checks_1.isString)(extension['name'])) {
21
53
  throw new Error('manifest.json: extension "name" must be a string');
@@ -29,10 +61,21 @@ function validateManifestOrThrow(manifest) {
29
61
  if (!(0, checks_1.isTypedArray)(checks_1.isString)(extension['scopes'])) {
30
62
  throw new Error('manifest.json: extension "scopes" must be a string array');
31
63
  }
32
- if (extension['product'] !== 'chart' &&
33
- extension['product'] !== 'spark' &&
34
- extension['product'] !== 'teamspaces') {
35
- 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
+ }
36
79
  }
37
80
  }
38
81
  }
@@ -40,6 +83,7 @@ function validateManifestOrThrow(manifest) {
40
83
  if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['shapeLibraries'])) {
41
84
  throw new Error('manifest.json: "shapeLibraries" must be an array of objects');
42
85
  }
86
+ validateUniqueNames('shapeLibraries', manifest['shapeLibraries']);
43
87
  for (const shapeLibrary of manifest['shapeLibraries']) {
44
88
  if (!(0, checks_1.isString)(shapeLibrary['name'])) {
45
89
  throw new Error('manifest.json: shape library "name" must be a string');
@@ -56,6 +100,7 @@ function validateManifestOrThrow(manifest) {
56
100
  if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['oauthProviders'])) {
57
101
  throw new Error('manifest.json: "oauthProviders" must be an array of objects');
58
102
  }
103
+ validateUniqueNames('oauthProviders', manifest['oauthProviders']);
59
104
  for (const provider of manifest['oauthProviders']) {
60
105
  if (!(0, checks_1.isString)(provider['name'])) {
61
106
  throw new Error('manifest.json: OAuth provider "name" must be a string');
@@ -93,6 +138,7 @@ function validateManifestOrThrow(manifest) {
93
138
  if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['mergeProviders'])) {
94
139
  throw new Error('manifest.json: "mergeProviders" must be an array of objects');
95
140
  }
141
+ validateUniqueNames('mergeProviders', manifest['mergeProviders']);
96
142
  for (const provider of manifest['mergeProviders']) {
97
143
  if (!(0, checks_1.isString)(provider['name'])) {
98
144
  throw new Error('manifest.json: Merge provider "name" must be a string');
@@ -112,6 +158,7 @@ function validateManifestOrThrow(manifest) {
112
158
  if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['dataConnectors'])) {
113
159
  throw new Error('manifest.json: "dataConnectors" must be an array of objects');
114
160
  }
161
+ validateUniqueNames('dataConnectors', manifest['dataConnectors']);
115
162
  for (const provider of manifest['dataConnectors']) {
116
163
  if (!(0, checks_1.isString)(provider['name'])) {
117
164
  throw new Error('manifest.json: Data connector "name" must be a string');
@@ -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 = {}));