@sprucelabs/spruce-templates 24.1.32 → 25.0.0
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/build/addons/eq.addon.js.map +1 -0
- package/build/addons/escape.addon.js.map +1 -0
- package/build/addons/fieldDefinitionBodyPartial.addon.js.map +1 -0
- package/build/addons/fieldDefinitionOptions.addon.js.map +1 -0
- package/build/addons/fieldTypeEnum.addon.js.map +1 -0
- package/build/addons/fieldValue.addon.js.map +1 -0
- package/build/addons/gt.addon.js.map +1 -0
- package/build/addons/hasKeys.addon.js.map +1 -0
- package/build/addons/hasNoneCoreSchemaTemplateItems.addon.js.map +1 -0
- package/build/addons/importRelatedSchemas.addon.js.map +1 -0
- package/build/addons/index.js.map +1 -0
- package/build/addons/isDefined.addon.js.map +1 -0
- package/build/addons/json.addon.js.map +1 -0
- package/build/addons/neq.addon.js.map +1 -0
- package/build/addons/operators.addon.js.map +1 -0
- package/build/addons/pascalCase.addon.js.map +1 -0
- package/build/addons/permissionContractBuilder.addon.js.map +1 -0
- package/build/addons/schemaBodyPartial.addon.js.map +1 -0
- package/build/addons/schemaNamespacePath.addon.js.map +1 -0
- package/build/addons/schemaValuesPartial.addon.js.map +1 -0
- package/build/addons/valueTypeGenerator.addon.js.map +1 -0
- package/build/addons/valueTypeLiteral.addon.js.map +1 -0
- package/build/addons/valueTypeMapper.addon.js.map +1 -0
- package/build/dist/templates/directories/skill/.nvmrc +1 -0
- package/build/dist/templates/directories/skill/README.md +4 -0
- package/build/dist/templates/directories/skill/eslint.config.mjs +3 -0
- package/build/dist/templates/directories/skill/package.json.hbs +15 -0
- package/build/dist/templates/directories/skill/src/errors/SpruceError.ts.hbs +20 -0
- package/build/dist/templates/directories/skill/tsconfig.json +39 -0
- package/build/dist/templates/directories/vscode/.vscode/launch.json +58 -0
- package/build/dist/templates/directories/vscode/.vscode/settings.json +67 -0
- package/build/dist/templates/directories/vscode/.vscode/tasks.json +112 -0
- package/build/dist/templates/typescript/conversation/conversation.plugin.ts.hbs +1 -0
- package/build/dist/templates/typescript/conversation/conversation.topic.ts.hbs +19 -0
- package/build/dist/templates/typescript/deploy/deploy.plugin.ts.hbs +1 -0
- package/build/dist/templates/typescript/error/SpruceError.ts.hbs +31 -0
- package/build/dist/templates/typescript/error/error.plugin.ts.hbs +78 -0
- package/build/dist/templates/typescript/error/example.ts.hbs +10 -0
- package/build/dist/templates/typescript/error/options.types.ts.hbs +12 -0
- package/build/dist/templates/typescript/event/event.contract.ts.hbs +26 -0
- package/build/dist/templates/typescript/event/event.options.ts.hbs +11 -0
- package/build/dist/templates/typescript/event/events.contract.ts.hbs +24 -0
- package/build/dist/templates/typescript/event/listener.ts.hbs +23 -0
- package/build/dist/templates/typescript/event/listeners.ts.hbs +15 -0
- package/build/dist/templates/typescript/event/payload.builder.ts.hbs +15 -0
- package/build/dist/templates/typescript/log/transport.plugin.ts.hbs +14 -0
- package/build/dist/templates/typescript/permissions/contract.builder.ts.hbs +36 -0
- package/build/dist/templates/typescript/permissions/permission.plugin.ts.hbs +1 -0
- package/build/dist/templates/typescript/permissions/permissions.ts.hbs +13 -0
- package/build/dist/templates/typescript/permissions/permissions.types.ts.hbs +14 -0
- package/build/dist/templates/typescript/polish/polish.ts.hbs +67 -0
- package/build/dist/templates/typescript/sandbox/will-boot.listener.ts.hbs +172 -0
- package/build/dist/templates/typescript/schema/builder.ts.hbs +24 -0
- package/build/dist/templates/typescript/schema/core.schemas.types.ts.hbs +34 -0
- package/build/dist/templates/typescript/schema/example.ts.hbs +20 -0
- package/build/dist/templates/typescript/schema/fields/fieldClassMap.ts.hbs +16 -0
- package/build/dist/templates/typescript/schema/fields/fields.types.ts.hbs +1 -0
- package/build/dist/templates/typescript/schema/imported.schema.ts.hbs +1 -0
- package/build/dist/templates/typescript/schema/partials/fieldDefinitionBody.ts.hbs +12 -0
- package/build/dist/templates/typescript/schema/partials/schemaBody.ts.hbs +20 -0
- package/build/dist/templates/typescript/schema/partials/schemaValues.ts.hbs +7 -0
- package/build/dist/templates/typescript/schema/schema.plugin.ts.hbs +101 -0
- package/build/dist/templates/typescript/schema/schema.ts.hbs +12 -0
- package/build/dist/templates/typescript/schema/schemas.types.ts.hbs +44 -0
- package/build/dist/templates/typescript/schema/valueTypes.ts.hbs +67 -0
- package/build/dist/templates/typescript/store/Store.store.ts.hbs +95 -0
- package/build/dist/templates/typescript/store/store.plugin.ts.hbs +1 -0
- package/build/dist/templates/typescript/store/stores.ts.hbs +9 -0
- package/build/dist/templates/typescript/store/stores.types.ts.hbs +17 -0
- package/build/dist/templates/typescript/test/StaticTest.test.ts.hbs +20 -0
- package/build/dist/templates/typescript/test/Test.test.ts.hbs +21 -0
- package/build/dist/templates/typescript/view/App.ac.ts.hbs +6 -0
- package/build/dist/templates/typescript/view/View.svc.ts.hbs +23 -0
- package/build/dist/templates/typescript/view/View.vc.ts.hbs +17 -0
- package/build/dist/templates/typescript/view/skill.theme.ts.hbs +70 -0
- package/build/dist/templates/typescript/view/view.plugin.ts.hbs +1 -0
- package/build/dist/templates/typescript/view/viewController.plugin.ts.hbs +3 -0
- package/build/dist/templates/typescript/view/views.ts.hbs +93 -0
- package/build/esm/addons/eq.addon.d.ts +1 -0
- package/build/esm/addons/eq.addon.js +4 -0
- package/build/esm/addons/escape.addon.d.ts +1 -0
- package/build/esm/addons/escape.addon.js +5 -0
- package/build/esm/addons/fieldDefinitionBodyPartial.addon.d.ts +1 -0
- package/build/esm/addons/fieldDefinitionBodyPartial.addon.js +8 -0
- package/build/esm/addons/fieldDefinitionOptions.addon.d.ts +1 -0
- package/build/esm/addons/fieldDefinitionOptions.addon.js +66 -0
- package/build/esm/addons/fieldTypeEnum.addon.d.ts +1 -0
- package/build/esm/addons/fieldTypeEnum.addon.js +9 -0
- package/build/esm/addons/fieldValue.addon.d.ts +1 -0
- package/build/esm/addons/fieldValue.addon.js +8 -0
- package/build/esm/addons/gt.addon.d.ts +1 -0
- package/build/esm/addons/gt.addon.js +4 -0
- package/build/esm/addons/hasKeys.addon.d.ts +1 -0
- package/build/esm/addons/hasKeys.addon.js +4 -0
- package/build/esm/addons/hasNoneCoreSchemaTemplateItems.addon.d.ts +1 -0
- package/build/esm/addons/hasNoneCoreSchemaTemplateItems.addon.js +6 -0
- package/build/esm/addons/importRelatedSchemas.addon.d.ts +1 -0
- package/build/esm/addons/importRelatedSchemas.addon.js +34 -0
- package/build/esm/addons/index.d.ts +23 -0
- package/build/esm/addons/index.js +23 -0
- package/build/esm/addons/isDefined.addon.d.ts +1 -0
- package/build/esm/addons/isDefined.addon.js +5 -0
- package/build/esm/addons/json.addon.d.ts +1 -0
- package/build/esm/addons/json.addon.js +7 -0
- package/build/esm/addons/neq.addon.d.ts +1 -0
- package/build/esm/addons/neq.addon.js +4 -0
- package/build/esm/addons/operators.addon.d.ts +1 -0
- package/build/esm/addons/operators.addon.js +15 -0
- package/build/esm/addons/pascalCase.addon.d.ts +1 -0
- package/build/esm/addons/pascalCase.addon.js +6 -0
- package/build/esm/addons/permissionContractBuilder.addon.d.ts +1 -0
- package/build/esm/addons/permissionContractBuilder.addon.js +4 -0
- package/build/esm/addons/schemaBodyPartial.addon.d.ts +1 -0
- package/build/esm/addons/schemaBodyPartial.addon.js +8 -0
- package/build/esm/addons/schemaNamespacePath.addon.d.ts +1 -0
- package/build/esm/addons/schemaNamespacePath.addon.js +18 -0
- package/build/esm/addons/schemaValuesPartial.addon.d.ts +1 -0
- package/build/esm/addons/schemaValuesPartial.addon.js +8 -0
- package/build/esm/addons/valueTypeGenerator.addon.d.ts +1 -0
- package/build/esm/addons/valueTypeGenerator.addon.js +15 -0
- package/build/esm/addons/valueTypeLiteral.addon.d.ts +1 -0
- package/build/esm/addons/valueTypeLiteral.addon.js +32 -0
- package/build/esm/addons/valueTypeMapper.addon.d.ts +1 -0
- package/build/esm/addons/valueTypeMapper.addon.js +9 -0
- package/build/esm/index.d.ts +141 -0
- package/build/esm/index.js +258 -0
- package/build/esm/templates/directories/skill/.nvmrc +1 -0
- package/build/esm/templates/directories/skill/README.md +4 -0
- package/build/esm/templates/directories/skill/eslint.config.mjs +3 -0
- package/build/esm/templates/directories/skill/package.json.hbs +15 -0
- package/build/esm/templates/directories/skill/src/.spruce/errors/options.types.ts +6 -0
- package/build/esm/templates/directories/skill/src/.spruce/features/event.plugin.ts +1 -0
- package/build/esm/templates/directories/skill/src/.spruce/skill.ts +8 -0
- package/build/esm/templates/directories/skill/src/errors/SpruceError.ts.hbs +20 -0
- package/build/esm/templates/directories/skill/src/index.ts +35 -0
- package/build/esm/templates/directories/skill/tsconfig.json +39 -0
- package/build/esm/templates/directories/vscode/.vscode/launch.json +58 -0
- package/build/esm/templates/directories/vscode/.vscode/settings.json +67 -0
- package/build/esm/templates/directories/vscode/.vscode/tasks.json +112 -0
- package/build/esm/templates/typescript/conversation/conversation.plugin.ts.hbs +1 -0
- package/build/esm/templates/typescript/conversation/conversation.topic.ts.hbs +19 -0
- package/build/esm/templates/typescript/deploy/deploy.plugin.ts.hbs +1 -0
- package/build/esm/templates/typescript/error/SpruceError.ts.hbs +31 -0
- package/build/esm/templates/typescript/error/error.plugin.ts.hbs +78 -0
- package/build/esm/templates/typescript/error/example.ts.hbs +10 -0
- package/build/esm/templates/typescript/error/options.types.ts.hbs +12 -0
- package/build/esm/templates/typescript/event/event.contract.ts.hbs +26 -0
- package/build/esm/templates/typescript/event/event.options.ts.hbs +11 -0
- package/build/esm/templates/typescript/event/events.contract.ts.hbs +24 -0
- package/build/esm/templates/typescript/event/listener.ts.hbs +23 -0
- package/build/esm/templates/typescript/event/listeners.ts.hbs +15 -0
- package/build/esm/templates/typescript/event/payload.builder.ts.hbs +15 -0
- package/build/esm/templates/typescript/log/transport.plugin.ts.hbs +14 -0
- package/build/esm/templates/typescript/permissions/contract.builder.ts.hbs +36 -0
- package/build/esm/templates/typescript/permissions/permission.plugin.ts.hbs +1 -0
- package/build/esm/templates/typescript/permissions/permissions.ts.hbs +13 -0
- package/build/esm/templates/typescript/permissions/permissions.types.ts.hbs +14 -0
- package/build/esm/templates/typescript/polish/polish.ts.hbs +67 -0
- package/build/esm/templates/typescript/sandbox/will-boot.listener.ts.hbs +172 -0
- package/build/esm/templates/typescript/schema/builder.ts.hbs +24 -0
- package/build/esm/templates/typescript/schema/core.schemas.types.ts.hbs +34 -0
- package/build/esm/templates/typescript/schema/example.ts.hbs +20 -0
- package/build/esm/templates/typescript/schema/fields/fieldClassMap.ts.hbs +16 -0
- package/build/esm/templates/typescript/schema/fields/fields.types.ts.hbs +1 -0
- package/build/esm/templates/typescript/schema/imported.schema.ts.hbs +1 -0
- package/build/esm/templates/typescript/schema/partials/fieldDefinitionBody.ts.hbs +12 -0
- package/build/esm/templates/typescript/schema/partials/schemaBody.ts.hbs +20 -0
- package/build/esm/templates/typescript/schema/partials/schemaValues.ts.hbs +7 -0
- package/build/esm/templates/typescript/schema/schema.plugin.ts.hbs +101 -0
- package/build/esm/templates/typescript/schema/schema.ts.hbs +12 -0
- package/build/esm/templates/typescript/schema/schemas.types.ts.hbs +44 -0
- package/build/esm/templates/typescript/schema/valueTypes.ts.hbs +67 -0
- package/build/esm/templates/typescript/store/Store.store.ts.hbs +95 -0
- package/build/esm/templates/typescript/store/store.plugin.ts.hbs +1 -0
- package/build/esm/templates/typescript/store/stores.ts.hbs +9 -0
- package/build/esm/templates/typescript/store/stores.types.ts.hbs +17 -0
- package/build/esm/templates/typescript/test/StaticTest.test.ts.hbs +20 -0
- package/build/esm/templates/typescript/test/Test.test.ts.hbs +21 -0
- package/build/esm/templates/typescript/view/App.ac.ts.hbs +6 -0
- package/build/esm/templates/typescript/view/View.svc.ts.hbs +23 -0
- package/build/esm/templates/typescript/view/View.vc.ts.hbs +17 -0
- package/build/esm/templates/typescript/view/skill.theme.ts.hbs +70 -0
- package/build/esm/templates/typescript/view/view.plugin.ts.hbs +1 -0
- package/build/esm/templates/typescript/view/viewController.plugin.ts.hbs +3 -0
- package/build/esm/templates/typescript/view/views.ts.hbs +93 -0
- package/build/esm/types/templates.types.d.ts +122 -0
- package/build/esm/types/templates.types.js +5 -0
- package/build/esm/utilities/DirectoryTemplateUtility.d.ts +15 -0
- package/build/esm/utilities/DirectoryTemplateUtility.js +79 -0
- package/build/esm/utilities/KeyGeneratorUtility.d.ts +5 -0
- package/build/esm/utilities/KeyGeneratorUtility.js +6 -0
- package/build/esm/utilities/importExtractor.utility.d.ts +10 -0
- package/build/esm/utilities/importExtractor.utility.js +32 -0
- package/build/esm/utilities/templateImporter.utility.d.ts +4 -0
- package/build/esm/utilities/templateImporter.utility.js +18 -0
- package/build/esm/utilities/templateItem.utility.d.ts +6 -0
- package/build/esm/utilities/templateItem.utility.js +25 -0
- package/build/index.js.map +1 -0
- package/build/types/templates.types.js.map +1 -0
- package/build/utilities/DirectoryTemplateUtility.js.map +1 -0
- package/build/utilities/KeyGeneratorUtility.js.map +1 -0
- package/build/utilities/importExtractor.utility.js.map +1 -0
- package/build/utilities/templateImporter.utility.js.map +1 -0
- package/build/utilities/templateItem.utility.js.map +1 -0
- package/package.json +7 -7
- package/LICENSE +0 -21
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SchemaField } from '@sprucelabs/schema';
|
|
2
|
+
import handlebars from 'handlebars';
|
|
3
|
+
import { camelCase, uniq } from 'lodash';
|
|
4
|
+
handlebars.registerHelper('importRelatedSchemas', function (schema, options) {
|
|
5
|
+
var _a;
|
|
6
|
+
if (!schema) {
|
|
7
|
+
throw new Error('importRelatedSchemas needs a Schema as the first arg');
|
|
8
|
+
}
|
|
9
|
+
const { data: { root }, } = options;
|
|
10
|
+
const schemaTemplateItems = root === null || root === void 0 ? void 0 : root.schemaTemplateItems;
|
|
11
|
+
if (!schemaTemplateItems) {
|
|
12
|
+
throw new Error('importRelatedSchemas needs schemaTemplateItems passed to parent template');
|
|
13
|
+
}
|
|
14
|
+
const fields = schema.dynamicFieldSignature
|
|
15
|
+
? [schema.dynamicFieldSignature]
|
|
16
|
+
: Object.values((_a = schema.fields) !== null && _a !== void 0 ? _a : {});
|
|
17
|
+
const imports = [];
|
|
18
|
+
fields.forEach((field) => {
|
|
19
|
+
if (field.type === 'schema') {
|
|
20
|
+
const related = SchemaField.mapFieldDefinitionToSchemaIdsWithVersion(field);
|
|
21
|
+
related.forEach((idWithVersion) => {
|
|
22
|
+
const matched = schemaTemplateItems.find((t) => t.id === idWithVersion.id &&
|
|
23
|
+
t.schema.version === idWithVersion.version &&
|
|
24
|
+
t.schema.namespace === idWithVersion.namespace);
|
|
25
|
+
if (matched) {
|
|
26
|
+
imports.push(`import ${matched.nameCamel}Schema${matched.schema.version
|
|
27
|
+
? `_${matched.schema.version}`
|
|
28
|
+
: ''} from '${matched.destinationDir}/${camelCase(matched.namespace)}${matched.schema.version ? `/${matched.schema.version}` : ''}/${matched.id}.schema'`);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return uniq(imports).join('\n');
|
|
34
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import './eq.addon';
|
|
2
|
+
import './escape.addon';
|
|
3
|
+
import './fieldDefinitionBodyPartial.addon';
|
|
4
|
+
import './fieldDefinitionOptions.addon';
|
|
5
|
+
import './fieldTypeEnum.addon';
|
|
6
|
+
import './fieldValue.addon';
|
|
7
|
+
import './gt.addon';
|
|
8
|
+
import './hasKeys.addon';
|
|
9
|
+
import './hasNoneCoreSchemaTemplateItems.addon';
|
|
10
|
+
import './importRelatedSchemas.addon';
|
|
11
|
+
import './index';
|
|
12
|
+
import './isDefined.addon';
|
|
13
|
+
import './json.addon';
|
|
14
|
+
import './neq.addon';
|
|
15
|
+
import './operators.addon';
|
|
16
|
+
import './pascalCase.addon';
|
|
17
|
+
import './permissionContractBuilder.addon';
|
|
18
|
+
import './schemaBodyPartial.addon';
|
|
19
|
+
import './schemaNamespacePath.addon';
|
|
20
|
+
import './schemaValuesPartial.addon';
|
|
21
|
+
import './valueTypeGenerator.addon';
|
|
22
|
+
import './valueTypeLiteral.addon';
|
|
23
|
+
import './valueTypeMapper.addon';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import './eq.addon';
|
|
2
|
+
import './escape.addon';
|
|
3
|
+
import './fieldDefinitionBodyPartial.addon';
|
|
4
|
+
import './fieldDefinitionOptions.addon';
|
|
5
|
+
import './fieldTypeEnum.addon';
|
|
6
|
+
import './fieldValue.addon';
|
|
7
|
+
import './gt.addon';
|
|
8
|
+
import './hasKeys.addon';
|
|
9
|
+
import './hasNoneCoreSchemaTemplateItems.addon';
|
|
10
|
+
import './importRelatedSchemas.addon';
|
|
11
|
+
import './index';
|
|
12
|
+
import './isDefined.addon';
|
|
13
|
+
import './json.addon';
|
|
14
|
+
import './neq.addon';
|
|
15
|
+
import './operators.addon';
|
|
16
|
+
import './pascalCase.addon';
|
|
17
|
+
import './permissionContractBuilder.addon';
|
|
18
|
+
import './schemaBodyPartial.addon';
|
|
19
|
+
import './schemaNamespacePath.addon';
|
|
20
|
+
import './schemaValuesPartial.addon';
|
|
21
|
+
import './valueTypeGenerator.addon';
|
|
22
|
+
import './valueTypeLiteral.addon';
|
|
23
|
+
import './valueTypeMapper.addon';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import handlebars from 'handlebars';
|
|
2
|
+
/* Quick way to do an equals check against 2 values */
|
|
3
|
+
handlebars.registerHelper('json', function (arg1) {
|
|
4
|
+
//@ts-ignore // TODO how should this work in a typed environment?
|
|
5
|
+
const value = JSON.stringify(arg1);
|
|
6
|
+
return value;
|
|
7
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import handlebars from 'handlebars';
|
|
2
|
+
handlebars.registerHelper({
|
|
3
|
+
eq: (v1, v2) => v1 === v2,
|
|
4
|
+
ne: (v1, v2) => v1 !== v2,
|
|
5
|
+
lt: (v1, v2) => v1 < v2,
|
|
6
|
+
gt: (v1, v2) => v1 > v2,
|
|
7
|
+
lte: (v1, v2) => v1 <= v2,
|
|
8
|
+
gte: (v1, v2) => v1 >= v2,
|
|
9
|
+
and(...params) {
|
|
10
|
+
return Array.prototype.every.call(params, Boolean);
|
|
11
|
+
},
|
|
12
|
+
or(...params) {
|
|
13
|
+
return Array.prototype.slice.call(params, 0, -1).some(Boolean);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import handlebars from 'handlebars';
|
|
4
|
+
const templatePath = path.join(__dirname, '..', 'templates', 'typescript');
|
|
5
|
+
const schemaBodyPartial = fs
|
|
6
|
+
.readFileSync(path.join(templatePath, 'schema/partials/schemaBody.ts.hbs'))
|
|
7
|
+
.toString();
|
|
8
|
+
handlebars.registerPartial('schemaBody', schemaBodyPartial);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import handlebars from 'handlebars';
|
|
2
|
+
handlebars.registerHelper('schemaNamespacePath', function (options) {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
const { schemaTemplateItem } = options.hash;
|
|
5
|
+
if (!schemaTemplateItem) {
|
|
6
|
+
throw new Error(`schemaNamespacePath needs schemaTemplateItem=item`);
|
|
7
|
+
}
|
|
8
|
+
const { globalSchemaNamespace } = (_b = (_a = options === null || options === void 0 ? void 0 : options.data) === null || _a === void 0 ? void 0 : _a.root) !== null && _b !== void 0 ? _b : {};
|
|
9
|
+
if (!globalSchemaNamespace) {
|
|
10
|
+
throw new Error('schemaNamespacePath template addon needs globalSchemaNamespace in the root context.');
|
|
11
|
+
}
|
|
12
|
+
let path = `${globalSchemaNamespace}.${schemaTemplateItem.namespace}`;
|
|
13
|
+
if (schemaTemplateItem.schema.version) {
|
|
14
|
+
path += `.${schemaTemplateItem.schema.version}`;
|
|
15
|
+
}
|
|
16
|
+
path += `.${schemaTemplateItem.namePascal}`;
|
|
17
|
+
return path;
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import handlebars from 'handlebars';
|
|
4
|
+
const templatePath = path.join(__dirname, '..', 'templates', 'typescript');
|
|
5
|
+
const schemaValuesPartial = fs
|
|
6
|
+
.readFileSync(path.join(templatePath, 'schema/partials/schemaValues.ts.hbs'))
|
|
7
|
+
.toString();
|
|
8
|
+
handlebars.registerPartial('schemaValues', schemaValuesPartial);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import handlebars from 'handlebars';
|
|
2
|
+
import { upperFirst } from 'lodash';
|
|
3
|
+
handlebars.registerHelper('valueTypeGenerator', function (fieldDefinition, renderAs, func, options) {
|
|
4
|
+
const { data: { root: { fieldTemplateItems }, }, } = options;
|
|
5
|
+
const match = fieldTemplateItems.filter((item) => item.camelType === fieldDefinition.type)[0];
|
|
6
|
+
if (!match) {
|
|
7
|
+
throw new Error(`valueTypeGenerator.addon could not find a fieldTemplateItem with type ${fieldDefinition.type}`);
|
|
8
|
+
}
|
|
9
|
+
const type = handlebars.helpers.fieldTypeEnum(fieldDefinition, options);
|
|
10
|
+
const fieldDefinitionCopy = Object.assign({}, fieldDefinition);
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
fieldDefinitionCopy === null || fieldDefinitionCopy === void 0 ? true : delete fieldDefinitionCopy.keyName;
|
|
13
|
+
const def = JSON.stringify(Object.assign(Object.assign({}, fieldDefinitionCopy), { type: '{{TYPE_ENUM}}' })).replace('"{{TYPE_ENUM}}"', type);
|
|
14
|
+
return `${func}(${def}, TemplateRenderAs.${upperFirst(renderAs)}, "${match.importAs}")`;
|
|
15
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TemplateRenderAs } from '@sprucelabs/schema';
|
|
2
|
+
import { SCHEMA_VERSION_FALLBACK } from '@sprucelabs/spruce-skill-utils';
|
|
3
|
+
import handlebars from 'handlebars';
|
|
4
|
+
/* The type for the value of a field. the special case is if the field is of type schema, then we get the target's interface */
|
|
5
|
+
handlebars.registerHelper('valueTypeLiteral', function (namespace, nameCamel, version, fieldName, renderAs, options) {
|
|
6
|
+
var _a, _b, _c, _d;
|
|
7
|
+
if (!namespace) {
|
|
8
|
+
throw new Error('valueTypeLiteral needs namespace as 1st argument');
|
|
9
|
+
}
|
|
10
|
+
if (!nameCamel) {
|
|
11
|
+
throw new Error('valueTypeLiteral needs nameCamel as 2st argument');
|
|
12
|
+
}
|
|
13
|
+
if (!fieldName) {
|
|
14
|
+
throw new Error('valueTypeLiteral needs fieldName as 3st argument');
|
|
15
|
+
}
|
|
16
|
+
if (renderAs !== TemplateRenderAs.Value &&
|
|
17
|
+
renderAs !== TemplateRenderAs.Type &&
|
|
18
|
+
renderAs !== TemplateRenderAs.SchemaType) {
|
|
19
|
+
throw new Error('valueTypeLiteral helper needs renderAs to be "TemplateRenderAs.Type" or "TemplateRenderAs.Value" or "TemplateRenderAs.schemaType"');
|
|
20
|
+
}
|
|
21
|
+
const { data: { root }, } = options;
|
|
22
|
+
const valueTypes = root === null || root === void 0 ? void 0 : root.valueTypes;
|
|
23
|
+
if (!valueTypes) {
|
|
24
|
+
throw new Error('valueTypeLiteral helper needs a valuesTypes in the root context');
|
|
25
|
+
}
|
|
26
|
+
const v = version ? version : SCHEMA_VERSION_FALLBACK;
|
|
27
|
+
const valueType = (_d = (_c = (_b = (_a = valueTypes[namespace]) === null || _a === void 0 ? void 0 : _a[nameCamel]) === null || _b === void 0 ? void 0 : _b[v]) === null || _c === void 0 ? void 0 : _c[fieldName]) === null || _d === void 0 ? void 0 : _d.valueTypes[renderAs];
|
|
28
|
+
if (!valueType) {
|
|
29
|
+
throw new Error(`Unable to render value type for field "${namespace}.${nameCamel}.${v}.${fieldName}"`);
|
|
30
|
+
}
|
|
31
|
+
return valueType;
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { PermissionContractMap } from '@sprucelabs/mercury-types';
|
|
2
|
+
import { Schema, SchemaTemplateItem, FieldTemplateItem } from '@sprucelabs/schema';
|
|
3
|
+
import { TemplateRenderAs } from '@sprucelabs/schema';
|
|
4
|
+
import handlebars from 'handlebars';
|
|
5
|
+
import { FieldDefinitions } from '#spruce/schemas/fields/fields.types';
|
|
6
|
+
import { DirectoryTemplateCode, DirectoryTemplateContextMap, ValueTypes, SchemaBuilderTemplateItem, ErrorOptions, ErrorTemplateItem, TestOptions, EventListenerOptions, EventContractTemplateItem, EventPayloadOptions, StoreTemplateOptions, StoreTemplateItem, ViewsOptions as CombinedViewsOptions, ListenerTemplateItem } from './types/templates.types';
|
|
7
|
+
import './addons';
|
|
8
|
+
export declare const templates: {
|
|
9
|
+
schemasTypes(options: {
|
|
10
|
+
schemaTemplateItems: SchemaTemplateItem[];
|
|
11
|
+
fieldTemplateItems: FieldTemplateItem[];
|
|
12
|
+
valueTypes: ValueTypes;
|
|
13
|
+
globalSchemaNamespace?: string;
|
|
14
|
+
typesTemplate?: string;
|
|
15
|
+
}): string;
|
|
16
|
+
valueTypes(options: {
|
|
17
|
+
schemaTemplateItems: SchemaTemplateItem[];
|
|
18
|
+
fieldTemplateItems: FieldTemplateItem[];
|
|
19
|
+
globalSchemaNamespace?: string;
|
|
20
|
+
}): string;
|
|
21
|
+
schema(options: SchemaTemplateItem & {
|
|
22
|
+
schemaTemplateItems: SchemaTemplateItem[];
|
|
23
|
+
fieldTemplateItems: FieldTemplateItem[];
|
|
24
|
+
valueTypes: ValueTypes;
|
|
25
|
+
globalSchemaNamespace?: string;
|
|
26
|
+
registerBuiltSchemas: boolean;
|
|
27
|
+
schemaFile?: string;
|
|
28
|
+
typesFile?: string;
|
|
29
|
+
}): string;
|
|
30
|
+
schemaBuilder(options: SchemaBuilderTemplateItem): string;
|
|
31
|
+
error(options: ErrorOptions): string;
|
|
32
|
+
errorOptionsTypes(options: {
|
|
33
|
+
options: ErrorTemplateItem[];
|
|
34
|
+
}): string;
|
|
35
|
+
schemaExample(options: {
|
|
36
|
+
nameCamel: string;
|
|
37
|
+
namePascal: string;
|
|
38
|
+
definition: Schema;
|
|
39
|
+
}): string;
|
|
40
|
+
schemaPlugin(): string;
|
|
41
|
+
errorPlugin(): string;
|
|
42
|
+
conversationPlugin(): string;
|
|
43
|
+
deployPlugin(): string;
|
|
44
|
+
errorExample(options: {
|
|
45
|
+
nameCamel: string;
|
|
46
|
+
namePascal: string;
|
|
47
|
+
definition: Schema;
|
|
48
|
+
}): string;
|
|
49
|
+
test(options: TestOptions): string;
|
|
50
|
+
fieldsTypes(options: {
|
|
51
|
+
fieldTemplateItems: FieldTemplateItem[];
|
|
52
|
+
}): string;
|
|
53
|
+
fieldClassMap(options: {
|
|
54
|
+
fieldTemplateItems: FieldTemplateItem[];
|
|
55
|
+
}): string;
|
|
56
|
+
launchConfig(): string;
|
|
57
|
+
vsCodeSettings(): Promise<string>;
|
|
58
|
+
listener(options: EventListenerOptions): string;
|
|
59
|
+
listeners(options: {
|
|
60
|
+
listeners: ListenerTemplateItem[];
|
|
61
|
+
}): string;
|
|
62
|
+
eventContract(options: EventContractTemplateItem & {
|
|
63
|
+
schemaTemplateItems: SchemaTemplateItem[];
|
|
64
|
+
}): string;
|
|
65
|
+
eventOptions(options: {
|
|
66
|
+
isGlobal: boolean;
|
|
67
|
+
}): string;
|
|
68
|
+
permissionPlugin(): string;
|
|
69
|
+
permissions(options: {
|
|
70
|
+
contracts: {
|
|
71
|
+
path: string;
|
|
72
|
+
nameCamel: string;
|
|
73
|
+
}[];
|
|
74
|
+
}): string;
|
|
75
|
+
permissionContractBuilder(options: {
|
|
76
|
+
nameCamel: string;
|
|
77
|
+
nameKebab: string;
|
|
78
|
+
nameReadable: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
}): string;
|
|
81
|
+
permissionTypes(options: {
|
|
82
|
+
contracts: PermissionContractMap;
|
|
83
|
+
}): string;
|
|
84
|
+
eventEmitPayload(options: EventPayloadOptions): string;
|
|
85
|
+
eventEmitTarget(options: EventPayloadOptions): string;
|
|
86
|
+
eventResponsePayload(options: EventPayloadOptions): string;
|
|
87
|
+
combinedEventsContract(options: {
|
|
88
|
+
templateItems: EventContractTemplateItem[];
|
|
89
|
+
shouldImportCoreEvents?: boolean;
|
|
90
|
+
skillEventContractTypesFile: string;
|
|
91
|
+
}): string;
|
|
92
|
+
sandboxWillBootListener(): string;
|
|
93
|
+
polish(): string;
|
|
94
|
+
directoryTemplate<K extends DirectoryTemplateCode>(options: {
|
|
95
|
+
kind: K;
|
|
96
|
+
context: DirectoryTemplateContextMap[K];
|
|
97
|
+
}): Promise<(import("./types/templates.types").DirectoryTemplateFile & {
|
|
98
|
+
contents: string;
|
|
99
|
+
})[]>;
|
|
100
|
+
isValidTemplatedDirectory(options: {
|
|
101
|
+
kind: DirectoryTemplateCode;
|
|
102
|
+
dir: string;
|
|
103
|
+
}): Promise<boolean>;
|
|
104
|
+
conversationTopic(options: {
|
|
105
|
+
nameReadable: string;
|
|
106
|
+
}): string;
|
|
107
|
+
generateFieldKey(renderAs: TemplateRenderAs, definition: FieldDefinitions): string;
|
|
108
|
+
storePlugin(): string;
|
|
109
|
+
store(options: StoreTemplateOptions): string;
|
|
110
|
+
storeTypes(options: {
|
|
111
|
+
stores: StoreTemplateItem[];
|
|
112
|
+
}): string;
|
|
113
|
+
stores(options: {
|
|
114
|
+
stores: StoreTemplateItem[];
|
|
115
|
+
}): string;
|
|
116
|
+
skillViewController(options: {
|
|
117
|
+
namePascal: string;
|
|
118
|
+
nameKebab: string;
|
|
119
|
+
}): string;
|
|
120
|
+
viewController(options: {
|
|
121
|
+
viewModel: string;
|
|
122
|
+
namePascal: string;
|
|
123
|
+
nameKebab: string;
|
|
124
|
+
}): string;
|
|
125
|
+
appController(options: {
|
|
126
|
+
id: string;
|
|
127
|
+
namespacePascal: string;
|
|
128
|
+
}): string;
|
|
129
|
+
views(options: CombinedViewsOptions): string;
|
|
130
|
+
viewPlugin(): string;
|
|
131
|
+
viewControllerPlugin(options: {
|
|
132
|
+
namePascal: string;
|
|
133
|
+
nameCamel: string;
|
|
134
|
+
}): string;
|
|
135
|
+
theme(): string;
|
|
136
|
+
logTransport(): string;
|
|
137
|
+
};
|
|
138
|
+
export type Templates = typeof templates;
|
|
139
|
+
export { default as importExtractorUtil } from './utilities/importExtractor.utility';
|
|
140
|
+
export default handlebars;
|
|
141
|
+
export * from './types/templates.types';
|