diff --git a/lib/blueprints/notify-blueprint/blueprint.json b/lib/blueprints/notify-blueprint/blueprint.json new file mode 100644 index 0000000..1f6b898 --- /dev/null +++ b/lib/blueprints/notify-blueprint/blueprint.json @@ -0,0 +1,10 @@ +{ + "namespace": "notify", + "name": "notify-blueprint", + "version": "1.0", + "label": "notify-blueprint", + "author": "WMFS", + "organisation": "West Midlands Fire Service", + "description": "Tymly blueprint to manage notifications", + "categories": [] +} diff --git a/lib/blueprints/tymly-blueprint/card-templates/gov-uk-notification.json b/lib/blueprints/notify-blueprint/card-templates/view-notification.json similarity index 91% rename from lib/blueprints/tymly-blueprint/card-templates/gov-uk-notification.json rename to lib/blueprints/notify-blueprint/card-templates/view-notification.json index ca6b48e..4b1a55c 100644 --- a/lib/blueprints/tymly-blueprint/card-templates/gov-uk-notification.json +++ b/lib/blueprints/notify-blueprint/card-templates/view-notification.json @@ -5,7 +5,7 @@ "body": [ { "type": "Jumbotron", - "title": "GOV UK Notification" + "title": "View Notification" }, { "type": "Container", @@ -15,7 +15,7 @@ "type": "FactSet", "facts": [ { - "title": "GOV UK Notify Message Status", + "title": "Message Status", "value": "{{ data.messageStatus.status }}" } ] @@ -85,8 +85,8 @@ } ], "templateMeta": { - "name": "gov-uk-notifications", - "title": "GOV UK Notifications", - "category": "system" + "name": "view-notifications", + "title": "View Notifications", + "category": "notify" } } diff --git a/lib/blueprints/tymly-blueprint/card-templates/gov-uk-notifications.json b/lib/blueprints/notify-blueprint/card-templates/view-notifications.json similarity index 92% rename from lib/blueprints/tymly-blueprint/card-templates/gov-uk-notifications.json rename to lib/blueprints/notify-blueprint/card-templates/view-notifications.json index 4e36e0e..5806325 100644 --- a/lib/blueprints/tymly-blueprint/card-templates/gov-uk-notifications.json +++ b/lib/blueprints/notify-blueprint/card-templates/view-notifications.json @@ -5,7 +5,7 @@ "body": [ { "type": "Jumbotron", - "title": "GOV UK Notifications" + "title": "View Notifications" }, { "id": "notifyLookup", @@ -14,7 +14,7 @@ "resultsPerPage": 10, "buttonText": "Search", "endpoint": { - "name": "tymly_getGovUkNotifications_1_0" + "name": "notify_getNotifications_1_0" }, "ctxPaths": { "results": "results", @@ -84,9 +84,9 @@ } ], "templateMeta": { - "name": "gov-uk-notifications", - "title": "GOV UK Notifications", - "category": "system" + "name": "notifications", + "title": "View Notifications", + "category": "notify" }, "hooks": { "afterLeave": { diff --git a/lib/blueprints/notify-blueprint/categories/notify.json b/lib/blueprints/notify-blueprint/categories/notify.json new file mode 100644 index 0000000..a4a1e45 --- /dev/null +++ b/lib/blueprints/notify-blueprint/categories/notify.json @@ -0,0 +1,4 @@ +{ + "label": "Notify", + "description": "Notify" +} diff --git a/lib/blueprints/tymly-blueprint/functions/get-gov-uk-notifications.js b/lib/blueprints/notify-blueprint/functions/get-notifications.js similarity index 79% rename from lib/blueprints/tymly-blueprint/functions/get-gov-uk-notifications.js rename to lib/blueprints/notify-blueprint/functions/get-notifications.js index b2cb895..ad11970 100644 --- a/lib/blueprints/tymly-blueprint/functions/get-gov-uk-notifications.js +++ b/lib/blueprints/notify-blueprint/functions/get-notifications.js @@ -1,4 +1,4 @@ -module.exports = function getGovUkNotifications () { +module.exports = function getNotifications () { return async function (event, env) { if (!event.offset) event.offset = 0 // todo: fix this, why is it null? @@ -26,15 +26,15 @@ module.exports = function getGovUkNotifications () { const whereClause = whereParts.length > 0 ? `WHERE ${whereParts.join(' AND ')}` : '' - const totalHitsRes = await client.query(`SELECT COUNT(*) FROM tymly.gov_uk_notifications ${whereClause};`) - const res = await client.query(`SELECT * FROM tymly.gov_uk_notifications ${whereClause} ORDER BY _modified DESC LIMIT ${limit} OFFSET ${offset};`) + const totalHitsRes = await client.query(`SELECT COUNT(*) FROM notify.notifications ${whereClause};`) + const res = await client.query(`SELECT * FROM notify.notifications ${whereClause} ORDER BY _modified DESC LIMIT ${limit} OFFSET ${offset};`) const results = [] for (const row of res.rows) { row.launches = [{ title: 'View', - stateMachineName: 'tymly_viewGovUkNotification_1_0', + stateMachineName: 'notify_viewNotification_1_0', input: { id: row.id } }] diff --git a/lib/blueprints/tymly-blueprint/functions/set-gov-uk-notification-input-path.js b/lib/blueprints/notify-blueprint/functions/set-notification-input-path.js similarity index 82% rename from lib/blueprints/tymly-blueprint/functions/set-gov-uk-notification-input-path.js rename to lib/blueprints/notify-blueprint/functions/set-notification-input-path.js index 2390534..104e04a 100644 --- a/lib/blueprints/tymly-blueprint/functions/set-gov-uk-notification-input-path.js +++ b/lib/blueprints/notify-blueprint/functions/set-notification-input-path.js @@ -1,4 +1,4 @@ -module.exports = function setGovUkNotificationInputPath () { +module.exports = function setNotificationInputPath () { return async function (event) { const messageStatusInput = {} diff --git a/lib/blueprints/tymly-blueprint/models/gov-uk-notifications.json b/lib/blueprints/notify-blueprint/models/notifications.json similarity index 100% rename from lib/blueprints/tymly-blueprint/models/gov-uk-notifications.json rename to lib/blueprints/notify-blueprint/models/notifications.json diff --git a/lib/blueprints/tymly-blueprint/state-machines/get-gov-uk-notifications.json b/lib/blueprints/notify-blueprint/state-machines/get-notifications.json similarity index 52% rename from lib/blueprints/tymly-blueprint/state-machines/get-gov-uk-notifications.json rename to lib/blueprints/notify-blueprint/state-machines/get-notifications.json index 2e74c82..12b2d5c 100644 --- a/lib/blueprints/tymly-blueprint/state-machines/get-gov-uk-notifications.json +++ b/lib/blueprints/notify-blueprint/state-machines/get-notifications.json @@ -1,21 +1,21 @@ { - "Comment": "Get GOV UK Notify Notifications", - "name": "Get GOV UK Notify Notifications", + "Comment": "Get Notifications", + "name": "Get Notifications", "version": "1.0", "categories": [ - "system" + "notify" ], "StartAt": "GetData", "States": { "GetData": { "Type": "Task", - "Resource": "function:tymly_getGovUkNotifications", + "Resource": "function:notify_getNotifications", "End": true } }, "restrictions": [ { - "roleId": "tymly_govUkNotifyAdmin", + "roleId": "notify_admin", "allows": [ "*" ] diff --git a/lib/blueprints/tymly-blueprint/state-machines/view-gov-uk-notification.json b/lib/blueprints/notify-blueprint/state-machines/view-notification.json similarity index 73% rename from lib/blueprints/tymly-blueprint/state-machines/view-gov-uk-notification.json rename to lib/blueprints/notify-blueprint/state-machines/view-notification.json index 2dd8136..dc28c50 100644 --- a/lib/blueprints/tymly-blueprint/state-machines/view-gov-uk-notification.json +++ b/lib/blueprints/notify-blueprint/state-machines/view-notification.json @@ -1,9 +1,9 @@ { - "Comment": "View notification sent via GOV UK Notify Service", - "name": "View GOV UK Notify Notification", + "Comment": "View notification sent via Notify Service", + "name": "View Notification", "version": "1.0", "categories": [ - "system" + "notify" ], "StartAt": "Finding", "States": { @@ -12,14 +12,14 @@ "InputPath": "$.id", "Resource": "module:findingById", "ResourceConfig": { - "modelId": "tymly_govUkNotifications" + "modelId": "notify_notifications" }, "ResultPath": "$", "Next": "SetInputPath" }, "SetInputPath": { "Type": "Task", - "Resource": "function:tymly_setGovUkNotificationInputPath", + "Resource": "function:notify_setNotificationInputPath", "ResultPath": "$.messageStatusInput", "Next": "GetMessageStatus" }, @@ -34,7 +34,7 @@ "Type": "Task", "Resource": "module:awaitingHumanInput", "ResourceConfig": { - "uiName": "tymly_govUkNotification", + "uiName": "notify_viewNotification", "dataPath": "$" }, "End": true @@ -42,7 +42,7 @@ }, "restrictions": [ { - "roleId": "tymly_govUkNotifyAdmin", + "roleId": "notify_admin", "allows": [ "*" ] diff --git a/lib/blueprints/tymly-blueprint/state-machines/view-gov-uk-notifications.json b/lib/blueprints/notify-blueprint/state-machines/view-notifications.json similarity index 66% rename from lib/blueprints/tymly-blueprint/state-machines/view-gov-uk-notifications.json rename to lib/blueprints/notify-blueprint/state-machines/view-notifications.json index f2b6e0f..9b4af6c 100644 --- a/lib/blueprints/tymly-blueprint/state-machines/view-gov-uk-notifications.json +++ b/lib/blueprints/notify-blueprint/state-machines/view-notifications.json @@ -1,9 +1,9 @@ { - "Comment": "View notifications sent via GOV UK Notify Service", - "name": "View GOV UK Notify Notifications", + "Comment": "View notifications sent via Notify Service", + "name": "View Notifications", "version": "1.0", "categories": [ - "system" + "notify" ], "instigators": [ "user" @@ -15,7 +15,7 @@ "Type": "Task", "Resource": "module:awaitingHumanInput", "ResourceConfig": { - "uiName": "tymly_govUkNotifications", + "uiName": "notify_viewNotifications", "dataPath": "$" }, "End": true @@ -23,7 +23,7 @@ }, "restrictions": [ { - "roleId": "tymly_govUkNotifyAdmin", + "roleId": "notify_admin", "allows": [ "*" ] diff --git a/lib/blueprints/notify-blueprint/template-roles/admin.json b/lib/blueprints/notify-blueprint/template-roles/admin.json new file mode 100644 index 0000000..0eecdfd --- /dev/null +++ b/lib/blueprints/notify-blueprint/template-roles/admin.json @@ -0,0 +1,4 @@ +{ + "label": "notify-admin", + "description": "Notify administrator" +} diff --git a/lib/blueprints/tymly-blueprint/blueprint.json b/lib/blueprints/tymly-blueprint/blueprint.json deleted file mode 100644 index 3ca71f2..0000000 --- a/lib/blueprints/tymly-blueprint/blueprint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "namespace": "tymly", - "name": "tymly-blueprint", - "version": "1.0", - "label": "tymly-blueprint", - "author": "WMFS", - "organisation": "West Midlands Fire Service", - "description": "Tymly blueprint to store notifications.", - "categories": [] -} diff --git a/lib/blueprints/tymly-blueprint/template-roles/gov-uk-notify-admin.json b/lib/blueprints/tymly-blueprint/template-roles/gov-uk-notify-admin.json deleted file mode 100644 index d7d602b..0000000 --- a/lib/blueprints/tymly-blueprint/template-roles/gov-uk-notify-admin.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "label": "gov-uk-notify-admin", - "description": "GOV UK Notify administrator" -} diff --git a/lib/components/services/notify/doc/index.js b/lib/components/services/notify/doc/index.js index b633bca..6c5f9c7 100644 --- a/lib/components/services/notify/doc/index.js +++ b/lib/components/services/notify/doc/index.js @@ -1,5 +1,5 @@ module.exports = { - description: 'Provides functions for interacting with Gov UK Notify service', + description: 'Provides functions for interacting with GOV UK Notify service', blueprintDirs: { 'message-templates': 'One JSON file per message template' } diff --git a/lib/components/services/notify/index.js b/lib/components/services/notify/index.js index 8fa50d1..811c336 100644 --- a/lib/components/services/notify/index.js +++ b/lib/components/services/notify/index.js @@ -7,7 +7,7 @@ class NotifyService { this.templates = {} - const notificationModel = options.bootedServices.storage.models.tymly_govUkNotifications + const notificationModel = options.bootedServices.storage.models.notify_notifications if (options.blueprintComponents.messageTemplates) { for (const [key, definition] of Object.entries(options.blueprintComponents.messageTemplates)) {