@sprucelabs/spruce-templates 25.0.0 → 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/LICENSE +21 -0
- package/package.json +7 -7
- package/build/addons/eq.addon.js.map +0 -1
- package/build/addons/escape.addon.js.map +0 -1
- package/build/addons/fieldDefinitionBodyPartial.addon.js.map +0 -1
- package/build/addons/fieldDefinitionOptions.addon.js.map +0 -1
- package/build/addons/fieldTypeEnum.addon.js.map +0 -1
- package/build/addons/fieldValue.addon.js.map +0 -1
- package/build/addons/gt.addon.js.map +0 -1
- package/build/addons/hasKeys.addon.js.map +0 -1
- package/build/addons/hasNoneCoreSchemaTemplateItems.addon.js.map +0 -1
- package/build/addons/importRelatedSchemas.addon.js.map +0 -1
- package/build/addons/index.js.map +0 -1
- package/build/addons/isDefined.addon.js.map +0 -1
- package/build/addons/json.addon.js.map +0 -1
- package/build/addons/neq.addon.js.map +0 -1
- package/build/addons/operators.addon.js.map +0 -1
- package/build/addons/pascalCase.addon.js.map +0 -1
- package/build/addons/permissionContractBuilder.addon.js.map +0 -1
- package/build/addons/schemaBodyPartial.addon.js.map +0 -1
- package/build/addons/schemaNamespacePath.addon.js.map +0 -1
- package/build/addons/schemaValuesPartial.addon.js.map +0 -1
- package/build/addons/valueTypeGenerator.addon.js.map +0 -1
- package/build/addons/valueTypeLiteral.addon.js.map +0 -1
- package/build/addons/valueTypeMapper.addon.js.map +0 -1
- package/build/dist/templates/directories/skill/.nvmrc +0 -1
- package/build/dist/templates/directories/skill/README.md +0 -4
- package/build/dist/templates/directories/skill/eslint.config.mjs +0 -3
- package/build/dist/templates/directories/skill/package.json.hbs +0 -15
- package/build/dist/templates/directories/skill/src/errors/SpruceError.ts.hbs +0 -20
- package/build/dist/templates/directories/skill/tsconfig.json +0 -39
- package/build/dist/templates/directories/vscode/.vscode/launch.json +0 -58
- package/build/dist/templates/directories/vscode/.vscode/settings.json +0 -67
- package/build/dist/templates/directories/vscode/.vscode/tasks.json +0 -112
- package/build/dist/templates/typescript/conversation/conversation.plugin.ts.hbs +0 -1
- package/build/dist/templates/typescript/conversation/conversation.topic.ts.hbs +0 -19
- package/build/dist/templates/typescript/deploy/deploy.plugin.ts.hbs +0 -1
- package/build/dist/templates/typescript/error/SpruceError.ts.hbs +0 -31
- package/build/dist/templates/typescript/error/error.plugin.ts.hbs +0 -78
- package/build/dist/templates/typescript/error/example.ts.hbs +0 -10
- package/build/dist/templates/typescript/error/options.types.ts.hbs +0 -12
- package/build/dist/templates/typescript/event/event.contract.ts.hbs +0 -26
- package/build/dist/templates/typescript/event/event.options.ts.hbs +0 -11
- package/build/dist/templates/typescript/event/events.contract.ts.hbs +0 -24
- package/build/dist/templates/typescript/event/listener.ts.hbs +0 -23
- package/build/dist/templates/typescript/event/listeners.ts.hbs +0 -15
- package/build/dist/templates/typescript/event/payload.builder.ts.hbs +0 -15
- package/build/dist/templates/typescript/log/transport.plugin.ts.hbs +0 -14
- package/build/dist/templates/typescript/permissions/contract.builder.ts.hbs +0 -36
- package/build/dist/templates/typescript/permissions/permission.plugin.ts.hbs +0 -1
- package/build/dist/templates/typescript/permissions/permissions.ts.hbs +0 -13
- package/build/dist/templates/typescript/permissions/permissions.types.ts.hbs +0 -14
- package/build/dist/templates/typescript/polish/polish.ts.hbs +0 -67
- package/build/dist/templates/typescript/sandbox/will-boot.listener.ts.hbs +0 -172
- package/build/dist/templates/typescript/schema/builder.ts.hbs +0 -24
- package/build/dist/templates/typescript/schema/core.schemas.types.ts.hbs +0 -34
- package/build/dist/templates/typescript/schema/example.ts.hbs +0 -20
- package/build/dist/templates/typescript/schema/fields/fieldClassMap.ts.hbs +0 -16
- package/build/dist/templates/typescript/schema/fields/fields.types.ts.hbs +0 -1
- package/build/dist/templates/typescript/schema/imported.schema.ts.hbs +0 -1
- package/build/dist/templates/typescript/schema/partials/fieldDefinitionBody.ts.hbs +0 -12
- package/build/dist/templates/typescript/schema/partials/schemaBody.ts.hbs +0 -20
- package/build/dist/templates/typescript/schema/partials/schemaValues.ts.hbs +0 -7
- package/build/dist/templates/typescript/schema/schema.plugin.ts.hbs +0 -101
- package/build/dist/templates/typescript/schema/schema.ts.hbs +0 -12
- package/build/dist/templates/typescript/schema/schemas.types.ts.hbs +0 -44
- package/build/dist/templates/typescript/schema/valueTypes.ts.hbs +0 -67
- package/build/dist/templates/typescript/store/Store.store.ts.hbs +0 -95
- package/build/dist/templates/typescript/store/store.plugin.ts.hbs +0 -1
- package/build/dist/templates/typescript/store/stores.ts.hbs +0 -9
- package/build/dist/templates/typescript/store/stores.types.ts.hbs +0 -17
- package/build/dist/templates/typescript/test/StaticTest.test.ts.hbs +0 -20
- package/build/dist/templates/typescript/test/Test.test.ts.hbs +0 -21
- package/build/dist/templates/typescript/view/App.ac.ts.hbs +0 -6
- package/build/dist/templates/typescript/view/View.svc.ts.hbs +0 -23
- package/build/dist/templates/typescript/view/View.vc.ts.hbs +0 -17
- package/build/dist/templates/typescript/view/skill.theme.ts.hbs +0 -70
- package/build/dist/templates/typescript/view/view.plugin.ts.hbs +0 -1
- package/build/dist/templates/typescript/view/viewController.plugin.ts.hbs +0 -3
- package/build/dist/templates/typescript/view/views.ts.hbs +0 -93
- package/build/esm/addons/eq.addon.d.ts +0 -1
- package/build/esm/addons/eq.addon.js +0 -4
- package/build/esm/addons/escape.addon.d.ts +0 -1
- package/build/esm/addons/escape.addon.js +0 -5
- package/build/esm/addons/fieldDefinitionBodyPartial.addon.d.ts +0 -1
- package/build/esm/addons/fieldDefinitionBodyPartial.addon.js +0 -8
- package/build/esm/addons/fieldDefinitionOptions.addon.d.ts +0 -1
- package/build/esm/addons/fieldDefinitionOptions.addon.js +0 -66
- package/build/esm/addons/fieldTypeEnum.addon.d.ts +0 -1
- package/build/esm/addons/fieldTypeEnum.addon.js +0 -9
- package/build/esm/addons/fieldValue.addon.d.ts +0 -1
- package/build/esm/addons/fieldValue.addon.js +0 -8
- package/build/esm/addons/gt.addon.d.ts +0 -1
- package/build/esm/addons/gt.addon.js +0 -4
- package/build/esm/addons/hasKeys.addon.d.ts +0 -1
- package/build/esm/addons/hasKeys.addon.js +0 -4
- package/build/esm/addons/hasNoneCoreSchemaTemplateItems.addon.d.ts +0 -1
- package/build/esm/addons/hasNoneCoreSchemaTemplateItems.addon.js +0 -6
- package/build/esm/addons/importRelatedSchemas.addon.d.ts +0 -1
- package/build/esm/addons/importRelatedSchemas.addon.js +0 -34
- package/build/esm/addons/index.d.ts +0 -23
- package/build/esm/addons/index.js +0 -23
- package/build/esm/addons/isDefined.addon.d.ts +0 -1
- package/build/esm/addons/isDefined.addon.js +0 -5
- package/build/esm/addons/json.addon.d.ts +0 -1
- package/build/esm/addons/json.addon.js +0 -7
- package/build/esm/addons/neq.addon.d.ts +0 -1
- package/build/esm/addons/neq.addon.js +0 -4
- package/build/esm/addons/operators.addon.d.ts +0 -1
- package/build/esm/addons/operators.addon.js +0 -15
- package/build/esm/addons/pascalCase.addon.d.ts +0 -1
- package/build/esm/addons/pascalCase.addon.js +0 -6
- package/build/esm/addons/permissionContractBuilder.addon.d.ts +0 -1
- package/build/esm/addons/permissionContractBuilder.addon.js +0 -4
- package/build/esm/addons/schemaBodyPartial.addon.d.ts +0 -1
- package/build/esm/addons/schemaBodyPartial.addon.js +0 -8
- package/build/esm/addons/schemaNamespacePath.addon.d.ts +0 -1
- package/build/esm/addons/schemaNamespacePath.addon.js +0 -18
- package/build/esm/addons/schemaValuesPartial.addon.d.ts +0 -1
- package/build/esm/addons/schemaValuesPartial.addon.js +0 -8
- package/build/esm/addons/valueTypeGenerator.addon.d.ts +0 -1
- package/build/esm/addons/valueTypeGenerator.addon.js +0 -15
- package/build/esm/addons/valueTypeLiteral.addon.d.ts +0 -1
- package/build/esm/addons/valueTypeLiteral.addon.js +0 -32
- package/build/esm/addons/valueTypeMapper.addon.d.ts +0 -1
- package/build/esm/addons/valueTypeMapper.addon.js +0 -9
- package/build/esm/index.d.ts +0 -141
- package/build/esm/index.js +0 -258
- package/build/esm/templates/directories/skill/.nvmrc +0 -1
- package/build/esm/templates/directories/skill/README.md +0 -4
- package/build/esm/templates/directories/skill/eslint.config.mjs +0 -3
- package/build/esm/templates/directories/skill/package.json.hbs +0 -15
- package/build/esm/templates/directories/skill/src/.spruce/errors/options.types.ts +0 -6
- package/build/esm/templates/directories/skill/src/.spruce/features/event.plugin.ts +0 -1
- package/build/esm/templates/directories/skill/src/.spruce/skill.ts +0 -8
- package/build/esm/templates/directories/skill/src/errors/SpruceError.ts.hbs +0 -20
- package/build/esm/templates/directories/skill/src/index.ts +0 -35
- package/build/esm/templates/directories/skill/tsconfig.json +0 -39
- package/build/esm/templates/directories/vscode/.vscode/launch.json +0 -58
- package/build/esm/templates/directories/vscode/.vscode/settings.json +0 -67
- package/build/esm/templates/directories/vscode/.vscode/tasks.json +0 -112
- package/build/esm/templates/typescript/conversation/conversation.plugin.ts.hbs +0 -1
- package/build/esm/templates/typescript/conversation/conversation.topic.ts.hbs +0 -19
- package/build/esm/templates/typescript/deploy/deploy.plugin.ts.hbs +0 -1
- package/build/esm/templates/typescript/error/SpruceError.ts.hbs +0 -31
- package/build/esm/templates/typescript/error/error.plugin.ts.hbs +0 -78
- package/build/esm/templates/typescript/error/example.ts.hbs +0 -10
- package/build/esm/templates/typescript/error/options.types.ts.hbs +0 -12
- package/build/esm/templates/typescript/event/event.contract.ts.hbs +0 -26
- package/build/esm/templates/typescript/event/event.options.ts.hbs +0 -11
- package/build/esm/templates/typescript/event/events.contract.ts.hbs +0 -24
- package/build/esm/templates/typescript/event/listener.ts.hbs +0 -23
- package/build/esm/templates/typescript/event/listeners.ts.hbs +0 -15
- package/build/esm/templates/typescript/event/payload.builder.ts.hbs +0 -15
- package/build/esm/templates/typescript/log/transport.plugin.ts.hbs +0 -14
- package/build/esm/templates/typescript/permissions/contract.builder.ts.hbs +0 -36
- package/build/esm/templates/typescript/permissions/permission.plugin.ts.hbs +0 -1
- package/build/esm/templates/typescript/permissions/permissions.ts.hbs +0 -13
- package/build/esm/templates/typescript/permissions/permissions.types.ts.hbs +0 -14
- package/build/esm/templates/typescript/polish/polish.ts.hbs +0 -67
- package/build/esm/templates/typescript/sandbox/will-boot.listener.ts.hbs +0 -172
- package/build/esm/templates/typescript/schema/builder.ts.hbs +0 -24
- package/build/esm/templates/typescript/schema/core.schemas.types.ts.hbs +0 -34
- package/build/esm/templates/typescript/schema/example.ts.hbs +0 -20
- package/build/esm/templates/typescript/schema/fields/fieldClassMap.ts.hbs +0 -16
- package/build/esm/templates/typescript/schema/fields/fields.types.ts.hbs +0 -1
- package/build/esm/templates/typescript/schema/imported.schema.ts.hbs +0 -1
- package/build/esm/templates/typescript/schema/partials/fieldDefinitionBody.ts.hbs +0 -12
- package/build/esm/templates/typescript/schema/partials/schemaBody.ts.hbs +0 -20
- package/build/esm/templates/typescript/schema/partials/schemaValues.ts.hbs +0 -7
- package/build/esm/templates/typescript/schema/schema.plugin.ts.hbs +0 -101
- package/build/esm/templates/typescript/schema/schema.ts.hbs +0 -12
- package/build/esm/templates/typescript/schema/schemas.types.ts.hbs +0 -44
- package/build/esm/templates/typescript/schema/valueTypes.ts.hbs +0 -67
- package/build/esm/templates/typescript/store/Store.store.ts.hbs +0 -95
- package/build/esm/templates/typescript/store/store.plugin.ts.hbs +0 -1
- package/build/esm/templates/typescript/store/stores.ts.hbs +0 -9
- package/build/esm/templates/typescript/store/stores.types.ts.hbs +0 -17
- package/build/esm/templates/typescript/test/StaticTest.test.ts.hbs +0 -20
- package/build/esm/templates/typescript/test/Test.test.ts.hbs +0 -21
- package/build/esm/templates/typescript/view/App.ac.ts.hbs +0 -6
- package/build/esm/templates/typescript/view/View.svc.ts.hbs +0 -23
- package/build/esm/templates/typescript/view/View.vc.ts.hbs +0 -17
- package/build/esm/templates/typescript/view/skill.theme.ts.hbs +0 -70
- package/build/esm/templates/typescript/view/view.plugin.ts.hbs +0 -1
- package/build/esm/templates/typescript/view/viewController.plugin.ts.hbs +0 -3
- package/build/esm/templates/typescript/view/views.ts.hbs +0 -93
- package/build/esm/types/templates.types.d.ts +0 -122
- package/build/esm/types/templates.types.js +0 -5
- package/build/esm/utilities/DirectoryTemplateUtility.d.ts +0 -15
- package/build/esm/utilities/DirectoryTemplateUtility.js +0 -79
- package/build/esm/utilities/KeyGeneratorUtility.d.ts +0 -5
- package/build/esm/utilities/KeyGeneratorUtility.js +0 -6
- package/build/esm/utilities/importExtractor.utility.d.ts +0 -10
- package/build/esm/utilities/importExtractor.utility.js +0 -32
- package/build/esm/utilities/templateImporter.utility.d.ts +0 -4
- package/build/esm/utilities/templateImporter.utility.js +0 -18
- package/build/esm/utilities/templateItem.utility.d.ts +0 -6
- package/build/esm/utilities/templateItem.utility.js +0 -25
- package/build/index.js.map +0 -1
- package/build/types/templates.types.js.map +0 -1
- package/build/utilities/DirectoryTemplateUtility.js.map +0 -1
- package/build/utilities/KeyGeneratorUtility.js.map +0 -1
- package/build/utilities/importExtractor.utility.js.map +0 -1
- package/build/utilities/templateImporter.utility.js.map +0 -1
- package/build/utilities/templateItem.utility.js.map +0 -1
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { TemplateRenderAs } from '@sprucelabs/schema';
|
|
2
|
-
import handlebars from 'handlebars';
|
|
3
|
-
/** Renders field options */
|
|
4
|
-
handlebars.registerHelper('fieldDefinitionOptions', function (namespace, schemaNameCamel, version, fieldName, fieldDefinition, renderAs, options) {
|
|
5
|
-
if (typeof namespace !== 'string') {
|
|
6
|
-
throw new Error('fieldDefinitionOptions helper needs namespace first');
|
|
7
|
-
}
|
|
8
|
-
if (typeof schemaNameCamel !== 'string') {
|
|
9
|
-
throw new Error('fieldDefinitionOptions helper needs schemaNameCamel 2nd.');
|
|
10
|
-
}
|
|
11
|
-
if (typeof fieldName !== 'string') {
|
|
12
|
-
throw new Error('fieldDefinitionOptions helper needs fieldName 3rd');
|
|
13
|
-
}
|
|
14
|
-
if (!fieldDefinition) {
|
|
15
|
-
throw new Error('fieldDefinitionOptions helper needs a FieldDefinition as the 4th argument');
|
|
16
|
-
}
|
|
17
|
-
if (!options ||
|
|
18
|
-
(renderAs !== TemplateRenderAs.Type &&
|
|
19
|
-
renderAs !== TemplateRenderAs.Value)) {
|
|
20
|
-
throw new Error("fieldDefinitionOptions helper's second arg as type|value");
|
|
21
|
-
}
|
|
22
|
-
const { data: { root }, } = options;
|
|
23
|
-
const schemaTemplateItems = root && root.schemaTemplateItems;
|
|
24
|
-
if (!schemaTemplateItems) {
|
|
25
|
-
throw new Error('fieldDefinitionOptions needs schemaTemplateItems passed to parent template');
|
|
26
|
-
}
|
|
27
|
-
const updatedOptions = fieldDefinition.options && Object.assign({}, fieldDefinition.options);
|
|
28
|
-
// If this is a schema type, we need to map it to it's proper value type
|
|
29
|
-
if (fieldDefinition.type === 'schema' && updatedOptions) {
|
|
30
|
-
const value = handlebars.helpers.valueTypeLiteral(namespace, schemaNameCamel, version, fieldName, renderAs === TemplateRenderAs.Type
|
|
31
|
-
? TemplateRenderAs.SchemaType
|
|
32
|
-
: TemplateRenderAs.Value, options);
|
|
33
|
-
// Swap out id for reference
|
|
34
|
-
delete updatedOptions.schemaId;
|
|
35
|
-
delete updatedOptions.schema;
|
|
36
|
-
delete updatedOptions.schemaIds;
|
|
37
|
-
delete updatedOptions.schemas;
|
|
38
|
-
if (value.substr(-1) === ']') {
|
|
39
|
-
updatedOptions.schemas = value;
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
updatedOptions.schema = value;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
// No options, undefined is acceptable
|
|
46
|
-
if (Object.keys(updatedOptions !== null && updatedOptions !== void 0 ? updatedOptions : {}).length === 0) {
|
|
47
|
-
return 'undefined';
|
|
48
|
-
}
|
|
49
|
-
let template = `{`;
|
|
50
|
-
Object.keys(updatedOptions !== null && updatedOptions !== void 0 ? updatedOptions : {}).forEach((key) => {
|
|
51
|
-
// @ts-ignore TODO how to type this
|
|
52
|
-
const value = updatedOptions[key];
|
|
53
|
-
template += `${key}: `;
|
|
54
|
-
if (key === 'schemas' || key === 'schema') {
|
|
55
|
-
template += `${value},`;
|
|
56
|
-
}
|
|
57
|
-
else if (typeof value !== 'string') {
|
|
58
|
-
template += `${JSON.stringify(value)},`;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
template += `\`${value.replace(/([`])/g, '\\$1')}\`,`;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
template += '}';
|
|
65
|
-
return template;
|
|
66
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import handlebars from 'handlebars';
|
|
2
|
-
/* The enum for schema.fields.fieldName.type as a string */
|
|
3
|
-
handlebars.registerHelper('fieldTypeEnum', function (fieldDefinitions) {
|
|
4
|
-
if (!fieldDefinitions) {
|
|
5
|
-
throw new Error('fieldTypeEnum helper needs a FieldDefinitions as the first argument');
|
|
6
|
-
}
|
|
7
|
-
const { type } = fieldDefinitions;
|
|
8
|
-
return `'${type}'`;
|
|
9
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import handlebars from 'handlebars';
|
|
2
|
-
/** Drop in the value of a field which quotes if needed */
|
|
3
|
-
handlebars.registerHelper('fieldValue', function (fieldDefinitions, value) {
|
|
4
|
-
if (value) {
|
|
5
|
-
throw new Error('field value not yet implemented');
|
|
6
|
-
}
|
|
7
|
-
return value;
|
|
8
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CORE_NAMESPACE } from '@sprucelabs/spruce-skill-utils';
|
|
2
|
-
import handlebars from 'handlebars';
|
|
3
|
-
handlebars.registerHelper('hasNonCoreSchemaTemplateItems', function (schemaTemplateItems) {
|
|
4
|
-
return (schemaTemplateItems.filter((i) => i.namespace !== CORE_NAMESPACE)
|
|
5
|
-
.length > 0);
|
|
6
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
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';
|
|
@@ -1,23 +0,0 @@
|
|
|
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';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
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);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
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);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/build/esm/index.d.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
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';
|