@sprucelabs/spruce-cli 18.1.7 → 18.2.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.
Files changed (155) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/build/__tests__/behavioral/WatchingSkillViews.test.js +1 -1
  3. package/build/__tests__/behavioral/WatchingSkillViews.test.js.map +1 -1
  4. package/build/__tests__/behavioral/permissions/AbstractPermissionsTest.d.ts +8 -0
  5. package/build/__tests__/behavioral/permissions/AbstractPermissionsTest.js +85 -0
  6. package/build/__tests__/behavioral/permissions/AbstractPermissionsTest.js.map +1 -0
  7. package/build/__tests__/behavioral/permissions/CreatingPermissions.test.d.ts +5 -6
  8. package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js +54 -34
  9. package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js.map +1 -1
  10. package/build/__tests__/behavioral/permissions/PermissionStore.test.d.ts +24 -0
  11. package/build/__tests__/behavioral/permissions/PermissionStore.test.js +420 -0
  12. package/build/__tests__/behavioral/permissions/PermissionStore.test.js.map +1 -0
  13. package/build/__tests__/behavioral/permissions/SyncingPermissions.test.d.ts +7 -0
  14. package/build/__tests__/behavioral/permissions/SyncingPermissions.test.js +88 -0
  15. package/build/__tests__/behavioral/permissions/SyncingPermissions.test.js.map +1 -0
  16. package/build/__tests__/implementation/{GlobalEmitter.d.ts → GlobalEmitter.test.d.ts} +0 -0
  17. package/build/__tests__/implementation/{GlobalEmitter.js → GlobalEmitter.test.js} +1 -1
  18. package/build/__tests__/implementation/GlobalEmitter.test.js.map +1 -0
  19. package/build/__tests__/support/EventFaker.d.ts +5 -0
  20. package/build/__tests__/support/EventFaker.js +48 -0
  21. package/build/__tests__/support/EventFaker.js.map +1 -0
  22. package/build/features/error/writers/ErrorWriter.js +1 -4
  23. package/build/features/error/writers/ErrorWriter.js.map +1 -1
  24. package/build/features/event/EventFeature.js.map +1 -1
  25. package/build/features/event/writers/EventWriter.js +6 -2
  26. package/build/features/event/writers/EventWriter.js.map +1 -1
  27. package/build/features/permission/actions/CreateAction.d.ts +51 -24
  28. package/build/features/permission/actions/CreateAction.js +36 -10
  29. package/build/features/permission/actions/CreateAction.js.map +1 -1
  30. package/build/features/permission/actions/SyncAction.d.ts +16 -0
  31. package/build/features/permission/actions/SyncAction.js +71 -0
  32. package/build/features/permission/actions/SyncAction.js.map +1 -0
  33. package/build/features/permission/stores/PermissionStore.d.ts +7 -0
  34. package/build/features/permission/stores/PermissionStore.js +159 -0
  35. package/build/features/permission/stores/PermissionStore.js.map +1 -0
  36. package/build/features/permission/writers/PermissionWriter.d.ts +10 -0
  37. package/build/features/permission/writers/PermissionWriter.js +94 -0
  38. package/build/features/permission/writers/PermissionWriter.js.map +1 -0
  39. package/build/features/view/actions/WatchAction.js +1 -1
  40. package/build/features/view/actions/WatchAction.js.map +1 -1
  41. package/build/stores/StoreFactory.d.ts +2 -0
  42. package/build/stores/StoreFactory.js +3 -1
  43. package/build/stores/StoreFactory.js.map +1 -1
  44. package/build/tests/cleanTestData.js +25 -18
  45. package/build/tests/cleanTestData.js.map +1 -1
  46. package/build/writers/WriterFactory.d.ts +2 -0
  47. package/build/writers/WriterFactory.js +3 -1
  48. package/build/writers/WriterFactory.js.map +1 -1
  49. package/node_modules/@typescript-eslint/parser/package.json +6 -6
  50. package/node_modules/@typescript-eslint/scope-manager/dist/ScopeManager.js +9 -9
  51. package/node_modules/@typescript-eslint/scope-manager/dist/ScopeManager.js.map +1 -1
  52. package/node_modules/@typescript-eslint/scope-manager/dist/definition/Definition.d.ts +1 -1
  53. package/node_modules/@typescript-eslint/scope-manager/dist/definition/Definition.d.ts.map +1 -1
  54. package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.d.ts.map +1 -1
  55. package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.iterable.d.ts.map +1 -1
  56. package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.iterable.js +1 -0
  57. package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.iterable.js.map +1 -1
  58. package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.js +21 -7
  59. package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.js.map +1 -1
  60. package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.d.ts.map +1 -1
  61. package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.intl.d.ts +3 -0
  62. package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.intl.d.ts.map +1 -0
  63. package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.intl.js +12 -0
  64. package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.intl.js.map +1 -0
  65. package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.js +2 -1
  66. package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.js.map +1 -1
  67. package/node_modules/@typescript-eslint/scope-manager/dist/lib/index.d.ts +1 -0
  68. package/node_modules/@typescript-eslint/scope-manager/dist/lib/index.d.ts.map +1 -1
  69. package/node_modules/@typescript-eslint/scope-manager/dist/lib/index.js +2 -0
  70. package/node_modules/@typescript-eslint/scope-manager/dist/lib/index.js.map +1 -1
  71. package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.d.ts.map +1 -1
  72. package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.iterable.d.ts.map +1 -1
  73. package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.iterable.js +2 -0
  74. package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.iterable.js.map +1 -1
  75. package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.js +39 -1
  76. package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.js.map +1 -1
  77. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/ExportVisitor.d.ts +1 -1
  78. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/ExportVisitor.d.ts.map +1 -1
  79. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.d.ts +2 -2
  80. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.d.ts.map +1 -1
  81. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.js +9 -9
  82. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.js.map +1 -1
  83. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Reference.js +17 -17
  84. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Reference.js.map +1 -1
  85. package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.js.map +1 -1
  86. package/node_modules/@typescript-eslint/scope-manager/dist/scope/Scope.d.ts +1 -1
  87. package/node_modules/@typescript-eslint/scope-manager/dist/scope/Scope.d.ts.map +1 -1
  88. package/node_modules/@typescript-eslint/scope-manager/dist/scope/ScopeBase.d.ts +1 -1
  89. package/node_modules/@typescript-eslint/scope-manager/dist/scope/ScopeBase.d.ts.map +1 -1
  90. package/node_modules/@typescript-eslint/scope-manager/package.json +12 -12
  91. package/node_modules/@typescript-eslint/types/_ts3.4/dist/generated/ast-spec.d.ts +8 -2
  92. package/node_modules/@typescript-eslint/types/_ts3.4/dist/lib.d.ts +1 -1
  93. package/node_modules/@typescript-eslint/types/_ts3.4/dist/parser-options.d.ts +3 -3
  94. package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.d.ts +8 -2
  95. package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.d.ts.map +1 -1
  96. package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.js +1 -0
  97. package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.js.map +1 -1
  98. package/node_modules/@typescript-eslint/types/dist/lib.d.ts +1 -1
  99. package/node_modules/@typescript-eslint/types/dist/lib.d.ts.map +1 -1
  100. package/node_modules/@typescript-eslint/types/dist/parser-options.d.ts +3 -3
  101. package/node_modules/@typescript-eslint/types/dist/parser-options.d.ts.map +1 -1
  102. package/node_modules/@typescript-eslint/types/package.json +3 -3
  103. package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/create-program/shared.d.ts +1 -1
  104. package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/parseSettings/index.d.ts +2 -2
  105. package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/parser-options.d.ts +1 -1
  106. package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/parser.d.ts +1 -1
  107. package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/simple-traverse.d.ts +1 -1
  108. package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/ts-estree/estree-to-ts-node-types.d.ts +2 -1
  109. package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/ts-estree/ts-nodes.d.ts +2 -2
  110. package/node_modules/@typescript-eslint/typescript-estree/dist/convert.d.ts.map +1 -1
  111. package/node_modules/@typescript-eslint/typescript-estree/dist/convert.js +7 -0
  112. package/node_modules/@typescript-eslint/typescript-estree/dist/convert.js.map +1 -1
  113. package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.d.ts.map +1 -1
  114. package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.js +9 -0
  115. package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.js.map +1 -1
  116. package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/shared.d.ts +1 -1
  117. package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/shared.d.ts.map +1 -1
  118. package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/index.d.ts +2 -2
  119. package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/index.d.ts.map +1 -1
  120. package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.js +1 -1
  121. package/node_modules/@typescript-eslint/typescript-estree/dist/parser-options.d.ts +1 -1
  122. package/node_modules/@typescript-eslint/typescript-estree/dist/parser-options.d.ts.map +1 -1
  123. package/node_modules/@typescript-eslint/typescript-estree/dist/parser.d.ts +1 -1
  124. package/node_modules/@typescript-eslint/typescript-estree/dist/parser.d.ts.map +1 -1
  125. package/node_modules/@typescript-eslint/typescript-estree/dist/simple-traverse.d.ts +1 -1
  126. package/node_modules/@typescript-eslint/typescript-estree/dist/simple-traverse.d.ts.map +1 -1
  127. package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/estree-to-ts-node-types.d.ts +2 -1
  128. package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/estree-to-ts-node-types.d.ts.map +1 -1
  129. package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-nodes.d.ts +2 -2
  130. package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-nodes.d.ts.map +1 -1
  131. package/node_modules/@typescript-eslint/typescript-estree/package.json +6 -6
  132. package/node_modules/@typescript-eslint/visitor-keys/dist/visitor-keys.d.ts.map +1 -1
  133. package/node_modules/@typescript-eslint/visitor-keys/dist/visitor-keys.js +1 -0
  134. package/node_modules/@typescript-eslint/visitor-keys/dist/visitor-keys.js.map +1 -1
  135. package/node_modules/@typescript-eslint/visitor-keys/package.json +4 -4
  136. package/package.json +28 -26
  137. package/src/__tests__/behavioral/WatchingSkillViews.test.ts +1 -1
  138. package/src/__tests__/behavioral/permissions/AbstractPermissionsTest.ts +20 -0
  139. package/src/__tests__/behavioral/permissions/CreatingPermissions.test.ts +32 -16
  140. package/src/__tests__/behavioral/permissions/PermissionStore.test.ts +233 -0
  141. package/src/__tests__/behavioral/permissions/SyncingPermissions.test.ts +25 -0
  142. package/src/__tests__/implementation/{GlobalEmitter.ts → GlobalEmitter.test.ts} +0 -0
  143. package/src/__tests__/support/EventFaker.ts +23 -0
  144. package/src/features/error/writers/ErrorWriter.ts +0 -2
  145. package/src/features/event/EventFeature.ts +0 -1
  146. package/src/features/event/writers/EventWriter.ts +4 -0
  147. package/src/features/permission/actions/CreateAction.ts +39 -16
  148. package/src/features/permission/actions/SyncAction.ts +23 -0
  149. package/src/features/permission/stores/PermissionStore.ts +51 -0
  150. package/src/features/permission/writers/PermissionWriter.ts +54 -0
  151. package/src/features/view/actions/WatchAction.ts +1 -1
  152. package/src/stores/StoreFactory.ts +5 -2
  153. package/src/tests/cleanTestData.ts +7 -3
  154. package/src/writers/WriterFactory.ts +3 -0
  155. package/build/__tests__/implementation/GlobalEmitter.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorWriter.js","names":["ErrorWriter","destinationDir","errors","results","length","Error","resolvedDestination","diskUtil","resolvePath","doesFileExist","ui","startLoading","errorContents","templates","error","filter","isNested","writeFileIfChangedMixinResults","dropInNewErrorCases","updates","push","description","lint","destinationFile","dropInErrorCaseIfMissing","dropInResults","errorBlock","renderClassDefinition","currentErrorContents","readFile","blockMatches","search","doesErrorCaseExist","newErrorContents","substring","code","currentContents","RegExp","errorTemplateItems","contents","errorOptionsTypes","options","destination","cwd","resolveHashSprucePath","pluginContents","errorPlugin","AbstractWriter"],"sources":["../../../../src/features/error/writers/ErrorWriter.ts"],"sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { ErrorTemplateItem } from '@sprucelabs/spruce-templates'\nimport { GeneratedFile } from '../../../types/cli.types'\nimport AbstractWriter, { WriteResults } from '../../../writers/AbstractWriter'\n\nexport default class ErrorWriter extends AbstractWriter {\n\tpublic async writeOrAppendErrorsToClass(\n\t\tdestinationDir: string,\n\t\terrors: ErrorTemplateItem[]\n\t): Promise<WriteResults> {\n\t\tlet results: WriteResults = []\n\n\t\tif (errors.length === 0) {\n\t\t\t// todo move to proper error\n\t\t\tthrow new Error('Need at least one error')\n\t\t}\n\n\t\tconst resolvedDestination = diskUtil.resolvePath(\n\t\t\tdestinationDir,\n\t\t\t`SpruceError.ts`\n\t\t)\n\n\t\tif (!diskUtil.doesFileExist(resolvedDestination)) {\n\t\t\tthis.ui.startLoading('Creating Error class')\n\n\t\t\tconst errorContents = this.templates.error({\n\t\t\t\terrors: errors.filter((error) => !error.isNested),\n\t\t\t})\n\t\t\tresults = await this.writeFileIfChangedMixinResults(\n\t\t\t\tresolvedDestination,\n\t\t\t\terrorContents,\n\t\t\t\t'A new subclass of SpruceBaseError where you can control your error messaging.',\n\t\t\t\tresults\n\t\t\t)\n\t\t} else {\n\t\t\tthis.ui.startLoading('Updating Error class')\n\n\t\t\tconst updates = await this.dropInNewErrorCases(\n\t\t\t\terrors,\n\t\t\t\tresolvedDestination\n\t\t\t)\n\t\t\tif (updates.length > 0) {\n\t\t\t\tresults.push({\n\t\t\t\t\t...updates[0],\n\t\t\t\t\tdescription: `${updates.length} new error cases were dropped in.`,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tawait this.lint(resolvedDestination)\n\n\t\treturn results\n\t}\n\n\tprivate async dropInNewErrorCases(\n\t\terrors: ErrorTemplateItem[],\n\t\tdestinationFile: string\n\t) {\n\t\tlet results: GeneratedFile[] = []\n\n\t\tfor (const error of errors) {\n\t\t\tif (!error.isNested) {\n\t\t\t\tconst dropInResults = await this.dropInErrorCaseIfMissing(\n\t\t\t\t\terror,\n\t\t\t\t\tdestinationFile\n\t\t\t\t)\n\t\t\t\tresults.push(...dropInResults)\n\t\t\t}\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprivate async dropInErrorCaseIfMissing(\n\t\terror: ErrorTemplateItem,\n\t\tdestinationFile: string\n\t) {\n\t\tlet results: GeneratedFile[] = []\n\t\tconst errorBlock = this.templates.error({\n\t\t\terrors: [error],\n\t\t\trenderClassDefinition: false,\n\t\t})\n\n\t\t// Try and drop in the block right before \"default:\"\n\t\tconst currentErrorContents = diskUtil.readFile(destinationFile)\n\t\tconst blockMatches = currentErrorContents.search(/default:/g)\n\t\tif (\n\t\t\tblockMatches > -1 &&\n\t\t\t!this.doesErrorCaseExist(currentErrorContents, error)\n\t\t) {\n\t\t\tconst newErrorContents =\n\t\t\t\tcurrentErrorContents.substring(0, blockMatches) +\n\t\t\t\t'\\n' +\n\t\t\t\terrorBlock +\n\t\t\t\t'\\n' +\n\t\t\t\tcurrentErrorContents.substring(blockMatches)\n\n\t\t\tresults = await this.writeFileIfChangedMixinResults(\n\t\t\t\tdestinationFile,\n\t\t\t\tnewErrorContents,\n\t\t\t\t`A new block was added to handle ${error.code}.`,\n\t\t\t\tresults\n\t\t\t)\n\t\t}\n\t\treturn results\n\t}\n\n\tprivate doesErrorCaseExist(\n\t\tcurrentContents: string,\n\t\terror: ErrorTemplateItem\n\t) {\n\t\treturn currentContents.search(new RegExp(`case '${error.code}':`)) > -1\n\t}\n\n\tpublic async writeOptionsTypesFile(\n\t\tdestinationDir: string,\n\t\terrorTemplateItems: ErrorTemplateItem[]\n\t): Promise<WriteResults> {\n\t\tconst contents = this.templates.errorOptionsTypes({\n\t\t\toptions: errorTemplateItems,\n\t\t})\n\n\t\tconst destination = diskUtil.resolvePath(destinationDir, 'options.types.ts')\n\n\t\tthis.ui.startLoading('Updating error options...')\n\n\t\tconst results = this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tcontents,\n\t\t\t'A union of all possible error codes and their options.'\n\t\t)\n\n\t\tawait this.lint(destination)\n\n\t\treturn results\n\t}\n\n\tpublic async writePlugin(cwd: string) {\n\t\tconst destination = diskUtil.resolveHashSprucePath(\n\t\t\tcwd,\n\t\t\t'features',\n\t\t\t'error.plugin.ts'\n\t\t)\n\n\t\tconst pluginContents = this.templates.errorPlugin()\n\n\t\tconst results = this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tpluginContents,\n\t\t\t'Supports your skill with Error generation and handling.'\n\t\t)\n\n\t\tawait this.lint(destination)\n\n\t\treturn results\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAGA;AAA8E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAEzDA,WAAW;EAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;MAAA,gHAC/B,iBACCC,cAAsB,EACtBC,MAA2B;QAAA;QAAA;UAAA;YAAA;cAAA;gBAEvBC,OAAqB,GA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7C3C,OAAO,GAAG,IAAI,CAACc,8BAA8B,CAClDyB,WAAW,EACXG,cAAc,EACd,yDAAyD,CACzD;gBAAA;gBAAA,OAEK,IAAI,CAACvB,IAAI,CAACoB,WAAW,CAAC;cAAA;gBAAA,kCAErBvC,OAAO;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,CACd;MAAA;QAAA;MAAA;MAAA;IAAA;EAAA;EAAA;AAAA,EAtJuC4C,2BAAc;AAAA"}
1
+ {"version":3,"file":"ErrorWriter.js","names":["ErrorWriter","destinationDir","errors","results","length","Error","resolvedDestination","diskUtil","resolvePath","doesFileExist","ui","startLoading","errorContents","templates","error","filter","isNested","writeFileIfChangedMixinResults","dropInNewErrorCases","updates","push","description","destinationFile","dropInErrorCaseIfMissing","dropInResults","errorBlock","renderClassDefinition","currentErrorContents","readFile","blockMatches","search","doesErrorCaseExist","newErrorContents","substring","code","currentContents","RegExp","errorTemplateItems","contents","errorOptionsTypes","options","destination","lint","cwd","resolveHashSprucePath","pluginContents","errorPlugin","AbstractWriter"],"sources":["../../../../src/features/error/writers/ErrorWriter.ts"],"sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { ErrorTemplateItem } from '@sprucelabs/spruce-templates'\nimport { GeneratedFile } from '../../../types/cli.types'\nimport AbstractWriter, { WriteResults } from '../../../writers/AbstractWriter'\n\nexport default class ErrorWriter extends AbstractWriter {\n\tpublic async writeOrAppendErrorsToClass(\n\t\tdestinationDir: string,\n\t\terrors: ErrorTemplateItem[]\n\t): Promise<WriteResults> {\n\t\tlet results: WriteResults = []\n\n\t\tif (errors.length === 0) {\n\t\t\t// todo move to proper error\n\t\t\tthrow new Error('Need at least one error')\n\t\t}\n\n\t\tconst resolvedDestination = diskUtil.resolvePath(\n\t\t\tdestinationDir,\n\t\t\t`SpruceError.ts`\n\t\t)\n\n\t\tif (!diskUtil.doesFileExist(resolvedDestination)) {\n\t\t\tthis.ui.startLoading('Creating Error class')\n\n\t\t\tconst errorContents = this.templates.error({\n\t\t\t\terrors: errors.filter((error) => !error.isNested),\n\t\t\t})\n\t\t\tresults = await this.writeFileIfChangedMixinResults(\n\t\t\t\tresolvedDestination,\n\t\t\t\terrorContents,\n\t\t\t\t'A new subclass of SpruceBaseError where you can control your error messaging.',\n\t\t\t\tresults\n\t\t\t)\n\t\t} else {\n\t\t\tthis.ui.startLoading('Updating Error class')\n\n\t\t\tconst updates = await this.dropInNewErrorCases(\n\t\t\t\terrors,\n\t\t\t\tresolvedDestination\n\t\t\t)\n\t\t\tif (updates.length > 0) {\n\t\t\t\tresults.push({\n\t\t\t\t\t...updates[0],\n\t\t\t\t\tdescription: `${updates.length} new error cases were dropped in.`,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprivate async dropInNewErrorCases(\n\t\terrors: ErrorTemplateItem[],\n\t\tdestinationFile: string\n\t) {\n\t\tlet results: GeneratedFile[] = []\n\n\t\tfor (const error of errors) {\n\t\t\tif (!error.isNested) {\n\t\t\t\tconst dropInResults = await this.dropInErrorCaseIfMissing(\n\t\t\t\t\terror,\n\t\t\t\t\tdestinationFile\n\t\t\t\t)\n\t\t\t\tresults.push(...dropInResults)\n\t\t\t}\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprivate async dropInErrorCaseIfMissing(\n\t\terror: ErrorTemplateItem,\n\t\tdestinationFile: string\n\t) {\n\t\tlet results: GeneratedFile[] = []\n\t\tconst errorBlock = this.templates.error({\n\t\t\terrors: [error],\n\t\t\trenderClassDefinition: false,\n\t\t})\n\n\t\t// Try and drop in the block right before \"default:\"\n\t\tconst currentErrorContents = diskUtil.readFile(destinationFile)\n\t\tconst blockMatches = currentErrorContents.search(/default:/g)\n\t\tif (\n\t\t\tblockMatches > -1 &&\n\t\t\t!this.doesErrorCaseExist(currentErrorContents, error)\n\t\t) {\n\t\t\tconst newErrorContents =\n\t\t\t\tcurrentErrorContents.substring(0, blockMatches) +\n\t\t\t\t'\\n' +\n\t\t\t\terrorBlock +\n\t\t\t\t'\\n' +\n\t\t\t\tcurrentErrorContents.substring(blockMatches)\n\n\t\t\tresults = await this.writeFileIfChangedMixinResults(\n\t\t\t\tdestinationFile,\n\t\t\t\tnewErrorContents,\n\t\t\t\t`A new block was added to handle ${error.code}.`,\n\t\t\t\tresults\n\t\t\t)\n\t\t}\n\t\treturn results\n\t}\n\n\tprivate doesErrorCaseExist(\n\t\tcurrentContents: string,\n\t\terror: ErrorTemplateItem\n\t) {\n\t\treturn currentContents.search(new RegExp(`case '${error.code}':`)) > -1\n\t}\n\n\tpublic async writeOptionsTypesFile(\n\t\tdestinationDir: string,\n\t\terrorTemplateItems: ErrorTemplateItem[]\n\t): Promise<WriteResults> {\n\t\tconst contents = this.templates.errorOptionsTypes({\n\t\t\toptions: errorTemplateItems,\n\t\t})\n\n\t\tconst destination = diskUtil.resolvePath(destinationDir, 'options.types.ts')\n\n\t\tthis.ui.startLoading('Updating error options...')\n\n\t\tconst results = this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tcontents,\n\t\t\t'A union of all possible error codes and their options.'\n\t\t)\n\n\t\tawait this.lint(destination)\n\n\t\treturn results\n\t}\n\n\tpublic async writePlugin(cwd: string) {\n\t\tconst destination = diskUtil.resolveHashSprucePath(\n\t\t\tcwd,\n\t\t\t'features',\n\t\t\t'error.plugin.ts'\n\t\t)\n\n\t\tconst pluginContents = this.templates.errorPlugin()\n\n\t\tconst results = this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tpluginContents,\n\t\t\t'Supports your skill with Error generation and handling.'\n\t\t)\n\n\t\tawait this.lint(destination)\n\n\t\treturn results\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAGA;AAA8E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAEzDA,WAAW;EAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;MAAA,gHAC/B,iBACCC,cAAsB,EACtBC,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,GAAG,IAAI,CAACc,8BAA8B,CAClDwB,WAAW,EACXI,cAAc,EACd,yDAAyD,CACzD;gBAAA;gBAAA,OAEK,IAAI,CAACH,IAAI,CAACD,WAAW,CAAC;cAAA;gBAAA,kCAErBtC,OAAO;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,CACd;MAAA;QAAA;MAAA;MAAA;IAAA;EAAA;EAAA;AAAA,EApJuC4C,2BAAc;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"EventFeature.js","names":["EventFeature","options","code","isRequired","name","diskUtil","resolvePath","__dirname","emitter","on","handleDidFetchSchemas","bind","handleWillExecute","handleDidExecute","createDir","cwd","featureInstaller","isInstalled","isSkillInstalled","Action","execute","payload","featureCode","actionCode","results","initiatingAction","EventStore","clearCache","combined","combineCodes","settings","Service","clearListenerCache","isRemoteRelevant","appendRemoteToResultsOrPrompt","remoteResults","actionUtil","mergeActionResults","syncResults","isUpgrade","syncListenersAndMixinResults","remote","r","getRemote","TerminalInterface","doesSupportColor","Error","ui","stopLoading","renderLine","summaryLines","getHost","lastSync","getLastSyncOptions","writer","getEventContractBuilder","fetchContractsAndGenerateUniqueSchemas","schemas","shouldSyncOnlyCoreEvents","uniqueSchemas","contractBuilder","EventContractBuilder","optionsSchema","syncEventActionSchema","eventGenerator","Writer","eventStore","Store","skillStore","dependencyService","doesHashSprucePathExist","hasCombinedContractBeenWritten","AbstractFeature"],"sources":["../../../src/features/event/EventFeature.ts"],"sourcesContent":["import { Schema } from '@sprucelabs/schema'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport syncEventActionSchema from '#spruce/schemas/spruceCli/v2020_07_22/syncEventOptions.schema'\nimport TerminalInterface from '../../interfaces/TerminalInterface'\nimport { FileDescription } from '../../types/cli.types'\nimport actionUtil from '../../utilities/action.utility'\nimport AbstractFeature, {\n\tFeatureDependency,\n\tFeatureOptions,\n} from '../AbstractFeature'\nimport { FeatureActionResponse, FeatureCode } from '../features.types'\nimport EventContractBuilder from './builders/EventContractBuilder'\nimport EventStore from './stores/EventStore'\n\ndeclare module '../../features/features.types' {\n\tinterface FeatureMap {\n\t\tevent: EventFeature\n\t}\n\n\tinterface FeatureOptionsMap {\n\t\tevent: undefined\n\t}\n}\n\nexport default class EventFeature extends AbstractFeature {\n\tpublic code: FeatureCode = 'event'\n\tpublic nameReadable = 'Events'\n\tpublic description = 'Connect to the Mercury Event Engine.'\n\tpublic dependencies: FeatureDependency[] = [\n\t\t{ code: 'schema', isRequired: true },\n\t]\n\tpublic packageDependencies = [\n\t\t{\n\t\t\tname: '@sprucelabs/mercury-client',\n\t\t},\n\t\t{\n\t\t\tname: '@sprucelabs/mercury-types',\n\t\t},\n\t\t{\n\t\t\tname: '@sprucelabs/spruce-event-utils',\n\t\t},\n\t\t{\n\t\t\tname: '@sprucelabs/spruce-event-plugin',\n\t\t},\n\t\t{\n\t\t\tname: '@sprucelabs/mercury-core-events',\n\t\t},\n\t]\n\n\tpublic actionsDir = diskUtil.resolvePath(__dirname, 'actions')\n\n\tpublic readonly fileDescriptions: FileDescription[] = []\n\tprivate contractBuilder?: EventContractBuilder\n\tprivate initiatingAction?: string\n\n\tpublic constructor(options: FeatureOptions) {\n\t\tsuper(options)\n\n\t\tvoid this.emitter.on(\n\t\t\t'schema.did-fetch-schemas',\n\t\t\tthis.handleDidFetchSchemas.bind(this)\n\t\t)\n\n\t\tvoid this.emitter.on(\n\t\t\t'feature.will-execute',\n\t\t\tthis.handleWillExecute.bind(this)\n\t\t)\n\n\t\tvoid this.emitter.on(\n\t\t\t'feature.did-execute',\n\t\t\tthis.handleDidExecute.bind(this)\n\t\t)\n\t}\n\n\tpublic async afterPackageInstall() {\n\t\tdiskUtil.createDir(diskUtil.resolvePath(this.cwd, 'src', 'events'))\n\t\tconst isSkillInstalled = await this.featureInstaller.isInstalled('skill')\n\t\tif (isSkillInstalled) {\n\t\t\treturn await this.Action('event', 'sync.listeners').execute({})\n\t\t}\n\n\t\treturn {}\n\t}\n\n\tprivate async handleWillExecute(payload: {\n\t\tfeatureCode: string\n\t\tactionCode: string\n\t}): Promise<FeatureActionResponse> {\n\t\tconst { featureCode, actionCode } = payload\n\n\t\tlet results: FeatureActionResponse = {}\n\n\t\tif (!this.initiatingAction) {\n\t\t\tEventStore.clearCache()\n\t\t\tconst combined = this.combineCodes(featureCode, actionCode)\n\t\t\tthis.initiatingAction = combined\n\t\t}\n\n\t\tif (featureCode === 'node' || featureCode === 'upgrade') {\n\t\t\tconst settings = this.Service('eventSettings')\n\t\t\tsettings.clearListenerCache()\n\t\t}\n\n\t\tconst isInstalled = await this.featureInstaller.isInstalled('event')\n\t\tconst isRemoteRelevant =\n\t\t\tisInstalled &&\n\t\t\t(featureCode === 'event' ||\n\t\t\t\tfeatureCode === 'eventContract' ||\n\t\t\t\tactionCode === 'login') &&\n\t\t\tactionCode !== 'setRemote'\n\n\t\tif (isRemoteRelevant) {\n\t\t\tconst remoteResults = await this.appendRemoteToResultsOrPrompt()\n\t\t\tresults = actionUtil.mergeActionResults(results, remoteResults)\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprivate async syncListenersAndMixinResults(results: FeatureActionResponse) {\n\t\tconst syncResults = await this.Action('event', 'sync.listeners').execute({})\n\t\tresults = actionUtil.mergeActionResults(results, syncResults)\n\t\treturn results\n\t}\n\n\tprivate async handleDidExecute(payload: {\n\t\tfeatureCode: string\n\t\tactionCode: string\n\t}) {\n\t\tconst { featureCode, actionCode } = payload\n\t\tconst isInstalled = await this.featureInstaller.isInstalled('event')\n\n\t\tlet results = {}\n\n\t\tconst isUpgrade =\n\t\t\tisInstalled && featureCode === 'node' && actionCode === 'upgrade'\n\n\t\tif (isUpgrade) {\n\t\t\tresults = await this.Action('event', 'sync').execute({})\n\t\t\tresults = await this.syncListenersAndMixinResults(results)\n\t\t}\n\n\t\tif (this.initiatingAction === this.combineCodes(featureCode, actionCode)) {\n\t\t\tEventStore.clearCache()\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprivate combineCodes(featureCode: string, actionCode: string) {\n\t\treturn `${featureCode}.${actionCode}`\n\t}\n\n\tprivate async appendRemoteToResultsOrPrompt(): Promise<FeatureActionResponse> {\n\t\tconst remote = this.Service('remote')\n\t\tconst r = remote.getRemote()\n\n\t\tif (!r) {\n\t\t\tif (!TerminalInterface.doesSupportColor()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Dang! I couldn't find env.HOST. Once that is set, lets try again!`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tthis.ui.stopLoading()\n\t\t\tthis.ui.renderLine(\n\t\t\t\t`Uh oh! It looks like you haven't configured your remote! We gotta do that.`\n\t\t\t)\n\n\t\t\tconst results = await this.Action('event', 'setRemote').execute({})\n\n\t\t\treturn results\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tsummaryLines: [`Remote: ${r}`, `Host: ${remote.getHost()}`],\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async handleDidFetchSchemas(payload: { schemas?: Schema[] | null }) {\n\t\tconst isInstalled = await this.featureInstaller.isInstalled(this.code)\n\n\t\tconst lastSync = this.Service('eventSettings').getLastSyncOptions()\n\n\t\tif (lastSync && isInstalled) {\n\t\t\tconst writer = this.getEventContractBuilder()\n\n\t\t\tconst uniqueSchemas = await writer.fetchContractsAndGenerateUniqueSchemas(\n\t\t\t\tpayload.schemas ?? [],\n\t\t\t\tlastSync.shouldSyncOnlyCoreEvents\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tschemas: uniqueSchemas.schemas ?? [],\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tschemas: [],\n\t\t}\n\t}\n\n\tpublic getEventContractBuilder() {\n\t\tif (!this.contractBuilder) {\n\t\t\tthis.contractBuilder = new EventContractBuilder({\n\t\t\t\tcwd: this.cwd,\n\t\t\t\toptionsSchema: syncEventActionSchema,\n\t\t\t\tui: this.ui,\n\t\t\t\teventGenerator: this.Writer('event'),\n\t\t\t\teventStore: this.Store('event'),\n\t\t\t\tskillStore: this.Store('skill'),\n\t\t\t\tdependencyService: this.Service('dependency'),\n\t\t\t})\n\t\t}\n\n\t\treturn this.contractBuilder\n\t}\n\n\tpublic hasBeenSynced() {\n\t\tif (diskUtil.doesHashSprucePathExist(this.cwd)) {\n\t\t\tconst writer = this.Writer('event')\n\n\t\t\treturn writer.hasCombinedContractBeenWritten(this.cwd)\n\t\t}\n\n\t\treturn false\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA;AACA;AACA;AAEA;AACA;AAKA;AACA;AAA4C;AAAA;AAAA,IAYvBA,YAAY;EAAA;EAAA;EA+BhC,sBAAmBC,OAAuB,EAAE;IAAA;IAAA;IAC3C,0BAAMA,OAAO;IAAC,yFA/BY,OAAO;IAAA,iGACZ,QAAQ;IAAA,gGACT,sCAAsC;IAAA,iGAChB,CAC1C;MAAEC,IAAI,EAAE,QAAQ;MAAEC,UAAU,EAAE;IAAK,CAAC,CACpC;IAAA,wGAC4B,CAC5B;MACCC,IAAI,EAAE;IACP,CAAC,EACD;MACCA,IAAI,EAAE;IACP,CAAC,EACD;MACCA,IAAI,EAAE;IACP,CAAC,EACD;MACCA,IAAI,EAAE;IACP,CAAC,EACD;MACCA,IAAI,EAAE;IACP,CAAC,CACD;IAAA,+FAEmBC,0BAAQ,CAACC,WAAW,CAACC,SAAS,EAAE,SAAS,CAAC;IAAA,qGAER,EAAE;IAAA;IAAA;IAOvD,KAAK,MAAKC,OAAO,CAACC,EAAE,CACnB,0BAA0B,EAC1B,MAAKC,qBAAqB,CAACC,IAAI,gDAAM,CACrC;IAED,KAAK,MAAKH,OAAO,CAACC,EAAE,CACnB,sBAAsB,EACtB,MAAKG,iBAAiB,CAACD,IAAI,gDAAM,CACjC;IAED,KAAK,MAAKH,OAAO,CAACC,EAAE,CACnB,qBAAqB,EACrB,MAAKI,gBAAgB,CAACF,IAAI,gDAAM,CAChC;IAAA;EACF;EAAC;IAAA;IAAA;MAAA,yGAED;QAAA;QAAA;UAAA;YAAA;cAAA;gB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vD,0BAAQ,CAACiE,uBAAuB,CAAC,IAAI,CAACvD,GAAG,CAAC,EAAE;QAC/C,IAAMuC,MAAM,GAAG,IAAI,CAACW,MAAM,CAAC,OAAO,CAAC;QAEnC,OAAOX,MAAM,CAACiB,8BAA8B,CAAC,IAAI,CAACxD,GAAG,CAAC;MACvD;MAEA,OAAO,KAAK;IACb;EAAC;EAAA;AAAA,EA1MwCyD,4BAAe;AAAA"}
1
+ {"version":3,"file":"EventFeature.js","names":["EventFeature","options","code","isRequired","name","diskUtil","resolvePath","__dirname","emitter","on","handleDidFetchSchemas","bind","handleWillExecute","handleDidExecute","createDir","cwd","featureInstaller","isInstalled","isSkillInstalled","Action","execute","payload","featureCode","actionCode","results","initiatingAction","EventStore","clearCache","combined","combineCodes","settings","Service","clearListenerCache","isRemoteRelevant","appendRemoteToResultsOrPrompt","remoteResults","actionUtil","mergeActionResults","syncResults","isUpgrade","syncListenersAndMixinResults","remote","r","getRemote","TerminalInterface","doesSupportColor","Error","ui","stopLoading","renderLine","summaryLines","getHost","lastSync","getLastSyncOptions","writer","getEventContractBuilder","fetchContractsAndGenerateUniqueSchemas","schemas","shouldSyncOnlyCoreEvents","uniqueSchemas","contractBuilder","EventContractBuilder","optionsSchema","syncEventActionSchema","eventGenerator","Writer","eventStore","Store","skillStore","dependencyService","doesHashSprucePathExist","hasCombinedContractBeenWritten","AbstractFeature"],"sources":["../../../src/features/event/EventFeature.ts"],"sourcesContent":["import { Schema } from '@sprucelabs/schema'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport syncEventActionSchema from '#spruce/schemas/spruceCli/v2020_07_22/syncEventOptions.schema'\nimport TerminalInterface from '../../interfaces/TerminalInterface'\nimport { FileDescription } from '../../types/cli.types'\nimport actionUtil from '../../utilities/action.utility'\nimport AbstractFeature, {\n\tFeatureDependency,\n\tFeatureOptions,\n} from '../AbstractFeature'\nimport { FeatureActionResponse, FeatureCode } from '../features.types'\nimport EventContractBuilder from './builders/EventContractBuilder'\nimport EventStore from './stores/EventStore'\n\ndeclare module '../../features/features.types' {\n\tinterface FeatureMap {\n\t\tevent: EventFeature\n\t}\n\n\tinterface FeatureOptionsMap {\n\t\tevent: undefined\n\t}\n}\n\nexport default class EventFeature extends AbstractFeature {\n\tpublic code: FeatureCode = 'event'\n\tpublic nameReadable = 'Events'\n\tpublic description = 'Connect to the Mercury Event Engine.'\n\tpublic dependencies: FeatureDependency[] = [\n\t\t{ code: 'schema', isRequired: true },\n\t]\n\tpublic packageDependencies = [\n\t\t{\n\t\t\tname: '@sprucelabs/mercury-client',\n\t\t},\n\t\t{\n\t\t\tname: '@sprucelabs/mercury-types',\n\t\t},\n\t\t{\n\t\t\tname: '@sprucelabs/spruce-event-utils',\n\t\t},\n\t\t{\n\t\t\tname: '@sprucelabs/spruce-event-plugin',\n\t\t},\n\t\t{\n\t\t\tname: '@sprucelabs/mercury-core-events',\n\t\t},\n\t]\n\n\tpublic actionsDir = diskUtil.resolvePath(__dirname, 'actions')\n\n\tpublic readonly fileDescriptions: FileDescription[] = []\n\tprivate contractBuilder?: EventContractBuilder\n\tprivate initiatingAction?: string\n\n\tpublic constructor(options: FeatureOptions) {\n\t\tsuper(options)\n\n\t\tvoid this.emitter.on(\n\t\t\t'schema.did-fetch-schemas',\n\t\t\tthis.handleDidFetchSchemas.bind(this)\n\t\t)\n\n\t\tvoid this.emitter.on(\n\t\t\t'feature.will-execute',\n\t\t\tthis.handleWillExecute.bind(this)\n\t\t)\n\n\t\tvoid this.emitter.on(\n\t\t\t'feature.did-execute',\n\t\t\tthis.handleDidExecute.bind(this)\n\t\t)\n\t}\n\n\tpublic async afterPackageInstall() {\n\t\tdiskUtil.createDir(diskUtil.resolvePath(this.cwd, 'src', 'events'))\n\t\tconst isSkillInstalled = await this.featureInstaller.isInstalled('skill')\n\t\tif (isSkillInstalled) {\n\t\t\treturn await this.Action('event', 'sync.listeners').execute({})\n\t\t}\n\n\t\treturn {}\n\t}\n\n\tprivate async handleWillExecute(payload: {\n\t\tfeatureCode: string\n\t\tactionCode: string\n\t}): Promise<FeatureActionResponse> {\n\t\tconst { featureCode, actionCode } = payload\n\n\t\tlet results: FeatureActionResponse = {}\n\n\t\tif (!this.initiatingAction) {\n\t\t\tEventStore.clearCache()\n\t\t\tconst combined = this.combineCodes(featureCode, actionCode)\n\t\t\tthis.initiatingAction = combined\n\t\t}\n\n\t\tif (featureCode === 'node' || featureCode === 'upgrade') {\n\t\t\tconst settings = this.Service('eventSettings')\n\t\t\tsettings.clearListenerCache()\n\t\t}\n\n\t\tconst isInstalled = await this.featureInstaller.isInstalled('event')\n\t\tconst isRemoteRelevant =\n\t\t\tisInstalled &&\n\t\t\t(featureCode === 'event' ||\n\t\t\t\tfeatureCode === 'eventContract' ||\n\t\t\t\tactionCode === 'login') &&\n\t\t\tactionCode !== 'setRemote'\n\n\t\tif (isRemoteRelevant) {\n\t\t\tconst remoteResults = await this.appendRemoteToResultsOrPrompt()\n\t\t\tresults = actionUtil.mergeActionResults(results, remoteResults)\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprivate async syncListenersAndMixinResults(results: FeatureActionResponse) {\n\t\tconst syncResults = await this.Action('event', 'sync.listeners').execute({})\n\t\tresults = actionUtil.mergeActionResults(results, syncResults)\n\t\treturn results\n\t}\n\n\tprivate async handleDidExecute(payload: {\n\t\tfeatureCode: string\n\t\tactionCode: string\n\t}) {\n\t\tconst { featureCode, actionCode } = payload\n\t\tconst isInstalled = await this.featureInstaller.isInstalled('event')\n\n\t\tlet results = {}\n\n\t\tconst isUpgrade =\n\t\t\tisInstalled && featureCode === 'node' && actionCode === 'upgrade'\n\n\t\tif (isUpgrade) {\n\t\t\tresults = await this.Action('event', 'sync').execute({})\n\t\t\tresults = await this.syncListenersAndMixinResults(results)\n\t\t}\n\n\t\tif (this.initiatingAction === this.combineCodes(featureCode, actionCode)) {\n\t\t\tEventStore.clearCache()\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprivate combineCodes(featureCode: string, actionCode: string) {\n\t\treturn `${featureCode}.${actionCode}`\n\t}\n\n\tprivate async appendRemoteToResultsOrPrompt(): Promise<FeatureActionResponse> {\n\t\tconst remote = this.Service('remote')\n\t\tconst r = remote.getRemote()\n\n\t\tif (!r) {\n\t\t\tif (!TerminalInterface.doesSupportColor()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Dang! I couldn't find env.HOST. Once that is set, lets try again!`\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tthis.ui.stopLoading()\n\t\t\tthis.ui.renderLine(\n\t\t\t\t`Uh oh! It looks like you haven't configured your remote! We gotta do that.`\n\t\t\t)\n\n\t\t\tconst results = await this.Action('event', 'setRemote').execute({})\n\n\t\t\treturn results\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tsummaryLines: [`Remote: ${r}`, `Host: ${remote.getHost()}`],\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async handleDidFetchSchemas(payload: { schemas?: Schema[] | null }) {\n\t\tconst isInstalled = await this.featureInstaller.isInstalled(this.code)\n\n\t\tconst lastSync = this.Service('eventSettings').getLastSyncOptions()\n\n\t\tif (lastSync && isInstalled) {\n\t\t\tconst writer = this.getEventContractBuilder()\n\n\t\t\tconst uniqueSchemas = await writer.fetchContractsAndGenerateUniqueSchemas(\n\t\t\t\tpayload.schemas ?? [],\n\t\t\t\tlastSync.shouldSyncOnlyCoreEvents\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tschemas: uniqueSchemas.schemas ?? [],\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tschemas: [],\n\t\t}\n\t}\n\n\tpublic getEventContractBuilder() {\n\t\tif (!this.contractBuilder) {\n\t\t\tthis.contractBuilder = new EventContractBuilder({\n\t\t\t\tcwd: this.cwd,\n\t\t\t\toptionsSchema: syncEventActionSchema,\n\t\t\t\tui: this.ui,\n\t\t\t\teventGenerator: this.Writer('event'),\n\t\t\t\teventStore: this.Store('event'),\n\t\t\t\tskillStore: this.Store('skill'),\n\t\t\t\tdependencyService: this.Service('dependency'),\n\t\t\t})\n\t\t}\n\n\t\treturn this.contractBuilder\n\t}\n\n\tpublic hasBeenSynced() {\n\t\tif (diskUtil.doesHashSprucePathExist(this.cwd)) {\n\t\t\tconst writer = this.Writer('event')\n\t\t\treturn writer.hasCombinedContractBeenWritten(this.cwd)\n\t\t}\n\n\t\treturn false\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA;AACA;AACA;AAEA;AACA;AAKA;AACA;AAA4C;AAAA;AAAA,IAYvBA,YAAY;EAAA;EAAA;EA+BhC,sBAAmBC,OAAuB,EAAE;IAAA;IAAA;IAC3C,0BAAMA,OAAO;IAAC,yFA/BY,OAAO;IAAA,iGACZ,QAAQ;IAAA,gGACT,sCAAsC;IAAA,iGAChB,CAC1C;MAAEC,IAAI,EAAE,QAAQ;MAAEC,UAAU,EAAE;IAAK,CAAC,CACpC;IAAA,wGAC4B,CAC5B;MACCC,IAAI,EAAE;IACP,CAAC,EACD;MACCA,IAAI,EAAE;IACP,CAAC,EACD;MACCA,IAAI,EAAE;IACP,CAAC,EACD;MACCA,IAAI,EAAE;IACP,CAAC,EACD;MACCA,IAAI,EAAE;IACP,CAAC,CACD;IAAA,+FAEmBC,0BAAQ,CAACC,WAAW,CAACC,SAAS,EAAE,SAAS,CAAC;IAAA,qGAER,EAAE;IAAA;IAAA;IAOvD,KAAK,MAAKC,OAAO,CAACC,EAAE,CACnB,0BAA0B,EAC1B,MAAKC,qBAAqB,CAACC,IAAI,gDAAM,CACrC;IAED,KAAK,MAAKH,OAAO,CAACC,EAAE,CACnB,sBAAsB,EACtB,MAAKG,iBAAiB,CAACD,IAAI,gDAAM,CACjC;IAED,KAAK,MAAKH,OAAO,CAACC,EAAE,CACnB,qBAAqB,EACrB,MAAKI,gBAAgB,CAACF,IAAI,gDAAM,CAChC;IAAA;EACF;EAAC;IAAA;IAAA;MAAA,yGAED;QAAA;QAAA;UAAA;YAAA;cAAA;gBACCN,0BAAQ,CAACS,SAAS,C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,CAAC,IAAI,CAACvD,GAAG,CAAC,EAAE;QAC/C,IAAMuC,MAAM,GAAG,IAAI,CAACW,MAAM,CAAC,OAAO,CAAC;QACnC,OAAOX,MAAM,CAACiB,8BAA8B,CAAC,IAAI,CAACxD,GAAG,CAAC;MACvD;MAEA,OAAO,KAAK;IACb;EAAC;EAAA;AAAA,EAzMwCyD,4BAAe;AAAA"}
@@ -253,7 +253,9 @@ var EventWriter = /*#__PURE__*/function (_AbstractWriter) {
253
253
  action: 'generated',
254
254
  description: 'Permissions someone else will need to emit your event.',
255
255
  context: {
256
- nameCamel: nameCamel + 'Emit'
256
+ nameCamel: nameCamel + 'Emit',
257
+ nameKebab: nameKebab,
258
+ description: ''
257
259
  }
258
260
  }, {
259
261
  templateMethod: 'permissionContractBuilder',
@@ -261,7 +263,9 @@ var EventWriter = /*#__PURE__*/function (_AbstractWriter) {
261
263
  action: 'generated',
262
264
  description: 'Permissions someone else will need to listen to your event.',
263
265
  context: {
264
- nameCamel: nameCamel + 'Listen'
266
+ nameCamel: nameCamel + 'Listen',
267
+ nameKebab: nameKebab,
268
+ description: ''
265
269
  }
266
270
  }, {
267
271
  templateMethod: 'eventOptions',
@@ -1 +1 @@
1
- {"version":3,"file":"EventWriter.js","names":["CONTRACT_FILE_NAME","EventWriter","destinationDir","options","eventContractTemplateItems","shouldImportCoreEvents","generated","item","push","writeContract","eventContractTemplateItem","writeCombinedEvents","templateItems","Promise","all","lint","schemaTemplateItems","destinationFile","diskUtil","resolvePath","namespaceCamel","generateEventContractFileName","eventsContractContents","templates","eventContract","writeFileIfChangedMixinResults","Object","keys","eventSignatures","results","cwd","doesHashSprucePathExist","path","resolveHashSprucePath","doesFileExist","contents","combinedEventsContract","schemaTypesLookupDir","fullyQualifiedEventName","event","eventNameUtil","split","resolvedDestination","eventDiskUtil","resolveListenerPath","relativeTypesFile","resolveSchemaTypesFile","namespace","eventNamespace","listenerContents","listener","schemaTypesFile","destination","listeners","version","nameKebab","nameCamel","nameReadable","isGlobal","templateMethod","name","action","description","context","files","file","resolveEventPath","fileName","eventName","writeFile","pathUtil","join","DEFAULT_SCHEMA_TYPES_FILENAME","resolveRelativePath","dirname","replace","extname","AbstractWriter"],"sources":["../../../../src/features/event/writers/EventWriter.ts"],"sourcesContent":["import pathUtil from 'path'\nimport { SchemaTemplateItem } from '@sprucelabs/schema'\nimport { eventDiskUtil, eventNameUtil } from '@sprucelabs/spruce-event-utils'\nimport {\n\tdiskUtil,\n\tDEFAULT_SCHEMA_TYPES_FILENAME,\n} from '@sprucelabs/spruce-skill-utils'\nimport {\n\tEventContractTemplateItem,\n\tEventListenerOptions,\n\tListenerTemplateItem,\n} from '@sprucelabs/spruce-templates'\nimport { GeneratedFile } from '../../../types/cli.types'\nimport AbstractWriter from '../../../writers/AbstractWriter'\n\nconst CONTRACT_FILE_NAME = `events.contract.ts`\nexport default class EventWriter extends AbstractWriter {\n\tpublic async writeContracts(\n\t\tdestinationDir: string,\n\t\toptions: {\n\t\t\teventContractTemplateItems: EventContractTemplateItem[]\n\t\t\tschemaTemplateItems: SchemaTemplateItem[]\n\t\t\tshouldImportCoreEvents?: boolean\n\t\t\tskillEventContractTypesFile: string\n\t\t\teventBuilderFile: string\n\t\t}\n\t) {\n\t\tconst { eventContractTemplateItems, shouldImportCoreEvents = true } =\n\t\t\toptions\n\n\t\tconst generated: Promise<GeneratedFile>[] = []\n\n\t\tfor (const item of eventContractTemplateItems) {\n\t\t\tgenerated.push(\n\t\t\t\tthis.writeContract({\n\t\t\t\t\t...options,\n\t\t\t\t\tdestinationDir,\n\t\t\t\t\teventContractTemplateItem: item,\n\t\t\t\t})\n\t\t\t)\n\t\t}\n\n\t\tgenerated.push(\n\t\t\tthis.writeCombinedEvents({\n\t\t\t\t...options,\n\t\t\t\tshouldImportCoreEvents,\n\t\t\t\tdestinationDir,\n\t\t\t\ttemplateItems: eventContractTemplateItems,\n\t\t\t})\n\t\t)\n\n\t\tconst all = await Promise.all(generated)\n\n\t\tawait this.lint(destinationDir)\n\n\t\treturn all\n\t}\n\n\tprivate async writeContract(options: {\n\t\tdestinationDir: string\n\t\teventContractTemplateItem: EventContractTemplateItem\n\t\tschemaTemplateItems: SchemaTemplateItem[]\n\t\teventBuilderFile: string\n\t}): Promise<GeneratedFile> {\n\t\tconst { destinationDir, eventContractTemplateItem, schemaTemplateItems } =\n\t\t\toptions\n\n\t\tconst destinationFile = diskUtil.resolvePath(\n\t\t\tdestinationDir,\n\t\t\teventContractTemplateItem.namespaceCamel,\n\t\t\tgenerateEventContractFileName(eventContractTemplateItem)\n\t\t)\n\n\t\tconst eventsContractContents = this.templates.eventContract({\n\t\t\t...options,\n\t\t\t...eventContractTemplateItem,\n\t\t\tschemaTemplateItems,\n\t\t})\n\n\t\tconst results = await this.writeFileIfChangedMixinResults(\n\t\t\tdestinationFile,\n\t\t\teventsContractContents,\n\t\t\t`The event contract for ${\n\t\t\t\tObject.keys(eventContractTemplateItem.eventSignatures)[0]\n\t\t\t}`\n\t\t)\n\n\t\treturn results[0]\n\t}\n\n\tpublic hasCombinedContractBeenWritten(cwd: string) {\n\t\tif (diskUtil.doesHashSprucePathExist(cwd)) {\n\t\t\tconst path = diskUtil.resolveHashSprucePath(\n\t\t\t\tcwd,\n\t\t\t\t'events',\n\t\t\t\tCONTRACT_FILE_NAME\n\t\t\t)\n\n\t\t\treturn diskUtil.doesFileExist(path)\n\t\t}\n\n\t\treturn false\n\t}\n\n\tprivate async writeCombinedEvents(options: {\n\t\tdestinationDir: string\n\t\ttemplateItems: EventContractTemplateItem[]\n\t\tshouldImportCoreEvents?: boolean\n\t\tskillEventContractTypesFile: string\n\t}): Promise<GeneratedFile> {\n\t\tconst { destinationDir } = options\n\n\t\tconst destinationFile = diskUtil.resolvePath(\n\t\t\tdestinationDir,\n\t\t\tCONTRACT_FILE_NAME\n\t\t)\n\n\t\tconst contents = this.templates.combinedEventsContract(options)\n\n\t\tconst results = await this.writeFileIfChangedMixinResults(\n\t\t\tdestinationFile,\n\t\t\tcontents,\n\t\t\t'All event contracts combined to a single export.'\n\t\t)\n\n\t\treturn results[0]\n\t}\n\n\tpublic async writeListener(\n\t\tdestinationDir: string,\n\t\toptions: Omit<EventListenerOptions, 'schemaTypesFile'> & {\n\t\t\tschemaTypesLookupDir: string\n\t\t}\n\t) {\n\t\tconst { schemaTypesLookupDir, fullyQualifiedEventName } = options\n\n\t\tconst event = eventNameUtil.split(fullyQualifiedEventName)\n\t\tconst resolvedDestination = eventDiskUtil.resolveListenerPath(\n\t\t\tdestinationDir,\n\t\t\tevent as any\n\t\t)\n\n\t\tconst relativeTypesFile = this.resolveSchemaTypesFile({\n\t\t\tnamespace: event.eventNamespace,\n\t\t\tschemaTypesLookupDir,\n\t\t\tresolvedDestination,\n\t\t})\n\n\t\tconst listenerContents = this.templates.listener({\n\t\t\t...options,\n\t\t\tschemaTypesFile: relativeTypesFile,\n\t\t})\n\n\t\tconst results = await this.writeFileIfChangedMixinResults(\n\t\t\tresolvedDestination,\n\t\t\tlistenerContents,\n\t\t\t`Listener for ${fullyQualifiedEventName}.`\n\t\t)\n\n\t\tawait this.lint(resolvedDestination)\n\n\t\treturn results\n\t}\n\n\tpublic async writeListenerMap(\n\t\tdestinationDir: string,\n\t\toptions: {\n\t\t\tlisteners: ListenerTemplateItem[]\n\t\t}\n\t) {\n\t\tconst destination = diskUtil.resolvePath(destinationDir, 'listeners.ts')\n\t\tconst contents = this.templates.listeners({ listeners: options.listeners })\n\n\t\tconst results = await this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tcontents,\n\t\t\t'All your listeners imported to one place for your skill to use when booting!'\n\t\t)\n\n\t\treturn results\n\t}\n\n\tpublic async writeEvent(\n\t\tdestinationDir: string,\n\t\toptions: {\n\t\t\tnameCamel: string\n\t\t\tnameKebab: string\n\t\t\tversion: string\n\t\t\tnameReadable: string\n\t\t\tisGlobal?: boolean\n\t\t}\n\t) {\n\t\tconst {\n\t\t\tversion,\n\t\t\tnameKebab,\n\t\t\tnameCamel,\n\t\t\tnameReadable,\n\t\t\tisGlobal = false,\n\t\t} = options\n\n\t\tconst templates: ({\n\t\t\tcontext?: any\n\t\t\ttemplateMethod:\n\t\t\t\t| 'eventEmitPayload'\n\t\t\t\t| 'eventEmitTarget'\n\t\t\t\t| 'eventResponsePayload'\n\t\t\t\t| 'permissionContractBuilder'\n\t\t\t\t| 'eventOptions'\n\t\t} & Omit<GeneratedFile, 'path'>)[] = [\n\t\t\t{\n\t\t\t\ttemplateMethod: 'eventEmitPayload',\n\t\t\t\tname: 'emitPayload.builder.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription: 'The payload that will be sent when you emit this event.',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttemplateMethod: 'eventEmitTarget',\n\t\t\t\tname: 'emitTarget.builder.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription: 'The target that will be sent when you emit this event.',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttemplateMethod: 'eventResponsePayload',\n\t\t\t\tname: 'responsePayload.builder.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription:\n\t\t\t\t\t'The payload that every listener will need to respond with. Delete this file for events that are fire and forget.',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttemplateMethod: 'permissionContractBuilder',\n\t\t\t\tname: 'emitPermissions.builder.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription: 'Permissions someone else will need to emit your event.',\n\t\t\t\tcontext: {\n\t\t\t\t\tnameCamel: nameCamel + 'Emit',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttemplateMethod: 'permissionContractBuilder',\n\t\t\t\tname: 'listenPermissions.builder.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription:\n\t\t\t\t\t'Permissions someone else will need to listen to your event.',\n\t\t\t\tcontext: {\n\t\t\t\t\tnameCamel: nameCamel + 'Listen',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttemplateMethod: 'eventOptions',\n\t\t\t\tname: 'event.options.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription: 'Extra options that can be set for your event',\n\t\t\t\tcontext: {\n\t\t\t\t\tisGlobal,\n\t\t\t\t},\n\t\t\t},\n\t\t]\n\n\t\tconst files: GeneratedFile[] = []\n\n\t\tfor (const file of templates) {\n\t\t\tconst destination = eventDiskUtil.resolveEventPath(destinationDir, {\n\t\t\t\tfileName: file.name as any,\n\t\t\t\teventName: nameKebab,\n\t\t\t\tversion,\n\t\t\t})\n\n\t\t\tconst contents = this.templates[file.templateMethod]({\n\t\t\t\tnameCamel,\n\t\t\t\tnameReadable,\n\t\t\t\tversion,\n\t\t\t\t...file.context,\n\t\t\t})\n\n\t\t\tdiskUtil.writeFile(destination, contents)\n\n\t\t\tfiles.push({\n\t\t\t\t...file,\n\t\t\t\tpath: destination,\n\t\t\t})\n\t\t}\n\n\t\tawait this.lint(destinationDir)\n\n\t\treturn files\n\t}\n\n\tprivate resolveSchemaTypesFile(options: {\n\t\tnamespace?: string\n\t\tschemaTypesLookupDir: string\n\t\tresolvedDestination: string\n\t}) {\n\t\tconst { schemaTypesLookupDir, resolvedDestination, namespace } = options\n\n\t\tif (!namespace) {\n\t\t\treturn '@sprucelabs/mercury-types'\n\t\t}\n\n\t\tconst schemaTypesFile = pathUtil.join(\n\t\t\tschemaTypesLookupDir,\n\t\t\tDEFAULT_SCHEMA_TYPES_FILENAME\n\t\t)\n\n\t\tlet relativeTypesFile = diskUtil.resolveRelativePath(\n\t\t\tpathUtil.dirname(resolvedDestination),\n\t\t\tschemaTypesFile\n\t\t)\n\n\t\trelativeTypesFile = relativeTypesFile.replace(\n\t\t\tpathUtil.extname(relativeTypesFile),\n\t\t\t''\n\t\t)\n\n\t\treturn relativeTypesFile\n\t}\n}\n\nexport function generateEventContractFileName(options: {\n\tnameCamel: string\n\tversion: string\n}): string {\n\treturn `${options.nameCamel}.${options.version}.contract.ts`\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAEA;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AI,CAACA,SAAS,EAAE;QACf,OAAO,2BAA2B;MACnC;MAEA,IAAMI,eAAe,GAAGmB,gBAAQ,CAACC,IAAI,CACpClC,oBAAoB,EACpBmC,+CAA6B,CAC7B;MAED,IAAI3B,iBAAiB,GAAG3B,0BAAQ,CAACuD,mBAAmB,CACnDH,gBAAQ,CAACI,OAAO,CAAChC,mBAAmB,CAAC,EACrCS,eAAe,CACf;MAEDN,iBAAiB,GAAGA,iBAAiB,CAAC8B,OAAO,CAC5CL,gBAAQ,CAACM,OAAO,CAAC/B,iBAAiB,CAAC,EACnC,EAAE,CACF;MAED,OAAOA,iBAAiB;IACzB;EAAC;EAAA;AAAA,EA1SuCgC,2BAAc;AAAA;AA6ShD,SAASxD,6BAA6B,CAAClB,OAG7C,EAAU;EACV,iBAAUA,OAAO,CAACqD,SAAS,cAAIrD,OAAO,CAACmD,OAAO;AAC/C"}
1
+ {"version":3,"file":"EventWriter.js","names":["CONTRACT_FILE_NAME","EventWriter","destinationDir","options","eventContractTemplateItems","shouldImportCoreEvents","generated","item","push","writeContract","eventContractTemplateItem","writeCombinedEvents","templateItems","Promise","all","lint","schemaTemplateItems","destinationFile","diskUtil","resolvePath","namespaceCamel","generateEventContractFileName","eventsContractContents","templates","eventContract","writeFileIfChangedMixinResults","Object","keys","eventSignatures","results","cwd","doesHashSprucePathExist","path","resolveHashSprucePath","doesFileExist","contents","combinedEventsContract","schemaTypesLookupDir","fullyQualifiedEventName","event","eventNameUtil","split","resolvedDestination","eventDiskUtil","resolveListenerPath","relativeTypesFile","resolveSchemaTypesFile","namespace","eventNamespace","listenerContents","listener","schemaTypesFile","destination","listeners","version","nameKebab","nameCamel","nameReadable","isGlobal","templateMethod","name","action","description","context","files","file","resolveEventPath","fileName","eventName","writeFile","pathUtil","join","DEFAULT_SCHEMA_TYPES_FILENAME","resolveRelativePath","dirname","replace","extname","AbstractWriter"],"sources":["../../../../src/features/event/writers/EventWriter.ts"],"sourcesContent":["import pathUtil from 'path'\nimport { SchemaTemplateItem } from '@sprucelabs/schema'\nimport { eventDiskUtil, eventNameUtil } from '@sprucelabs/spruce-event-utils'\nimport {\n\tdiskUtil,\n\tDEFAULT_SCHEMA_TYPES_FILENAME,\n} from '@sprucelabs/spruce-skill-utils'\nimport {\n\tEventContractTemplateItem,\n\tEventListenerOptions,\n\tListenerTemplateItem,\n} from '@sprucelabs/spruce-templates'\nimport { GeneratedFile } from '../../../types/cli.types'\nimport AbstractWriter from '../../../writers/AbstractWriter'\n\nconst CONTRACT_FILE_NAME = `events.contract.ts`\nexport default class EventWriter extends AbstractWriter {\n\tpublic async writeContracts(\n\t\tdestinationDir: string,\n\t\toptions: {\n\t\t\teventContractTemplateItems: EventContractTemplateItem[]\n\t\t\tschemaTemplateItems: SchemaTemplateItem[]\n\t\t\tshouldImportCoreEvents?: boolean\n\t\t\tskillEventContractTypesFile: string\n\t\t\teventBuilderFile: string\n\t\t}\n\t) {\n\t\tconst { eventContractTemplateItems, shouldImportCoreEvents = true } =\n\t\t\toptions\n\n\t\tconst generated: Promise<GeneratedFile>[] = []\n\n\t\tfor (const item of eventContractTemplateItems) {\n\t\t\tgenerated.push(\n\t\t\t\tthis.writeContract({\n\t\t\t\t\t...options,\n\t\t\t\t\tdestinationDir,\n\t\t\t\t\teventContractTemplateItem: item,\n\t\t\t\t})\n\t\t\t)\n\t\t}\n\n\t\tgenerated.push(\n\t\t\tthis.writeCombinedEvents({\n\t\t\t\t...options,\n\t\t\t\tshouldImportCoreEvents,\n\t\t\t\tdestinationDir,\n\t\t\t\ttemplateItems: eventContractTemplateItems,\n\t\t\t})\n\t\t)\n\n\t\tconst all = await Promise.all(generated)\n\n\t\tawait this.lint(destinationDir)\n\n\t\treturn all\n\t}\n\n\tprivate async writeContract(options: {\n\t\tdestinationDir: string\n\t\teventContractTemplateItem: EventContractTemplateItem\n\t\tschemaTemplateItems: SchemaTemplateItem[]\n\t\teventBuilderFile: string\n\t}): Promise<GeneratedFile> {\n\t\tconst { destinationDir, eventContractTemplateItem, schemaTemplateItems } =\n\t\t\toptions\n\n\t\tconst destinationFile = diskUtil.resolvePath(\n\t\t\tdestinationDir,\n\t\t\teventContractTemplateItem.namespaceCamel,\n\t\t\tgenerateEventContractFileName(eventContractTemplateItem)\n\t\t)\n\n\t\tconst eventsContractContents = this.templates.eventContract({\n\t\t\t...options,\n\t\t\t...eventContractTemplateItem,\n\t\t\tschemaTemplateItems,\n\t\t})\n\n\t\tconst results = await this.writeFileIfChangedMixinResults(\n\t\t\tdestinationFile,\n\t\t\teventsContractContents,\n\t\t\t`The event contract for ${\n\t\t\t\tObject.keys(eventContractTemplateItem.eventSignatures)[0]\n\t\t\t}`\n\t\t)\n\n\t\treturn results[0]\n\t}\n\n\tpublic hasCombinedContractBeenWritten(cwd: string) {\n\t\tif (diskUtil.doesHashSprucePathExist(cwd)) {\n\t\t\tconst path = diskUtil.resolveHashSprucePath(\n\t\t\t\tcwd,\n\t\t\t\t'events',\n\t\t\t\tCONTRACT_FILE_NAME\n\t\t\t)\n\n\t\t\treturn diskUtil.doesFileExist(path)\n\t\t}\n\n\t\treturn false\n\t}\n\n\tprivate async writeCombinedEvents(options: {\n\t\tdestinationDir: string\n\t\ttemplateItems: EventContractTemplateItem[]\n\t\tshouldImportCoreEvents?: boolean\n\t\tskillEventContractTypesFile: string\n\t}): Promise<GeneratedFile> {\n\t\tconst { destinationDir } = options\n\n\t\tconst destinationFile = diskUtil.resolvePath(\n\t\t\tdestinationDir,\n\t\t\tCONTRACT_FILE_NAME\n\t\t)\n\n\t\tconst contents = this.templates.combinedEventsContract(options)\n\n\t\tconst results = await this.writeFileIfChangedMixinResults(\n\t\t\tdestinationFile,\n\t\t\tcontents,\n\t\t\t'All event contracts combined to a single export.'\n\t\t)\n\n\t\treturn results[0]\n\t}\n\n\tpublic async writeListener(\n\t\tdestinationDir: string,\n\t\toptions: Omit<EventListenerOptions, 'schemaTypesFile'> & {\n\t\t\tschemaTypesLookupDir: string\n\t\t}\n\t) {\n\t\tconst { schemaTypesLookupDir, fullyQualifiedEventName } = options\n\n\t\tconst event = eventNameUtil.split(fullyQualifiedEventName)\n\t\tconst resolvedDestination = eventDiskUtil.resolveListenerPath(\n\t\t\tdestinationDir,\n\t\t\tevent as any\n\t\t)\n\n\t\tconst relativeTypesFile = this.resolveSchemaTypesFile({\n\t\t\tnamespace: event.eventNamespace,\n\t\t\tschemaTypesLookupDir,\n\t\t\tresolvedDestination,\n\t\t})\n\n\t\tconst listenerContents = this.templates.listener({\n\t\t\t...options,\n\t\t\tschemaTypesFile: relativeTypesFile,\n\t\t})\n\n\t\tconst results = await this.writeFileIfChangedMixinResults(\n\t\t\tresolvedDestination,\n\t\t\tlistenerContents,\n\t\t\t`Listener for ${fullyQualifiedEventName}.`\n\t\t)\n\n\t\tawait this.lint(resolvedDestination)\n\n\t\treturn results\n\t}\n\n\tpublic async writeListenerMap(\n\t\tdestinationDir: string,\n\t\toptions: {\n\t\t\tlisteners: ListenerTemplateItem[]\n\t\t}\n\t) {\n\t\tconst destination = diskUtil.resolvePath(destinationDir, 'listeners.ts')\n\t\tconst contents = this.templates.listeners({ listeners: options.listeners })\n\n\t\tconst results = await this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tcontents,\n\t\t\t'All your listeners imported to one place for your skill to use when booting!'\n\t\t)\n\n\t\treturn results\n\t}\n\n\tpublic async writeEvent(\n\t\tdestinationDir: string,\n\t\toptions: {\n\t\t\tnameCamel: string\n\t\t\tnameKebab: string\n\t\t\tversion: string\n\t\t\tnameReadable: string\n\t\t\tisGlobal?: boolean\n\t\t}\n\t) {\n\t\tconst {\n\t\t\tversion,\n\t\t\tnameKebab,\n\t\t\tnameCamel,\n\t\t\tnameReadable,\n\t\t\tisGlobal = false,\n\t\t} = options\n\n\t\tconst templates: ({\n\t\t\tcontext?: any\n\t\t\ttemplateMethod:\n\t\t\t\t| 'eventEmitPayload'\n\t\t\t\t| 'eventEmitTarget'\n\t\t\t\t| 'eventResponsePayload'\n\t\t\t\t| 'permissionContractBuilder'\n\t\t\t\t| 'eventOptions'\n\t\t} & Omit<GeneratedFile, 'path'>)[] = [\n\t\t\t{\n\t\t\t\ttemplateMethod: 'eventEmitPayload',\n\t\t\t\tname: 'emitPayload.builder.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription: 'The payload that will be sent when you emit this event.',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttemplateMethod: 'eventEmitTarget',\n\t\t\t\tname: 'emitTarget.builder.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription: 'The target that will be sent when you emit this event.',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttemplateMethod: 'eventResponsePayload',\n\t\t\t\tname: 'responsePayload.builder.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription:\n\t\t\t\t\t'The payload that every listener will need to respond with. Delete this file for events that are fire and forget.',\n\t\t\t},\n\t\t\t{\n\t\t\t\ttemplateMethod: 'permissionContractBuilder',\n\t\t\t\tname: 'emitPermissions.builder.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription: 'Permissions someone else will need to emit your event.',\n\t\t\t\tcontext: {\n\t\t\t\t\tnameCamel: nameCamel + 'Emit',\n\t\t\t\t\tnameKebab,\n\t\t\t\t\tdescription: '',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttemplateMethod: 'permissionContractBuilder',\n\t\t\t\tname: 'listenPermissions.builder.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription:\n\t\t\t\t\t'Permissions someone else will need to listen to your event.',\n\t\t\t\tcontext: {\n\t\t\t\t\tnameCamel: nameCamel + 'Listen',\n\t\t\t\t\tnameKebab,\n\t\t\t\t\tdescription: '',\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\ttemplateMethod: 'eventOptions',\n\t\t\t\tname: 'event.options.ts',\n\t\t\t\taction: 'generated',\n\t\t\t\tdescription: 'Extra options that can be set for your event',\n\t\t\t\tcontext: {\n\t\t\t\t\tisGlobal,\n\t\t\t\t},\n\t\t\t},\n\t\t]\n\n\t\tconst files: GeneratedFile[] = []\n\n\t\tfor (const file of templates) {\n\t\t\tconst destination = eventDiskUtil.resolveEventPath(destinationDir, {\n\t\t\t\tfileName: file.name as any,\n\t\t\t\teventName: nameKebab,\n\t\t\t\tversion,\n\t\t\t})\n\n\t\t\tconst contents = this.templates[file.templateMethod]({\n\t\t\t\tnameCamel,\n\t\t\t\tnameReadable,\n\t\t\t\tversion,\n\t\t\t\t...file.context,\n\t\t\t})\n\n\t\t\tdiskUtil.writeFile(destination, contents)\n\n\t\t\tfiles.push({\n\t\t\t\t...file,\n\t\t\t\tpath: destination,\n\t\t\t})\n\t\t}\n\n\t\tawait this.lint(destinationDir)\n\n\t\treturn files\n\t}\n\n\tprivate resolveSchemaTypesFile(options: {\n\t\tnamespace?: string\n\t\tschemaTypesLookupDir: string\n\t\tresolvedDestination: string\n\t}) {\n\t\tconst { schemaTypesLookupDir, resolvedDestination, namespace } = options\n\n\t\tif (!namespace) {\n\t\t\treturn '@sprucelabs/mercury-types'\n\t\t}\n\n\t\tconst schemaTypesFile = pathUtil.join(\n\t\t\tschemaTypesLookupDir,\n\t\t\tDEFAULT_SCHEMA_TYPES_FILENAME\n\t\t)\n\n\t\tlet relativeTypesFile = diskUtil.resolveRelativePath(\n\t\t\tpathUtil.dirname(resolvedDestination),\n\t\t\tschemaTypesFile\n\t\t)\n\n\t\trelativeTypesFile = relativeTypesFile.replace(\n\t\t\tpathUtil.extname(relativeTypesFile),\n\t\t\t''\n\t\t)\n\n\t\treturn relativeTypesFile\n\t}\n}\n\nexport function generateEventContractFileName(options: {\n\tnameCamel: string\n\tversion: string\n}): string {\n\treturn `${options.nameCamel}.${options.version}.contract.ts`\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAEA;AACA;AAUA;AAA4D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAE5D,IAAMA,kBAAkB,uBAAuB;AAAA,IAC1BC,WAAW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AI,CAACA,SAAS,EAAE;QACf,OAAO,2BAA2B;MACnC;MAEA,IAAMI,eAAe,GAAGmB,gBAAQ,CAACC,IAAI,CACpClC,oBAAoB,EACpBmC,+CAA6B,CAC7B;MAED,IAAI3B,iBAAiB,GAAG3B,0BAAQ,CAACuD,mBAAmB,CACnDH,gBAAQ,CAACI,OAAO,CAAChC,mBAAmB,CAAC,EACrCS,eAAe,CACf;MAEDN,iBAAiB,GAAGA,iBAAiB,CAAC8B,OAAO,CAC5CL,gBAAQ,CAACM,OAAO,CAAC/B,iBAAiB,CAAC,EACnC,EAAE,CACF;MAED,OAAOA,iBAAiB;IACzB;EAAC;EAAA;AAAA,EA9SuCgC,2BAAc;AAAA;AAiThD,SAASxD,6BAA6B,CAAClB,OAG7C,EAAU;EACV,iBAAUA,OAAO,CAACqD,SAAS,cAAIrD,OAAO,CAACmD,OAAO;AAC/C"}
@@ -1,35 +1,21 @@
1
1
  import { SchemaValues } from '@sprucelabs/schema';
2
2
  import AbstractAction from '../../AbstractAction';
3
3
  import { FeatureActionResponse } from '../../features.types';
4
- declare const schema: {
5
- id: string;
6
- fields: {
7
- nameReadable: {
8
- label: "Readable name";
9
- type: "text";
10
- isRequired: true;
11
- hint: "The name people will read";
12
- options: undefined;
13
- };
14
- nameKebab: {
15
- label: "Kebab case name";
16
- type: "text";
17
- hint: "kebab-case of the name";
18
- options: undefined;
19
- };
20
- };
21
- };
22
- declare type OptionsSchema = typeof schema;
23
- declare type Options = SchemaValues<OptionsSchema>;
24
4
  export default class CreateAction extends AbstractAction<OptionsSchema> {
25
5
  optionsSchema: {
26
6
  id: string;
27
7
  fields: {
28
- nameReadable: {
29
- label: "Readable name";
8
+ description: {
9
+ label: string;
10
+ type: "text";
11
+ hint: "Describe a bit more here";
12
+ options: undefined;
13
+ };
14
+ nameCamel: {
15
+ label: "Camel case name";
30
16
  type: "text";
31
17
  isRequired: true;
32
- hint: "The name people will read";
18
+ hint: "camelCase version of the name";
33
19
  options: undefined;
34
20
  };
35
21
  nameKebab: {
@@ -38,9 +24,50 @@ export default class CreateAction extends AbstractAction<OptionsSchema> {
38
24
  hint: "kebab-case of the name";
39
25
  options: undefined;
40
26
  };
27
+ nameReadable: {
28
+ label: string;
29
+ hint: string;
30
+ type: "text";
31
+ isRequired: true;
32
+ options: undefined;
33
+ };
41
34
  };
42
35
  };
43
36
  invocationMessage: string;
44
- execute(_options: Options): Promise<FeatureActionResponse>;
37
+ readonly commandAliases: string[];
38
+ execute(options: Options): Promise<FeatureActionResponse>;
45
39
  }
40
+ declare const schema: {
41
+ id: string;
42
+ fields: {
43
+ description: {
44
+ label: string;
45
+ type: "text";
46
+ hint: "Describe a bit more here";
47
+ options: undefined;
48
+ };
49
+ nameCamel: {
50
+ label: "Camel case name";
51
+ type: "text";
52
+ isRequired: true;
53
+ hint: "camelCase version of the name";
54
+ options: undefined;
55
+ };
56
+ nameKebab: {
57
+ label: "Kebab case name";
58
+ type: "text";
59
+ hint: "kebab-case of the name";
60
+ options: undefined;
61
+ };
62
+ nameReadable: {
63
+ label: string;
64
+ hint: string;
65
+ type: "text";
66
+ isRequired: true;
67
+ options: undefined;
68
+ };
69
+ };
70
+ };
71
+ declare type OptionsSchema = typeof schema;
72
+ declare type Options = SchemaValues<OptionsSchema>;
46
73
  export {};
@@ -15,16 +15,13 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
15
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
17
  var _schema = require("@sprucelabs/schema");
18
+ var _spruceSkillUtils = require("@sprucelabs/spruce-skill-utils");
18
19
  var _namedTemplateItem = _interopRequireDefault(require("../../../.spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema"));
19
20
  var _AbstractAction2 = _interopRequireDefault(require("../../AbstractAction"));
20
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
21
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
21
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
22
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
24
- var schema = (0, _schema.buildSchema)({
25
- id: 'createPermission',
26
- fields: _objectSpread({}, (0, _schema.pickFields)(_namedTemplateItem["default"].fields, ['nameReadable', 'nameKebab']))
27
- });
23
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
24
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
28
25
  var CreateAction = /*#__PURE__*/function (_AbstractAction) {
29
26
  (0, _inherits2["default"])(CreateAction, _AbstractAction);
30
27
  var _super = _createSuper(CreateAction);
@@ -37,23 +34,39 @@ var CreateAction = /*#__PURE__*/function (_AbstractAction) {
37
34
  _this = _super.call.apply(_super, [this].concat(args));
38
35
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "optionsSchema", schema);
39
36
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "invocationMessage", 'Creating a permission contract... 🛡');
37
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "commandAliases", ['create.permissions', 'create.permission']);
40
38
  return _this;
41
39
  }
42
40
  (0, _createClass2["default"])(CreateAction, [{
43
41
  key: "execute",
44
42
  value: function () {
45
- var _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_options) {
43
+ var _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(options) {
44
+ var _this$validateAndNorm, nameKebab, nameReadable, nameCamel, description, destination, writer, files;
46
45
  return _regenerator["default"].wrap(function _callee$(_context) {
47
46
  while (1) {
48
47
  switch (_context.prev = _context.next) {
49
48
  case 0:
50
- return _context.abrupt("return", {});
51
- case 1:
49
+ _this$validateAndNorm = this.validateAndNormalizeOptions(options), nameKebab = _this$validateAndNorm.nameKebab, nameReadable = _this$validateAndNorm.nameReadable, nameCamel = _this$validateAndNorm.nameCamel, description = _this$validateAndNorm.description;
50
+ destination = _spruceSkillUtils.diskUtil.resolvePath(this.cwd, 'src', 'permissions');
51
+ writer = this.Writer('permission');
52
+ _context.next = 5;
53
+ return writer.writeContract(destination, {
54
+ nameKebab: nameKebab !== null && nameKebab !== void 0 ? nameKebab : _spruceSkillUtils.namesUtil.toKebab(nameReadable),
55
+ nameReadable: nameReadable,
56
+ nameCamel: nameCamel,
57
+ description: description
58
+ });
59
+ case 5:
60
+ files = _context.sent;
61
+ return _context.abrupt("return", {
62
+ files: files
63
+ });
64
+ case 7:
52
65
  case "end":
53
66
  return _context.stop();
54
67
  }
55
68
  }
56
- }, _callee);
69
+ }, _callee, this);
57
70
  }));
58
71
  function execute(_x) {
59
72
  return _execute.apply(this, arguments);
@@ -64,4 +77,17 @@ var CreateAction = /*#__PURE__*/function (_AbstractAction) {
64
77
  return CreateAction;
65
78
  }(_AbstractAction2["default"]);
66
79
  exports["default"] = CreateAction;
80
+ var schema = (0, _schema.buildSchema)({
81
+ id: 'createPermission',
82
+ fields: _objectSpread(_objectSpread({
83
+ nameReadable: _objectSpread(_objectSpread({}, _namedTemplateItem["default"].fields.nameReadable), {}, {
84
+ label: "Name your permission contract",
85
+ hint: "A contract contains many permissions grouped by a responsibility"
86
+ })
87
+ }, (0, _schema.pickFields)(_namedTemplateItem["default"].fields, ['nameCamel', 'nameKebab'])), {}, {
88
+ description: _objectSpread(_objectSpread({}, _namedTemplateItem["default"].fields.description), {}, {
89
+ label: "Describe this contract"
90
+ })
91
+ })
92
+ });
67
93
  //# sourceMappingURL=CreateAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CreateAction.js","names":["schema","buildSchema","id","fields","pickFields","namedTemplateItemSchema","CreateAction","_options","AbstractAction"],"sources":["../../../../src/features/permission/actions/CreateAction.ts"],"sourcesContent":["import { buildSchema, pickFields, SchemaValues } from '@sprucelabs/schema'\nimport namedTemplateItemSchema from '#spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema'\nimport AbstractAction from '../../AbstractAction'\nimport { FeatureActionResponse } from '../../features.types'\n\nconst schema = buildSchema({\n\tid: 'createPermission',\n\tfields: {\n\t\t...pickFields(namedTemplateItemSchema.fields, [\n\t\t\t'nameReadable',\n\t\t\t'nameKebab',\n\t\t]),\n\t},\n})\n\ntype OptionsSchema = typeof schema\ntype Options = SchemaValues<OptionsSchema>\n\nexport default class CreateAction extends AbstractAction<OptionsSchema> {\n\tpublic optionsSchema = schema\n\tpublic invocationMessage = 'Creating a permission contract... 🛡'\n\n\tpublic async execute(_options: Options): Promise<FeatureActionResponse> {\n\t\t// const { nameKebab, nameReadable } =\n\t\t// \tthis.validateAndNormalizeOptions(options)\n\n\t\treturn {}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAAiD;AAAA;AAAA;AAAA;AAGjD,IAAMA,MAAM,GAAG,IAAAC,mBAAW,EAAC;EAC1BC,EAAE,EAAE,kBAAkB;EACtBC,MAAM,oBACF,IAAAC,kBAAU,EAACC,6BAAuB,CAACF,MAAM,EAAE,CAC7C,cAAc,EACd,WAAW,CACX,CAAC;AAEJ,CAAC,CAAC;AAAA,IAKmBG,YAAY;EAAA;EAAA;EAAA;IAAA;IAAA;IAAA;MAAA;IAAA;IAAA;IAAA,kGACTN,MAAM;IAAA,sGACF,sCAAsC;IAAA;EAAA;EAAA;IAAA;IAAA;MAAA,6FAEjE,iBAAqBO,QAAiB;QAAA;UAAA;YAAA;cAAA;gBAAA,iCAI9B,CAAC,CAAC;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,CACT;MAAA;QAAA;MAAA;MAAA;IAAA;EAAA;EAAA;AAAA,EATwCC,2BAAc;AAAA"}
1
+ {"version":3,"file":"CreateAction.js","names":["CreateAction","schema","options","validateAndNormalizeOptions","nameKebab","nameReadable","nameCamel","description","destination","diskUtil","resolvePath","cwd","writer","Writer","writeContract","namesUtil","toKebab","files","AbstractAction","buildSchema","id","fields","namedTemplateItemSchema","label","hint","pickFields"],"sources":["../../../../src/features/permission/actions/CreateAction.ts"],"sourcesContent":["import { buildSchema, pickFields, SchemaValues } from '@sprucelabs/schema'\nimport { diskUtil, namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport namedTemplateItemSchema from '#spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema'\nimport AbstractAction from '../../AbstractAction'\nimport { FeatureActionResponse } from '../../features.types'\n\nexport default class CreateAction extends AbstractAction<OptionsSchema> {\n\tpublic optionsSchema = schema\n\tpublic invocationMessage = 'Creating a permission contract... 🛡'\n\tpublic readonly commandAliases: string[] = [\n\t\t'create.permissions',\n\t\t'create.permission',\n\t]\n\n\tpublic async execute(options: Options): Promise<FeatureActionResponse> {\n\t\tconst { nameKebab, nameReadable, nameCamel, description } =\n\t\t\tthis.validateAndNormalizeOptions(options)\n\n\t\tconst destination = diskUtil.resolvePath(this.cwd, 'src', 'permissions')\n\n\t\tconst writer = this.Writer('permission')\n\t\tconst files = await writer.writeContract(destination, {\n\t\t\tnameKebab: nameKebab ?? namesUtil.toKebab(nameReadable),\n\t\t\tnameReadable,\n\t\t\tnameCamel,\n\t\t\tdescription,\n\t\t})\n\n\t\treturn {\n\t\t\tfiles,\n\t\t}\n\t}\n}\n\nconst schema = buildSchema({\n\tid: 'createPermission',\n\tfields: {\n\t\tnameReadable: {\n\t\t\t...namedTemplateItemSchema.fields.nameReadable,\n\t\t\tlabel: `Name your permission contract`,\n\t\t\thint: `A contract contains many permissions grouped by a responsibility`,\n\t\t},\n\t\t...pickFields(namedTemplateItemSchema.fields, ['nameCamel', 'nameKebab']),\n\t\tdescription: {\n\t\t\t...namedTemplateItemSchema.fields.description,\n\t\t\tlabel: `Describe this contract`,\n\t\t},\n\t},\n})\n\ntype OptionsSchema = typeof schema\ntype Options = SchemaValues<OptionsSchema>\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AAAiD;AAAA;AAAA;AAAA;AAAA,IAG5BA,YAAY;EAAA;EAAA;EAAA;IAAA;IAAA;IAAA;MAAA;IAAA;IAAA;IAAA,kGACTC,MAAM;IAAA,sGACF,sCAAsC;IAAA,mGACtB,CAC1C,oBAAoB,EACpB,mBAAmB,CACnB;IAAA;EAAA;EAAA;IAAA;IAAA;MAAA,6FAED,iBAAqBC,OAAgB;QAAA;QAAA;UAAA;YAAA;cAAA;gBAAA,wBAEnC,IAAI,CAACC,2BAA2B,CAACD,OAAO,CAAC,EADlCE,SAAS,yBAATA,SAAS,EAAEC,YAAY,yBAAZA,YAAY,EAAEC,SAAS,yBAATA,SAAS,EAAEC,WAAW,yBAAXA,WAAW;gBAGjDC,WAAW,GAAGC,0BAAQ,CAACC,WAAW,CAAC,IAAI,CAACC,GAAG,EAAE,KAAK,EAAE,aAAa,CAAC;gBAElEC,MAAM,GAAG,IAAI,CAACC,MAAM,CAAC,YAAY,CAAC;gBAAA;gBAAA,OACpBD,MAAM,CAACE,aAAa,CAACN,WAAW,EAAE;kBACrDJ,SAAS,EAAEA,SAAS,aAATA,SAAS,cAATA,SAAS,GAAIW,2BAAS,CAACC,OAAO,CAACX,YAAY,CAAC;kBACvDA,YAAY,EAAZA,YAAY;kBACZC,SAAS,EAATA,SAAS;kBACTC,WAAW,EAAXA;gBACD,CAAC,CAAC;cAAA;gBALIU,KAAK;gBAAA,iCAOJ;kBACNA,KAAK,EAALA;gBACD,CAAC;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,CACD;MAAA;QAAA;MAAA;MAAA;IAAA;EAAA;EAAA;AAAA,EAzBwCC,2BAAc;AAAA;AA4BxD,IAAMjB,MAAM,GAAG,IAAAkB,mBAAW,EAAC;EAC1BC,EAAE,EAAE,kBAAkB;EACtBC,MAAM;IACLhB,YAAY,kCACRiB,6BAAuB,CAACD,MAAM,CAAChB,YAAY;MAC9CkB,KAAK,iCAAiC;MACtCC,IAAI;IAAoE;EACxE,GACE,IAAAC,kBAAU,EAACH,6BAAuB,CAACD,MAAM,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACzEd,WAAW,kCACPe,6BAAuB,CAACD,MAAM,CAACd,WAAW;MAC7CgB,KAAK;IAA0B;EAC/B;AAEH,CAAC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import AbstractAction from '../../AbstractAction';
2
+ import { FeatureActionResponse } from '../../features.types';
3
+ export default class SyncAction extends AbstractAction<OptionsSchema> {
4
+ invocationMessage: string;
5
+ optionsSchema: {
6
+ id: string;
7
+ fields: {};
8
+ };
9
+ execute(): Promise<FeatureActionResponse>;
10
+ }
11
+ declare const schema: {
12
+ id: string;
13
+ fields: {};
14
+ };
15
+ declare type OptionsSchema = typeof schema;
16
+ export {};
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
13
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
15
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
+ var _schema = require("@sprucelabs/schema");
18
+ var _AbstractAction2 = _interopRequireDefault(require("../../AbstractAction"));
19
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
20
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
21
+ var SyncAction = /*#__PURE__*/function (_AbstractAction) {
22
+ (0, _inherits2["default"])(SyncAction, _AbstractAction);
23
+ var _super = _createSuper(SyncAction);
24
+ function SyncAction() {
25
+ var _this;
26
+ (0, _classCallCheck2["default"])(this, SyncAction);
27
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28
+ args[_key] = arguments[_key];
29
+ }
30
+ _this = _super.call.apply(_super, [this].concat(args));
31
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "invocationMessage", 'Syncing permissions... 🛡');
32
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "optionsSchema", schema);
33
+ return _this;
34
+ }
35
+ (0, _createClass2["default"])(SyncAction, [{
36
+ key: "execute",
37
+ value: function () {
38
+ var _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
39
+ var files;
40
+ return _regenerator["default"].wrap(function _callee$(_context) {
41
+ while (1) {
42
+ switch (_context.prev = _context.next) {
43
+ case 0:
44
+ _context.next = 2;
45
+ return this.Writer('permission').writeTypesFile(this.cwd);
46
+ case 2:
47
+ files = _context.sent;
48
+ return _context.abrupt("return", {
49
+ files: files
50
+ });
51
+ case 4:
52
+ case "end":
53
+ return _context.stop();
54
+ }
55
+ }
56
+ }, _callee, this);
57
+ }));
58
+ function execute() {
59
+ return _execute.apply(this, arguments);
60
+ }
61
+ return execute;
62
+ }()
63
+ }]);
64
+ return SyncAction;
65
+ }(_AbstractAction2["default"]);
66
+ exports["default"] = SyncAction;
67
+ var schema = (0, _schema.buildSchema)({
68
+ id: 'syncPermissions',
69
+ fields: {}
70
+ });
71
+ //# sourceMappingURL=SyncAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SyncAction.js","names":["SyncAction","schema","Writer","writeTypesFile","cwd","files","AbstractAction","buildSchema","id","fields"],"sources":["../../../../src/features/permission/actions/SyncAction.ts"],"sourcesContent":["import { buildSchema } from '@sprucelabs/schema'\nimport AbstractAction from '../../AbstractAction'\nimport { FeatureActionResponse } from '../../features.types'\n\nexport default class SyncAction extends AbstractAction<OptionsSchema> {\n\tpublic invocationMessage = 'Syncing permissions... 🛡'\n\tpublic optionsSchema = schema\n\n\tpublic async execute(): Promise<FeatureActionResponse> {\n\t\tconst files = await this.Writer('permission').writeTypesFile(this.cwd)\n\n\t\treturn {\n\t\t\tfiles,\n\t\t}\n\t}\n}\n\nconst schema = buildSchema({\n\tid: 'syncPermissions',\n\tfields: {},\n})\n\ntype OptionsSchema = typeof schema\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AAAiD;AAAA;AAAA,IAG5BA,UAAU;EAAA;EAAA;EAAA;IAAA;IAAA;IAAA;MAAA;IAAA;IAAA;IAAA,sGACH,2BAA2B;IAAA,kGAC/BC,MAAM;IAAA;EAAA;EAAA;IAAA;IAAA;MAAA,6FAE7B;QAAA;QAAA;UAAA;YAAA;cAAA;gBAAA;gBAAA,OACqB,IAAI,CAACC,MAAM,CAAC,YAAY,CAAC,CAACC,cAAc,CAAC,IAAI,CAACC,GAAG,CAAC;cAAA;gBAAhEC,KAAK;gBAAA,iCAEJ;kBACNA,KAAK,EAALA;gBACD,CAAC;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,CACD;MAAA;QAAA;MAAA;MAAA;IAAA;EAAA;EAAA;AAAA,EAVsCC,2BAAc;AAAA;AAatD,IAAML,MAAM,GAAG,IAAAM,mBAAW,EAAC;EAC1BC,EAAE,EAAE,iBAAiB;EACrBC,MAAM,EAAE,CAAC;AACV,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { PermissionContractMap } from '@sprucelabs/mercury-types';
2
+ import AbstractStore from '../../../stores/AbstractStore';
3
+ export default class PermissionStore extends AbstractStore {
4
+ name: string;
5
+ private loadLocalPermissions;
6
+ fetchContracts(): Promise<PermissionContractMap>;
7
+ }