lucid-package 0.0.36 → 0.0.38
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 +2 -2
- package/src/packagemanifest.d.ts +10 -1
- package/src/packagemanifest.js +40 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lucid-package",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
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.
|
|
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",
|
package/src/packagemanifest.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export declare enum SettingType {
|
|
2
|
+
STRING = "string"
|
|
3
|
+
}
|
|
1
4
|
export declare type PackageManifest = {
|
|
2
5
|
'id'?: string;
|
|
3
6
|
'version': string;
|
|
@@ -6,7 +9,7 @@ export declare type PackageManifest = {
|
|
|
6
9
|
'title': string;
|
|
7
10
|
'codePath': string;
|
|
8
11
|
'scopes': string[];
|
|
9
|
-
'product': 'chart' | 'spark';
|
|
12
|
+
'product': 'chart' | 'spark' | 'teamspaces';
|
|
10
13
|
}[];
|
|
11
14
|
'shapeLibraries'?: {
|
|
12
15
|
'name': string;
|
|
@@ -33,6 +36,12 @@ export declare type PackageManifest = {
|
|
|
33
36
|
'callbackUrl': string;
|
|
34
37
|
'callbackEvents': string[];
|
|
35
38
|
}[];
|
|
39
|
+
'settings'?: {
|
|
40
|
+
'name': string;
|
|
41
|
+
'label': string;
|
|
42
|
+
'description': string;
|
|
43
|
+
'type': SettingType;
|
|
44
|
+
}[];
|
|
36
45
|
};
|
|
37
46
|
/**
|
|
38
47
|
* @param manifestOverrideEnv The environment to override the manifest with
|
package/src/packagemanifest.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
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
|
+
var SettingType;
|
|
9
|
+
(function (SettingType) {
|
|
10
|
+
SettingType["STRING"] = "string";
|
|
11
|
+
})(SettingType = exports.SettingType || (exports.SettingType = {}));
|
|
7
12
|
const versionRegex = /^\d+\.\d+\.\d+$/;
|
|
8
13
|
function validateManifestOrThrow(manifest) {
|
|
9
14
|
if (!(0, checks_1.isObject)(manifest)) {
|
|
@@ -12,10 +17,36 @@ function validateManifestOrThrow(manifest) {
|
|
|
12
17
|
if (!(0, checks_1.isString)(manifest['version']) || !versionRegex.test(manifest['version'])) {
|
|
13
18
|
throw new Error('manifest.json: "version" must be a string in the format <major>.<minor>.<patch>');
|
|
14
19
|
}
|
|
20
|
+
function validateUniqueNames(kindOfThings, things) {
|
|
21
|
+
if (new Set(things.map((one) => one['name'])).size !== things.length) {
|
|
22
|
+
throw new Error(kindOfThings + ' must have unique named');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (manifest['settings']) {
|
|
26
|
+
if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['settings'])) {
|
|
27
|
+
throw new Error('manifest.json: "settings" must be an array of objects');
|
|
28
|
+
}
|
|
29
|
+
validateUniqueNames('settings', manifest['settings']);
|
|
30
|
+
for (const setting of manifest['settings']) {
|
|
31
|
+
if (!(0, checks_1.isString)(setting['name'])) {
|
|
32
|
+
throw new Error('manifest.json: setting "name" must be a string');
|
|
33
|
+
}
|
|
34
|
+
if (!(0, checks_1.isString)(setting['label'])) {
|
|
35
|
+
throw new Error('manifest.json: setting "label" must be a string');
|
|
36
|
+
}
|
|
37
|
+
if (!(0, checks_1.isString)(setting['description'])) {
|
|
38
|
+
throw new Error('manifest.json: setting "description" must be a string');
|
|
39
|
+
}
|
|
40
|
+
if (!(0, validators_1.enumValidator)(SettingType)(setting['type'])) {
|
|
41
|
+
throw new Error('manifest.json: setting "type" must be "string"');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
15
45
|
if (manifest['extensions']) {
|
|
16
46
|
if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['extensions'])) {
|
|
17
47
|
throw new Error('manifest.json: "extensions" must be an array of objects');
|
|
18
48
|
}
|
|
49
|
+
validateUniqueNames('extensions', manifest['extensions']);
|
|
19
50
|
for (const extension of manifest['extensions']) {
|
|
20
51
|
if (!(0, checks_1.isString)(extension['name'])) {
|
|
21
52
|
throw new Error('manifest.json: extension "name" must be a string');
|
|
@@ -29,8 +60,10 @@ function validateManifestOrThrow(manifest) {
|
|
|
29
60
|
if (!(0, checks_1.isTypedArray)(checks_1.isString)(extension['scopes'])) {
|
|
30
61
|
throw new Error('manifest.json: extension "scopes" must be a string array');
|
|
31
62
|
}
|
|
32
|
-
if (extension['product'] !== 'chart' &&
|
|
33
|
-
|
|
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"`);
|
|
34
67
|
}
|
|
35
68
|
}
|
|
36
69
|
}
|
|
@@ -38,6 +71,7 @@ function validateManifestOrThrow(manifest) {
|
|
|
38
71
|
if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['shapeLibraries'])) {
|
|
39
72
|
throw new Error('manifest.json: "shapeLibraries" must be an array of objects');
|
|
40
73
|
}
|
|
74
|
+
validateUniqueNames('shapeLibraries', manifest['shapeLibraries']);
|
|
41
75
|
for (const shapeLibrary of manifest['shapeLibraries']) {
|
|
42
76
|
if (!(0, checks_1.isString)(shapeLibrary['name'])) {
|
|
43
77
|
throw new Error('manifest.json: shape library "name" must be a string');
|
|
@@ -54,6 +88,7 @@ function validateManifestOrThrow(manifest) {
|
|
|
54
88
|
if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['oauthProviders'])) {
|
|
55
89
|
throw new Error('manifest.json: "oauthProviders" must be an array of objects');
|
|
56
90
|
}
|
|
91
|
+
validateUniqueNames('oauthProviders', manifest['oauthProviders']);
|
|
57
92
|
for (const provider of manifest['oauthProviders']) {
|
|
58
93
|
if (!(0, checks_1.isString)(provider['name'])) {
|
|
59
94
|
throw new Error('manifest.json: OAuth provider "name" must be a string');
|
|
@@ -91,6 +126,7 @@ function validateManifestOrThrow(manifest) {
|
|
|
91
126
|
if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['mergeProviders'])) {
|
|
92
127
|
throw new Error('manifest.json: "mergeProviders" must be an array of objects');
|
|
93
128
|
}
|
|
129
|
+
validateUniqueNames('mergeProviders', manifest['mergeProviders']);
|
|
94
130
|
for (const provider of manifest['mergeProviders']) {
|
|
95
131
|
if (!(0, checks_1.isString)(provider['name'])) {
|
|
96
132
|
throw new Error('manifest.json: Merge provider "name" must be a string');
|
|
@@ -110,6 +146,7 @@ function validateManifestOrThrow(manifest) {
|
|
|
110
146
|
if (!(0, checks_1.isTypedArray)(checks_1.isObject)(manifest['dataConnectors'])) {
|
|
111
147
|
throw new Error('manifest.json: "dataConnectors" must be an array of objects');
|
|
112
148
|
}
|
|
149
|
+
validateUniqueNames('dataConnectors', manifest['dataConnectors']);
|
|
113
150
|
for (const provider of manifest['dataConnectors']) {
|
|
114
151
|
if (!(0, checks_1.isString)(provider['name'])) {
|
|
115
152
|
throw new Error('manifest.json: Data connector "name" must be a string');
|