@sprucelabs/spruce-templates 23.0.0 → 24.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/LICENSE +21 -0
- package/build/templates/typescript/event/event.contract.ts.hbs +2 -0
- package/build/templates/typescript/sandbox/will-boot.listener.ts.hbs +138 -73
- package/package.json +10 -10
- 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 -24
- 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 -109
- 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/Test.test.ts.hbs +0 -20
- 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 -255
- 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 -24
- 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 -109
- 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/Test.test.ts.hbs +0 -20
- 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 -121
- 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,93 +0,0 @@
|
|
|
1
|
-
{{#each svcTemplateItems}}
|
|
2
|
-
import {{namePascal}} from '{{path}}'
|
|
3
|
-
{{/each}}
|
|
4
|
-
{{#each vcTemplateItems}}
|
|
5
|
-
import {{namePascal}} from '{{path}}'
|
|
6
|
-
{{/each}}
|
|
7
|
-
{{#each viewPluginItems}}
|
|
8
|
-
import {{namePascal}} from '{{path}}'
|
|
9
|
-
{{/each}}
|
|
10
|
-
{{#if appTemplateItem}}
|
|
11
|
-
import {{appTemplateItem.namePascal}} from '{{appTemplateItem.path}}'
|
|
12
|
-
{{/if}}
|
|
13
|
-
|
|
14
|
-
import '@sprucelabs/heartwood-view-controllers'
|
|
15
|
-
|
|
16
|
-
const vcs = {
|
|
17
|
-
{{#each svcTemplateItems}}
|
|
18
|
-
{{namePascal}},
|
|
19
|
-
{{/each}}
|
|
20
|
-
{{#each vcTemplateItems}}
|
|
21
|
-
{{namePascal}},
|
|
22
|
-
{{/each}}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const pluginsByName = {
|
|
26
|
-
{{#each viewPluginItems}}
|
|
27
|
-
{{nameCamel}}: {{namePascal}},
|
|
28
|
-
{{/each}}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{{#if svcTemplateItems}}
|
|
34
|
-
type LoadOptions<Args extends Record<string,any>[]> = Args[0]['args'] extends Record<string, any> ? Args[0]['args'] : Record<never, any>
|
|
35
|
-
{{/if}}
|
|
36
|
-
|
|
37
|
-
declare module '@sprucelabs/heartwood-view-controllers/build/types/heartwood.types' {
|
|
38
|
-
interface SkillViewControllerMap {
|
|
39
|
-
{{#each svcTemplateItems}}
|
|
40
|
-
'{{../namespaceKebab}}.{{id}}': {{namePascal}}
|
|
41
|
-
{{/each}}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
interface SkillViewControllerArgsMap {
|
|
45
|
-
{{#each svcTemplateItems}}
|
|
46
|
-
'{{../namespaceKebab}}.{{id}}': LoadOptions<Parameters<{{namePascal}}['load']>>
|
|
47
|
-
{{/each}}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface ViewControllerMap {
|
|
51
|
-
{{#each vcTemplateItems}}
|
|
52
|
-
'{{../namespaceKebab}}.{{id}}': {{namePascal}}
|
|
53
|
-
{{/each}}
|
|
54
|
-
{{#each svcTemplateItems}}
|
|
55
|
-
'{{../namespaceKebab}}.{{id}}': {{namePascal}}
|
|
56
|
-
{{/each}}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
interface ViewControllerOptionsMap {
|
|
60
|
-
{{#each vcTemplateItems}}
|
|
61
|
-
'{{../namespaceKebab}}.{{id}}': ConstructorParameters<typeof {{namePascal}}>[0]
|
|
62
|
-
{{/each}}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface ViewControllerPlugins {
|
|
66
|
-
{{#each viewPluginItems}}
|
|
67
|
-
{{nameCamel}}: {{namePascal}}
|
|
68
|
-
{{/each}}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface AppControllerMap {
|
|
72
|
-
{{#if appTemplateItem}}
|
|
73
|
-
'{{namespaceKebab}}': {{appTemplateItem.namePascal}}
|
|
74
|
-
{{/if}}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
//@ts-ignore
|
|
80
|
-
if(typeof heartwood === 'function') {
|
|
81
|
-
{{#if appTemplateItem}}
|
|
82
|
-
//@ts-ignore
|
|
83
|
-
heartwood({ vcs, pluginsByName, App: {{appTemplateItem.namePascal}} })
|
|
84
|
-
{{else}}
|
|
85
|
-
//@ts-ignore
|
|
86
|
-
heartwood({ vcs, pluginsByName })
|
|
87
|
-
{{/if}}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export default vcs
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
export const App = {{#if appTemplateItem}}{{appTemplateItem.namePascal}}{{else}}undefined{{/if}}
|
|
@@ -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 fieldPartial = fs
|
|
6
|
-
.readFileSync(path.join(templatePath, 'schema/partials/fieldDefinitionBody.ts.hbs'))
|
|
7
|
-
.toString();
|
|
8
|
-
handlebars.registerPartial('fieldDefinitionBody', fieldPartial);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -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 {};
|