-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cmd-api-server): fully dynamic plugin imports via config file/en…
…v/CLI It leverages the PluginRegistry to its full potential. Had to slightly refactor how the plugin factories are exported from the plugin packages but it is a non-breaking change. Also: decoupled the consortium web service plugins tests from the plugin itself (e.g. moved it to a separate package) so that circular package dependencies are avoided where with cmd-api-server Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
- Loading branch information
Showing
23 changed files
with
2,822 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/cactus-cmd-api-server/src/main/typescript/config/convict-plugin-array-format.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import convict from "convict"; | ||
|
||
export const validate = (sources: any[], schema?: any) => { | ||
if (!Array.isArray(sources)) { | ||
throw new Error("must be of type Array"); | ||
} | ||
|
||
for (const source of sources) { | ||
convict(schema.pluginSchema).load(source).validate(); | ||
} | ||
}; | ||
|
||
export const coerce = (value: string) => { | ||
// CLI sends comman separated objects as a JSON string without the array square brackets | ||
// ENV sends the proper array that is valid JSON so we have to detect and handle both cases | ||
const isJsonArray = value.startsWith("[") && value.endsWith("]"); | ||
return isJsonArray ? JSON.parse(value) : JSON.parse(`[${value}]`); | ||
}; | ||
|
||
export const FORMAT_PLUGIN_ARRAY = { | ||
name: "plugin-array", | ||
validate, | ||
coerce, | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/cactus-plugin-keychain-memory/src/main/typescript/public-api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
export { PluginKeychainMemory } from "./plugin-keychain-memory"; | ||
export { PluginFactoryKeychain } from "./plugin-factory-keychain"; | ||
|
||
import { PluginFactoryKeychain } from "./plugin-factory-keychain"; | ||
|
||
export async function createPluginFactory( | ||
options?: any | ||
): Promise<PluginFactoryKeychain> { | ||
return new PluginFactoryKeychain(); | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/cactus-plugin-kv-storage-memory/src/main/typescript/public-api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
export { PluginKVStorageMemory } from "./plugin-kv-storage-memory"; | ||
export { PluginFactoryKVStorage } from "./plugin-factory-kv-storage"; | ||
|
||
import { PluginFactoryKVStorage } from "./plugin-factory-kv-storage"; | ||
|
||
export async function createPluginFactory( | ||
options?: any | ||
): Promise<PluginFactoryKVStorage> { | ||
return new PluginFactoryKVStorage(); | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/cactus-plugin-ledger-connector-besu/src/main/typescript/public-api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
export { PluginLedgerConnectorBesu } from "./plugin-ledger-connector-besu"; | ||
export { PluginFactoryLedgerConnector } from "./plugin-factory-ledger-connector"; | ||
|
||
import { PluginFactoryLedgerConnector } from "./plugin-factory-ledger-connector"; | ||
|
||
export async function createPluginFactory( | ||
options?: any | ||
): Promise<PluginFactoryLedgerConnector> { | ||
return new PluginFactoryLedgerConnector(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...gration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-via-web-service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/cactus-test-plugin-web-service-consortium/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# `@hyperledger/cactus-test-plugin-web-service-consortium` | ||
|
||
|
||
## Usage | ||
|
||
``` | ||
// TODO: DEMONSTRATE API | ||
``` | ||
|
||
## FAQ | ||
|
||
### **What is a dedicatd test package for?** | ||
|
||
This is a dedicated test package meaning that it verifies the integration between two packages that are somehow dependent on each other and therefore these tests cannot be added properly in the child package due to circular dependency issues and it would not be fitting to add it in the parent because the child package's tests should not be held by the parent as a matter of principle. |
Oops, something went wrong.