@betty-blocks/cli 26.0.0-beta.9 → 26.0.1
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/README.md +2 -16
- package/assets/app-functions/wasm-template/.wasm-functions +0 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/Cargo.lock +449 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/Cargo.toml +10 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/Justfile +12 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/function.json +35 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/src/lib.rs +19 -0
- package/assets/app-functions/wasm-template/functions/say-hello/1.0/wit/world.wit +13 -0
- package/build/bb-blocks-new.d.ts +1 -0
- package/build/bb-blocks-new.js +26 -0
- package/build/bb-blocks-new.js.map +1 -0
- package/build/bb-blocks-publish.d.ts +1 -0
- package/build/bb-blocks-publish.js +98 -0
- package/build/bb-blocks-publish.js.map +1 -0
- package/build/bb-blocks-release.d.ts +1 -0
- package/build/bb-blocks-release.js +18 -0
- package/build/bb-blocks-release.js.map +1 -0
- package/build/bb-blocks.d.ts +1 -0
- package/build/bb-blocks.js +17 -0
- package/build/bb-blocks.js.map +1 -0
- package/build/bb-bundle-init.d.ts +1 -0
- package/build/bb-bundle-init.js +33 -0
- package/build/bb-bundle-init.js.map +1 -0
- package/build/bb-bundle.d.ts +1 -0
- package/build/bb-bundle.js +17 -0
- package/build/bb-bundle.js.map +1 -0
- package/build/bb-components-build.d.ts +1 -0
- package/build/bb-components-build.js +416 -0
- package/build/bb-components-build.js.map +1 -0
- package/build/bb-components-create.d.ts +1 -0
- package/build/bb-components-create.js +41 -0
- package/build/bb-components-create.js.map +1 -0
- package/build/bb-components-generate.d.ts +1 -0
- package/build/bb-components-generate.js +168 -0
- package/build/bb-components-generate.js.map +1 -0
- package/build/bb-components-publish-bundle.d.ts +1 -0
- package/build/bb-components-publish-bundle.js +50 -0
- package/build/bb-components-publish-bundle.js.map +1 -0
- package/build/bb-components-publish.d.ts +1 -0
- package/build/bb-components-publish.js +57 -0
- package/build/bb-components-publish.js.map +1 -0
- package/build/bb-components-serve.d.ts +1 -0
- package/build/bb-components-serve.js +35 -0
- package/build/bb-components-serve.js.map +1 -0
- package/build/bb-components.d.ts +1 -0
- package/build/bb-components.js +29 -0
- package/build/bb-components.js.map +1 -0
- package/build/bb-functions-bump.d.ts +1 -0
- package/build/bb-functions-bump.js +37 -0
- package/build/bb-functions-bump.js.map +1 -0
- package/build/bb-functions-init.d.ts +1 -0
- package/build/bb-functions-init.js +31 -0
- package/build/bb-functions-init.js.map +1 -0
- package/build/bb-functions-login.d.ts +1 -0
- package/build/bb-functions-login.js +17 -0
- package/build/bb-functions-login.js.map +1 -0
- package/build/bb-functions-logout.d.ts +1 -0
- package/build/bb-functions-logout.js +10 -0
- package/build/bb-functions-logout.js.map +1 -0
- package/build/bb-functions-new.d.ts +1 -0
- package/build/bb-functions-new.js +25 -0
- package/build/bb-functions-new.js.map +1 -0
- package/build/bb-functions-publish.d.ts +1 -0
- package/build/bb-functions-publish.js +52 -0
- package/build/bb-functions-publish.js.map +1 -0
- package/build/bb-functions-validate.d.ts +1 -0
- package/build/bb-functions-validate.js +17 -0
- package/build/bb-functions-validate.js.map +1 -0
- package/build/bb-functions.d.ts +1 -0
- package/build/bb-functions.js +29 -0
- package/build/bb-functions.js.map +1 -0
- package/build/bb.d.ts +2 -0
- package/build/bb.js +27 -0
- package/build/bb.js.map +1 -0
- package/build/blocks/blockDefinitions.d.ts +10 -0
- package/build/blocks/blockDefinitions.js +62 -0
- package/build/blocks/blockDefinitions.js.map +1 -0
- package/build/blocks/publishBlocks.d.ts +2 -0
- package/build/blocks/publishBlocks.js +54 -0
- package/build/blocks/publishBlocks.js.map +1 -0
- package/build/blocks/releaseBlocks.d.ts +5 -0
- package/build/blocks/releaseBlocks.js +78 -0
- package/build/blocks/releaseBlocks.js.map +1 -0
- package/build/components/bb-components-functions.d.ts +10 -0
- package/build/components/bb-components-functions.js +40 -0
- package/build/components/bb-components-functions.js.map +1 -0
- package/build/components/comments.d.ts +3 -0
- package/build/components/comments.js +78 -0
- package/build/components/comments.js.map +1 -0
- package/build/components/compatibility.d.ts +7 -0
- package/build/components/compatibility.js +60 -0
- package/build/components/compatibility.js.map +1 -0
- package/build/components/transformers/index.d.ts +3 -0
- package/build/components/transformers/index.js +36 -0
- package/build/components/transformers/index.js.map +1 -0
- package/build/components-build/index.d.ts +2 -0
- package/build/components-build/index.js +3 -0
- package/build/components-build/index.js.map +1 -0
- package/build/components-build/reportDiagnostics.d.ts +2 -0
- package/build/components-build/reportDiagnostics.js +13 -0
- package/build/components-build/reportDiagnostics.js.map +1 -0
- package/build/components-build/styles.d.ts +4 -0
- package/build/components-build/styles.js +87 -0
- package/build/components-build/styles.js.map +1 -0
- package/build/functions/config.d.ts +67 -0
- package/build/functions/config.js +190 -0
- package/build/functions/config.js.map +1 -0
- package/build/functions/createWasmDefinitionFiles.d.ts +4 -0
- package/build/functions/createWasmDefinitionFiles.js +61 -0
- package/build/functions/createWasmDefinitionFiles.js.map +1 -0
- package/build/functions/functionDefinitions.d.ts +23 -0
- package/build/functions/functionDefinitions.js +229 -0
- package/build/functions/functionDefinitions.js.map +1 -0
- package/build/functions/functionVersionBump.d.ts +19 -0
- package/build/functions/functionVersionBump.js +62 -0
- package/build/functions/functionVersionBump.js.map +1 -0
- package/build/functions/publishAppFunctions.d.ts +13 -0
- package/build/functions/publishAppFunctions.js +90 -0
- package/build/functions/publishAppFunctions.js.map +1 -0
- package/build/functions/publishWasmBlockStoreFunctions.d.ts +1 -0
- package/build/functions/publishWasmBlockStoreFunctions.js +100 -0
- package/build/functions/publishWasmBlockStoreFunctions.js.map +1 -0
- package/build/functions/utils.d.ts +2 -0
- package/build/functions/utils.js +20 -0
- package/build/functions/utils.js.map +1 -0
- package/build/functions/validateFunctions.d.ts +3 -0
- package/build/functions/validateFunctions.js +23 -0
- package/build/functions/validateFunctions.js.map +1 -0
- package/build/functions/validations.d.ts +31 -0
- package/build/functions/validations.js +140 -0
- package/build/functions/validations.js.map +1 -0
- package/build/interactions/compatibility.d.ts +3 -0
- package/build/interactions/compatibility.js +84 -0
- package/build/interactions/compatibility.js.map +1 -0
- package/build/interactions/diagnostics.d.ts +2 -0
- package/build/interactions/diagnostics.js +23 -0
- package/build/interactions/diagnostics.js.map +1 -0
- package/build/types.d.ts +377 -0
- package/build/types.js +40 -0
- package/build/types.js.map +1 -0
- package/build/utils/arguments.d.ts +2 -0
- package/build/utils/arguments.js +6 -0
- package/build/utils/arguments.js.map +1 -0
- package/build/utils/checkPackageVersion.d.ts +1 -0
- package/build/utils/checkPackageVersion.js +10 -0
- package/build/utils/checkPackageVersion.js.map +1 -0
- package/build/utils/checkUpdateAvailable.d.ts +1 -0
- package/build/utils/checkUpdateAvailable.js +65 -0
- package/build/utils/checkUpdateAvailable.js.map +1 -0
- package/build/utils/fusionAuth.d.ts +21 -0
- package/build/utils/fusionAuth.js +108 -0
- package/build/utils/fusionAuth.js.map +1 -0
- package/build/utils/hash.d.ts +2 -0
- package/build/utils/hash.js +3 -0
- package/build/utils/hash.js.map +1 -0
- package/build/utils/login.d.ts +15 -0
- package/build/utils/login.js +116 -0
- package/build/utils/login.js.map +1 -0
- package/build/utils/pick.d.ts +7 -0
- package/build/utils/pick.js +16 -0
- package/build/utils/pick.js.map +1 -0
- package/build/utils/readFilesByType.d.ts +2 -0
- package/build/utils/readFilesByType.js +23 -0
- package/build/utils/readFilesByType.js.map +1 -0
- package/build/utils/rootDir.d.ts +2 -0
- package/build/utils/rootDir.js +4 -0
- package/build/utils/rootDir.js.map +1 -0
- package/build/utils/serveComponentSet.d.ts +3 -0
- package/build/utils/serveComponentSet.js +52 -0
- package/build/utils/serveComponentSet.js.map +1 -0
- package/build/utils/transpile.d.ts +2 -0
- package/build/utils/transpile.js +25 -0
- package/build/utils/transpile.js.map +1 -0
- package/build/utils/uploadBlob.d.ts +24 -0
- package/build/utils/uploadBlob.js +56 -0
- package/build/utils/uploadBlob.js.map +1 -0
- package/build/utils/validation.d.ts +4 -0
- package/build/utils/validation.js +74 -0
- package/build/utils/validation.js.map +1 -0
- package/build/validations/component.d.ts +3 -0
- package/build/validations/component.js +56 -0
- package/build/validations/component.js.map +1 -0
- package/build/validations/constants.d.ts +16 -0
- package/build/validations/constants.js +208 -0
- package/build/validations/constants.js.map +1 -0
- package/build/validations/function-block-validations/index.d.ts +22 -0
- package/build/validations/function-block-validations/index.js +72 -0
- package/build/validations/function-block-validations/index.js.map +1 -0
- package/build/validations/interaction.d.ts +3 -0
- package/build/validations/interaction.js +22 -0
- package/build/validations/interaction.js.map +1 -0
- package/build/validations/prefab/action.d.ts +2 -0
- package/build/validations/prefab/action.js +99 -0
- package/build/validations/prefab/action.js.map +1 -0
- package/build/validations/prefab/component.d.ts +10 -0
- package/build/validations/prefab/component.js +290 -0
- package/build/validations/prefab/component.js.map +1 -0
- package/build/validations/prefab/componentOption.d.ts +3 -0
- package/build/validations/prefab/componentOption.js +176 -0
- package/build/validations/prefab/componentOption.js.map +1 -0
- package/build/validations/prefab/interaction.d.ts +2 -0
- package/build/validations/prefab/interaction.js +38 -0
- package/build/validations/prefab/interaction.js.map +1 -0
- package/build/validations/prefab/linkedOption.d.ts +3 -0
- package/build/validations/prefab/linkedOption.js +39 -0
- package/build/validations/prefab/linkedOption.js.map +1 -0
- package/build/validations/prefab/linkedPartial.d.ts +3 -0
- package/build/validations/prefab/linkedPartial.js +30 -0
- package/build/validations/prefab/linkedPartial.js.map +1 -0
- package/build/validations/prefab/variable.d.ts +3 -0
- package/build/validations/prefab/variable.js +36 -0
- package/build/validations/prefab/variable.js.map +1 -0
- package/build/validations/prefab.d.ts +17 -0
- package/build/validations/prefab.js +66 -0
- package/build/validations/prefab.js.map +1 -0
- package/build/validations/styles.d.ts +6 -0
- package/build/validations/styles.js +103 -0
- package/build/validations/styles.js.map +1 -0
- package/package.json +38 -40
- package/assets/app-functions/templates/test/helpers.js +0 -3
- package/assets/app-functions/templates/test/say-hello.test.js +0 -4
- package/assets/functions/packer/package.json +0 -9
- package/assets/functions/packer/webpack.config.js +0 -12
- package/assets/functions/templates/functions.json +0 -14
- package/assets/functions/templates/package.json +0 -11
- package/assets/functions/templates/src/all-users.js +0 -14
- package/assets/functions/templates/src/get-json.js +0 -9
- package/assets/functions/templates/src/index.js +0 -5
- package/assets/functions/templates/src/say-hello.js +0 -13
- package/build/src/bb-blocks-new.js +0 -6789
- package/build/src/bb-blocks-publish.js +0 -32641
- package/build/src/bb-blocks-release.js +0 -15528
- package/build/src/bb-blocks.js +0 -2149
- package/build/src/bb-bundle-init.js +0 -6034
- package/build/src/bb-bundle.js +0 -2636
- package/build/src/bb-components-build.js +0 -240546
- package/build/src/bb-components-create.js +0 -6045
- package/build/src/bb-components-generate.js +0 -6173
- package/build/src/bb-components-publish-bundle.js +0 -43346
- package/build/src/bb-components-publish.js +0 -43353
- package/build/src/bb-components-serve.js +0 -15326
- package/build/src/bb-components.js +0 -2157
- package/build/src/bb-functions-build.js +0 -4284
- package/build/src/bb-functions-bump.js +0 -14582
- package/build/src/bb-functions-init.js +0 -4749
- package/build/src/bb-functions-login.js +0 -15440
- package/build/src/bb-functions-logout.js +0 -15434
- package/build/src/bb-functions-new.js +0 -9144
- package/build/src/bb-functions-publish.js +0 -86693
- package/build/src/bb-functions-validate.js +0 -22160
- package/build/src/bb-functions.js +0 -2159
- package/build/src/bb.js +0 -2740
- /package/assets/app-functions/{templates → js-template}/.app-functions +0 -0
- /package/assets/app-functions/{templates → js-template}/functions/say-hello/1.0/function.json +0 -0
- /package/assets/app-functions/{templates → js-template}/functions/say-hello/1.0/index.js +0 -0
- /package/assets/app-functions/{templates → js-template}/package.json +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ValidationError, Validator } from 'jsonschema';
|
|
2
|
+
import Config from './config';
|
|
3
|
+
import { type FunctionDefinition } from './functionDefinitions';
|
|
4
|
+
export interface Schema {
|
|
5
|
+
$id: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ValidationResult {
|
|
8
|
+
path: string;
|
|
9
|
+
status: string;
|
|
10
|
+
functionName?: string;
|
|
11
|
+
errors: ValidationError[] | Error[];
|
|
12
|
+
}
|
|
13
|
+
declare const functionValidator: (config: Config) => Promise<Validator>;
|
|
14
|
+
declare const validateSchema: (functionJson: FunctionDefinition, validator: Validator) => ValidationResult;
|
|
15
|
+
interface ValidateFunctionsProps {
|
|
16
|
+
functionName?: string;
|
|
17
|
+
blockFunctions?: FunctionDefinition[];
|
|
18
|
+
isWasmFunctionProject?: boolean;
|
|
19
|
+
inputFunctionName?: string;
|
|
20
|
+
}
|
|
21
|
+
declare class FunctionValidator {
|
|
22
|
+
private schemaValidator;
|
|
23
|
+
private config;
|
|
24
|
+
private functionsDir;
|
|
25
|
+
constructor(config: Config, functionsDir: string);
|
|
26
|
+
initSchema(): Promise<void>;
|
|
27
|
+
validateFunction(definition: FunctionDefinition, isWasmFunctionProject: boolean): ValidationResult;
|
|
28
|
+
validateFunctions({ functionName, blockFunctions, isWasmFunctionProject, inputFunctionName, }: ValidateFunctionsProps): Promise<ValidationResult[]>;
|
|
29
|
+
}
|
|
30
|
+
declare const logValidationResult: ({ path: functionPath, status, functionName, errors, }: ValidationResult) => void;
|
|
31
|
+
export { FunctionValidator, functionValidator, logValidationResult, validateSchema, };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { ValidationError, Validator, ValidatorResult } from 'jsonschema';
|
|
4
|
+
import fetch from 'node-fetch';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import Config from './config';
|
|
7
|
+
import { functionDefinitions, isFunctionVersion, } from './functionDefinitions';
|
|
8
|
+
const fetchRemoteSchema = async (schemaUrl, config) => {
|
|
9
|
+
const res = await fetch(schemaUrl, { agent: config.agent });
|
|
10
|
+
const json = await res.json();
|
|
11
|
+
return json;
|
|
12
|
+
};
|
|
13
|
+
const importNextSchema = async (validator, schemaId, config) => {
|
|
14
|
+
const schemaJSON = await fetchRemoteSchema(schemaId, config);
|
|
15
|
+
validator.addSchema(schemaJSON, schemaId);
|
|
16
|
+
const nextSchemaId = validator.unresolvedRefs.shift();
|
|
17
|
+
if (!nextSchemaId) {
|
|
18
|
+
return validator;
|
|
19
|
+
}
|
|
20
|
+
return importNextSchema(validator, nextSchemaId, config);
|
|
21
|
+
};
|
|
22
|
+
const importSchema = async (validator, config) => {
|
|
23
|
+
const functionSchemaUrl = config.schemaUrl + config.functionSchemaPath;
|
|
24
|
+
return importNextSchema(validator, functionSchemaUrl, config);
|
|
25
|
+
};
|
|
26
|
+
const functionValidator = async (config) => {
|
|
27
|
+
const validator = new Validator();
|
|
28
|
+
return importSchema(validator, config);
|
|
29
|
+
};
|
|
30
|
+
const validateFunctionDefinition = (validator, definition) => {
|
|
31
|
+
const functionSchemaId = Object.keys(validator.schemas).find((k) => k.match(/function\.json$/));
|
|
32
|
+
if (!functionSchemaId) {
|
|
33
|
+
throw new Error(`Cannot find Function schema Id, ${functionSchemaId}`);
|
|
34
|
+
}
|
|
35
|
+
const functionSchema = validator.schemas[functionSchemaId];
|
|
36
|
+
return validator.validate(definition, functionSchema);
|
|
37
|
+
};
|
|
38
|
+
const forceVersion = ({ path: functionPath }, functionsDir) => {
|
|
39
|
+
if (!isFunctionVersion(path.dirname(functionPath), functionsDir)) {
|
|
40
|
+
throw new Error(`${path.dirname(functionPath)} does not apply as a valid version directory`);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const validateSchema = (functionJson, validator) => {
|
|
44
|
+
const { name, version, path: definitionPath, schema } = functionJson;
|
|
45
|
+
const { errors } = validateFunctionDefinition(validator, schema);
|
|
46
|
+
const status = errors.length ? 'error' : 'ok';
|
|
47
|
+
return {
|
|
48
|
+
errors,
|
|
49
|
+
functionName: `${name}-${version}`,
|
|
50
|
+
path: definitionPath,
|
|
51
|
+
status,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
const validateWasmProjectStructure = (functionDir) => {
|
|
55
|
+
const functionFiles = fs.readdirSync(functionDir, {
|
|
56
|
+
withFileTypes: true,
|
|
57
|
+
});
|
|
58
|
+
const hasWasmFile = functionFiles.some((file) => file.name.endsWith('.wasm'));
|
|
59
|
+
const errors = [];
|
|
60
|
+
if (!hasWasmFile) {
|
|
61
|
+
errors.push(new Error(`Missing .wasm file in ${functionDir}`));
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
errors,
|
|
65
|
+
status: errors.length ? 'error' : 'ok',
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const mergeValidationResults = (schemaResult, wasmResult = null) => {
|
|
69
|
+
if (!wasmResult) {
|
|
70
|
+
return schemaResult;
|
|
71
|
+
}
|
|
72
|
+
const mergedErrors = [...schemaResult.errors, ...wasmResult.errors];
|
|
73
|
+
const status = mergedErrors.length ? 'error' : 'ok';
|
|
74
|
+
return {
|
|
75
|
+
...schemaResult,
|
|
76
|
+
errors: mergedErrors,
|
|
77
|
+
status,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
class FunctionValidator {
|
|
81
|
+
schemaValidator;
|
|
82
|
+
config;
|
|
83
|
+
functionsDir;
|
|
84
|
+
constructor(config, functionsDir) {
|
|
85
|
+
this.config = config;
|
|
86
|
+
this.schemaValidator = new Validator();
|
|
87
|
+
this.functionsDir = functionsDir;
|
|
88
|
+
}
|
|
89
|
+
async initSchema() {
|
|
90
|
+
await importSchema(this.schemaValidator, this.config);
|
|
91
|
+
}
|
|
92
|
+
validateFunction(definition, isWasmFunctionProject) {
|
|
93
|
+
const functionPath = definition.path;
|
|
94
|
+
const functionName = functionPath;
|
|
95
|
+
try {
|
|
96
|
+
forceVersion(definition, this.functionsDir);
|
|
97
|
+
const validatedSchema = validateSchema(definition, this.schemaValidator);
|
|
98
|
+
let validatedWasmStructure = null;
|
|
99
|
+
if (isWasmFunctionProject) {
|
|
100
|
+
const functionDir = path.dirname(functionPath);
|
|
101
|
+
validatedWasmStructure = validateWasmProjectStructure(functionDir);
|
|
102
|
+
}
|
|
103
|
+
return mergeValidationResults(validatedSchema, validatedWasmStructure);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
107
|
+
return {
|
|
108
|
+
errors: [new Error(message)],
|
|
109
|
+
functionName,
|
|
110
|
+
path: functionPath,
|
|
111
|
+
status: 'error',
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async validateFunctions({ functionName, blockFunctions, isWasmFunctionProject = false, inputFunctionName, }) {
|
|
116
|
+
const definitions = await functionDefinitions(this.functionsDir, true, inputFunctionName);
|
|
117
|
+
const functions = blockFunctions ?? definitions;
|
|
118
|
+
const validations = [];
|
|
119
|
+
functions.forEach((definition) => {
|
|
120
|
+
const preleadingPath = path.join(this.functionsDir, functionName ?? '', path.sep);
|
|
121
|
+
if (definition.path.indexOf(preleadingPath) === 0) {
|
|
122
|
+
validations.push(this.validateFunction(definition, isWasmFunctionProject));
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return Promise.all(validations);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const logValidationResult = ({ path: functionPath, status, functionName, errors, }) => {
|
|
129
|
+
if (status === 'ok') {
|
|
130
|
+
const mark = chalk.green(`✔`);
|
|
131
|
+
console.log(`${mark} Validate: ${functionName}`);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const msg = chalk.red(`${errors.join('\n\t')}`);
|
|
135
|
+
const mark = chalk.red(`✖`);
|
|
136
|
+
console.log(`${mark} Validate: ${functionName ?? functionPath}\n\t${msg}`);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
export { FunctionValidator, functionValidator, logValidationResult, validateSchema, };
|
|
140
|
+
//# sourceMappingURL=validations.js.map
|
|
@@ -0,0 +1 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;IACnD,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,cAAc,YAAY,IAAI,YAAY,OAAO,GAAG,EAAE,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC,CAAC;AAEF,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,GACf,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import Case from 'case';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import * as ts from 'typescript';
|
|
4
|
+
import {} from '../types';
|
|
5
|
+
const allowedTypes = [
|
|
6
|
+
'Event',
|
|
7
|
+
'Locale',
|
|
8
|
+
'Page',
|
|
9
|
+
'PageVariable',
|
|
10
|
+
'PageVariableId',
|
|
11
|
+
'boolean',
|
|
12
|
+
'number',
|
|
13
|
+
'string',
|
|
14
|
+
'unknown',
|
|
15
|
+
'void',
|
|
16
|
+
];
|
|
17
|
+
export default (filename) => {
|
|
18
|
+
if (!filename)
|
|
19
|
+
throw new Error(`unable to determine interaction name from ${filename}`);
|
|
20
|
+
const program = ts.createProgram([filename], {});
|
|
21
|
+
const typeChecker = program.getTypeChecker();
|
|
22
|
+
const sourceFile = program.getSourceFile(filename);
|
|
23
|
+
if (!sourceFile)
|
|
24
|
+
throw new Error('no source file');
|
|
25
|
+
const interactionName = Case.camel(path.basename(filename).replace(/.ts/, ''));
|
|
26
|
+
const interaction = {};
|
|
27
|
+
// Loop through the root AST nodes of the file
|
|
28
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
29
|
+
if (ts.isFunctionDeclaration(node)) {
|
|
30
|
+
// name
|
|
31
|
+
const functionName = node.name ? node.name.text : '';
|
|
32
|
+
if (functionName !== interactionName) {
|
|
33
|
+
throw new RangeError('file contains multiple statements');
|
|
34
|
+
}
|
|
35
|
+
interaction.name = functionName;
|
|
36
|
+
interaction.parameters = {};
|
|
37
|
+
// return type
|
|
38
|
+
const typeNode = node.type;
|
|
39
|
+
if (!typeNode) {
|
|
40
|
+
throw new Error(`You forgot to declare a type for ${interactionName}`);
|
|
41
|
+
}
|
|
42
|
+
const returnType = typeChecker.typeToString(typeChecker.getTypeFromTypeNode(typeNode));
|
|
43
|
+
interaction.type = Case.pascal(returnType);
|
|
44
|
+
if (node.parameters.length > 1) {
|
|
45
|
+
throw new Error(`Only one parameter is allowed for ${interactionName}`);
|
|
46
|
+
}
|
|
47
|
+
const [firstParameter] = node.parameters;
|
|
48
|
+
if (firstParameter) {
|
|
49
|
+
if (!firstParameter.type) {
|
|
50
|
+
throw new Error(`You forgot to add a type to the parameter "${firstParameter.name.getText()}" for ${interactionName}`);
|
|
51
|
+
}
|
|
52
|
+
const t = typeChecker.getTypeFromTypeNode(firstParameter.type);
|
|
53
|
+
const parameters = JSON.parse(typeChecker
|
|
54
|
+
.typeToString(t)
|
|
55
|
+
.replace(/;(?!.*;)/g, '')
|
|
56
|
+
.replace(/;/g, ',')
|
|
57
|
+
.replace(/(\w+)/g, '"$1"'));
|
|
58
|
+
Object.entries(parameters).forEach(([paramName, paramType]) => {
|
|
59
|
+
if (!allowedTypes.includes(paramType)) {
|
|
60
|
+
throw new TypeError(`unsupported type for: ${paramName}`);
|
|
61
|
+
}
|
|
62
|
+
parameters[paramName] = Case.pascal(paramType);
|
|
63
|
+
});
|
|
64
|
+
interaction.parameters = parameters;
|
|
65
|
+
}
|
|
66
|
+
// function body
|
|
67
|
+
const functionBody = node.getText(sourceFile);
|
|
68
|
+
if (!functionBody) {
|
|
69
|
+
throw new Error(`You forgot to add code to your interaction for ${interactionName}`);
|
|
70
|
+
}
|
|
71
|
+
interaction.function = ts.transpileModule(node.getText(), {}).outputText;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (!interaction.function) {
|
|
75
|
+
throw new RangeError(`
|
|
76
|
+
expected expression of the kind
|
|
77
|
+
function ${interactionName}({ event, argument }: { event: Event, argument: ArgumentType }): ReturnType {
|
|
78
|
+
// body
|
|
79
|
+
}
|
|
80
|
+
`);
|
|
81
|
+
}
|
|
82
|
+
return interaction;
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=compatibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility.js","sourceRoot":"","sources":["../../src/interactions/compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAgD,MAAM,UAAU,CAAC;AAExE,MAAM,YAAY,GAAG;IACnB,OAAO;IACP,QAAQ;IACR,MAAM;IACN,cAAc;IACd,gBAAgB;IAChB,SAAS;IACT,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;CACP,CAAC;AAEF,eAAe,CAAC,QAAgB,EAAe,EAAE;IAC/C,IAAI,CAAC,QAAQ;QACX,MAAM,IAAI,KAAK,CAAC,6CAA6C,QAAQ,EAAE,CAAC,CAAC;IAE3E,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;IACjD,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAEnD,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAEnD,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAChC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAC3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OAAO,WAA0B,CAAC;AACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createProgram, flattenDiagnosticMessageText, getDefaultCompilerOptions, getPreEmitDiagnostics, } from 'typescript';
|
|
2
|
+
const reportDiagnostics = (diagnostics) => {
|
|
3
|
+
diagnostics.forEach((diagnostic) => {
|
|
4
|
+
let message = 'Error';
|
|
5
|
+
if (diagnostic.file) {
|
|
6
|
+
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start ?? 0);
|
|
7
|
+
message += ` ${diagnostic.file.fileName} (${line + 1},${character + 1})`;
|
|
8
|
+
}
|
|
9
|
+
message += `: ${flattenDiagnosticMessageText(diagnostic.messageText, '\n')}`;
|
|
10
|
+
console.error(`\u001b[31m${message}\u001b[0m`);
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export default (filePath) => {
|
|
14
|
+
const config = getDefaultCompilerOptions();
|
|
15
|
+
config.strict = true;
|
|
16
|
+
const program = createProgram([filePath], config);
|
|
17
|
+
const diagnostics = [...getPreEmitDiagnostics(program)];
|
|
18
|
+
if (diagnostics.length > 0) {
|
|
19
|
+
reportDiagnostics(diagnostics);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/interactions/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,4BAA4B,EAC5B,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,MAAM,iBAAiB,GAAG,CAAC,WAAyB,EAAQ,EAAE;IAC5D,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QACjC,IAAI,OAAO,GAAG,OAAO,CAAC;QACtB,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,6BAA6B,CACvE,UAAU,CAAC,KAAK,IAAI,CAAC,CACtB,CAAC;YACF,OAAO,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC,GAAG,CAAC;QAC3E,CAAC;QACD,OAAO,IAAI,KAAK,4BAA4B,CAC1C,UAAU,CAAC,WAAW,EACtB,IAAI,CACL,EAAE,CAAC;QACJ,OAAO,CAAC,KAAK,CAAC,aAAa,OAAO,WAAW,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,CAAC,QAAgB,EAAQ,EAAE;IACxC,MAAM,MAAM,GAAG,yBAAyB,EAAE,CAAC;IAE3C,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;IAErB,MAAM,OAAO,GAAG,aAAa,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;IAElD,MAAM,WAAW,GAAG,CAAC,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;IAExD,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC"}
|
package/build/types.d.ts
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { ICONS } from './validations/constants';
|
|
2
|
+
export type Category = DefaultCategory | string;
|
|
3
|
+
export type CommandBB = 'blocks' | 'components' | 'functions' | 'interactions' | 'bundle' | 'help';
|
|
4
|
+
export type CommandComponents = 'create' | 'build' | 'serve' | 'publish' | 'help' | 'generate' | 'publish-bundle';
|
|
5
|
+
export type CommandFunctions = 'bump' | 'init' | 'login' | 'logout' | 'new' | 'publish' | 'validate';
|
|
6
|
+
export type CommandBlocks = 'publish' | 'release' | 'new';
|
|
7
|
+
export type CommandBundle = 'init';
|
|
8
|
+
export type DefaultCategory = 'CONTENT' | 'DATA' | 'FORM' | 'LAYOUT' | 'NAVIGATION' | 'TABLE';
|
|
9
|
+
interface RefOrValue {
|
|
10
|
+
type: 'THEME_COLOR' | 'STATIC';
|
|
11
|
+
value: string;
|
|
12
|
+
}
|
|
13
|
+
export interface StyleDefinitionCssObject {
|
|
14
|
+
backgroundColor?: RefOrValue;
|
|
15
|
+
borderColor?: RefOrValue;
|
|
16
|
+
borderRadius?: string[];
|
|
17
|
+
borderStyle?: string;
|
|
18
|
+
borderWidth?: string[];
|
|
19
|
+
boxShadow?: string;
|
|
20
|
+
color?: RefOrValue;
|
|
21
|
+
fontFamily?: string;
|
|
22
|
+
fontSize?: string;
|
|
23
|
+
fontStyle?: string;
|
|
24
|
+
fontWeight?: string;
|
|
25
|
+
letterSpacing?: string;
|
|
26
|
+
lineHeight?: string;
|
|
27
|
+
padding?: string[];
|
|
28
|
+
textDecoration?: string;
|
|
29
|
+
textTransform?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface StyleDefinitionState {
|
|
32
|
+
name: StyleStateKeys;
|
|
33
|
+
content: StyleDefinitionCssObject;
|
|
34
|
+
}
|
|
35
|
+
export interface StyleDefinition {
|
|
36
|
+
type: string;
|
|
37
|
+
name: string;
|
|
38
|
+
basis: StyleDefinitionCssObject;
|
|
39
|
+
states: StyleDefinitionState[];
|
|
40
|
+
}
|
|
41
|
+
export declare enum AllowedStateKeys {
|
|
42
|
+
SELECTED = "selected",
|
|
43
|
+
HOVER = "hover",
|
|
44
|
+
FOCUS = "focus",
|
|
45
|
+
DISABLED = "disabled",
|
|
46
|
+
VALID = "valid",
|
|
47
|
+
INVALID = "invalid",
|
|
48
|
+
READONLY = "readOnly"
|
|
49
|
+
}
|
|
50
|
+
export type StyleStateKeys = 'selected' | 'hover' | 'focus' | 'disabled' | 'valid' | 'invalid' | 'readOnly';
|
|
51
|
+
type StyleDefinitionContentBase = Record<StyleStateKeys | 'basis', StyleDefinitionCssObject>;
|
|
52
|
+
export type StyleDefinitionContent = Partial<StyleDefinitionContentBase> & Pick<StyleDefinitionContentBase, 'basis'>;
|
|
53
|
+
export type BuildStyleDefinitionContentOverwrites = Partial<StyleDefinitionContentBase>;
|
|
54
|
+
export type StyleDefinitionContentKeys = Partial<Record<StyleStateKeys, string[]>> & {
|
|
55
|
+
basis: string[];
|
|
56
|
+
};
|
|
57
|
+
export interface StyleDefinitionContentOverwrites extends Omit<StyleDefinitionState, 'name'> {
|
|
58
|
+
name: string;
|
|
59
|
+
}
|
|
60
|
+
export interface OverwriteStyleDefinitionState extends Omit<StyleDefinitionState, 'name'> {
|
|
61
|
+
name: string;
|
|
62
|
+
}
|
|
63
|
+
export interface BuildStyleDefinition extends Omit<StyleDefinition, 'states' | 'basis'> {
|
|
64
|
+
content: StyleDefinitionContent;
|
|
65
|
+
}
|
|
66
|
+
export type GroupedStyles = Record<string, Record<string, StyleDefinition>>;
|
|
67
|
+
export interface Component {
|
|
68
|
+
allowedTypes: string[];
|
|
69
|
+
jsx: string;
|
|
70
|
+
name: string;
|
|
71
|
+
orientation: Orientation;
|
|
72
|
+
styles: string;
|
|
73
|
+
styleType: string;
|
|
74
|
+
type: string;
|
|
75
|
+
}
|
|
76
|
+
export type PrefabReference = PrefabComponent | PrefabPartial | PrefabWrapper;
|
|
77
|
+
export type BuildStyleOverwrite = {
|
|
78
|
+
backgroundColor?: {
|
|
79
|
+
value: string;
|
|
80
|
+
type: string;
|
|
81
|
+
};
|
|
82
|
+
borderColor?: {
|
|
83
|
+
value: string;
|
|
84
|
+
type: string;
|
|
85
|
+
};
|
|
86
|
+
borderRadius?: string | string[];
|
|
87
|
+
borderStyle?: string;
|
|
88
|
+
borderWidth?: string | string[];
|
|
89
|
+
boxShadow?: string;
|
|
90
|
+
color?: {
|
|
91
|
+
value: string;
|
|
92
|
+
type: string;
|
|
93
|
+
};
|
|
94
|
+
fontFamily?: string;
|
|
95
|
+
fontSize?: string;
|
|
96
|
+
fontStyle?: string;
|
|
97
|
+
fontWeight?: string;
|
|
98
|
+
letterSpacing?: string;
|
|
99
|
+
lineHeight?: string;
|
|
100
|
+
padding?: string | string[];
|
|
101
|
+
textDecoration?: string;
|
|
102
|
+
textTransform?: string;
|
|
103
|
+
} | BuildStyleDefinitionContentOverwrites;
|
|
104
|
+
export interface BuildStyle {
|
|
105
|
+
name?: string;
|
|
106
|
+
overwrite?: BuildStyleOverwrite;
|
|
107
|
+
}
|
|
108
|
+
export interface BuildPrefabComponent extends Omit<PrefabComponent, 'style' | 'descendants'> {
|
|
109
|
+
hash: string;
|
|
110
|
+
style?: BuildStyle;
|
|
111
|
+
descendants: BuildPrefabReference[];
|
|
112
|
+
}
|
|
113
|
+
export interface BuildPrefabWrapper extends Omit<PrefabWrapper, 'descendants'> {
|
|
114
|
+
descendants: BuildPrefabReference[];
|
|
115
|
+
}
|
|
116
|
+
export type BuildPrefabReference = BuildPrefabComponent | PrefabPartial | BuildPrefabWrapper;
|
|
117
|
+
export interface PrefabPartial {
|
|
118
|
+
type: 'PARTIAL';
|
|
119
|
+
partialId: string;
|
|
120
|
+
}
|
|
121
|
+
export interface PrefabWrapper {
|
|
122
|
+
type: 'WRAPPER';
|
|
123
|
+
descendants: PrefabReference[];
|
|
124
|
+
optionCategories?: PrefabComponentOptionCategory[];
|
|
125
|
+
options: PrefabComponentOption[];
|
|
126
|
+
}
|
|
127
|
+
type PrefabComponentStyleOverwrite = {
|
|
128
|
+
backgroundColor?: {
|
|
129
|
+
value: string;
|
|
130
|
+
type: string;
|
|
131
|
+
};
|
|
132
|
+
borderColor?: {
|
|
133
|
+
value: string;
|
|
134
|
+
type: string;
|
|
135
|
+
};
|
|
136
|
+
borderRadius?: string | string[];
|
|
137
|
+
borderStyle?: string;
|
|
138
|
+
borderWidth?: string | string[];
|
|
139
|
+
boxShadow?: string;
|
|
140
|
+
color?: {
|
|
141
|
+
value: string;
|
|
142
|
+
type: string;
|
|
143
|
+
};
|
|
144
|
+
fontFamily?: string;
|
|
145
|
+
fontSize?: string;
|
|
146
|
+
fontStyle?: string;
|
|
147
|
+
fontWeight?: string;
|
|
148
|
+
letterSpacing?: string;
|
|
149
|
+
lineHeight?: string;
|
|
150
|
+
padding?: string | string[];
|
|
151
|
+
textDecoration?: string;
|
|
152
|
+
textTransform?: string;
|
|
153
|
+
} | StyleDefinitionContentOverwrites[];
|
|
154
|
+
export interface PrefabComponent {
|
|
155
|
+
type?: 'COMPONENT';
|
|
156
|
+
actions?: PrefabAction[];
|
|
157
|
+
name: string;
|
|
158
|
+
style?: {
|
|
159
|
+
name?: string;
|
|
160
|
+
overwrite?: PrefabComponentStyleOverwrite;
|
|
161
|
+
};
|
|
162
|
+
descendants: PrefabReference[];
|
|
163
|
+
optionCategories?: PrefabComponentOptionCategory[];
|
|
164
|
+
options: PrefabComponentOption[];
|
|
165
|
+
ref?: {
|
|
166
|
+
id: string;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export type ComponentStyleMap = Record<PrefabComponent['name'], {
|
|
170
|
+
styleType: Component['styleType'];
|
|
171
|
+
}>;
|
|
172
|
+
export type Icon = (typeof ICONS)[number];
|
|
173
|
+
export type ValueConfig = Record<string, unknown>;
|
|
174
|
+
export interface PrefabComponentOptionBase {
|
|
175
|
+
label: string;
|
|
176
|
+
key: string;
|
|
177
|
+
type: string;
|
|
178
|
+
configuration?: unknown;
|
|
179
|
+
optionRef?: {
|
|
180
|
+
id?: string;
|
|
181
|
+
sourceId?: string;
|
|
182
|
+
inherit?: string | (OptionRefInheritObject | string)[] | OptionRefInheritObject;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
export interface ValueDefault {
|
|
186
|
+
value: string | string[] | ValueConfig;
|
|
187
|
+
ref?: {
|
|
188
|
+
id?: string;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
export interface ValueRef {
|
|
192
|
+
ref: {
|
|
193
|
+
id?: string;
|
|
194
|
+
value: string;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export interface PrefabComponentOptionCategory {
|
|
198
|
+
label: string;
|
|
199
|
+
extended?: boolean;
|
|
200
|
+
members: string[];
|
|
201
|
+
condition?: {
|
|
202
|
+
type: string;
|
|
203
|
+
option: string;
|
|
204
|
+
comparator: string;
|
|
205
|
+
value: string | boolean | number;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
export type PrefabComponentOption = PrefabComponentOptionBase & (ValueDefault | ValueRef);
|
|
209
|
+
export type Orientation = 'VERTICAL' | 'HORIZONTAL';
|
|
210
|
+
export declare enum InteractionOptionType {
|
|
211
|
+
Boolean = "Boolean",
|
|
212
|
+
Number = "Number",
|
|
213
|
+
String = "String",
|
|
214
|
+
Event = "Event",
|
|
215
|
+
Void = "Void",
|
|
216
|
+
Page = "Page",
|
|
217
|
+
Locale = "Locale",
|
|
218
|
+
Unknown = "Unknown"
|
|
219
|
+
}
|
|
220
|
+
export declare enum InteractionOptionTypeToDo {
|
|
221
|
+
Color = "Color",
|
|
222
|
+
Endpoint = "Endpoint",
|
|
223
|
+
Filter = "Filter",
|
|
224
|
+
Font = "Font",
|
|
225
|
+
Properties = "Properties",
|
|
226
|
+
Property = "Property",
|
|
227
|
+
Size = "Size",
|
|
228
|
+
Unit = "Unit"
|
|
229
|
+
}
|
|
230
|
+
export interface InteractionCompatibility {
|
|
231
|
+
name: string;
|
|
232
|
+
parameters: Record<string, InteractionOptionType>;
|
|
233
|
+
type: InteractionOptionType;
|
|
234
|
+
}
|
|
235
|
+
export interface Interaction extends InteractionCompatibility {
|
|
236
|
+
function: string;
|
|
237
|
+
}
|
|
238
|
+
export interface Prefab {
|
|
239
|
+
actions?: PrefabAction[];
|
|
240
|
+
beforeCreate?: string;
|
|
241
|
+
category: Category;
|
|
242
|
+
name: string;
|
|
243
|
+
keywords?: string[];
|
|
244
|
+
icon: Icon;
|
|
245
|
+
interactions?: PrefabInteraction[];
|
|
246
|
+
structure: PrefabReference[];
|
|
247
|
+
variables?: PrefabVariable[];
|
|
248
|
+
type?: string;
|
|
249
|
+
description?: string;
|
|
250
|
+
reconfigure?: {
|
|
251
|
+
children: PrefabComponent[];
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
export interface BuildPrefab extends Omit<Prefab, 'structure'> {
|
|
255
|
+
structure: BuildPrefabReference[];
|
|
256
|
+
}
|
|
257
|
+
export declare enum InteractionType {
|
|
258
|
+
Custom = "Custom",
|
|
259
|
+
Global = "Global"
|
|
260
|
+
}
|
|
261
|
+
export interface BasePrefabInteraction<T extends InteractionType> {
|
|
262
|
+
name: string;
|
|
263
|
+
ref: {
|
|
264
|
+
sourceComponentId: string;
|
|
265
|
+
targetComponentId?: string;
|
|
266
|
+
};
|
|
267
|
+
targetOptionName: string;
|
|
268
|
+
sourceEvent: string;
|
|
269
|
+
type: T;
|
|
270
|
+
}
|
|
271
|
+
export interface ParameterOptionWithId {
|
|
272
|
+
parameter: string;
|
|
273
|
+
id: string[];
|
|
274
|
+
}
|
|
275
|
+
export interface ParameterOptionWithPath {
|
|
276
|
+
path: string[];
|
|
277
|
+
parameter: string;
|
|
278
|
+
}
|
|
279
|
+
export interface ParameterOptionWithComponentRef {
|
|
280
|
+
name: string;
|
|
281
|
+
parameter: string;
|
|
282
|
+
ref: {
|
|
283
|
+
componentId: string;
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
export type PrefabInteractionParameter = ParameterOptionWithId | ParameterOptionWithPath | ParameterOptionWithComponentRef;
|
|
287
|
+
export type PrefabInteraction = BasePrefabInteraction<InteractionType.Custom> | (BasePrefabInteraction<InteractionType.Global> & {
|
|
288
|
+
parameters: PrefabInteractionParameter[];
|
|
289
|
+
});
|
|
290
|
+
export interface Versions {
|
|
291
|
+
remoteVersionCLI: string;
|
|
292
|
+
remoteVersionPreview: string;
|
|
293
|
+
}
|
|
294
|
+
export interface ServeOptions {
|
|
295
|
+
rootDir: string;
|
|
296
|
+
host: string;
|
|
297
|
+
port: number;
|
|
298
|
+
ssl: boolean;
|
|
299
|
+
sslCert: string;
|
|
300
|
+
sslKey: string;
|
|
301
|
+
transpile?: boolean;
|
|
302
|
+
}
|
|
303
|
+
export interface PrefabAction {
|
|
304
|
+
name: string;
|
|
305
|
+
ref: {
|
|
306
|
+
id: string;
|
|
307
|
+
endpointId?: string;
|
|
308
|
+
};
|
|
309
|
+
options?: {
|
|
310
|
+
ref: {
|
|
311
|
+
result: string;
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
useNewRuntime: boolean;
|
|
315
|
+
events?: PrefabActionStep[];
|
|
316
|
+
}
|
|
317
|
+
export interface PrefabActionAssign {
|
|
318
|
+
leftHandSide: string;
|
|
319
|
+
ref: {
|
|
320
|
+
path: string[];
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
export interface PrefabActionUpdateStepOption {
|
|
324
|
+
ref: {
|
|
325
|
+
object: string;
|
|
326
|
+
customModel?: string;
|
|
327
|
+
};
|
|
328
|
+
assign: PrefabActionAssign[];
|
|
329
|
+
}
|
|
330
|
+
export interface PrefabActionCreateStepOption {
|
|
331
|
+
modelId: string;
|
|
332
|
+
assign: PrefabActionAssign[];
|
|
333
|
+
ref: {
|
|
334
|
+
customModel: string;
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
export interface PrefabActionDeleteStepOption {
|
|
338
|
+
ref: {
|
|
339
|
+
object: string;
|
|
340
|
+
customModel: string;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
export interface AuthenticateUserStepOption {
|
|
344
|
+
authenticationProfileId: string;
|
|
345
|
+
ref: {
|
|
346
|
+
username: string;
|
|
347
|
+
password: string;
|
|
348
|
+
jwtAs: string;
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
export interface PrefabActionStep {
|
|
352
|
+
kind: string;
|
|
353
|
+
options?: PrefabActionUpdateStepOption | PrefabActionCreateStepOption | PrefabActionDeleteStepOption | AuthenticateUserStepOption;
|
|
354
|
+
}
|
|
355
|
+
export type PrefabVariableKind = 'construct' | 'object' | 'string';
|
|
356
|
+
export interface PrefabVariable {
|
|
357
|
+
kind: PrefabVariableKind;
|
|
358
|
+
name: string;
|
|
359
|
+
ref: {
|
|
360
|
+
actionId?: string;
|
|
361
|
+
endpointId?: string;
|
|
362
|
+
id: string;
|
|
363
|
+
};
|
|
364
|
+
options?: unknown;
|
|
365
|
+
}
|
|
366
|
+
export interface ComponentDependency {
|
|
367
|
+
label: string;
|
|
368
|
+
package: string;
|
|
369
|
+
imports: string[];
|
|
370
|
+
}
|
|
371
|
+
export interface OptionRefInheritObject {
|
|
372
|
+
id: string;
|
|
373
|
+
type: 'PROPERTY' | 'PROPERTY_LABEL';
|
|
374
|
+
name?: string;
|
|
375
|
+
useKey?: string;
|
|
376
|
+
}
|
|
377
|
+
export {};
|