@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.
Files changed (206) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +7 -7
  3. package/build/addons/eq.addon.js.map +0 -1
  4. package/build/addons/escape.addon.js.map +0 -1
  5. package/build/addons/fieldDefinitionBodyPartial.addon.js.map +0 -1
  6. package/build/addons/fieldDefinitionOptions.addon.js.map +0 -1
  7. package/build/addons/fieldTypeEnum.addon.js.map +0 -1
  8. package/build/addons/fieldValue.addon.js.map +0 -1
  9. package/build/addons/gt.addon.js.map +0 -1
  10. package/build/addons/hasKeys.addon.js.map +0 -1
  11. package/build/addons/hasNoneCoreSchemaTemplateItems.addon.js.map +0 -1
  12. package/build/addons/importRelatedSchemas.addon.js.map +0 -1
  13. package/build/addons/index.js.map +0 -1
  14. package/build/addons/isDefined.addon.js.map +0 -1
  15. package/build/addons/json.addon.js.map +0 -1
  16. package/build/addons/neq.addon.js.map +0 -1
  17. package/build/addons/operators.addon.js.map +0 -1
  18. package/build/addons/pascalCase.addon.js.map +0 -1
  19. package/build/addons/permissionContractBuilder.addon.js.map +0 -1
  20. package/build/addons/schemaBodyPartial.addon.js.map +0 -1
  21. package/build/addons/schemaNamespacePath.addon.js.map +0 -1
  22. package/build/addons/schemaValuesPartial.addon.js.map +0 -1
  23. package/build/addons/valueTypeGenerator.addon.js.map +0 -1
  24. package/build/addons/valueTypeLiteral.addon.js.map +0 -1
  25. package/build/addons/valueTypeMapper.addon.js.map +0 -1
  26. package/build/dist/templates/directories/skill/.nvmrc +0 -1
  27. package/build/dist/templates/directories/skill/README.md +0 -4
  28. package/build/dist/templates/directories/skill/eslint.config.mjs +0 -3
  29. package/build/dist/templates/directories/skill/package.json.hbs +0 -15
  30. package/build/dist/templates/directories/skill/src/errors/SpruceError.ts.hbs +0 -20
  31. package/build/dist/templates/directories/skill/tsconfig.json +0 -39
  32. package/build/dist/templates/directories/vscode/.vscode/launch.json +0 -58
  33. package/build/dist/templates/directories/vscode/.vscode/settings.json +0 -67
  34. package/build/dist/templates/directories/vscode/.vscode/tasks.json +0 -112
  35. package/build/dist/templates/typescript/conversation/conversation.plugin.ts.hbs +0 -1
  36. package/build/dist/templates/typescript/conversation/conversation.topic.ts.hbs +0 -19
  37. package/build/dist/templates/typescript/deploy/deploy.plugin.ts.hbs +0 -1
  38. package/build/dist/templates/typescript/error/SpruceError.ts.hbs +0 -31
  39. package/build/dist/templates/typescript/error/error.plugin.ts.hbs +0 -78
  40. package/build/dist/templates/typescript/error/example.ts.hbs +0 -10
  41. package/build/dist/templates/typescript/error/options.types.ts.hbs +0 -12
  42. package/build/dist/templates/typescript/event/event.contract.ts.hbs +0 -26
  43. package/build/dist/templates/typescript/event/event.options.ts.hbs +0 -11
  44. package/build/dist/templates/typescript/event/events.contract.ts.hbs +0 -24
  45. package/build/dist/templates/typescript/event/listener.ts.hbs +0 -23
  46. package/build/dist/templates/typescript/event/listeners.ts.hbs +0 -15
  47. package/build/dist/templates/typescript/event/payload.builder.ts.hbs +0 -15
  48. package/build/dist/templates/typescript/log/transport.plugin.ts.hbs +0 -14
  49. package/build/dist/templates/typescript/permissions/contract.builder.ts.hbs +0 -36
  50. package/build/dist/templates/typescript/permissions/permission.plugin.ts.hbs +0 -1
  51. package/build/dist/templates/typescript/permissions/permissions.ts.hbs +0 -13
  52. package/build/dist/templates/typescript/permissions/permissions.types.ts.hbs +0 -14
  53. package/build/dist/templates/typescript/polish/polish.ts.hbs +0 -67
  54. package/build/dist/templates/typescript/sandbox/will-boot.listener.ts.hbs +0 -172
  55. package/build/dist/templates/typescript/schema/builder.ts.hbs +0 -24
  56. package/build/dist/templates/typescript/schema/core.schemas.types.ts.hbs +0 -34
  57. package/build/dist/templates/typescript/schema/example.ts.hbs +0 -20
  58. package/build/dist/templates/typescript/schema/fields/fieldClassMap.ts.hbs +0 -16
  59. package/build/dist/templates/typescript/schema/fields/fields.types.ts.hbs +0 -1
  60. package/build/dist/templates/typescript/schema/imported.schema.ts.hbs +0 -1
  61. package/build/dist/templates/typescript/schema/partials/fieldDefinitionBody.ts.hbs +0 -12
  62. package/build/dist/templates/typescript/schema/partials/schemaBody.ts.hbs +0 -20
  63. package/build/dist/templates/typescript/schema/partials/schemaValues.ts.hbs +0 -7
  64. package/build/dist/templates/typescript/schema/schema.plugin.ts.hbs +0 -101
  65. package/build/dist/templates/typescript/schema/schema.ts.hbs +0 -12
  66. package/build/dist/templates/typescript/schema/schemas.types.ts.hbs +0 -44
  67. package/build/dist/templates/typescript/schema/valueTypes.ts.hbs +0 -67
  68. package/build/dist/templates/typescript/store/Store.store.ts.hbs +0 -95
  69. package/build/dist/templates/typescript/store/store.plugin.ts.hbs +0 -1
  70. package/build/dist/templates/typescript/store/stores.ts.hbs +0 -9
  71. package/build/dist/templates/typescript/store/stores.types.ts.hbs +0 -17
  72. package/build/dist/templates/typescript/test/StaticTest.test.ts.hbs +0 -20
  73. package/build/dist/templates/typescript/test/Test.test.ts.hbs +0 -21
  74. package/build/dist/templates/typescript/view/App.ac.ts.hbs +0 -6
  75. package/build/dist/templates/typescript/view/View.svc.ts.hbs +0 -23
  76. package/build/dist/templates/typescript/view/View.vc.ts.hbs +0 -17
  77. package/build/dist/templates/typescript/view/skill.theme.ts.hbs +0 -70
  78. package/build/dist/templates/typescript/view/view.plugin.ts.hbs +0 -1
  79. package/build/dist/templates/typescript/view/viewController.plugin.ts.hbs +0 -3
  80. package/build/dist/templates/typescript/view/views.ts.hbs +0 -93
  81. package/build/esm/addons/eq.addon.d.ts +0 -1
  82. package/build/esm/addons/eq.addon.js +0 -4
  83. package/build/esm/addons/escape.addon.d.ts +0 -1
  84. package/build/esm/addons/escape.addon.js +0 -5
  85. package/build/esm/addons/fieldDefinitionBodyPartial.addon.d.ts +0 -1
  86. package/build/esm/addons/fieldDefinitionBodyPartial.addon.js +0 -8
  87. package/build/esm/addons/fieldDefinitionOptions.addon.d.ts +0 -1
  88. package/build/esm/addons/fieldDefinitionOptions.addon.js +0 -66
  89. package/build/esm/addons/fieldTypeEnum.addon.d.ts +0 -1
  90. package/build/esm/addons/fieldTypeEnum.addon.js +0 -9
  91. package/build/esm/addons/fieldValue.addon.d.ts +0 -1
  92. package/build/esm/addons/fieldValue.addon.js +0 -8
  93. package/build/esm/addons/gt.addon.d.ts +0 -1
  94. package/build/esm/addons/gt.addon.js +0 -4
  95. package/build/esm/addons/hasKeys.addon.d.ts +0 -1
  96. package/build/esm/addons/hasKeys.addon.js +0 -4
  97. package/build/esm/addons/hasNoneCoreSchemaTemplateItems.addon.d.ts +0 -1
  98. package/build/esm/addons/hasNoneCoreSchemaTemplateItems.addon.js +0 -6
  99. package/build/esm/addons/importRelatedSchemas.addon.d.ts +0 -1
  100. package/build/esm/addons/importRelatedSchemas.addon.js +0 -34
  101. package/build/esm/addons/index.d.ts +0 -23
  102. package/build/esm/addons/index.js +0 -23
  103. package/build/esm/addons/isDefined.addon.d.ts +0 -1
  104. package/build/esm/addons/isDefined.addon.js +0 -5
  105. package/build/esm/addons/json.addon.d.ts +0 -1
  106. package/build/esm/addons/json.addon.js +0 -7
  107. package/build/esm/addons/neq.addon.d.ts +0 -1
  108. package/build/esm/addons/neq.addon.js +0 -4
  109. package/build/esm/addons/operators.addon.d.ts +0 -1
  110. package/build/esm/addons/operators.addon.js +0 -15
  111. package/build/esm/addons/pascalCase.addon.d.ts +0 -1
  112. package/build/esm/addons/pascalCase.addon.js +0 -6
  113. package/build/esm/addons/permissionContractBuilder.addon.d.ts +0 -1
  114. package/build/esm/addons/permissionContractBuilder.addon.js +0 -4
  115. package/build/esm/addons/schemaBodyPartial.addon.d.ts +0 -1
  116. package/build/esm/addons/schemaBodyPartial.addon.js +0 -8
  117. package/build/esm/addons/schemaNamespacePath.addon.d.ts +0 -1
  118. package/build/esm/addons/schemaNamespacePath.addon.js +0 -18
  119. package/build/esm/addons/schemaValuesPartial.addon.d.ts +0 -1
  120. package/build/esm/addons/schemaValuesPartial.addon.js +0 -8
  121. package/build/esm/addons/valueTypeGenerator.addon.d.ts +0 -1
  122. package/build/esm/addons/valueTypeGenerator.addon.js +0 -15
  123. package/build/esm/addons/valueTypeLiteral.addon.d.ts +0 -1
  124. package/build/esm/addons/valueTypeLiteral.addon.js +0 -32
  125. package/build/esm/addons/valueTypeMapper.addon.d.ts +0 -1
  126. package/build/esm/addons/valueTypeMapper.addon.js +0 -9
  127. package/build/esm/index.d.ts +0 -141
  128. package/build/esm/index.js +0 -258
  129. package/build/esm/templates/directories/skill/.nvmrc +0 -1
  130. package/build/esm/templates/directories/skill/README.md +0 -4
  131. package/build/esm/templates/directories/skill/eslint.config.mjs +0 -3
  132. package/build/esm/templates/directories/skill/package.json.hbs +0 -15
  133. package/build/esm/templates/directories/skill/src/.spruce/errors/options.types.ts +0 -6
  134. package/build/esm/templates/directories/skill/src/.spruce/features/event.plugin.ts +0 -1
  135. package/build/esm/templates/directories/skill/src/.spruce/skill.ts +0 -8
  136. package/build/esm/templates/directories/skill/src/errors/SpruceError.ts.hbs +0 -20
  137. package/build/esm/templates/directories/skill/src/index.ts +0 -35
  138. package/build/esm/templates/directories/skill/tsconfig.json +0 -39
  139. package/build/esm/templates/directories/vscode/.vscode/launch.json +0 -58
  140. package/build/esm/templates/directories/vscode/.vscode/settings.json +0 -67
  141. package/build/esm/templates/directories/vscode/.vscode/tasks.json +0 -112
  142. package/build/esm/templates/typescript/conversation/conversation.plugin.ts.hbs +0 -1
  143. package/build/esm/templates/typescript/conversation/conversation.topic.ts.hbs +0 -19
  144. package/build/esm/templates/typescript/deploy/deploy.plugin.ts.hbs +0 -1
  145. package/build/esm/templates/typescript/error/SpruceError.ts.hbs +0 -31
  146. package/build/esm/templates/typescript/error/error.plugin.ts.hbs +0 -78
  147. package/build/esm/templates/typescript/error/example.ts.hbs +0 -10
  148. package/build/esm/templates/typescript/error/options.types.ts.hbs +0 -12
  149. package/build/esm/templates/typescript/event/event.contract.ts.hbs +0 -26
  150. package/build/esm/templates/typescript/event/event.options.ts.hbs +0 -11
  151. package/build/esm/templates/typescript/event/events.contract.ts.hbs +0 -24
  152. package/build/esm/templates/typescript/event/listener.ts.hbs +0 -23
  153. package/build/esm/templates/typescript/event/listeners.ts.hbs +0 -15
  154. package/build/esm/templates/typescript/event/payload.builder.ts.hbs +0 -15
  155. package/build/esm/templates/typescript/log/transport.plugin.ts.hbs +0 -14
  156. package/build/esm/templates/typescript/permissions/contract.builder.ts.hbs +0 -36
  157. package/build/esm/templates/typescript/permissions/permission.plugin.ts.hbs +0 -1
  158. package/build/esm/templates/typescript/permissions/permissions.ts.hbs +0 -13
  159. package/build/esm/templates/typescript/permissions/permissions.types.ts.hbs +0 -14
  160. package/build/esm/templates/typescript/polish/polish.ts.hbs +0 -67
  161. package/build/esm/templates/typescript/sandbox/will-boot.listener.ts.hbs +0 -172
  162. package/build/esm/templates/typescript/schema/builder.ts.hbs +0 -24
  163. package/build/esm/templates/typescript/schema/core.schemas.types.ts.hbs +0 -34
  164. package/build/esm/templates/typescript/schema/example.ts.hbs +0 -20
  165. package/build/esm/templates/typescript/schema/fields/fieldClassMap.ts.hbs +0 -16
  166. package/build/esm/templates/typescript/schema/fields/fields.types.ts.hbs +0 -1
  167. package/build/esm/templates/typescript/schema/imported.schema.ts.hbs +0 -1
  168. package/build/esm/templates/typescript/schema/partials/fieldDefinitionBody.ts.hbs +0 -12
  169. package/build/esm/templates/typescript/schema/partials/schemaBody.ts.hbs +0 -20
  170. package/build/esm/templates/typescript/schema/partials/schemaValues.ts.hbs +0 -7
  171. package/build/esm/templates/typescript/schema/schema.plugin.ts.hbs +0 -101
  172. package/build/esm/templates/typescript/schema/schema.ts.hbs +0 -12
  173. package/build/esm/templates/typescript/schema/schemas.types.ts.hbs +0 -44
  174. package/build/esm/templates/typescript/schema/valueTypes.ts.hbs +0 -67
  175. package/build/esm/templates/typescript/store/Store.store.ts.hbs +0 -95
  176. package/build/esm/templates/typescript/store/store.plugin.ts.hbs +0 -1
  177. package/build/esm/templates/typescript/store/stores.ts.hbs +0 -9
  178. package/build/esm/templates/typescript/store/stores.types.ts.hbs +0 -17
  179. package/build/esm/templates/typescript/test/StaticTest.test.ts.hbs +0 -20
  180. package/build/esm/templates/typescript/test/Test.test.ts.hbs +0 -21
  181. package/build/esm/templates/typescript/view/App.ac.ts.hbs +0 -6
  182. package/build/esm/templates/typescript/view/View.svc.ts.hbs +0 -23
  183. package/build/esm/templates/typescript/view/View.vc.ts.hbs +0 -17
  184. package/build/esm/templates/typescript/view/skill.theme.ts.hbs +0 -70
  185. package/build/esm/templates/typescript/view/view.plugin.ts.hbs +0 -1
  186. package/build/esm/templates/typescript/view/viewController.plugin.ts.hbs +0 -3
  187. package/build/esm/templates/typescript/view/views.ts.hbs +0 -93
  188. package/build/esm/types/templates.types.d.ts +0 -122
  189. package/build/esm/types/templates.types.js +0 -5
  190. package/build/esm/utilities/DirectoryTemplateUtility.d.ts +0 -15
  191. package/build/esm/utilities/DirectoryTemplateUtility.js +0 -79
  192. package/build/esm/utilities/KeyGeneratorUtility.d.ts +0 -5
  193. package/build/esm/utilities/KeyGeneratorUtility.js +0 -6
  194. package/build/esm/utilities/importExtractor.utility.d.ts +0 -10
  195. package/build/esm/utilities/importExtractor.utility.js +0 -32
  196. package/build/esm/utilities/templateImporter.utility.d.ts +0 -4
  197. package/build/esm/utilities/templateImporter.utility.js +0 -18
  198. package/build/esm/utilities/templateItem.utility.d.ts +0 -6
  199. package/build/esm/utilities/templateItem.utility.js +0 -25
  200. package/build/index.js.map +0 -1
  201. package/build/types/templates.types.js.map +0 -1
  202. package/build/utilities/DirectoryTemplateUtility.js.map +0 -1
  203. package/build/utilities/KeyGeneratorUtility.js.map +0 -1
  204. package/build/utilities/importExtractor.utility.js.map +0 -1
  205. package/build/utilities/templateImporter.utility.js.map +0 -1
  206. package/build/utilities/templateItem.utility.js.map +0 -1
@@ -1,31 +0,0 @@
1
- {{#if renderClassDefinition}}
2
- import BaseSpruceError from '@sprucelabs/error'
3
- import ErrorOptions from '#spruce/errors/options.types'
4
-
5
- export default class SpruceError extends BaseSpruceError<ErrorOptions>{
6
-
7
- /** an easy to understand version of the errors */
8
- public friendlyMessage():string {
9
-
10
- const { options } = this
11
- let message
12
- switch (options?.code) {
13
- {{/if}}
14
- {{#each errors}}
15
- case '{{code}}':
16
- message = '{{#if description}}{{{escape description}}}{{else}}A {{{escape nameReadable}}} just happened!{{/if}}'
17
- break
18
- {{/each}}
19
- {{#if renderClassDefinition}}
20
- default:
21
- message = super.friendlyMessage()
22
- }
23
-
24
- const fullMessage = options.friendlyMessage
25
- ? options.friendlyMessage
26
- : message
27
-
28
- return fullMessage
29
- }
30
- }
31
- {{/if}}
@@ -1,78 +0,0 @@
1
- import globby from '@sprucelabs/globby'
2
- import {
3
- ErrorHealthCheckItem,
4
- SkillFeature,
5
- Skill,
6
- diskUtil,
7
- HASH_SPRUCE_DIR_NAME,
8
- BootCallback,
9
- } from '@sprucelabs/spruce-skill-utils'
10
-
11
- class ErrorSkillFeature implements SkillFeature {
12
- private skill: Skill
13
- private _isBooted = false
14
- private bootHandler?: BootCallback
15
-
16
- public constructor(skill: Skill) {
17
- this.skill = skill
18
- }
19
-
20
- public onBoot(cb: BootCallback) {
21
- this.bootHandler = cb
22
- }
23
-
24
- public execute = async () => {
25
- this._isBooted = true
26
- void this.bootHandler?.()
27
- }
28
-
29
- public checkHealth = async () => {
30
- const errorFiles = await this.getErrors()
31
-
32
- const errors = errorFiles.map((path) => {
33
- const schema = require(path).default
34
-
35
- return {
36
- id: schema.id,
37
- name: schema.name,
38
- description: schema.description,
39
- }
40
- })
41
-
42
- const health: ErrorHealthCheckItem = {
43
- status: 'passed',
44
- errorSchemas: errors,
45
- }
46
-
47
- return health
48
- }
49
-
50
- public isInstalled = async () => {
51
- return true
52
- }
53
-
54
- public async destroy() {
55
- this._isBooted = false
56
- }
57
-
58
- public isBooted() {
59
- return this._isBooted
60
- }
61
-
62
- private async getErrors() {
63
- const schemaFiles = await globby(
64
- diskUtil.resolvePath(
65
- this.skill.activeDir,
66
- HASH_SPRUCE_DIR_NAME,
67
- 'errors',
68
- '**/*.schema.[t|j]s'
69
- )
70
- )
71
- return schemaFiles
72
- }
73
- }
74
-
75
- export default (skill: Skill) => {
76
- const feature = new ErrorSkillFeature(skill)
77
- skill.registerFeature('error', feature)
78
- }
@@ -1,10 +0,0 @@
1
- // import your error
2
- import SpruceError from '../errors/Error'
3
-
4
- // throw your error
5
- throw new SpruceError({
6
- code: '{{nameConst}}'',
7
- {{#each schema.fields}}
8
- {{@key}}: ...,
9
- {{/each}}
10
- })
@@ -1,12 +0,0 @@
1
- import { SpruceErrors } from "#spruce/errors/errors.types"
2
- import { ErrorOptions as ISpruceErrorOptions} from "@sprucelabs/error"
3
-
4
- {{#each options}}
5
- export interface {{namePascal}}ErrorOptions extends SpruceErrors.{{namespace}}.{{namePascal}}, ISpruceErrorOptions {
6
- code: '{{code}}'
7
- }
8
- {{/each}}
9
-
10
- type ErrorOptions = {{#each options}} | {{namePascal}}ErrorOptions {{/each}}
11
-
12
- export default ErrorOptions
@@ -1,26 +0,0 @@
1
- import '#spruce/permissions/permissions.types'
2
- {{#each imports}}
3
- import {{importAs}} from '{{package}}'
4
- {{/each}}
5
-
6
-
7
- const {{nameCamel}}EventContract = buildEventContract({
8
- eventSignatures: {
9
- {{#each eventSignatures}}
10
- '{{@key}}': {
11
- {{#if isGlobal}}isGlobal: true,{{/if}}
12
- {{#if description}}description: `{{{description}}}`,{{/if}}
13
- {{#if aiInstructions}}aiInstructions: `{{{aiInstructions}}}`,{{/if}}
14
- {{#if emitPermissions}}emitPermissions: {{{json emitPermissions}}},{{/if}}
15
- {{#if listenPermissions}}listenPermissions: {{{json listenPermissions}}},{{/if}}
16
- {{#if emitPayloadSchema}}emitPayloadSchema: {{emitPayloadSchema.nameCamel}}Schema,{{/if}}
17
- {{#if responsePayloadSchema}}responsePayloadSchema: {{responsePayloadSchema.nameCamel}}Schema,{{/if}}
18
- {{#if emitPermissionContract}}emitPermissionContract: {{{ permissionContractBuilder emitPermissionContract }}},{{/if}}
19
- {{#if listenPermissionContract}}listenPermissionContract: {{{ permissionContractBuilder listenPermissionContract }}},{{/if}}
20
- }
21
- {{/each}}
22
- }
23
- })
24
- export default {{nameCamel}}EventContract
25
-
26
- export type {{namePascal}}EventContract = typeof {{nameCamel}}EventContract
@@ -1,11 +0,0 @@
1
- import { EventSignature } from '@sprucelabs/mercury-types'
2
- import '#spruce/permissions/permissions.types'
3
- import '@sprucelabs/mercury-core-events'
4
-
5
- type Options = Omit<EventSignature, 'responsePayloadSchema'| 'emitPayloadSchema'| 'listenPermissionContract'| 'emitPermissionContract' >
6
-
7
- const eventOptions: Options = {
8
- isGlobal: {{isGlobal}},
9
- }
10
-
11
- export default eventOptions
@@ -1,24 +0,0 @@
1
- {{#if shouldImportCoreEvents}}import { coreEventContracts } from '@sprucelabs/mercury-core-events'{{/if}}
2
-
3
- {{#each contracts}}
4
- import {{namespaceCamel}}{{namePascal}}EventContract_{{version}}, { {{namePascal}}EventContract as {{namespacePascal}}{{namePascal}}EventContract_{{version}} } from '#spruce/events/{{ namespaceCamel }}/{{ nameCamel }}.{{ version }}.contract'
5
- {{/each}}
6
-
7
- export default [
8
- {{#each contracts}}
9
- {{namespaceCamel}}{{namePascal}}EventContract_{{version}},
10
- {{/each}}
11
- {{#if shouldImportCoreEvents}}...coreEventContracts,{{/if}}
12
- ]
13
-
14
- declare module '{{skillEventContractTypesFile}}' {
15
- interface SkillEventSignatures {
16
- {{#each contracts}}
17
-
18
- {{#each eventSignatures}}
19
- '{{@key}}': {{../namespacePascal}}{{../namePascal}}EventContract_{{../version}}['eventSignatures']['{{@key}}'],
20
- {{/each}}
21
-
22
- {{/each}}
23
- }
24
- }
@@ -1,23 +0,0 @@
1
- import SpruceError from '#spruce/../errors/SpruceError'
2
- import { SpruceEvent, SpruceEventResponse } from '@sprucelabs/spruce-event-utils'
3
- {{#if emitPayloadSchemaTemplateItem}}import { SkillEventContract } from '@sprucelabs/mercury-types'{{/if}}
4
- {{#if shouldImportGlobalSchema}}import { {{globalSchemaNamespace}} } from '{{schemaTypesFile}}'{{/if}}
5
-
6
- export default async (event: SpruceEvent{{#if emitPayloadSchemaTemplateItem}}<SkillEventContract, EmitPayload>{{/if}}): SpruceEventResponse{{#if responsePayloadSchemaTemplateItem}}<ResponsePayload>{{/if}} => {
7
- console.log(event)
8
-
9
- throw new SpruceError({
10
- //@ts-ignore
11
- code: 'LISTENER_NOT_IMPLEMENTED',
12
- //@ts-ignore
13
- fullyQualifiedEventName: '{{fullyQualifiedEventName}}'
14
- })
15
-
16
- //return {}
17
- }
18
-
19
- {{#if emitPayloadSchemaTemplateItem}}
20
- type EmitPayload = {{{ schemaNamespacePath schemaTemplateItem=emitPayloadSchemaTemplateItem }}}
21
- {{/if}}{{#if responsePayloadSchemaTemplateItem}}
22
- type ResponsePayload = {{{ schemaNamespacePath schemaTemplateItem=responsePayloadSchemaTemplateItem }}}
23
- {{/if}}
@@ -1,15 +0,0 @@
1
- import { EventFeatureListener } from '@sprucelabs/spruce-event-utils'
2
-
3
- const listeners: EventFeatureListener[] = [
4
- {{#each listeners}}
5
- {
6
- eventName: '{{eventName}}',
7
- eventNamespace: '{{eventNamespace}}',
8
- version: '{{version}}',
9
- callback: require('{{path}}').default,
10
- isGlobal: require('{{path}}').isGlobal,
11
- },
12
- {{/each}}
13
- ]
14
-
15
- export default listeners
@@ -1,15 +0,0 @@
1
- import {
2
- buildSchema
3
- } from '@sprucelabs/schema'
4
-
5
- const {{nameCamel}}{{actionCamel}}Builder = buildSchema({
6
- id: '{{nameCamel}}{{actionCamel}}',
7
- fields: {
8
- aTextField: {
9
- type: 'text',
10
- label: 'Update me',
11
- }
12
- }
13
- })
14
-
15
- export default {{nameCamel}}{{actionCamel}}Builder
@@ -1,14 +0,0 @@
1
- import { Level, LogTransport } from '@sprucelabs/spruce-skill-utils'
2
-
3
- export default function (): {
4
- levels: Level[]
5
- transport: LogTransport
6
- } | null {
7
- return {
8
- levels: [],
9
- transport: (...messageParts: string[]) => {
10
- const message = messageParts.join(' ')
11
- console.log(message)
12
- },
13
- }
14
- }
@@ -1,36 +0,0 @@
1
- import {
2
- buildPermissionContract
3
- } from '@sprucelabs/mercury-types'
4
-
5
- const {{ nameCamel }}Permissions = buildPermissionContract({
6
- id: '{{nameKebab}}',
7
- name: '{{{escape nameReadable}}}',
8
- description: '{{{escape description}}}',
9
- requireAllPermissions: false,
10
- permissions: [
11
- {
12
- id: 'can-high-five',
13
- name: 'Can give high five',
14
- description: 'Will this person be allowed to high five?',
15
-
16
- defaults: {
17
- /**
18
- Uncomment this comment to set which roles will pass by default. Keep
19
- in mind this is overridden by the people who install your skill.
20
-
21
- guest: { onPrem: true },
22
- owner: { onPrem: true },
23
- groupManager: { onPrem: true },
24
- manager: { onPrem: true },
25
- teammate: { onPrem: true },
26
- anonymous: { default: false },
27
-
28
- **/
29
- skill: false,
30
- },
31
- requireAllStatuses: false,
32
- }
33
- ]
34
- })
35
-
36
- export default {{ nameCamel }}Permissions
@@ -1 +0,0 @@
1
- export { plugin as default } from '@sprucelabs/spruce-permission-plugin'
@@ -1,13 +0,0 @@
1
- import { PermissionContract } from "@sprucelabs/mercury-types"
2
- {{#each contracts}}
3
- import {{nameCamel}}PermissionContract from '{{path}}'
4
- {{/each}}
5
-
6
- const contracts: PermissionContract[] = [
7
- {{#each contracts}}
8
- {{nameCamel}}PermissionContract,
9
- {{/each}}
10
- ]
11
-
12
-
13
- export default contracts
@@ -1,14 +0,0 @@
1
- import '@sprucelabs/mercury-types'
2
-
3
- declare module '@sprucelabs/mercury-types/build/types/mercury.types' {
4
- interface PermissionContractMap {
5
- {{#each contracts}}
6
- '{{@key}}': [
7
- {{#each this}}'{{this}}',{{/each}}
8
- ]
9
- {{/each}}
10
- }
11
- }
12
-
13
-
14
- export interface PermissionContractMap {}
@@ -1,67 +0,0 @@
1
- import { PolishStep } from '@sprucelabs/heartwood-polish'
2
-
3
- // Documentation: https://developer.spruce.ai/#/polish/index
4
-
5
- const script: PolishStep[] = [
6
- /**{
7
- redirect: {
8
- id: 'heartwood.root',
9
- },
10
- },
11
- {
12
- typeText: {
13
- target: [['Field', 'phone']],
14
- text: '5555555555',
15
- },
16
- },
17
- {
18
- assert: {
19
- target: [['Field', 'phone']],
20
- inputValue: {
21
- equals: '+1 555-555-5555',
22
- },
23
- },
24
- },
25
- {
26
- click: {
27
- target: [['Button', 'primary']],
28
- },
29
- },
30
- {
31
- typeText: {
32
- target: [['Field', 'code']],
33
- text: '5555',
34
- },
35
- },
36
- {
37
- click: {
38
- target: [['NavMenu', 'settings']],
39
- },
40
- },
41
- {
42
- click: {
43
- target: [['NavLink', 'logout']],
44
- },
45
- },
46
- {
47
- click: {
48
- target: [['Dialog', 'primary']],
49
- },
50
- },
51
- {
52
- typeText: {
53
- target: [['Field', 'phone']],
54
- text: '555-555-2323',
55
- },
56
- },
57
- {
58
- assert: {
59
- target: [['Field', 'phone']],
60
- inputValue: {
61
- equals: '+1 555-555-2323',
62
- },
63
- },
64
- },**/
65
- ]
66
-
67
- export default script
@@ -1,172 +0,0 @@
1
- import { MercuryClient } from '@sprucelabs/mercury-client'
2
- import { SchemaError } from '@sprucelabs/schema'
3
- import { EventFeature } from '@sprucelabs/spruce-event-plugin'
4
- import {
5
- SpruceEvent,
6
- SpruceEventResponse,
7
- eventResponseUtil,
8
- } from '@sprucelabs/spruce-event-utils'
9
- import { EnvService, PkgService } from '@sprucelabs/spruce-skill-utils'
10
-
11
- export default async (event: SpruceEvent): SpruceEventResponse => {
12
- const sandboxNumber = process.env.SANDBOX_DEMO_NUMBER
13
-
14
- if (sandboxNumber && process.env.SKILL_ID) {
15
- const log = event.log.buildLog('Sandbox')
16
-
17
- log.info('Demo sandbox number detected. Checking skill status.')
18
-
19
- const events = event.skill.getFeatureByCode('event') as EventFeature
20
-
21
- const env = new EnvService(event.skill.rootDir)
22
- const pkg = new PkgService(event.skill.rootDir)
23
-
24
- process.env.SKILL_ID = (env.get('SKILL_ID') ??
25
- process.env.SKILL_ID) as string
26
- process.env.SKILL_API_KEY = (env.get('SKILL_API_KEY') ??
27
- process.env.SKILL_API_KEY) as string
28
-
29
- try {
30
- await events.connectToApi({ shouldWaitForWillBoot: false })
31
- return
32
- } catch {}
33
-
34
- log.warn('It looks like sandbox was reset. Re-registering.')
35
-
36
- const name = process.env.SKILL_NAME as string
37
- const slug = pkg.get(['skill', 'namespace']) as string
38
-
39
- assertRequiredParams(name, slug)
40
-
41
- delete process.env.SKILL_ID
42
- delete process.env.SKILL_API_KEY
43
-
44
- const client = (await events.connectToApi({
45
- shouldWaitForWillBoot: false,
46
- })) as any
47
-
48
- await login(client, sandboxNumber)
49
-
50
- const skill = await registerOrLoginSkill(client, name, slug)
51
- await client.emit(`logout::v2020_12_25`)
52
-
53
- await client.authenticate({
54
- skillId: skill.id,
55
- apiKey: skill.apiKey,
56
- })
57
-
58
- env.set('SKILL_ID', skill.id)
59
- env.set('SKILL_API_KEY', skill.apiKey)
60
- }
61
-
62
- return
63
- }
64
-
65
- async function login(client: any, sandboxNumber: string) {
66
- const requestResults = await client.emit('request-pin::v2020_12_25', {
67
- payload: {
68
- phone: sandboxNumber,
69
- },
70
- })
71
-
72
- const { challenge } =
73
- eventResponseUtil.getFirstResponseOrThrow(requestResults)
74
-
75
- const confirmResults = await client.emit('confirm-pin::v2020_12_25', {
76
- payload: {
77
- challenge,
78
- pin: sandboxNumber.substr(-4),
79
- },
80
- })
81
-
82
- eventResponseUtil.getFirstResponseOrThrow(confirmResults)
83
- }
84
-
85
- function assertRequiredParams(
86
- name: string | undefined,
87
- slug: string | undefined
88
- ) {
89
- const missing: string[] = []
90
-
91
- if (!name) {
92
- missing.push('env.SKILL_NAME')
93
- }
94
-
95
- if (!slug) {
96
- missing.push('env.SKILL_SLUG')
97
- }
98
-
99
- if (missing.length > 0) {
100
- throw new SchemaError({
101
- code: 'MISSING_PARAMETERS',
102
- parameters: missing,
103
- })
104
- }
105
- }
106
-
107
- async function registerOrLoginSkill(
108
- client: MercuryClient,
109
- name: string,
110
- slug: string
111
- ) {
112
- let skill: any
113
- try {
114
- skill = await registerSkill(client, name, slug)
115
- } catch (err: any) {
116
- skill = await loginSkill(client, slug)
117
- }
118
- process.env.SKILL_ID = skill.id
119
- process.env.SKILL_API_KEY = skill.apiKey
120
-
121
- return skill
122
- }
123
-
124
- async function registerSkill(
125
- client: MercuryClient,
126
- name: string,
127
- slug: string
128
- ) {
129
- const [{ skill }] = await client.emitAndFlattenResponses(
130
- 'register-skill::v2020_12_25',
131
- {
132
- payload: {
133
- name,
134
- description: 'Auto-generate for sandbox',
135
- slug,
136
- },
137
- }
138
- )
139
-
140
- return skill
141
- }
142
-
143
- async function loginSkill(client: MercuryClient, slug: string) {
144
- const [{ skills }] = await client.emitAndFlattenResponses(
145
- 'list-skills::v2020_12_25',
146
- {
147
- payload: {
148
- shouldOnlyShowMine: true,
149
- },
150
- }
151
- )
152
-
153
- const match = skills.find((s: any) => s.slug === slug)
154
-
155
- if (!match) {
156
- throw new Error(`Could not find skill with slug ${slug}`)
157
- }
158
-
159
- const [{ skill }] = await client.emitAndFlattenResponses(
160
- 'get-skill::v2020_12_25',
161
- {
162
- target: {
163
- skillId: match.id,
164
- },
165
- payload: {
166
- shouldIncludeApiKey: true,
167
- },
168
- }
169
- )
170
-
171
- return skill
172
- }
@@ -1,24 +0,0 @@
1
- import { {{builderFunction}} } from '@sprucelabs/schema'
2
-
3
-
4
- export default {{builderFunction}}({
5
- id: '{{nameCamel}}',
6
- name: '{{{escape nameReadable}}}',{{#if description}}
7
- description: '{{{escape description}}}',{{/if}}{{#if moduleToImportFromWhenRemote}}
8
- moduleToImportFromWhenRemote: '{{{escape moduleToImportFromWhenRemote}}}',{{/if}}
9
- fields: {
10
- fieldName1: {
11
- type: 'text',
12
- label: 'First Field',
13
- isRequired: true
14
- },
15
- fieldName2: {
16
- type: 'number',
17
- label: 'Second Field',
18
- isRequired: true,
19
- hint:
20
- 'A hint'
21
- }
22
- }
23
- })
24
-
@@ -1,34 +0,0 @@
1
- import { default as SchemaEntity } from '@sprucelabs/schema'
2
- {{#each imports}}
3
- import * as {{importAs}} from '{{package}}'
4
- {{/each}}
5
- {{#each schemaTemplateItems}}
6
-
7
- {{#each imports}}
8
- {{{this}}}
9
- {{/each}}
10
- {{/each}}
11
-
12
-
13
-
14
- {{#each schemaTemplateItems}}
15
-
16
- export declare namespace {{../globalSchemaNamespace}}.{{namespace}}{{#if (isDefined schema.version)}}.{{schema.version}}{{/if}} {
17
-
18
- {{#if schema.description}}/** {{schema.description}} */{{/if}}
19
- export interface {{namePascal}} {
20
- {{> schemaValues schema=schema renderAs="type" }}
21
- }
22
-
23
- export interface {{namePascal}}Schema extends SpruceSchema.Schema {
24
- {{> schemaBody namespace=namespace schema=schema renderAs="type" }}
25
- }
26
-
27
- export type {{namePascal}}Entity = SchemaEntity<{{../globalSchemaNamespace}}.{{namespace}}{{#if (isDefined schema.version)}}.{{schema.version}}{{/if}}.{{namePascal}}Schema>
28
-
29
- }
30
-
31
- {{/each}}
32
-
33
-
34
-
@@ -1,20 +0,0 @@
1
- // Importing your schema
2
- import {{nameCamel}}Schema from '#spruce/schemas/v2020_07_22/{{nameCamel}}.schema'
3
-
4
- // Importing interfaces
5
- import { {{namePascal}}, {{namePascal}}Entity } from '#spruce/schemas/v2020_07_22/{{nameCamel}}.types'
6
-
7
- // Create an entity instance based on a schema
8
- import Entity from '@sprucelabs/schema'
9
- const {{nameCamel}} = new Entity({{nameCamel}}Schema, values)
10
-
11
- // Set a value
12
- {{nameCamel}}.set('fieldName', newValue);
13
-
14
- // Get some values
15
- {{#each schema.fields}}
16
- const {{@key}} = {{../nameCamel}}.get('{{@key}}');
17
- {{/each}}
18
-
19
- // ensure it validates
20
- {{nameCamel}}.validate() // throws SchemaFieldValidationError
@@ -1,16 +0,0 @@
1
- import { fieldClassMap } from '@sprucelabs/schema'
2
-
3
- {{#each fieldTemplateItems}}
4
- {{#if isLocal}}
5
- import {{className}} from '{{package}}'
6
- {{/if}}
7
- {{/each}}
8
-
9
-
10
- {{#each fieldTemplateItems}}
11
- {{#if isLocal}}
12
- fieldClassMap.{{camelType}} = {{className}}
13
- {{/if}}
14
- {{/each}}
15
-
16
- export default fieldClassMap
@@ -1 +0,0 @@
1
- export { FieldDefinitions, FieldDefinitionMap, FieldValueTypeGeneratorMap, FieldMap } from '@sprucelabs/schema'
@@ -1 +0,0 @@
1
- export { {{nameCamel}}Schema as default } from '{{importFrom}}'