@sprucelabs/spruce-cli 17.1.1 → 17.1.2

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 (40) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/__tests__/behavioral/AddingADependency.test.js +2 -1
  3. package/build/__tests__/behavioral/AddingADependency.test.js.map +1 -1
  4. package/build/__tests__/behavioral/permissions/CreatingPermissions.test.d.ts +7 -0
  5. package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js +137 -0
  6. package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js.map +1 -0
  7. package/build/__tests__/testDirsAndFiles/related_schemas/v2020_10_06/skillWithExtraField.builder.d.ts +10 -2
  8. package/build/features/FeatureInstaller.d.ts +1 -1
  9. package/build/features/FeatureInstallerFactory.js +4 -2
  10. package/build/features/FeatureInstallerFactory.js.map +1 -1
  11. package/build/features/event/actions/CreateAction.d.ts +24 -16
  12. package/build/features/event/actions/CreateAction.js +3 -5
  13. package/build/features/event/actions/CreateAction.js.map +1 -1
  14. package/build/features/node/actions/UpdateDependenciesAction.js +25 -32
  15. package/build/features/node/actions/UpdateDependenciesAction.js.map +1 -1
  16. package/build/features/organization/OrganizationFeature.d.ts +5 -5
  17. package/build/features/organization/OrganizationFeature.js.map +1 -1
  18. package/build/features/permission/PermissionFeature.d.ts +15 -0
  19. package/build/features/permission/PermissionFeature.js +66 -0
  20. package/build/features/permission/PermissionFeature.js.map +1 -0
  21. package/build/features/permission/actions/CreateAction.d.ts +46 -0
  22. package/build/features/permission/actions/CreateAction.js +96 -0
  23. package/build/features/permission/actions/CreateAction.js.map +1 -0
  24. package/build/features/skill/stores/SkillStore.d.ts +9 -8
  25. package/build/features/skill/stores/SkillStore.js +4 -3
  26. package/build/features/skill/stores/SkillStore.js.map +1 -1
  27. package/build/tests/fixtures/SkillFixture.d.ts +3 -8
  28. package/build/tests/fixtures/SkillFixture.js.map +1 -1
  29. package/build/widgets/terminalKit/TkBaseWidget.js +9 -18
  30. package/build/widgets/terminalKit/TkBaseWidget.js.map +1 -1
  31. package/package.json +18 -3
  32. package/src/__tests__/behavioral/AddingADependency.test.ts +1 -0
  33. package/src/__tests__/behavioral/permissions/CreatingPermissions.test.ts +25 -0
  34. package/src/features/FeatureInstallerFactory.ts +3 -0
  35. package/src/features/event/actions/CreateAction.ts +5 -6
  36. package/src/features/organization/OrganizationFeature.ts +6 -6
  37. package/src/features/permission/PermissionFeature.ts +28 -0
  38. package/src/features/permission/actions/CreateAction.ts +29 -0
  39. package/src/features/skill/stores/SkillStore.ts +13 -11
  40. package/src/tests/fixtures/SkillFixture.ts +6 -3
@@ -5,10 +5,9 @@ import {
5
5
  } from '@sprucelabs/schema'
6
6
  import { eventNameUtil } from '@sprucelabs/spruce-event-utils'
7
7
  import { diskUtil } from '@sprucelabs/spruce-skill-utils'
8
+ import namedTemplateItemSchema from '#spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema'
8
9
  import syncEventActionSchema from '#spruce/schemas/spruceCli/v2020_07_22/syncEventOptions.schema'
9
10
  import SpruceError from '../../../errors/SpruceError'
10
- import namedTemplateItemBuilder from '../../../schemas/v2020_07_22/namedTemplateItem.builder'
11
- import syncEventActionBuilder from '../../../schemas/v2020_07_22/syncEventOptions.builder'
12
11
  import actionUtil from '../../../utilities/action.utility'
13
12
  import AbstractAction from '../../AbstractAction'
14
13
  import { FeatureActionResponse } from '../../features.types'
@@ -19,17 +18,17 @@ const optionsSchema = buildSchema({
19
18
  "Create a new event and I'll register it with Mercury when you boot the skill!",
20
19
  fields: {
21
20
  nameReadable: {
22
- ...namedTemplateItemBuilder.fields.nameReadable,
21
+ ...namedTemplateItemSchema.fields.nameReadable,
23
22
  isRequired: true,
24
23
  },
25
24
  nameKebab: {
26
- ...namedTemplateItemBuilder.fields.nameKebab,
25
+ ...namedTemplateItemSchema.fields.nameKebab,
27
26
  label: 'Event name',
28
27
  hint: `kebab-case`,
29
28
  isRequired: true,
30
29
  },
31
30
  nameCamel: {
32
- ...namedTemplateItemBuilder.fields.nameCamel,
31
+ ...namedTemplateItemSchema.fields.nameCamel,
33
32
  isRequired: true,
34
33
  },
35
34
  isGlobal: {
@@ -42,7 +41,7 @@ const optionsSchema = buildSchema({
42
41
  label: 'Version',
43
42
  isPrivate: true,
44
43
  },
45
- ...syncEventActionBuilder.fields,
44
+ ...syncEventActionSchema.fields,
46
45
  },
47
46
  })
48
47
 
@@ -2,12 +2,6 @@ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
2
2
  import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
3
3
  import { FeatureCode } from '../features.types'
4
4
 
5
- declare module '../../features/features.types' {
6
- interface FeatureMap {
7
- organization: OrganizationFeature
8
- }
9
- }
10
-
11
5
  export default class OrganizationFeature extends AbstractFeature {
12
6
  public code: FeatureCode = 'organization'
13
7
  public nameReadable = 'Organization'
@@ -26,3 +20,9 @@ export default class OrganizationFeature extends AbstractFeature {
26
20
 
27
21
  public actionsDir = diskUtil.resolvePath(__dirname, 'actions')
28
22
  }
23
+
24
+ declare module '../../features/features.types' {
25
+ interface FeatureMap {
26
+ organization: OrganizationFeature
27
+ }
28
+ }
@@ -0,0 +1,28 @@
1
+ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
2
+ import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
3
+ import { FeatureCode } from '../features.types'
4
+
5
+ export default class PermissionFeature extends AbstractFeature {
6
+ public code: FeatureCode = 'permission'
7
+ public nameReadable = 'permission'
8
+ public description = 'Manage permissions for your skill'
9
+ public dependencies: FeatureDependency[] = [
10
+ {
11
+ code: 'skill',
12
+ isRequired: true,
13
+ },
14
+ {
15
+ code: 'event',
16
+ isRequired: true,
17
+ },
18
+ ]
19
+ public packageDependencies = []
20
+
21
+ public actionsDir = diskUtil.resolvePath(__dirname, 'actions')
22
+ }
23
+
24
+ declare module '../../features/features.types' {
25
+ interface FeatureMap {
26
+ permission: PermissionFeature
27
+ }
28
+ }
@@ -0,0 +1,29 @@
1
+ import { buildSchema, pickFields, SchemaValues } from '@sprucelabs/schema'
2
+ import namedTemplateItemSchema from '#spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema'
3
+ import AbstractAction from '../../AbstractAction'
4
+ import { FeatureActionResponse } from '../../features.types'
5
+
6
+ const schema = buildSchema({
7
+ id: 'createPermission',
8
+ fields: {
9
+ ...pickFields(namedTemplateItemSchema.fields, [
10
+ 'nameReadable',
11
+ 'nameKebab',
12
+ ]),
13
+ },
14
+ })
15
+
16
+ type OptionsSchema = typeof schema
17
+ type Options = SchemaValues<OptionsSchema>
18
+
19
+ export default class CreateAction extends AbstractAction<OptionsSchema> {
20
+ public optionsSchema = schema
21
+ public invocationMessage = 'Creating a permission contract... 🛡'
22
+
23
+ public async execute(_options: Options): Promise<FeatureActionResponse> {
24
+ // const { nameKebab, nameReadable } =
25
+ // this.validateAndNormalizeOptions(options)
26
+
27
+ return {}
28
+ }
29
+ }
@@ -4,16 +4,6 @@ import SpruceError from '../../../errors/SpruceError'
4
4
  import AbstractStore from '../../../stores/AbstractStore'
5
5
  import { CurrentSkill, RegisteredSkill } from '../../../types/cli.types'
6
6
 
7
- export interface CreateSkill {
8
- name: string
9
- slug: string
10
- description?: string
11
- }
12
-
13
- export interface RegisterSkillOptions {
14
- isRegisteringCurrentSkill?: boolean
15
- }
16
-
17
7
  export default class SkillStore extends AbstractStore {
18
8
  public readonly name = 'skill'
19
9
  private static currentSkill?: CurrentSkill
@@ -31,7 +21,7 @@ export default class SkillStore extends AbstractStore {
31
21
 
32
22
  isRegisteringCurrentSkill && this.assertInSkill()
33
23
 
34
- const { name, slug, description } = values
24
+ const { name, slug, description, isPublished } = values
35
25
  const client = await this.connectToApi()
36
26
 
37
27
  const results = await client.emit('register-skill::v2020_12_25', {
@@ -39,6 +29,7 @@ export default class SkillStore extends AbstractStore {
39
29
  name,
40
30
  slug,
41
31
  description,
32
+ isPublished,
42
33
  },
43
34
  })
44
35
 
@@ -189,3 +180,14 @@ export default class SkillStore extends AbstractStore {
189
180
  return skills
190
181
  }
191
182
  }
183
+
184
+ export interface CreateSkill {
185
+ name: string
186
+ slug?: string
187
+ description?: string
188
+ isPublished?: boolean
189
+ }
190
+
191
+ export interface RegisterSkillOptions {
192
+ isRegisteringCurrentSkill?: boolean
193
+ }
@@ -1,6 +1,9 @@
1
1
  import { EventContract, SpruceSchemas } from '@sprucelabs/mercury-types'
2
2
  import { namesUtil } from '@sprucelabs/spruce-skill-utils'
3
- import { RegisterSkillOptions } from '../../features/skill/stores/SkillStore'
3
+ import {
4
+ CreateSkill,
5
+ RegisterSkillOptions,
6
+ } from '../../features/skill/stores/SkillStore'
4
7
  import StoreFactory from '../../stores/StoreFactory'
5
8
  import {
6
9
  ApiClientFactory,
@@ -27,7 +30,7 @@ export default class SkillFixture {
27
30
  }
28
31
 
29
32
  public async seedDemoSkill(
30
- values: { name: string },
33
+ values: CreateSkill,
31
34
  options?: { phone?: string }
32
35
  ) {
33
36
  return this.registerCurrentSkill(values, {
@@ -37,7 +40,7 @@ export default class SkillFixture {
37
40
  }
38
41
 
39
42
  public async registerCurrentSkill(
40
- values: { name: string; slug?: string },
43
+ values: CreateSkill,
41
44
  options?: RegisterSkillOptions & { phone?: string }
42
45
  ) {
43
46
  await this.personFixture.loginAsDemoPerson(options?.phone)