|
| 1 | +# sender-management |
| 2 | + |
| 3 | +TypeScript Library / CLI utility for managing comms manager sender configuration. These are currently stored in SSM Parameter Store. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +### CLI Usage |
| 8 | + |
| 9 | +From the repo root run: |
| 10 | + |
| 11 | +```bash |
| 12 | +npm --prefix utils/sender-management run-script cli -- <command> [options] |
| 13 | +``` |
| 14 | + |
| 15 | +### Library Usage |
| 16 | + |
| 17 | +Install the package as `@sender-management` |
| 18 | + |
| 19 | +Instantiate an instance of the library as follows. The library should take an implementation of an `IParameterStore` to define how the library will interact with SSM (e.g. caching vs non-caching). |
| 20 | + |
| 21 | +```ts |
| 22 | +import { SenderManagement } from '@sender-management'; |
| 23 | + |
| 24 | +const sm = SenderManagement({ parameterStore: new ParameterStore() }); |
| 25 | +``` |
| 26 | + |
| 27 | +### Global Options |
| 28 | + |
| 29 | +#### CLI Options |
| 30 | + |
| 31 | +- `--environment` - The name of the environment to run the command on e.g. 'pr123', 'main', 'uat', 'prod'. Required. |
| 32 | +- `--format` - print data in json or tabular format. Default is `table`. |
| 33 | + |
| 34 | +#### Library Options |
| 35 | + |
| 36 | +```ts |
| 37 | +const sm = SenderManagement({ |
| 38 | + parameterStore: new ParameterStore(), |
| 39 | + configOverrides: { environment: 'pr123' }, |
| 40 | +}); |
| 41 | +``` |
| 42 | + |
| 43 | +## Commands |
| 44 | + |
| 45 | +### Sender Configuration Commands |
| 46 | + |
| 47 | +- [Put Sender](#put-sender) |
| 48 | +- [List Senders](#list-senders) |
| 49 | +- [Get Sender](#get-sender) |
| 50 | +- [Delete Sender](#delete-sender) |
| 51 | + |
| 52 | +#### Put Sender |
| 53 | + |
| 54 | +Insert a new sender or update an existing one. Omit the `--sender-id` option to insert a new sender. Include it to update an existing sender. Note: the INT and PROD senderIds should be the same ID. |
| 55 | + |
| 56 | +##### Put Sender Options |
| 57 | + |
| 58 | +- `--sender-id` - the ID of the sender to update. (defaults to uuid. Should typically be excluded unless overwriting an existing sender). It cannot contain spaces. |
| 59 | +- `--sender-name` - the display name of the sender. Will throw an error if this name is already taken. Unique across all the senders. (required) |
| 60 | +- `--mesh-mailbox-sender-id` - the mesh mailbox id for this sender. Unique across all the senders. (required) |
| 61 | +- `--mesh-mailbox-reports-id` - the mesh mailbox id used for reporting for this sender. It can be the same as mesh-mailbox-sender-id. (required) |
| 62 | +- `--fallback-wait-time-seconds` - the fallback wait time to print letters. (required) (number) |
| 63 | +- `--routing-config-id` - the routing configuration id. |
| 64 | + |
| 65 | +##### Put Sender Examples |
| 66 | + |
| 67 | +```bash |
| 68 | +npm --prefix utils/sender-management run-script cli -- put-sender \ |
| 69 | + --sender-name 'Derby & Burton Trust' \ |
| 70 | + --mesh-mailbox-sender-id 'DerbyMailboxId' \ |
| 71 | + --mesh-mailbox-reports-id 'DerbyMailboxReportsId' \ |
| 72 | + --fallback-wait-time-seconds 100 \ |
| 73 | + --routing-config-id 'abc123' \ |
| 74 | + --environment 'pr123' |
| 75 | +``` |
| 76 | + |
| 77 | +```bash |
| 78 | +npm --prefix utils/sender-management run-script cli -- put-sender \ |
| 79 | + --sender-id 'integration_test_sender' \ |
| 80 | + --sender-name 'integration test sender' \ |
| 81 | + --mesh-mailbox-sender-id '123456' \ |
| 82 | + --mesh-mailbox-reports-id '123456' \ |
| 83 | + --fallback-wait-time-seconds 100 \ |
| 84 | + --routing-config-id 'abc123' \ |
| 85 | + --environment 'pr123' |
| 86 | +``` |
| 87 | + |
| 88 | +```ts |
| 89 | +const sender = await sm.putSender({ |
| 90 | + senderName: 'vaccs', |
| 91 | + meshMailboxSenderId: 'meshMailbox1234', |
| 92 | + meshMailboxReportsId: 'meshMailboxReport1234', |
| 93 | + fallbackWaitTimeSeconds: 300, |
| 94 | + routingConfigId: '1234', |
| 95 | +}); |
| 96 | +``` |
| 97 | + |
| 98 | +#### List Senders |
| 99 | + |
| 100 | +Return a list of all existing senders |
| 101 | + |
| 102 | +##### List Senders Examples |
| 103 | + |
| 104 | +```bash |
| 105 | +npm --prefix utils/sender-management run-script cli -- list-senders --environment pr123 |
| 106 | +``` |
| 107 | + |
| 108 | +```ts |
| 109 | +const senders = await sm.listSenders(); |
| 110 | +``` |
| 111 | + |
| 112 | +#### Get Sender |
| 113 | + |
| 114 | +Return an individual sender by senderId |
| 115 | + |
| 116 | +##### Get Sender Examples |
| 117 | + |
| 118 | +```bash |
| 119 | +npm --prefix utils/sender-management run-script cli -- get-sender \ |
| 120 | + --sender-id 'integration_test_sender' \ |
| 121 | + --environment 'pr123' |
| 122 | +``` |
| 123 | + |
| 124 | +```ts |
| 125 | +const sender = await sm.getSender({ |
| 126 | + senderId: 'integration_test_sender', |
| 127 | +}); |
| 128 | +``` |
| 129 | + |
| 130 | +#### Delete Sender |
| 131 | + |
| 132 | +Delete an individual sender by senderId. |
| 133 | + |
| 134 | +##### Delete Sender Examples |
| 135 | + |
| 136 | +```bash |
| 137 | +npm --prefix utils/sender-management run-script cli -- delete-sender \ |
| 138 | + --sender-id 'integration_test_sender' \ |
| 139 | + --environment pr123 |
| 140 | +``` |
| 141 | + |
| 142 | +```ts |
| 143 | +const sender = await sm.deleteSender({ |
| 144 | + senderId: 'integration_test_sender', |
| 145 | +}); |
| 146 | +``` |
0 commit comments