@sprucelabs/spruce-cli 18.3.0 → 18.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/build/__tests__/behavioral/eventContract/PullingMercuryEventContract.test.js +2 -14
- package/build/__tests__/behavioral/eventContract/PullingMercuryEventContract.test.js.map +1 -1
- package/build/__tests__/behavioral/events/EventWriter.test.d.ts +4 -0
- package/build/__tests__/behavioral/events/EventWriter.test.js +116 -0
- package/build/__tests__/behavioral/events/EventWriter.test.js.map +1 -0
- package/build/__tests__/behavioral/{ListeningToCoreEvents.test.d.ts → events/ListeningToCoreEvents.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{ListeningToCoreEvents.test.js → events/ListeningToCoreEvents.test.js} +1 -1
- package/build/__tests__/behavioral/events/ListeningToCoreEvents.test.js.map +1 -0
- package/build/__tests__/behavioral/{RegisteringEventsOnBoot.test.d.ts → events/RegisteringEventsOnBoot.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{RegisteringEventsOnBoot.test.js → events/RegisteringEventsOnBoot.test.js} +2 -2
- package/build/__tests__/behavioral/events/RegisteringEventsOnBoot.test.js.map +1 -0
- package/build/__tests__/behavioral/{RegisteringGlobalEvents.test.d.ts → events/RegisteringGlobalEvents.test.d.ts} +2 -3
- package/build/__tests__/behavioral/{RegisteringGlobalEvents.test.js → events/RegisteringGlobalEvents.test.js} +45 -70
- package/build/__tests__/behavioral/events/RegisteringGlobalEvents.test.js.map +1 -0
- package/build/__tests__/behavioral/{SyncingEventsOnlyFromDependencies.test.d.ts → events/SyncingEventsOnlyFromDependencies.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{SyncingEventsOnlyFromDependencies.test.js → events/SyncingEventsOnlyFromDependencies.test.js} +1 -1
- package/build/__tests__/behavioral/events/SyncingEventsOnlyFromDependencies.test.js.map +1 -0
- package/build/__tests__/behavioral/permissions/PermissionStore.test.js +1 -0
- package/build/__tests__/behavioral/permissions/PermissionStore.test.js.map +1 -1
- package/build/__tests__/behavioral/permissions/PermissionWriter.test.js +1 -1
- package/build/__tests__/behavioral/permissions/PermissionWriter.test.js.map +1 -1
- package/build/__tests__/behavioral/permissions/SyncingPermissions.test.d.ts +1 -0
- package/build/__tests__/behavioral/permissions/SyncingPermissions.test.js +53 -18
- package/build/__tests__/behavioral/permissions/SyncingPermissions.test.js.map +1 -1
- package/build/__tests__/behavioral/{CreatingSchemasWithGenerics.test.d.ts → schemas/CreatingSchemasWithGenerics.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{CreatingSchemasWithGenerics.test.js → schemas/CreatingSchemasWithGenerics.test.js} +2 -2
- package/build/__tests__/behavioral/schemas/CreatingSchemasWithGenerics.test.js.map +1 -0
- package/build/__tests__/behavioral/{SettingUpSchemasForModuleDistribution.test.d.ts → schemas/SettingUpSchemasForModuleDistribution.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{SettingUpSchemasForModuleDistribution.test.js → schemas/SettingUpSchemasForModuleDistribution.test.js} +3 -3
- package/build/__tests__/behavioral/schemas/SettingUpSchemasForModuleDistribution.test.js.map +1 -0
- package/build/__tests__/behavioral/{InstallingASkillAtAnOrg.test.d.ts → skill/InstallingASkillAtAnOrg.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{InstallingASkillAtAnOrg.test.js → skill/InstallingASkillAtAnOrg.test.js} +2 -2
- package/build/__tests__/behavioral/skill/InstallingASkillAtAnOrg.test.js.map +1 -0
- package/build/__tests__/behavioral/{LoggingInAsASkill.test.d.ts → skill/LoggingInAsASkill.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{LoggingInAsASkill.test.js → skill/LoggingInAsASkill.test.js} +2 -2
- package/build/__tests__/behavioral/skill/LoggingInAsASkill.test.js.map +1 -0
- package/build/__tests__/behavioral/{RebuildingASkill.test.d.ts → skill/RebuildingASkill.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{RebuildingASkill.test.js → skill/RebuildingASkill.test.js} +2 -2
- package/build/__tests__/behavioral/skill/RebuildingASkill.test.js.map +1 -0
- package/build/__tests__/behavioral/{SettingUpASkillForTesting.test.d.ts → tests/SettingUpASkillForTesting.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{SettingUpASkillForTesting.test.js → tests/SettingUpASkillForTesting.test.js} +2 -2
- package/build/__tests__/behavioral/tests/SettingUpASkillForTesting.test.js.map +1 -0
- package/build/__tests__/behavioral/{TestReporterSettingsRemembered.test.d.ts → tests/TestReporterSettingsRemembered.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{TestReporterSettingsRemembered.test.js → tests/TestReporterSettingsRemembered.test.js} +1 -1
- package/build/__tests__/behavioral/tests/TestReporterSettingsRemembered.test.js.map +1 -0
- package/build/__tests__/behavioral/{TestingDataStores.test.d.ts → tests/TestingDataStores.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{TestingDataStores.test.js → tests/TestingDataStores.test.js} +3 -3
- package/build/__tests__/behavioral/tests/TestingDataStores.test.js.map +1 -0
- package/build/__tests__/behavioral/{RegisteringSkillViewOnBoot.test.d.ts → views/RegisteringSkillViewOnBoot.test.d.ts} +4 -4
- package/build/__tests__/behavioral/{RegisteringSkillViewOnBoot.test.js → views/RegisteringSkillViewOnBoot.test.js} +2 -2
- package/build/__tests__/behavioral/views/RegisteringSkillViewOnBoot.test.js.map +1 -0
- package/build/__tests__/behavioral/{WatchingSkillViews.test.d.ts → views/WatchingSkillViews.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{WatchingSkillViews.test.js → views/WatchingSkillViews.test.js} +3 -3
- package/build/__tests__/behavioral/views/WatchingSkillViews.test.js.map +1 -0
- package/build/__tests__/support/EventFaker.d.ts +1 -1
- package/build/__tests__/support/EventFaker.js.map +1 -1
- package/build/features/eventContract/EventContractFeature.js +1 -4
- package/build/features/eventContract/EventContractFeature.js.map +1 -1
- package/build/features/eventContract/actions/PullAction.d.ts +1 -0
- package/build/features/eventContract/actions/PullAction.js +49 -8
- package/build/features/eventContract/actions/PullAction.js.map +1 -1
- package/build/features/permission/PermissionFeature.js +20 -12
- package/build/features/permission/PermissionFeature.js.map +1 -1
- package/build/features/permission/actions/SyncAction.d.ts +22 -3
- package/build/features/permission/actions/SyncAction.js +58 -16
- package/build/features/permission/actions/SyncAction.js.map +1 -1
- package/build/features/permission/stores/PermissionStore.d.ts +6 -2
- package/build/features/permission/stores/PermissionStore.js +25 -21
- package/build/features/permission/stores/PermissionStore.js.map +1 -1
- package/build/features/permission/writers/PermissionWriter.d.ts +1 -1
- package/build/features/permission/writers/PermissionWriter.js +2 -2
- package/build/features/permission/writers/PermissionWriter.js.map +1 -1
- package/build/features/view/actions/WatchAction.js +1 -1
- package/build/features/view/actions/WatchAction.js.map +1 -1
- package/node_modules/@typescript-eslint/parser/README.md +6 -300
- package/node_modules/@typescript-eslint/parser/dist/parser.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/parser/dist/parser.js +15 -17
- package/node_modules/@typescript-eslint/parser/dist/parser.js.map +1 -1
- package/node_modules/@typescript-eslint/parser/package.json +5 -5
- package/node_modules/@typescript-eslint/scope-manager/README.md +5 -117
- package/node_modules/@typescript-eslint/scope-manager/package.json +5 -5
- package/node_modules/@typescript-eslint/types/README.md +6 -11
- package/node_modules/@typescript-eslint/types/package.json +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/README.md +6 -379
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/create-program/{createWatchProgram.d.ts → getWatchProgramsForProjects.d.ts} +3 -4
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/index.d.ts +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createProjectProgram.js +3 -3
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createProjectProgram.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/{createWatchProgram.d.ts → getWatchProgramsForProjects.d.ts} +3 -4
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/getWatchProgramsForProjects.d.ts.map +1 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/{createWatchProgram.js → getWatchProgramsForProjects.js} +4 -5
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/getWatchProgramsForProjects.js.map +1 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/index.d.ts +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/index.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/index.js +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/dist/index.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.js +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/package.json +5 -5
- package/node_modules/@typescript-eslint/visitor-keys/README.md +6 -9
- package/node_modules/@typescript-eslint/visitor-keys/package.json +3 -3
- package/package.json +22 -22
- package/src/__tests__/behavioral/eventContract/PullingMercuryEventContract.test.ts +0 -5
- package/src/__tests__/behavioral/events/EventWriter.test.ts +75 -0
- package/src/__tests__/behavioral/{ListeningToCoreEvents.test.ts → events/ListeningToCoreEvents.test.ts} +1 -1
- package/src/__tests__/behavioral/{RegisteringEventsOnBoot.test.ts → events/RegisteringEventsOnBoot.test.ts} +2 -2
- package/src/__tests__/behavioral/{RegisteringGlobalEvents.test.ts → events/RegisteringGlobalEvents.test.ts} +4 -12
- package/src/__tests__/behavioral/{SyncingEventsOnlyFromDependencies.test.ts → events/SyncingEventsOnlyFromDependencies.test.ts} +2 -2
- package/src/__tests__/behavioral/permissions/PermissionStore.test.ts +2 -1
- package/src/__tests__/behavioral/permissions/PermissionWriter.test.ts +1 -0
- package/src/__tests__/behavioral/permissions/SyncingPermissions.test.ts +21 -3
- package/src/__tests__/behavioral/{CreatingSchemasWithGenerics.test.ts → schemas/CreatingSchemasWithGenerics.test.ts} +2 -2
- package/src/__tests__/behavioral/{SettingUpSchemasForModuleDistribution.test.ts → schemas/SettingUpSchemasForModuleDistribution.test.ts} +4 -4
- package/src/__tests__/behavioral/{InstallingASkillAtAnOrg.test.ts → skill/InstallingASkillAtAnOrg.test.ts} +2 -2
- package/src/__tests__/behavioral/{LoggingInAsASkill.test.ts → skill/LoggingInAsASkill.test.ts} +3 -3
- package/src/__tests__/behavioral/{RebuildingASkill.test.ts → skill/RebuildingASkill.test.ts} +2 -2
- package/src/__tests__/behavioral/{SettingUpASkillForTesting.test.ts → tests/SettingUpASkillForTesting.test.ts} +2 -2
- package/src/__tests__/behavioral/{TestReporterSettingsRemembered.test.ts → tests/TestReporterSettingsRemembered.test.ts} +2 -2
- package/src/__tests__/behavioral/{TestingDataStores.test.ts → tests/TestingDataStores.test.ts} +3 -3
- package/src/__tests__/behavioral/{RegisteringSkillViewOnBoot.test.ts → views/RegisteringSkillViewOnBoot.test.ts} +2 -2
- package/src/__tests__/behavioral/{WatchingSkillViews.test.ts → views/WatchingSkillViews.test.ts} +4 -4
- package/src/__tests__/support/EventFaker.ts +1 -2
- package/src/features/eventContract/EventContractFeature.ts +1 -6
- package/src/features/eventContract/actions/PullAction.ts +21 -3
- package/src/features/permission/PermissionFeature.ts +7 -10
- package/src/features/permission/actions/SyncAction.ts +42 -5
- package/src/features/permission/stores/PermissionStore.ts +26 -12
- package/src/features/permission/writers/PermissionWriter.ts +2 -5
- package/src/features/view/actions/WatchAction.ts +1 -1
- package/build/__tests__/behavioral/CreatingSchemasWithGenerics.test.js.map +0 -1
- package/build/__tests__/behavioral/InstallingASkillAtAnOrg.test.js.map +0 -1
- package/build/__tests__/behavioral/ListeningToCoreEvents.test.js.map +0 -1
- package/build/__tests__/behavioral/LoggingInAsASkill.test.js.map +0 -1
- package/build/__tests__/behavioral/RebuildingASkill.test.js.map +0 -1
- package/build/__tests__/behavioral/RegisteringEventsOnBoot.test.js.map +0 -1
- package/build/__tests__/behavioral/RegisteringGlobalEvents.test.js.map +0 -1
- package/build/__tests__/behavioral/RegisteringSkillViewOnBoot.test.js.map +0 -1
- package/build/__tests__/behavioral/SettingUpASkillForTesting.test.js.map +0 -1
- package/build/__tests__/behavioral/SettingUpSchemasForModuleDistribution.test.js.map +0 -1
- package/build/__tests__/behavioral/SyncingEventsOnlyFromDependencies.test.js.map +0 -1
- package/build/__tests__/behavioral/TestReporterSettingsRemembered.test.js.map +0 -1
- package/build/__tests__/behavioral/TestingDataStores.test.js.map +0 -1
- package/build/__tests__/behavioral/WatchingSkillViews.test.js.map +0 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.d.ts.map +0 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/visitor-keys",
|
|
3
|
-
"version": "5.45.
|
|
3
|
+
"version": "5.45.1",
|
|
4
4
|
"description": "Visitor keys used to help traverse the TypeScript-ESTree AST",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@typescript-eslint/types": "5.45.
|
|
42
|
+
"@typescript-eslint/types": "5.45.1",
|
|
43
43
|
"eslint-visitor-keys": "^3.3.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
]
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "2d0a88314dc6c4ea2c786135735fd83517945acd"
|
|
60
60
|
}
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
|
-
"version": "18.
|
|
21
|
+
"version": "18.4.0",
|
|
22
22
|
"bin": {
|
|
23
23
|
"spruce": "./build/index.js"
|
|
24
24
|
},
|
|
@@ -76,17 +76,17 @@
|
|
|
76
76
|
"@babel/plugin-proposal-decorators": "^7.20.5",
|
|
77
77
|
"@babel/runtime": "^7.20.6",
|
|
78
78
|
"@jest/reporters": "^29.3.1",
|
|
79
|
-
"@sprucelabs/error": "^5.0.
|
|
80
|
-
"@sprucelabs/heartwood-view-controllers": "^
|
|
81
|
-
"@sprucelabs/jest-json-reporter": "^6.0.
|
|
82
|
-
"@sprucelabs/mercury-client": "^
|
|
83
|
-
"@sprucelabs/mercury-event-emitter": "^
|
|
84
|
-
"@sprucelabs/mercury-types": "^
|
|
85
|
-
"@sprucelabs/schema": "^28.5.
|
|
86
|
-
"@sprucelabs/spruce-core-schemas": "^35.1.
|
|
87
|
-
"@sprucelabs/spruce-event-utils": "^
|
|
88
|
-
"@sprucelabs/spruce-skill-utils": "^28.1.
|
|
89
|
-
"@sprucelabs/spruce-templates": "^18.
|
|
79
|
+
"@sprucelabs/error": "^5.0.547",
|
|
80
|
+
"@sprucelabs/heartwood-view-controllers": "^99.0.1",
|
|
81
|
+
"@sprucelabs/jest-json-reporter": "^6.0.526",
|
|
82
|
+
"@sprucelabs/mercury-client": "^35.0.0",
|
|
83
|
+
"@sprucelabs/mercury-event-emitter": "^35.0.0",
|
|
84
|
+
"@sprucelabs/mercury-types": "^38.0.0",
|
|
85
|
+
"@sprucelabs/schema": "^28.5.74",
|
|
86
|
+
"@sprucelabs/spruce-core-schemas": "^35.1.70",
|
|
87
|
+
"@sprucelabs/spruce-event-utils": "^30.0.0",
|
|
88
|
+
"@sprucelabs/spruce-skill-utils": "^28.1.3",
|
|
89
|
+
"@sprucelabs/spruce-templates": "^18.4.0",
|
|
90
90
|
"@typescript-eslint/eslint-plugin": "^5.27.1",
|
|
91
91
|
"@typescript-eslint/parser": "^5.27.1",
|
|
92
92
|
"cfonts": "^3.1.1",
|
|
@@ -114,16 +114,16 @@
|
|
|
114
114
|
"uuid": "^9.0.0"
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
|
-
"@sprucelabs/data-stores": "^19.0.
|
|
117
|
+
"@sprucelabs/data-stores": "^19.0.62",
|
|
118
118
|
"@sprucelabs/jest-sheets-reporter": "^2.0.21",
|
|
119
|
-
"@sprucelabs/mercury-core-events": "^15.0.
|
|
120
|
-
"@sprucelabs/resolve-path-aliases": "^1.1.
|
|
121
|
-
"@sprucelabs/spruce-conversation-plugin": "^52.3.
|
|
122
|
-
"@sprucelabs/spruce-deploy-plugin": "^52.3.
|
|
123
|
-
"@sprucelabs/spruce-store-plugin": "^52.3.
|
|
124
|
-
"@sprucelabs/spruce-test-fixtures": "^52.3.
|
|
125
|
-
"@sprucelabs/test": "^7.7.
|
|
126
|
-
"@sprucelabs/test-utils": "^3.2.
|
|
119
|
+
"@sprucelabs/mercury-core-events": "^15.0.106",
|
|
120
|
+
"@sprucelabs/resolve-path-aliases": "^1.1.138",
|
|
121
|
+
"@sprucelabs/spruce-conversation-plugin": "^52.3.4",
|
|
122
|
+
"@sprucelabs/spruce-deploy-plugin": "^52.3.4",
|
|
123
|
+
"@sprucelabs/spruce-store-plugin": "^52.3.4",
|
|
124
|
+
"@sprucelabs/spruce-test-fixtures": "^52.3.4",
|
|
125
|
+
"@sprucelabs/test": "^7.7.392",
|
|
126
|
+
"@sprucelabs/test-utils": "^3.2.62",
|
|
127
127
|
"@types/blessed": "^0.1.19",
|
|
128
128
|
"@types/eslint": "^8.4.10",
|
|
129
129
|
"@types/fs-extra": "^9.0.13",
|
|
@@ -595,5 +595,5 @@
|
|
|
595
595
|
"terminal-kit"
|
|
596
596
|
]
|
|
597
597
|
},
|
|
598
|
-
"gitHead": "
|
|
598
|
+
"gitHead": "da522d85b8178d456ecda58e41b9b4a7067b9437"
|
|
599
599
|
}
|
|
@@ -116,11 +116,6 @@ export default class GeneratingMercuryEventContractTest extends AbstractCliTest
|
|
|
116
116
|
shouldAutoHandleDependencies: true,
|
|
117
117
|
}).execute({})
|
|
118
118
|
|
|
119
|
-
await this.waitForInput()
|
|
120
|
-
await this.ui.sendInput('Y')
|
|
121
|
-
await this.waitForInput()
|
|
122
|
-
await this.ui.sendInput('\n')
|
|
123
|
-
|
|
124
119
|
const results = await promise
|
|
125
120
|
|
|
126
121
|
const match = testUtil.assertFileByNameInGeneratedFiles(
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { namesUtil, versionUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
|
+
import { EventSignatureTemplateItem } from '@sprucelabs/spruce-templates'
|
|
3
|
+
import { test, assert, generateId } from '@sprucelabs/test-utils'
|
|
4
|
+
import AbstractCliTest from '../../../tests/AbstractCliTest'
|
|
5
|
+
|
|
6
|
+
export default class EventWriterTest extends AbstractCliTest {
|
|
7
|
+
@test()
|
|
8
|
+
protected static async canCreateEventWriter() {
|
|
9
|
+
await this.FeatureFixture().installCachedFeatures('events')
|
|
10
|
+
const writer = this.writers.Writer('event', { fileDescriptions: [] })
|
|
11
|
+
const name = 'My event'
|
|
12
|
+
const namespace = 'appointments'
|
|
13
|
+
|
|
14
|
+
const contractId1 = generateId() as any
|
|
15
|
+
const contractId2 = generateId() as any
|
|
16
|
+
const permissionId1 = generateId() as any
|
|
17
|
+
const permissionId2 = generateId() as any
|
|
18
|
+
|
|
19
|
+
const sig: EventSignatureTemplateItem = {
|
|
20
|
+
isGlobal: true,
|
|
21
|
+
emitPermissions: {
|
|
22
|
+
contractId: contractId1,
|
|
23
|
+
permissionIdsAny: [permissionId1],
|
|
24
|
+
},
|
|
25
|
+
listenPermissions: {
|
|
26
|
+
contractId: contractId2,
|
|
27
|
+
permissionIdsAny: [permissionId2],
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const permWriter = this.writers.Writer('permission', {
|
|
32
|
+
fileDescriptions: [],
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
//@ts-ignore
|
|
36
|
+
await permWriter.writeTypesFile(this.cwd, {
|
|
37
|
+
[contractId1]: [permissionId1],
|
|
38
|
+
[contractId2]: [permissionId2],
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const results = await writer.writeContracts(
|
|
42
|
+
this.resolveHashSprucePath('events'),
|
|
43
|
+
{
|
|
44
|
+
eventBuilderFile: '@sprucelabs/mercury-types',
|
|
45
|
+
schemaTemplateItems: [],
|
|
46
|
+
shouldImportCoreEvents: false,
|
|
47
|
+
skillEventContractTypesFile: '',
|
|
48
|
+
eventContractTemplateItems: [
|
|
49
|
+
{
|
|
50
|
+
imports: [
|
|
51
|
+
{
|
|
52
|
+
importAs: '{ buildEventContract }',
|
|
53
|
+
package: '@sprucelabs/mercury-types',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
isLocal: true,
|
|
57
|
+
nameCamel: namesUtil.toCamel(name),
|
|
58
|
+
namePascal: namesUtil.toPascal(name),
|
|
59
|
+
namespace,
|
|
60
|
+
namespaceCamel: namesUtil.toCamel(namespace),
|
|
61
|
+
namespacePascal: namesUtil.toPascal(namespace),
|
|
62
|
+
version: versionUtil.generateVersion().constValue,
|
|
63
|
+
eventSignatures: {
|
|
64
|
+
test: sig,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
const match = results[0]
|
|
72
|
+
const imported = await this.Service('import').importDefault(match.path)
|
|
73
|
+
assert.isEqualDeep(imported.eventSignatures.test, sig)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
|
-
import AbstractSkillTest from '
|
|
2
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
3
3
|
|
|
4
4
|
export default class ListeningToCoreEventsTest extends AbstractSkillTest {
|
|
5
5
|
protected static skillCacheKey = 'events'
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
} from '@sprucelabs/spruce-event-utils'
|
|
5
5
|
import { namesUtil, versionUtil } from '@sprucelabs/spruce-skill-utils'
|
|
6
6
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
7
|
-
import AbstractEventTest from '
|
|
8
|
-
import { DEMO_NUMBER_EVENTS_ON_BOOT } from '
|
|
7
|
+
import AbstractEventTest from '../../../tests/AbstractEventTest'
|
|
8
|
+
import { DEMO_NUMBER_EVENTS_ON_BOOT } from '../../../tests/constants'
|
|
9
9
|
|
|
10
10
|
const EVENT_NAME_READABLE = 'did book appointment'
|
|
11
11
|
const EVENT_NAME = 'did-book-appointment'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { versionUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
2
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
3
3
|
import dotenv from 'dotenv'
|
|
4
|
-
import AbstractSkillTest from '
|
|
5
|
-
import { DEMO_NUMBER_GLOBAL_EVENTS } from '
|
|
6
|
-
import testUtil from '
|
|
7
|
-
import { RegisteredSkill } from '
|
|
4
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
5
|
+
import { DEMO_NUMBER_GLOBAL_EVENTS } from '../../../tests/constants'
|
|
6
|
+
import testUtil from '../../../tests/utilities/test.utility'
|
|
7
|
+
import { RegisteredSkill } from '../../../types/cli.types'
|
|
8
8
|
dotenv.config()
|
|
9
9
|
|
|
10
10
|
const stamp = new Date().getTime()
|
|
@@ -21,8 +21,6 @@ export default class RegisteringGlobalEventsTest extends AbstractSkillTest {
|
|
|
21
21
|
|
|
22
22
|
await this.people.loginAsDemoPerson(DEMO_NUMBER_GLOBAL_EVENTS)
|
|
23
23
|
|
|
24
|
-
await this.resetAccount()
|
|
25
|
-
|
|
26
24
|
const orgFixture = this.getOrganizationFixture()
|
|
27
25
|
const skillFixture = this.getSkillFixture()
|
|
28
26
|
|
|
@@ -37,12 +35,6 @@ export default class RegisteringGlobalEventsTest extends AbstractSkillTest {
|
|
|
37
35
|
|
|
38
36
|
protected static async afterAll() {
|
|
39
37
|
await super.afterAll()
|
|
40
|
-
await this.resetAccount()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private static async resetAccount() {
|
|
44
|
-
// await this.getOrganizationFixture().clearAllOrgs()
|
|
45
|
-
// await this.getSkillFixture().clearAllSkills()
|
|
46
38
|
}
|
|
47
39
|
|
|
48
40
|
@test()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { diskUtil, namesUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
2
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
3
3
|
import fsUtil from 'fs-extra'
|
|
4
|
-
import AbstractSkillTest from '
|
|
5
|
-
import { RegisteredSkill } from '
|
|
4
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
5
|
+
import { RegisteredSkill } from '../../../types/cli.types'
|
|
6
6
|
|
|
7
7
|
export default class SyncingEventsOnlyFromDependenciesTest extends AbstractSkillTest {
|
|
8
8
|
protected static skillCacheKey = 'events'
|
|
@@ -4,9 +4,9 @@ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
|
4
4
|
import { test, assert, generateId } from '@sprucelabs/test-utils'
|
|
5
5
|
import PermissionStore, {
|
|
6
6
|
ImportedPermission,
|
|
7
|
+
ListPermContractsTargetAndPayload,
|
|
7
8
|
} from '../../../features/permission/stores/PermissionStore'
|
|
8
9
|
import { ApiClientFactoryOptions } from '../../../types/apiClient.types'
|
|
9
|
-
import { ListPermContractsTargetAndPayload } from '../../support/EventFaker'
|
|
10
10
|
import AbstractPermissionsTest from './support/AbstractPermissionsTest'
|
|
11
11
|
import generateShortAlphaId from './support/generateShortAlphaId'
|
|
12
12
|
import { sortPermissionContracts } from './support/sortPermissionContracts'
|
|
@@ -143,6 +143,7 @@ export default class PermissionStoreTest extends AbstractPermissionsTest {
|
|
|
143
143
|
})
|
|
144
144
|
|
|
145
145
|
const map = await this.fetchContracts()
|
|
146
|
+
//@ts-ignore
|
|
146
147
|
assert.isEqualDeep(map, {
|
|
147
148
|
[contractId]: [perm.id, perm2.id],
|
|
148
149
|
[contractId2]: [perm3.id],
|
|
@@ -2,7 +2,10 @@ import { MercuryClientFactory } from '@sprucelabs/mercury-client'
|
|
|
2
2
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
3
3
|
import { assert, test } from '@sprucelabs/test-utils'
|
|
4
4
|
import ActionFactory from '../../../features/ActionFactory'
|
|
5
|
-
import SyncAction
|
|
5
|
+
import SyncAction, {
|
|
6
|
+
SyncPermissionsOptions,
|
|
7
|
+
} from '../../../features/permission/actions/SyncAction'
|
|
8
|
+
import { ListPermContractsTargetAndPayload } from '../../../features/permission/stores/PermissionStore'
|
|
6
9
|
import testUtil from '../../../tests/utilities/test.utility'
|
|
7
10
|
import AbstractPermissionsTest from './support/AbstractPermissionsTest'
|
|
8
11
|
import generateShortAlphaId from './support/generateShortAlphaId'
|
|
@@ -112,6 +115,21 @@ export default class SyncingPermissionsTest extends AbstractPermissionsTest {
|
|
|
112
115
|
)
|
|
113
116
|
}
|
|
114
117
|
|
|
118
|
+
@test()
|
|
119
|
+
protected static async canSyncCorePermissions() {
|
|
120
|
+
let wasHit = false
|
|
121
|
+
let passedTarget: ListPermContractsTargetAndPayload['target']
|
|
122
|
+
|
|
123
|
+
await this.eventFaker.fakeListPermissionContracts((targetAndPayload) => {
|
|
124
|
+
passedTarget = targetAndPayload.target
|
|
125
|
+
wasHit = true
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
await this.sync({ shouldSyncCorePermissions: true })
|
|
129
|
+
assert.isTrue(wasHit)
|
|
130
|
+
assert.isUndefined(passedTarget)
|
|
131
|
+
}
|
|
132
|
+
|
|
115
133
|
private static getCombinedPath() {
|
|
116
134
|
return this.resolveHashSprucePath('permissions', 'permissions.ts')
|
|
117
135
|
}
|
|
@@ -120,8 +138,8 @@ export default class SyncingPermissionsTest extends AbstractPermissionsTest {
|
|
|
120
138
|
ActionFactory.setActionClass('permission', 'sync', ExecuteTrackingAction)
|
|
121
139
|
}
|
|
122
140
|
|
|
123
|
-
private static async sync() {
|
|
124
|
-
return await this.syncAction.execute()
|
|
141
|
+
private static async sync(options?: SyncPermissionsOptions) {
|
|
142
|
+
return await this.syncAction.execute(options)
|
|
125
143
|
}
|
|
126
144
|
|
|
127
145
|
private static async emitDidExecuteUpgrade() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
2
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
3
|
-
import AbstractSchemaTest from '
|
|
4
|
-
import testUtil from '
|
|
3
|
+
import AbstractSchemaTest from '../../../tests/AbstractSchemaTest'
|
|
4
|
+
import testUtil from '../../../tests/utilities/test.utility'
|
|
5
5
|
|
|
6
6
|
export default class CreatingSchemasWithGenericsTest extends AbstractSchemaTest {
|
|
7
7
|
@test()
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
} from '@sprucelabs/spruce-skill-utils'
|
|
7
7
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
8
8
|
import { errorAssert } from '@sprucelabs/test-utils'
|
|
9
|
-
import { FeatureActionResponse } from '
|
|
10
|
-
import SchemaTemplateItemBuilder from '
|
|
11
|
-
import AbstractSkillTest from '
|
|
12
|
-
import testUtil from '
|
|
9
|
+
import { FeatureActionResponse } from '../../../features/features.types'
|
|
10
|
+
import SchemaTemplateItemBuilder from '../../../templateItemBuilders/SchemaTemplateItemBuilder'
|
|
11
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
12
|
+
import testUtil from '../../../tests/utilities/test.utility'
|
|
13
13
|
|
|
14
14
|
const LOCAL_NAMESPACE = 'TestingSchemas'
|
|
15
15
|
const REMOTE_NAMESPACE = 'RemoteSchemas'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { eventAssertUtil } from '@sprucelabs/spruce-event-utils'
|
|
2
2
|
import { test, assert, assertUtil } from '@sprucelabs/test-utils'
|
|
3
3
|
import { errorAssert } from '@sprucelabs/test-utils'
|
|
4
|
-
import AbstractCliTest from '
|
|
5
|
-
import { DEMO_NUMBER_INSTALL_SKILL } from '
|
|
4
|
+
import AbstractCliTest from '../../../tests/AbstractCliTest'
|
|
5
|
+
import { DEMO_NUMBER_INSTALL_SKILL } from '../../../tests/constants'
|
|
6
6
|
|
|
7
7
|
export default class InstallingASkillAtAnOrgTest extends AbstractCliTest {
|
|
8
8
|
protected static async beforeEach() {
|
package/src/__tests__/behavioral/{LoggingInAsASkill.test.ts → skill/LoggingInAsASkill.test.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
2
|
import { errorAssert } from '@sprucelabs/test-utils'
|
|
3
|
-
import AbstractSkillTest from '
|
|
4
|
-
import { DEMO_NUMBER_LOGIN_AS_SKILL } from '
|
|
5
|
-
import { RegisteredSkill } from '
|
|
3
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
4
|
+
import { DEMO_NUMBER_LOGIN_AS_SKILL } from '../../../tests/constants'
|
|
5
|
+
import { RegisteredSkill } from '../../../types/cli.types'
|
|
6
6
|
|
|
7
7
|
export default class LoggingInAsASkillTest extends AbstractSkillTest {
|
|
8
8
|
protected static skillCacheKey = 'skills'
|
package/src/__tests__/behavioral/{RebuildingASkill.test.ts → skill/RebuildingASkill.test.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
2
|
import { errorAssert } from '@sprucelabs/test-utils'
|
|
3
|
-
import CommandService from '
|
|
4
|
-
import AbstractSkillTest from '
|
|
3
|
+
import CommandService from '../../../services/CommandService'
|
|
4
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
5
5
|
|
|
6
6
|
export default class RebuildingASkillTest extends AbstractSkillTest {
|
|
7
7
|
protected static skillCacheKey = 'skills'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
|
-
import AbstractSkillTest from '
|
|
3
|
-
import { DEMO_NUMBER } from '
|
|
2
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
3
|
+
import { DEMO_NUMBER } from '../../../tests/constants'
|
|
4
4
|
|
|
5
5
|
export default class SettingUpASkillForTestingTest extends AbstractSkillTest {
|
|
6
6
|
protected static skillCacheKey = 'tests'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
|
-
import TestAction from '
|
|
3
|
-
import AbstractTestTest from '
|
|
2
|
+
import TestAction from '../../../features/test/actions/TestAction'
|
|
3
|
+
import AbstractTestTest from '../../../tests/AbstractTestTest'
|
|
4
4
|
|
|
5
5
|
export default class TestReporterSettingsRememberedTest extends AbstractTestTest {
|
|
6
6
|
@test()
|
package/src/__tests__/behavioral/{TestingDataStores.test.ts → tests/TestingDataStores.test.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
2
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
3
|
-
import LintService from '
|
|
4
|
-
import AbstractSkillTest from '
|
|
5
|
-
import testUtil from '
|
|
3
|
+
import LintService from '../../../services/LintService'
|
|
4
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
5
|
+
import testUtil from '../../../tests/utilities/test.utility'
|
|
6
6
|
|
|
7
7
|
export default class TestingDataStoresTest extends AbstractSkillTest {
|
|
8
8
|
protected static skillCacheKey = 'storesWithTests'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
|
-
import AbstractSkillTest from '
|
|
3
|
-
import { DEMO_NUMBER_VIEWS_ON_BOOT } from '
|
|
2
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
3
|
+
import { DEMO_NUMBER_VIEWS_ON_BOOT } from '../../../tests/constants'
|
|
4
4
|
|
|
5
5
|
export default class RegisteringSkillViewOnBootTest extends AbstractSkillTest {
|
|
6
6
|
protected static skillCacheKey = 'views'
|
package/src/__tests__/behavioral/{WatchingSkillViews.test.ts → views/WatchingSkillViews.test.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
|
-
import WatchAction from '
|
|
3
|
-
import CommandService from '
|
|
4
|
-
import AbstractSkillTest from '
|
|
2
|
+
import WatchAction from '../../../features/view/actions/WatchAction'
|
|
3
|
+
import CommandService from '../../../services/CommandService'
|
|
4
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
5
5
|
|
|
6
6
|
export default class WatchingSkillViewsTest extends AbstractSkillTest {
|
|
7
7
|
protected static skillCacheKey = 'views'
|
|
@@ -22,7 +22,7 @@ export default class WatchingSkillViewsTest extends AbstractSkillTest {
|
|
|
22
22
|
protected static async shouldCallBoot() {
|
|
23
23
|
let wasHit = false
|
|
24
24
|
CommandService.fakeCommand(
|
|
25
|
-
'
|
|
25
|
+
'SHOULD_WATCH_VIEWS=true MAXIMUM_LOG_PREFIXES_LENGTH=0 yarn boot',
|
|
26
26
|
{
|
|
27
27
|
code: 200,
|
|
28
28
|
callback: () => {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { SpruceSchemas } from '@sprucelabs/mercury-types'
|
|
2
2
|
import { eventFaker } from '@sprucelabs/spruce-test-fixtures'
|
|
3
|
+
import { ListPermContractsTargetAndPayload } from '../../features/permission/stores/PermissionStore'
|
|
3
4
|
|
|
4
|
-
export type ListPermContractsTargetAndPayload =
|
|
5
|
-
SpruceSchemas.Mercury.v2020_12_25.ListPermissionContractsEmitTargetAndPayload
|
|
6
5
|
export default class EventFaker {
|
|
7
6
|
public async fakeListPermissionContracts(
|
|
8
7
|
cb?: (
|
|
@@ -14,12 +14,7 @@ export default class EventContractFeature extends AbstractFeature {
|
|
|
14
14
|
public nameReadable = 'Event Contract'
|
|
15
15
|
public description =
|
|
16
16
|
'Pull core Mercury events down and write to single, portable, dependency-free, strongly typed contract.'
|
|
17
|
-
public dependencies: FeatureDependency[] = [
|
|
18
|
-
{
|
|
19
|
-
code: 'permission',
|
|
20
|
-
isRequired: true,
|
|
21
|
-
},
|
|
22
|
-
]
|
|
17
|
+
public dependencies: FeatureDependency[] = []
|
|
23
18
|
public packageDependencies = []
|
|
24
19
|
|
|
25
20
|
public actionsDir = diskUtil.resolvePath(__dirname, 'actions')
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { buildSchema, SchemaValues } from '@sprucelabs/schema'
|
|
2
2
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
3
|
-
import actionUtil from '../../../utilities/action.utility'
|
|
4
3
|
import AbstractAction from '../../AbstractAction'
|
|
5
4
|
import { FeatureActionResponse } from '../../features.types'
|
|
6
5
|
|
|
@@ -50,10 +49,11 @@ export type CoreEventContract = ${contracts
|
|
|
50
49
|
|
|
51
50
|
diskUtil.writeFile(destination, contents)
|
|
52
51
|
|
|
53
|
-
const
|
|
52
|
+
const typesFiles = await this.syncPermissions()
|
|
54
53
|
|
|
55
|
-
return
|
|
54
|
+
return {
|
|
56
55
|
files: [
|
|
56
|
+
...typesFiles,
|
|
57
57
|
{
|
|
58
58
|
name: filename,
|
|
59
59
|
path: destination,
|
|
@@ -61,6 +61,24 @@ export type CoreEventContract = ${contracts
|
|
|
61
61
|
description: 'All your Mercury core events ready for testing!',
|
|
62
62
|
},
|
|
63
63
|
],
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private async syncPermissions() {
|
|
68
|
+
const permissions = this.Store('permission')
|
|
69
|
+
|
|
70
|
+
const coreMap = await permissions.fetchContracts({
|
|
71
|
+
shouldSyncCorePermissions: true,
|
|
64
72
|
})
|
|
73
|
+
|
|
74
|
+
const heartwoodMap = await permissions.fetchContracts({
|
|
75
|
+
namespaces: ['heartwood'],
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const typesFiles = await this.Writer('permission').writeTypesFile(
|
|
79
|
+
this.cwd,
|
|
80
|
+
{ ...coreMap, ...heartwoodMap }
|
|
81
|
+
)
|
|
82
|
+
return typesFiles
|
|
65
83
|
}
|
|
66
84
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PermissionContractMap } from '@sprucelabs/mercury-types'
|
|
1
2
|
import { diskUtil, NpmPackage } from '@sprucelabs/spruce-skill-utils'
|
|
2
3
|
import AbstractFeature, {
|
|
3
4
|
FeatureDependency,
|
|
@@ -40,13 +41,8 @@ export default class PermissionFeature extends AbstractFeature {
|
|
|
40
41
|
const isInstalled = await this.features.isInstalled('permission')
|
|
41
42
|
const isSkillInstalled = await this.features.isInstalled('skill')
|
|
42
43
|
|
|
43
|
-
if (
|
|
44
|
-
isSkillInstalled
|
|
45
|
-
isInstalled &&
|
|
46
|
-
featureCode === 'node' &&
|
|
47
|
-
actionCode === 'upgrade'
|
|
48
|
-
) {
|
|
49
|
-
const combinedFile = await this.writePlugin()
|
|
44
|
+
if (isInstalled && featureCode === 'node' && actionCode === 'upgrade') {
|
|
45
|
+
const combinedFile = isSkillInstalled ? await this.writePlugin() : []
|
|
50
46
|
const results = await this.Action('permission', 'sync').execute({})
|
|
51
47
|
|
|
52
48
|
results.files = [...(results.files ?? []), ...combinedFile]
|
|
@@ -66,9 +62,10 @@ export default class PermissionFeature extends AbstractFeature {
|
|
|
66
62
|
}
|
|
67
63
|
|
|
68
64
|
private async writeTypesFile() {
|
|
69
|
-
return await this.writer.writeTypesFile(
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
return await this.writer.writeTypesFile(
|
|
66
|
+
this.cwd,
|
|
67
|
+
{} as PermissionContractMap
|
|
68
|
+
)
|
|
72
69
|
}
|
|
73
70
|
|
|
74
71
|
private async writePlugin() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildSchema } from '@sprucelabs/schema'
|
|
1
|
+
import { buildSchema, SchemaValues } from '@sprucelabs/schema'
|
|
2
2
|
import AbstractAction from '../../AbstractAction'
|
|
3
3
|
import { ActionOptions, FeatureActionResponse } from '../../features.types'
|
|
4
4
|
import PermissionStore from '../stores/PermissionStore'
|
|
@@ -18,9 +18,23 @@ export default class SyncAction extends AbstractAction<OptionsSchema> {
|
|
|
18
18
|
this.writer = this.Writer('permission')
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
public async execute(
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
public async execute(
|
|
22
|
+
options?: SyncPermissionsOptions
|
|
23
|
+
): Promise<FeatureActionResponse> {
|
|
24
|
+
const { shouldSyncCorePermissions } = this.validateAndNormalizeOptions(
|
|
25
|
+
options ?? {}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const permissions = this.permissions
|
|
29
|
+
const writer = this.writer
|
|
30
|
+
const cwd = this.cwd
|
|
31
|
+
|
|
32
|
+
const typesFiles = await writePermissionTypesFile({
|
|
33
|
+
permissions,
|
|
34
|
+
shouldSyncCorePermissions,
|
|
35
|
+
writer,
|
|
36
|
+
cwd,
|
|
37
|
+
})
|
|
24
38
|
|
|
25
39
|
const local = await this.permissions.loadLocalPermissions()
|
|
26
40
|
const combinedFiles = await this.writer.writeCombinedFile(this.cwd, {
|
|
@@ -36,7 +50,30 @@ export default class SyncAction extends AbstractAction<OptionsSchema> {
|
|
|
36
50
|
|
|
37
51
|
const schema = buildSchema({
|
|
38
52
|
id: 'syncPermissions',
|
|
39
|
-
fields: {
|
|
53
|
+
fields: {
|
|
54
|
+
shouldSyncCorePermissions: {
|
|
55
|
+
type: 'boolean',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
40
58
|
})
|
|
41
59
|
|
|
42
60
|
type OptionsSchema = typeof schema
|
|
61
|
+
export type SyncPermissionsOptions = SchemaValues<OptionsSchema>
|
|
62
|
+
|
|
63
|
+
export async function writePermissionTypesFile(options: {
|
|
64
|
+
permissions: PermissionStore
|
|
65
|
+
shouldSyncCorePermissions: boolean | undefined
|
|
66
|
+
namespaces?: string[]
|
|
67
|
+
writer: PermissionWriter
|
|
68
|
+
cwd: string
|
|
69
|
+
}) {
|
|
70
|
+
const { permissions, shouldSyncCorePermissions, writer, cwd, namespaces } =
|
|
71
|
+
options
|
|
72
|
+
|
|
73
|
+
const map = await permissions.fetchContracts({
|
|
74
|
+
namespaces,
|
|
75
|
+
shouldSyncCorePermissions,
|
|
76
|
+
})
|
|
77
|
+
const typesFiles = await writer.writeTypesFile(cwd, map)
|
|
78
|
+
return typesFiles
|
|
79
|
+
}
|