@productcraft/notify 0.3.0 → 0.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.
@@ -7,13 +7,13 @@ export { SignWebhookParams, SignedWebhook, signWebhook } from '@productcraft/cor
7
7
  *
8
8
  * @example
9
9
  * ```ts
10
- * const { payload, headers } = await signWebhook({ payload: { id: "evt_test_1", type: "credential.invalid", created_at: new Date().toISOString(), data: {} }, secret });
10
+ * const { payload, headers } = await signWebhook({ payload: { id: "evt_test_1", type: "approval.resolved", created_at: new Date().toISOString(), data: {} }, secret });
11
11
  * const res = await fetch("http://localhost:3000/webhooks", { method: "POST", headers, body: payload });
12
12
  * ```
13
13
  */
14
14
 
15
15
  /** Every operation name, as `resource.method`. */
16
- type OperationName = "batches.flush" | "batches.list" | "batches.retrieve" | "categories.create" | "categories.delete" | "categories.list" | "categories.retrieve" | "categories.update" | "channels.apns.deleteCredential" | "channels.apns.uploadCredential" | "channels.fcm.deleteCredential" | "channels.fcm.uploadCredential" | "channels.list" | "channels.webpush.generateVapidKeys" | "channels.webpush.importVapidKeys" | "channels.webpush.retrieve" | "deliveries.list" | "deliveries.retrieve" | "export.retrieve" | "me.devices.delete" | "me.devices.register" | "me.inbox.counts" | "me.inbox.interact" | "me.inbox.list" | "me.inbox.mark" | "me.preferences.retrieve" | "me.preferences.update" | "me.webpush.vapidPublicKey" | "notificationTypes.archive" | "notificationTypes.create" | "notificationTypes.list" | "notificationTypes.preview" | "notificationTypes.replaceByKey" | "notificationTypes.retrieve" | "notificationTypes.templates.delete" | "notificationTypes.templates.retrieve" | "notificationTypes.templates.revert" | "notificationTypes.templates.update" | "notificationTypes.templates.versions" | "notificationTypes.update" | "notifications.cancel" | "notifications.cancelByKey" | "notifications.list" | "notifications.retract" | "notifications.retrieve" | "notifications.send" | "recipientTokens.mint" | "recipients.bulkIdentify" | "recipients.createPreferenceLink" | "recipients.delete" | "recipients.devices.create" | "recipients.devices.delete" | "recipients.devices.list" | "recipients.identify" | "recipients.inbox.list" | "recipients.list" | "recipients.preferences.replace" | "recipients.preferences.retrieve" | "recipients.preferences.update" | "recipients.retrieve" | "recipients.revokeTokens" | "recipients.timeline" | "recipients.update" | "settings.retrieve" | "settings.revokeAllTokens" | "settings.update" | "setupStatus.retrieve" | "stats.retrieve" | "webhooks.endpoints.create" | "webhooks.endpoints.delete" | "webhooks.endpoints.list" | "webhooks.endpoints.retrieve" | "webhooks.endpoints.rotateSecret" | "webhooks.endpoints.test" | "webhooks.endpoints.update" | "webhooks.eventTypes.list" | "webhooks.events.list" | "webhooks.events.replay" | "webhooks.events.retrieve";
16
+ type OperationName = "approvals.cancel" | "approvals.create" | "approvals.list" | "approvals.recordDecision" | "approvals.retrieve" | "batches.flush" | "batches.list" | "batches.retrieve" | "categories.create" | "categories.delete" | "categories.list" | "categories.retrieve" | "categories.update" | "channels.apns.deleteCredential" | "channels.apns.uploadCredential" | "channels.fcm.deleteCredential" | "channels.fcm.uploadCredential" | "channels.list" | "channels.webpush.generateVapidKeys" | "channels.webpush.importVapidKeys" | "channels.webpush.retrieve" | "deliveries.list" | "deliveries.retrieve" | "export.retrieve" | "me.approvals.decide" | "me.approvals.retrieve" | "me.devices.delete" | "me.devices.register" | "me.inbox.counts" | "me.inbox.interact" | "me.inbox.list" | "me.inbox.mark" | "me.preferences.retrieve" | "me.preferences.update" | "me.webpush.vapidPublicKey" | "notificationTypes.archive" | "notificationTypes.create" | "notificationTypes.list" | "notificationTypes.preview" | "notificationTypes.replaceByKey" | "notificationTypes.retrieve" | "notificationTypes.templates.delete" | "notificationTypes.templates.retrieve" | "notificationTypes.templates.revert" | "notificationTypes.templates.update" | "notificationTypes.templates.versions" | "notificationTypes.update" | "notifications.cancel" | "notifications.cancelByKey" | "notifications.list" | "notifications.retract" | "notifications.retrieve" | "notifications.send" | "recipientTokens.mint" | "recipients.bulkIdentify" | "recipients.createPreferenceLink" | "recipients.delete" | "recipients.devices.create" | "recipients.devices.delete" | "recipients.devices.list" | "recipients.identify" | "recipients.inbox.list" | "recipients.list" | "recipients.preferences.replace" | "recipients.preferences.retrieve" | "recipients.preferences.update" | "recipients.retrieve" | "recipients.revokeTokens" | "recipients.timeline" | "recipients.update" | "settings.retrieve" | "settings.revokeAllTokens" | "settings.update" | "setupStatus.retrieve" | "stats.retrieve" | "webhooks.endpoints.create" | "webhooks.endpoints.delete" | "webhooks.endpoints.list" | "webhooks.endpoints.retrieve" | "webhooks.endpoints.rotateSecret" | "webhooks.endpoints.test" | "webhooks.endpoints.update" | "webhooks.eventTypes.list" | "webhooks.events.list" | "webhooks.events.replay" | "webhooks.events.retrieve";
17
17
  /** One request the mock received. */
18
18
  interface MockCall {
19
19
  /** The matched operation, or `undefined` when nothing matched (the mock answers 404). */
package/dist/testing.d.ts CHANGED
@@ -7,13 +7,13 @@ export { SignWebhookParams, SignedWebhook, signWebhook } from '@productcraft/cor
7
7
  *
8
8
  * @example
9
9
  * ```ts
10
- * const { payload, headers } = await signWebhook({ payload: { id: "evt_test_1", type: "credential.invalid", created_at: new Date().toISOString(), data: {} }, secret });
10
+ * const { payload, headers } = await signWebhook({ payload: { id: "evt_test_1", type: "approval.resolved", created_at: new Date().toISOString(), data: {} }, secret });
11
11
  * const res = await fetch("http://localhost:3000/webhooks", { method: "POST", headers, body: payload });
12
12
  * ```
13
13
  */
14
14
 
15
15
  /** Every operation name, as `resource.method`. */
16
- type OperationName = "batches.flush" | "batches.list" | "batches.retrieve" | "categories.create" | "categories.delete" | "categories.list" | "categories.retrieve" | "categories.update" | "channels.apns.deleteCredential" | "channels.apns.uploadCredential" | "channels.fcm.deleteCredential" | "channels.fcm.uploadCredential" | "channels.list" | "channels.webpush.generateVapidKeys" | "channels.webpush.importVapidKeys" | "channels.webpush.retrieve" | "deliveries.list" | "deliveries.retrieve" | "export.retrieve" | "me.devices.delete" | "me.devices.register" | "me.inbox.counts" | "me.inbox.interact" | "me.inbox.list" | "me.inbox.mark" | "me.preferences.retrieve" | "me.preferences.update" | "me.webpush.vapidPublicKey" | "notificationTypes.archive" | "notificationTypes.create" | "notificationTypes.list" | "notificationTypes.preview" | "notificationTypes.replaceByKey" | "notificationTypes.retrieve" | "notificationTypes.templates.delete" | "notificationTypes.templates.retrieve" | "notificationTypes.templates.revert" | "notificationTypes.templates.update" | "notificationTypes.templates.versions" | "notificationTypes.update" | "notifications.cancel" | "notifications.cancelByKey" | "notifications.list" | "notifications.retract" | "notifications.retrieve" | "notifications.send" | "recipientTokens.mint" | "recipients.bulkIdentify" | "recipients.createPreferenceLink" | "recipients.delete" | "recipients.devices.create" | "recipients.devices.delete" | "recipients.devices.list" | "recipients.identify" | "recipients.inbox.list" | "recipients.list" | "recipients.preferences.replace" | "recipients.preferences.retrieve" | "recipients.preferences.update" | "recipients.retrieve" | "recipients.revokeTokens" | "recipients.timeline" | "recipients.update" | "settings.retrieve" | "settings.revokeAllTokens" | "settings.update" | "setupStatus.retrieve" | "stats.retrieve" | "webhooks.endpoints.create" | "webhooks.endpoints.delete" | "webhooks.endpoints.list" | "webhooks.endpoints.retrieve" | "webhooks.endpoints.rotateSecret" | "webhooks.endpoints.test" | "webhooks.endpoints.update" | "webhooks.eventTypes.list" | "webhooks.events.list" | "webhooks.events.replay" | "webhooks.events.retrieve";
16
+ type OperationName = "approvals.cancel" | "approvals.create" | "approvals.list" | "approvals.recordDecision" | "approvals.retrieve" | "batches.flush" | "batches.list" | "batches.retrieve" | "categories.create" | "categories.delete" | "categories.list" | "categories.retrieve" | "categories.update" | "channels.apns.deleteCredential" | "channels.apns.uploadCredential" | "channels.fcm.deleteCredential" | "channels.fcm.uploadCredential" | "channels.list" | "channels.webpush.generateVapidKeys" | "channels.webpush.importVapidKeys" | "channels.webpush.retrieve" | "deliveries.list" | "deliveries.retrieve" | "export.retrieve" | "me.approvals.decide" | "me.approvals.retrieve" | "me.devices.delete" | "me.devices.register" | "me.inbox.counts" | "me.inbox.interact" | "me.inbox.list" | "me.inbox.mark" | "me.preferences.retrieve" | "me.preferences.update" | "me.webpush.vapidPublicKey" | "notificationTypes.archive" | "notificationTypes.create" | "notificationTypes.list" | "notificationTypes.preview" | "notificationTypes.replaceByKey" | "notificationTypes.retrieve" | "notificationTypes.templates.delete" | "notificationTypes.templates.retrieve" | "notificationTypes.templates.revert" | "notificationTypes.templates.update" | "notificationTypes.templates.versions" | "notificationTypes.update" | "notifications.cancel" | "notifications.cancelByKey" | "notifications.list" | "notifications.retract" | "notifications.retrieve" | "notifications.send" | "recipientTokens.mint" | "recipients.bulkIdentify" | "recipients.createPreferenceLink" | "recipients.delete" | "recipients.devices.create" | "recipients.devices.delete" | "recipients.devices.list" | "recipients.identify" | "recipients.inbox.list" | "recipients.list" | "recipients.preferences.replace" | "recipients.preferences.retrieve" | "recipients.preferences.update" | "recipients.retrieve" | "recipients.revokeTokens" | "recipients.timeline" | "recipients.update" | "settings.retrieve" | "settings.revokeAllTokens" | "settings.update" | "setupStatus.retrieve" | "stats.retrieve" | "webhooks.endpoints.create" | "webhooks.endpoints.delete" | "webhooks.endpoints.list" | "webhooks.endpoints.retrieve" | "webhooks.endpoints.rotateSecret" | "webhooks.endpoints.test" | "webhooks.endpoints.update" | "webhooks.eventTypes.list" | "webhooks.events.list" | "webhooks.events.replay" | "webhooks.events.retrieve";
17
17
  /** One request the mock received. */
18
18
  interface MockCall {
19
19
  /** The matched operation, or `undefined` when nothing matched (the mock answers 404). */
package/dist/testing.js CHANGED
@@ -133,6 +133,7 @@ var ROUTES = [
133
133
  ]
134
134
  } },
135
135
  { op: "notificationTypes.create", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/notification-types$/, status: 201, contentType: "application/json", body: {
136
+ approval: { default_expires_in_seconds: 1, reason: "optional", timeout_outcome: "expired" },
136
137
  archived_at: "2026-01-01T00:00:00.000Z",
137
138
  batch: {
138
139
  inbox: "collapse",
@@ -166,6 +167,7 @@ var ROUTES = [
166
167
  { op: "notificationTypes.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/notification-types$/, status: 200, contentType: "application/json", body: {
167
168
  data: [
168
169
  {
170
+ approval: { default_expires_in_seconds: 1, reason: "optional", timeout_outcome: "expired" },
169
171
  archived_at: "2026-01-01T00:00:00.000Z",
170
172
  batch: {
171
173
  inbox: "collapse",
@@ -298,6 +300,23 @@ var ROUTES = [
298
300
  ],
299
301
  pagination: { next_cursor: null, has_more: false }
300
302
  } },
303
+ { op: "me.approvals.decide", method: "POST", pattern: /^\/v1\/client\/approvals\/[^\/]+\/decision$/, status: 200, contentType: "application/json", body: {
304
+ approvers: ["string"],
305
+ body: "string",
306
+ created_at: "2026-01-01T00:00:00.000Z",
307
+ decided_at: "2026-01-01T00:00:00.000Z",
308
+ decided_by: "string",
309
+ decided_via: "inbox",
310
+ expires_at: "2026-01-01T00:00:00.000Z",
311
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
312
+ metadata: {},
313
+ notification_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
314
+ reason: "string",
315
+ requester: { id: "string", kind: "agent", name: "string" },
316
+ status: "pending",
317
+ title: "string",
318
+ type: "deploy.approval"
319
+ } },
301
320
  { op: "notifications.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/notifications$/, status: 200, contentType: "application/json", body: {
302
321
  data: [
303
322
  {
@@ -470,6 +489,45 @@ var ROUTES = [
470
489
  ],
471
490
  pagination: { next_cursor: null, has_more: false }
472
491
  } },
492
+ { op: "approvals.create", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/approvals$/, status: 200, contentType: "application/json", body: {
493
+ approvers: ["string"],
494
+ body: "string",
495
+ created_at: "2026-01-01T00:00:00.000Z",
496
+ decided_at: "2026-01-01T00:00:00.000Z",
497
+ decided_by: "string",
498
+ decided_via: "inbox",
499
+ expires_at: "2026-01-01T00:00:00.000Z",
500
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
501
+ metadata: {},
502
+ notification_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
503
+ reason: "string",
504
+ requester: { id: "string", kind: "agent", name: "string" },
505
+ status: "pending",
506
+ title: "string",
507
+ type: "deploy.approval"
508
+ } },
509
+ { op: "approvals.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/approvals$/, status: 200, contentType: "application/json", body: {
510
+ data: [
511
+ {
512
+ approvers: ["string"],
513
+ body: "string",
514
+ created_at: "2026-01-01T00:00:00.000Z",
515
+ decided_at: "2026-01-01T00:00:00.000Z",
516
+ decided_by: "string",
517
+ decided_via: "inbox",
518
+ expires_at: "2026-01-01T00:00:00.000Z",
519
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
520
+ metadata: {},
521
+ notification_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
522
+ reason: "string",
523
+ requester: { id: "string", kind: "agent", name: "string" },
524
+ status: "pending",
525
+ title: "string",
526
+ type: "deploy.approval"
527
+ }
528
+ ],
529
+ pagination: { next_cursor: null, has_more: false }
530
+ } },
473
531
  { op: "channels.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/channels$/, status: 200, contentType: "application/json", body: {
474
532
  data: [
475
533
  {
@@ -562,6 +620,7 @@ var ROUTES = [
562
620
  exported_at: "2026-01-01T00:00:00.000Z",
563
621
  notification_types: [
564
622
  {
623
+ approval: { default_expires_in_seconds: 1, reason: "optional", timeout_outcome: "expired" },
565
624
  archived_at: "2026-01-01T00:00:00.000Z",
566
625
  batch: {
567
626
  inbox: "collapse",
@@ -593,6 +652,23 @@ var ROUTES = [
593
652
  email_enabled: true
594
653
  }
595
654
  } },
655
+ { op: "me.approvals.retrieve", method: "GET", pattern: /^\/v1\/client\/approvals\/[^\/]+$/, status: 200, contentType: "application/json", body: {
656
+ approvers: ["string"],
657
+ body: "string",
658
+ created_at: "2026-01-01T00:00:00.000Z",
659
+ decided_at: "2026-01-01T00:00:00.000Z",
660
+ decided_by: "string",
661
+ decided_via: "inbox",
662
+ expires_at: "2026-01-01T00:00:00.000Z",
663
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
664
+ metadata: {},
665
+ notification_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
666
+ reason: "string",
667
+ requester: { id: "string", kind: "agent", name: "string" },
668
+ status: "pending",
669
+ title: "string",
670
+ type: "deploy.approval"
671
+ } },
596
672
  { op: "stats.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/stats$/, status: 200, contentType: "application/json", body: {
597
673
  data: [
598
674
  {
@@ -634,6 +710,7 @@ var ROUTES = [
634
710
  url: "https://api.acme.com/webhooks"
635
711
  } },
636
712
  { op: "notificationTypes.archive", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/notification-types\/[^\/]+\/archive$/, status: 200, contentType: "application/json", body: {
713
+ approval: { default_expires_in_seconds: 1, reason: "optional", timeout_outcome: "expired" },
637
714
  archived_at: "2026-01-01T00:00:00.000Z",
638
715
  batch: {
639
716
  inbox: "collapse",
@@ -683,6 +760,7 @@ var ROUTES = [
683
760
  } },
684
761
  { op: "channels.apns.deleteCredential", method: "DELETE", pattern: /^\/v1\/workspaces\/[^\/]+\/channels\/apns\/credentials\/[^\/]+$/, status: 204, contentType: null, body: null },
685
762
  { op: "notificationTypes.replaceByKey", method: "PUT", pattern: /^\/v1\/workspaces\/[^\/]+\/notification-types\/by-key\/[^\/]+$/, status: 200, contentType: "application/json", body: {
763
+ approval: { default_expires_in_seconds: 1, reason: "optional", timeout_outcome: "expired" },
686
764
  archived_at: "2026-01-01T00:00:00.000Z",
687
765
  batch: {
688
766
  inbox: "collapse",
@@ -844,7 +922,25 @@ var ROUTES = [
844
922
  ],
845
923
  pagination: { next_cursor: null, has_more: false }
846
924
  } },
925
+ { op: "approvals.recordDecision", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/approvals\/[^\/]+\/decision$/, status: 200, contentType: "application/json", body: {
926
+ approvers: ["string"],
927
+ body: "string",
928
+ created_at: "2026-01-01T00:00:00.000Z",
929
+ decided_at: "2026-01-01T00:00:00.000Z",
930
+ decided_by: "string",
931
+ decided_via: "inbox",
932
+ expires_at: "2026-01-01T00:00:00.000Z",
933
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
934
+ metadata: {},
935
+ notification_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
936
+ reason: "string",
937
+ requester: { id: "string", kind: "agent", name: "string" },
938
+ status: "pending",
939
+ title: "string",
940
+ type: "deploy.approval"
941
+ } },
847
942
  { op: "notificationTypes.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/notification-types\/[^\/]+$/, status: 200, contentType: "application/json", body: {
943
+ approval: { default_expires_in_seconds: 1, reason: "optional", timeout_outcome: "expired" },
848
944
  archived_at: "2026-01-01T00:00:00.000Z",
849
945
  batch: {
850
946
  inbox: "collapse",
@@ -876,6 +972,7 @@ var ROUTES = [
876
972
  version: 1
877
973
  } },
878
974
  { op: "notificationTypes.update", method: "PATCH", pattern: /^\/v1\/workspaces\/[^\/]+\/notification-types\/[^\/]+$/, status: 200, contentType: "application/json", body: {
975
+ approval: { default_expires_in_seconds: 1, reason: "optional", timeout_outcome: "expired" },
879
976
  archived_at: "2026-01-01T00:00:00.000Z",
880
977
  batch: {
881
978
  inbox: "collapse",
@@ -981,6 +1078,23 @@ var ROUTES = [
981
1078
  updated_at: "2026-01-01T00:00:00.000Z",
982
1079
  url: "https://api.acme.com/webhooks"
983
1080
  } },
1081
+ { op: "approvals.cancel", method: "POST", pattern: /^\/v1\/workspaces\/[^\/]+\/approvals\/[^\/]+\/cancel$/, status: 200, contentType: "application/json", body: {
1082
+ approvers: ["string"],
1083
+ body: "string",
1084
+ created_at: "2026-01-01T00:00:00.000Z",
1085
+ decided_at: "2026-01-01T00:00:00.000Z",
1086
+ decided_by: "string",
1087
+ decided_via: "inbox",
1088
+ expires_at: "2026-01-01T00:00:00.000Z",
1089
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1090
+ metadata: {},
1091
+ notification_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1092
+ reason: "string",
1093
+ requester: { id: "string", kind: "agent", name: "string" },
1094
+ status: "pending",
1095
+ title: "string",
1096
+ type: "deploy.approval"
1097
+ } },
984
1098
  { op: "recipients.inbox.list", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/recipients\/[^\/]+\/inbox$/, status: 200, contentType: "application/json", body: {
985
1099
  counts: { unread: 1, unseen: 1 },
986
1100
  data: [
@@ -1210,6 +1324,24 @@ var ROUTES = [
1210
1324
  unsubscribed_all: true,
1211
1325
  updated_at: "2026-01-01T00:00:00.000Z"
1212
1326
  } },
1327
+ { op: "approvals.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/approvals\/[^\/]+$/, status: 200, contentType: "application/json", body: {
1328
+ approvers: ["string"],
1329
+ body: "string",
1330
+ created_at: "2026-01-01T00:00:00.000Z",
1331
+ decided_at: "2026-01-01T00:00:00.000Z",
1332
+ decided_by: "string",
1333
+ decided_via: "inbox",
1334
+ events: [{ actor: "string", at: "2026-01-01T00:00:00.000Z", detail: {}, kind: "decided" }],
1335
+ expires_at: "2026-01-01T00:00:00.000Z",
1336
+ id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1337
+ metadata: {},
1338
+ notification_id: "9b2f6c1e-0d6a-4a63-9a43-2f1c3e4d5a6b",
1339
+ reason: "string",
1340
+ requester: { id: "string", kind: "agent", name: "string" },
1341
+ status: "pending",
1342
+ title: "string",
1343
+ type: "deploy.approval"
1344
+ } },
1213
1345
  { op: "batches.retrieve", method: "GET", pattern: /^\/v1\/workspaces\/[^\/]+\/batches\/[^\/]+$/, status: 200, contentType: "application/json", body: {
1214
1346
  deliveries: [
1215
1347
  {