@didit-protocol/mcp-server 5.1.54 → 5.1.62

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.
Files changed (138) hide show
  1. package/README.md +14 -4
  2. package/dist/accept.d.ts +54 -0
  3. package/dist/accept.d.ts.map +1 -0
  4. package/dist/accept.js +98 -0
  5. package/dist/accept.js.map +1 -0
  6. package/dist/audit-log.d.ts.map +1 -1
  7. package/dist/audit-log.js +13 -4
  8. package/dist/audit-log.js.map +1 -1
  9. package/dist/auth/refusal-log.d.ts +62 -0
  10. package/dist/auth/refusal-log.d.ts.map +1 -0
  11. package/dist/auth/refusal-log.js +131 -0
  12. package/dist/auth/refusal-log.js.map +1 -0
  13. package/dist/chatgpt-app.d.ts +1 -0
  14. package/dist/chatgpt-app.d.ts.map +1 -1
  15. package/dist/chatgpt-app.js +4 -0
  16. package/dist/chatgpt-app.js.map +1 -1
  17. package/dist/config.d.ts +17 -1
  18. package/dist/config.d.ts.map +1 -1
  19. package/dist/config.js +62 -9
  20. package/dist/config.js.map +1 -1
  21. package/dist/connect-page.d.ts +10 -0
  22. package/dist/connect-page.d.ts.map +1 -0
  23. package/dist/connect-page.js +8 -0
  24. package/dist/connect-page.js.map +1 -0
  25. package/dist/connection-timeouts.d.ts +30 -0
  26. package/dist/connection-timeouts.d.ts.map +1 -0
  27. package/dist/connection-timeouts.js +52 -0
  28. package/dist/connection-timeouts.js.map +1 -0
  29. package/dist/http.d.ts.map +1 -1
  30. package/dist/http.js +95 -7
  31. package/dist/http.js.map +1 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +209 -3242
  34. package/dist/index.js.map +1 -1
  35. package/dist/permissions.d.ts.map +1 -1
  36. package/dist/permissions.js +3 -153
  37. package/dist/permissions.js.map +1 -1
  38. package/dist/release-version.d.ts +45 -0
  39. package/dist/release-version.d.ts.map +1 -0
  40. package/dist/release-version.js +90 -0
  41. package/dist/release-version.js.map +1 -0
  42. package/dist/schema/feature-config-schema.json +43 -4
  43. package/dist/security.d.ts.map +1 -1
  44. package/dist/security.js +41 -2
  45. package/dist/security.js.map +1 -1
  46. package/dist/tools/billing.d.ts +2 -0
  47. package/dist/tools/billing.d.ts.map +1 -1
  48. package/dist/tools/billing.js +124 -1
  49. package/dist/tools/billing.js.map +1 -1
  50. package/dist/tools/blocklist.d.ts +2 -0
  51. package/dist/tools/blocklist.d.ts.map +1 -1
  52. package/dist/tools/blocklist.js +94 -0
  53. package/dist/tools/blocklist.js.map +1 -1
  54. package/dist/tools/businesses.d.ts +2 -0
  55. package/dist/tools/businesses.d.ts.map +1 -1
  56. package/dist/tools/businesses.js +129 -0
  57. package/dist/tools/businesses.js.map +1 -1
  58. package/dist/tools/cases.d.ts +2 -0
  59. package/dist/tools/cases.d.ts.map +1 -1
  60. package/dist/tools/cases.js +131 -0
  61. package/dist/tools/cases.js.map +1 -1
  62. package/dist/tools/customization.d.ts +2 -0
  63. package/dist/tools/customization.d.ts.map +1 -1
  64. package/dist/tools/customization.js +43 -0
  65. package/dist/tools/customization.js.map +1 -1
  66. package/dist/tools/feature-config.d.ts +45 -0
  67. package/dist/tools/feature-config.d.ts.map +1 -1
  68. package/dist/tools/feature-config.js +100 -9
  69. package/dist/tools/feature-config.js.map +1 -1
  70. package/dist/tools/lists.d.ts +2 -0
  71. package/dist/tools/lists.d.ts.map +1 -1
  72. package/dist/tools/lists.js +193 -0
  73. package/dist/tools/lists.js.map +1 -1
  74. package/dist/tools/members.d.ts +2 -0
  75. package/dist/tools/members.d.ts.map +1 -1
  76. package/dist/tools/members.js +141 -0
  77. package/dist/tools/members.js.map +1 -1
  78. package/dist/tools/observability.d.ts +2 -0
  79. package/dist/tools/observability.d.ts.map +1 -1
  80. package/dist/tools/observability.js +77 -0
  81. package/dist/tools/observability.js.map +1 -1
  82. package/dist/tools/questionnaires.d.ts +2 -0
  83. package/dist/tools/questionnaires.d.ts.map +1 -1
  84. package/dist/tools/questionnaires.js +171 -0
  85. package/dist/tools/questionnaires.js.map +1 -1
  86. package/dist/tools/registered.d.ts +5 -0
  87. package/dist/tools/registered.d.ts.map +1 -0
  88. package/dist/tools/registered.js +30 -0
  89. package/dist/tools/registered.js.map +1 -0
  90. package/dist/tools/registry.d.ts +47 -0
  91. package/dist/tools/registry.d.ts.map +1 -0
  92. package/dist/tools/registry.js +40 -0
  93. package/dist/tools/registry.js.map +1 -0
  94. package/dist/tools/reports.d.ts +2 -0
  95. package/dist/tools/reports.d.ts.map +1 -1
  96. package/dist/tools/reports.js +65 -0
  97. package/dist/tools/reports.js.map +1 -1
  98. package/dist/tools/search.d.ts +2 -0
  99. package/dist/tools/search.d.ts.map +1 -1
  100. package/dist/tools/search.js +133 -3
  101. package/dist/tools/search.js.map +1 -1
  102. package/dist/tools/sessions.d.ts +3 -0
  103. package/dist/tools/sessions.d.ts.map +1 -1
  104. package/dist/tools/sessions.js +715 -8
  105. package/dist/tools/sessions.js.map +1 -1
  106. package/dist/tools/settings.d.ts +19 -0
  107. package/dist/tools/settings.d.ts.map +1 -1
  108. package/dist/tools/settings.js +93 -5
  109. package/dist/tools/settings.js.map +1 -1
  110. package/dist/tools/shared-schema.d.ts +27 -0
  111. package/dist/tools/shared-schema.d.ts.map +1 -0
  112. package/dist/tools/shared-schema.js +68 -0
  113. package/dist/tools/shared-schema.js.map +1 -0
  114. package/dist/tools/standalone.d.ts +6 -0
  115. package/dist/tools/standalone.d.ts.map +1 -1
  116. package/dist/tools/standalone.js +366 -0
  117. package/dist/tools/standalone.js.map +1 -1
  118. package/dist/tools/transactions.d.ts +3 -0
  119. package/dist/tools/transactions.d.ts.map +1 -1
  120. package/dist/tools/transactions.js +512 -0
  121. package/dist/tools/transactions.js.map +1 -1
  122. package/dist/tools/users.d.ts +2 -0
  123. package/dist/tools/users.d.ts.map +1 -1
  124. package/dist/tools/users.js +137 -0
  125. package/dist/tools/users.js.map +1 -1
  126. package/dist/tools/webhooks.d.ts +2 -0
  127. package/dist/tools/webhooks.d.ts.map +1 -1
  128. package/dist/tools/webhooks.js +98 -0
  129. package/dist/tools/webhooks.js.map +1 -1
  130. package/dist/tools/workflow-graph.d.ts +1 -0
  131. package/dist/tools/workflow-graph.d.ts.map +1 -1
  132. package/dist/tools/workflow-graph.js +107 -39
  133. package/dist/tools/workflow-graph.js.map +1 -1
  134. package/dist/tools/workflows.d.ts +3 -0
  135. package/dist/tools/workflows.d.ts.map +1 -0
  136. package/dist/tools/workflows.js +440 -0
  137. package/dist/tools/workflows.js.map +1 -0
  138. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VENDOR_USER_TOOLS = void 0;
3
4
  exports.listUsers = listUsers;
4
5
  exports.getUser = getUser;
5
6
  exports.createUser = createUser;
@@ -7,6 +8,9 @@ exports.updateUser = updateUser;
7
8
  exports.updateUserStatus = updateUserStatus;
8
9
  exports.deleteUsers = deleteUsers;
9
10
  const config_1 = require("../config");
11
+ const search_1 = require("./search");
12
+ const shared_schema_1 = require("./shared-schema");
13
+ const orgapp_1 = require("../orgapp");
10
14
  const security_1 = require("../security");
11
15
  // Vendor users — the console resource is `vendor-users`, org/app-scoped. List/get(by
12
16
  // vendor_data, legacy path)/bulk-delete map cleanly. The console keys updates by internal
@@ -49,4 +53,137 @@ async function deleteUsers(vendorDataList, deleteAll, confirm) {
49
53
  json: { vendor_data_list: vendorDataList, delete_all: wildcard },
50
54
  });
51
55
  }
56
+ // ── The vendor user tools (tools/registry.ts) ──────────────────────────────────
57
+ // Each tool declares here what index.ts and permissions.ts used to keep in their name-keyed tables.
58
+ // The definitions are listed where these tools always were, so the tool list does not change.
59
+ exports.VENDOR_USER_TOOLS = [
60
+ {
61
+ def: {
62
+ name: "didit_vendor_user_list",
63
+ description: "List verified users (grouped by vendor_data) for ONE app; with multiple apps (or no scope) it auto-spans all your apps. For a cross-app customer lookup prefer didit_vendor_user_search. Supports limit/offset pagination.",
64
+ inputSchema: {
65
+ type: "object",
66
+ properties: {
67
+ ...orgapp_1.ORG_APP_PROPS,
68
+ limit: { type: "string" },
69
+ offset: { type: "string" },
70
+ },
71
+ },
72
+ },
73
+ access: "read",
74
+ permission: "list:users", // GET …/vendor-users/ → vendor_user.py:283
75
+ run: (args) => listUsers(args),
76
+ spanAllApplications: (args) => (0, search_1.searchVendorUsers)(args),
77
+ },
78
+ {
79
+ def: {
80
+ name: "didit_vendor_user_create",
81
+ description: "Create a user record manually (e.g. to pre-register a vendor_data identity or attach allowlisted emails/phones).",
82
+ inputSchema: {
83
+ type: "object",
84
+ properties: {
85
+ ...orgapp_1.ORG_APP_PROPS,
86
+ vendor_data: { type: "string", description: "REQUIRED. Your unique identifier for the user" },
87
+ full_name: { type: "string" },
88
+ display_name: { type: "string" },
89
+ date_of_birth: { type: "string", description: "YYYY-MM-DD" },
90
+ status: { type: "string", enum: shared_schema_1.ENTITY_STATUSES },
91
+ metadata: { type: "object" },
92
+ approved_emails: { type: "array", items: { type: "string" } },
93
+ approved_phones: { type: "array", items: { type: "string" } },
94
+ issuing_states: { type: "array", items: { type: "string" } },
95
+ },
96
+ required: ["vendor_data"],
97
+ },
98
+ },
99
+ access: "write",
100
+ permission: "create:users", // POST …/vendor-users/ → vendor_user.py:330
101
+ run: (args) => createUser(args),
102
+ },
103
+ {
104
+ def: {
105
+ name: "didit_vendor_user_get",
106
+ description: "Get details of a specific user by their vendor_data identifier.",
107
+ inputSchema: {
108
+ type: "object",
109
+ properties: {
110
+ ...orgapp_1.ORG_APP_PROPS,
111
+ vendor_data: { type: "string", description: "The vendor_data value that identifies the user" },
112
+ },
113
+ required: ["vendor_data"],
114
+ },
115
+ },
116
+ access: "read",
117
+ permission: "read:users", // GET …/vendor-users/{vendor_data}/ → vendor_user.py:763
118
+ run: (args) => getUser(args.vendor_data),
119
+ },
120
+ {
121
+ def: {
122
+ name: "didit_vendor_user_update",
123
+ description: "Update a user's profile fields. Only send the fields you want to change. To change ONLY the monitoring status, prefer didit_vendor_user_update_status.",
124
+ inputSchema: {
125
+ type: "object",
126
+ properties: {
127
+ ...orgapp_1.ORG_APP_PROPS,
128
+ vendor_data: { type: "string", description: "The vendor_data value that identifies the user" },
129
+ full_name: { type: "string" },
130
+ display_name: { type: "string" },
131
+ date_of_birth: { type: "string", description: "YYYY-MM-DD" },
132
+ status: { type: "string", enum: shared_schema_1.ENTITY_STATUSES, description: "Monitoring status" },
133
+ metadata: { type: "object" },
134
+ approved_emails: { type: "array", items: { type: "string" } },
135
+ approved_phones: { type: "array", items: { type: "string" } },
136
+ issuing_states: { type: "array", items: { type: "string" } },
137
+ },
138
+ required: ["vendor_data"],
139
+ },
140
+ },
141
+ access: "write",
142
+ permission: "write:users", // PATCH …/vendor-users/{vendor_data}/update/ → vendor_user.py:1098
143
+ run: ({ vendor_data, ...data }) => updateUser(vendor_data, data),
144
+ },
145
+ {
146
+ def: {
147
+ name: "didit_vendor_user_update_status",
148
+ description: "Set a user's monitoring status (ACTIVE, FLAGGED, or BLOCKED).",
149
+ inputSchema: {
150
+ type: "object",
151
+ properties: {
152
+ ...orgapp_1.ORG_APP_PROPS,
153
+ vendor_data: { type: "string", description: "The vendor_data value that identifies the user" },
154
+ status: { type: "string", enum: shared_schema_1.ENTITY_STATUSES, description: "New status" },
155
+ },
156
+ required: ["vendor_data", "status"],
157
+ },
158
+ },
159
+ access: "write",
160
+ permission: "write:users", // POST …/vendor-users/bulk-status/ → vendor_user.py:1169
161
+ run: (args) => updateUserStatus(args.vendor_data, args.status),
162
+ },
163
+ {
164
+ def: {
165
+ name: "didit_vendor_user_delete",
166
+ description: "Batch delete users by vendor_data list, or delete all users. Deletion is permanent. If the API answers 409 (in_filed_report: a selected person is in a finalized regulatory report; subject_deletion_in_progress: another request is still deleting one of them), nothing is deleted: repeat the request once that deletion has finished.",
167
+ inputSchema: {
168
+ type: "object",
169
+ properties: {
170
+ ...orgapp_1.ORG_APP_PROPS,
171
+ vendor_data_list: {
172
+ type: "array",
173
+ items: { type: "string" },
174
+ description: "Array of vendor_data values to delete",
175
+ },
176
+ delete_all: { type: "boolean", description: "Set true to delete ALL users" },
177
+ confirm: {
178
+ type: "boolean",
179
+ description: "REQUIRED when delete_all is true - permanently removes EVERY vendor user. Only set after explicit user confirmation of this exact action.",
180
+ },
181
+ },
182
+ },
183
+ },
184
+ access: "destructive",
185
+ permission: "delete:users", // DELETE …/vendor-users/delete/ → vendor_user.py:1139
186
+ run: (args) => deleteUsers(args.vendor_data_list, args.delete_all, args.confirm),
187
+ },
188
+ ];
52
189
  //# sourceMappingURL=users.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"users.js","sourceRoot":"","sources":["../../src/tools/users.ts"],"names":[],"mappings":";;AAQA,8BAEC;AAED,0BAEC;AAED,gCAEC;AAED,gCAEC;AAED,4CAKC;AAED,kCAgBC;AA/CD,sCAAmD;AACnD,0CAAoF;AAEpF,qFAAqF;AACrF,0FAA0F;AAC1F,mFAAmF;AACnF,+EAA+E;AAExE,KAAK,UAAU,SAAS,CAAC,MAA+B;IAC7D,OAAO,IAAA,mBAAU,EAAC,IAAA,mBAAU,EAAC,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAC9D,CAAC;AAEM,KAAK,UAAU,OAAO,CAAC,UAAkB;IAC9C,OAAO,IAAA,mBAAU,EAAC,IAAA,mBAAU,EAAC,iBAAiB,IAAA,sBAAW,EAAC,UAAU,EAAE,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9G,CAAC;AAEM,KAAK,UAAU,UAAU,CAAC,IAAyB;IACxD,OAAO,IAAA,mBAAU,EAAC,IAAA,mBAAU,EAAC,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAClF,CAAC;AAEM,KAAK,UAAU,UAAU,CAAC,UAAkB,EAAE,IAAyB;IAC5E,OAAO,IAAA,mBAAU,EAAC,I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AE,gDAAgD,EAAE;oBAC9F,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,+BAAe,EAAE,WAAW,EAAE,YAAY,EAAE;iBAC7E;gBACD,QAAQ,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC;aACpC;SACF;QACD,MAAM,EAAE,OAAO;QACf,UAAU,EAAE,aAAa,EAAE,yDAAyD;QACpF,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC;KAC/D;IACD;QACE,GAAG,EAAE;YACH,IAAI,EAAE,0BAA0B;YAChC,WAAW,EAAE,2UAA2U;YACxV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAiB;gBACvB,UAAU,EAAE;oBACV,GAAG,sBAAa;oBAChB,gBAAgB,EAAE;wBAChB,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACzB,WAAW,EAAE,uCAAuC;qBACrD;oBACD,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,8BAA8B,EAAE;oBAC5E,OAAO,EAAE;wBACP,IAAI,EAAE,SAAS;wBACf,WAAW,EACT,2IAA2I;qBAC9I;iBACF;aACF;SACF;QACD,MAAM,EAAE,aAAa;QACrB,UAAU,EAAE,cAAc,EAAE,sDAAsD;QAClF,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC;KACjF;CACF,CAAC"}
@@ -1,6 +1,8 @@
1
+ import type { RegisteredTool } from "./registry";
1
2
  export declare function listDestinations(): Promise<any>;
2
3
  export declare function createDestination(data: Record<string, any>): Promise<any>;
3
4
  export declare function getDestination(destinationUuid: string): Promise<any>;
4
5
  export declare function updateDestination(destinationUuid: string, data: Record<string, any>): Promise<any>;
5
6
  export declare function deleteDestination(destinationUuid: string): Promise<any>;
7
+ export declare const WEBHOOK_TOOLS: readonly RegisteredTool[];
6
8
  //# sourceMappingURL=webhooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/tools/webhooks.ts"],"names":[],"mappings":"AAeA,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,CAErD;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAI/E;AAED,wBAAsB,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAI1E;AAED,wBAAsB,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAOxG;AAED,wBAAsB,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAI7E"}
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/tools/webhooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAejD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,CAErD;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAI/E;AAED,wBAAsB,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAI1E;AAED,wBAAsB,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAOxG;AAED,wBAAsB,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAI7E;AAKD,eAAO,MAAM,aAAa,EAAE,SAAS,cAAc,EA4FlD,CAAC"}
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WEBHOOK_TOOLS = void 0;
3
4
  exports.listDestinations = listDestinations;
4
5
  exports.createDestination = createDestination;
5
6
  exports.getDestination = getDestination;
6
7
  exports.updateDestination = updateDestination;
7
8
  exports.deleteDestination = deleteDestination;
8
9
  const config_1 = require("../config");
10
+ const orgapp_1 = require("../orgapp");
9
11
  const security_1 = require("../security");
10
12
  // Webhook destinations are org/app-scoped console resources (paths match 1:1).
11
13
  // The signing secret is redacted on every read; the destination URL is SSRF-guarded
@@ -38,4 +40,100 @@ async function deleteDestination(destinationUuid) {
38
40
  method: "DELETE",
39
41
  });
40
42
  }
43
+ // ── The webhook tools (tools/registry.ts) ──────────────────────────────────
44
+ // Each tool declares here what index.ts and permissions.ts used to keep in their name-keyed tables.
45
+ // The definitions are listed where the webhook tools always were, so the tool list does not change.
46
+ exports.WEBHOOK_TOOLS = [
47
+ {
48
+ def: {
49
+ name: "didit_webhook_list",
50
+ description: "List configured webhook destinations. Each destination has its own URL, version, enabled flag, subscribed events, and redacted signing-secret metadata.",
51
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
52
+ },
53
+ access: "read",
54
+ permission: "read:webhooks", // GET …/webhook/destinations/ → webhook_destinations.py:106
55
+ run: () => listDestinations(),
56
+ },
57
+ {
58
+ def: {
59
+ name: "didit_webhook_create",
60
+ description: "Create a webhook destination. The signing secret is redacted in the response.",
61
+ inputSchema: {
62
+ type: "object",
63
+ properties: {
64
+ ...orgapp_1.ORG_APP_PROPS,
65
+ label: { type: "string", description: "REQUIRED. Human-readable name" },
66
+ url: { type: "string", description: "REQUIRED. HTTPS endpoint to receive events" },
67
+ enabled: { type: "boolean", description: "Whether the destination receives events (default true)" },
68
+ webhook_version: { type: "string", enum: ["v1", "v2", "v3"], description: "Payload version (v3 recommended)" },
69
+ subscribed_events: { type: "array", items: { type: "string" }, description: "Event types to deliver (e.g. status.updated, data.updated, user.created). Omit to receive all." },
70
+ },
71
+ required: ["label", "url"],
72
+ },
73
+ },
74
+ // Registers an endpoint outside Didit that Didit then delivers verification data to.
75
+ access: "write",
76
+ openWorld: true,
77
+ permission: "write:webhooks", // POST …/webhook/destinations/ → webhook_destinations.py:112
78
+ run: (args) => createDestination(args),
79
+ },
80
+ {
81
+ def: {
82
+ name: "didit_webhook_get",
83
+ description: "Get a single webhook destination with redacted signing-secret metadata.",
84
+ inputSchema: {
85
+ type: "object",
86
+ properties: {
87
+ ...orgapp_1.ORG_APP_PROPS,
88
+ destination_uuid: { type: "string", description: "Webhook destination UUID" },
89
+ },
90
+ required: ["destination_uuid"],
91
+ },
92
+ },
93
+ access: "read",
94
+ permission: "read:webhooks", // GET …/webhook/destinations/{uuid}/ → webhook_destinations.py:151
95
+ run: (args) => getDestination(args.destination_uuid),
96
+ },
97
+ {
98
+ def: {
99
+ name: "didit_webhook_update",
100
+ description: "Overwrite the supplied settings of an existing webhook destination. Changing its URL redirects future deliveries; disabling it stops deliveries, and subscribed_events replaces its event subscriptions. Before calling, show the destination UUID and each proposed field change and obtain explicit user confirmation.",
101
+ inputSchema: {
102
+ type: "object",
103
+ properties: {
104
+ ...orgapp_1.ORG_APP_PROPS,
105
+ destination_uuid: { type: "string", description: "Webhook destination UUID" },
106
+ label: { type: "string" },
107
+ url: { type: "string" },
108
+ enabled: { type: "boolean" },
109
+ webhook_version: { type: "string", enum: ["v1", "v2", "v3"] },
110
+ subscribed_events: { type: "array", items: { type: "string" } },
111
+ },
112
+ required: ["destination_uuid"],
113
+ },
114
+ },
115
+ // Can redirect future deliveries to another URL, or stop them: a client asks before running it.
116
+ access: "destructive",
117
+ openWorld: true,
118
+ permission: "write:webhooks", // PATCH …/webhook/destinations/{uuid}/ → webhook_destinations.py:160
119
+ run: ({ destination_uuid, ...data }) => updateDestination(destination_uuid, data),
120
+ },
121
+ {
122
+ def: {
123
+ name: "didit_webhook_delete",
124
+ description: "Delete a webhook destination so it stops receiving events.",
125
+ inputSchema: {
126
+ type: "object",
127
+ properties: {
128
+ ...orgapp_1.ORG_APP_PROPS,
129
+ destination_uuid: { type: "string", description: "Webhook destination UUID" },
130
+ },
131
+ required: ["destination_uuid"],
132
+ },
133
+ },
134
+ access: "destructive",
135
+ permission: "write:webhooks", // DELETE …/webhook/destinations/{uuid}/ → webhook_destinations.py:181
136
+ run: (args) => deleteDestination(args.destination_uuid),
137
+ },
138
+ ];
41
139
  //# sourceMappingURL=webhooks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/tools/webhooks.ts"],"names":[],"mappings":";;AAeA,4CAEC;AAED,8CAIC;AAED,wCAIC;AAED,8CAOC;AAED,8CAIC;AA5CD,sCAAmD;AACnD,0CAA4G;AAE5G,+EAA+E;AAC/E,oFAAoF;AACpF,sDAAsD;AAEtD,SAAS,gBAAgB,CAAC,IAAyB;IACjD,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;IACxB,KAAK,MAAM,KAAK,IAAI,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,CAAC,EAAE,CAAC;QACrE,IAAI,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,QAAQ;YAAE,GAAG,CAAC,KAAK,CAAC,GAAG,IAAA,+BAAoB,EAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAEM,KAAK,UAAU,gBAAgB;IACpC,OAAO,IAAA,2BAAgB,EAAC,MAAM,IAAA,mBAAU,EAAC,IAAA,mBAAU,EAAC,wBAAwB,CAAC,CAAC,EAAE,mCAAwB,CAAC,CAAC;AAC5G,CAAC;AAEM,KAAK,UAAU,i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EAAE,IAAI,CAAC,EAAE;oBAC7D,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;iBAChE;gBACD,QAAQ,EAAE,CAAC,kBAAkB,CAAC;aAC/B;SACF;QACD,gGAAgG;QAChG,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,gBAAgB,EAAE,qEAAqE;QACnG,GAAG,EAAE,CAAC,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,IAAI,CAAC;KAClF;IACD;QACE,GAAG,EAAE;YACH,IAAI,EAAE,sBAAsB;YAC5B,WAAW,EAAE,4DAA4D;YACzE,WAAW,EAAE;gBACX,IAAI,EAAE,QAAiB;gBACvB,UAAU,EAAE;oBACV,GAAG,sBAAa;oBAChB,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0BAA0B,EAAE;iBAC9E;gBACD,QAAQ,EAAE,CAAC,kBAAkB,CAAC;aAC/B;SACF;QACD,MAAM,EAAE,aAAa;QACrB,UAAU,EAAE,gBAAgB,EAAE,sEAAsE;QACpG,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,CAAC;KACxD;CACF,CAAC"}
@@ -10,6 +10,7 @@ interface GraphOp {
10
10
  branches?: any[];
11
11
  start_node?: string;
12
12
  config?: Record<string, any>;
13
+ replace?: boolean;
13
14
  }
14
15
  /** Annotate each non-archived row with its age-assurance verdict, in place. */
15
16
  export declare function annotateAgeAssurance(payload: any): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-graph.d.ts","sourceRoot":"","sources":["../../src/tools/workflow-graph.ts"],"names":[],"mappings":"AAkBA,UAAU,KAAK;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAA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AACpE,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,GAAE,KAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAI7F;AA6GD;;;mCAGmC;AACnC,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,GAAE,KAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAoBzF;AAED;;6CAE6C;AAC7C,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,GAAG,EACV,OAAO,UAAQ,EACf,KAAK,GAAE,KAAU,GAChB,OAAO,CAAC,GAAG,CAAC,CAkDd;AAiBD;;;;wGAIwG;AACxG,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,OAAO,EAAE,EACrB,OAAO,UAAQ,EACf,KAAK,GAAE,KAAU,GAChB,OAAO,CAAC,GAAG,CAAC,CAqFd"}
@@ -18,6 +18,7 @@ const orgapp_1 = require("../orgapp");
18
18
  const search_1 = require("./search");
19
19
  const security_1 = require("../security");
20
20
  const feature_config_1 = require("./feature-config");
21
+ const settings_1 = require("./settings");
21
22
  // Real workflows carry huge feature configs (OCR `documents_allowed` ~157KB, POA
22
23
  // `poa_documents_allowed` ~49KB, phone-country lists, …). Returning or requiring those verbatim
23
24
  // overflows the model's context and makes edits fragile. We (a) summarize big config values when
@@ -64,6 +65,18 @@ function summarizeGraph(graph) {
64
65
  }
65
66
  return { start_node: graph.start_node, nodes };
66
67
  }
68
+ const isPlainObject = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
69
+ /** A map-valued config key (age_restrictions_by_country, documents_allowed, …) merges by entry:
70
+ * the entries sent update or add, the others are kept. Replacing the whole map is what turned
71
+ * `{GBR: 21}` into a 1-country age table that had held 237. Arrays and scalars replace, and so
72
+ * does any value when the op says `replace`. */
73
+ function mergeConfigValue(current, value, replace = false) {
74
+ return !replace && isPlainObject(current) && isPlainObject(value) ? { ...current, ...value } : value;
75
+ }
76
+ function mergeConfig(config, op) {
77
+ const merged = Object.entries(op.config || {}).map(([key, value]) => [key, mergeConfigValue(config[key], value, op.replace)]);
78
+ return { ...config, ...Object.fromEntries(merged) };
79
+ }
67
80
  function requireNode(graph, id) {
68
81
  if (!id || !graph.nodes?.[id]) {
69
82
  throw new Error(`Graph op references node '${id}' which does not exist. Existing nodes: ` +
@@ -107,7 +120,7 @@ function applyGraphOps(graph, operations) {
107
120
  break;
108
121
  case "merge_node_config":
109
122
  requireNode(g, op.node_id);
110
- g.nodes[op.node_id].config = { ...(g.nodes[op.node_id].config || {}), ...(op.config || {}) };
123
+ g.nodes[op.node_id].config = mergeConfig(g.nodes[op.node_id].config || {}, op);
111
124
  changes.push(`${op.node_id}.config merged (${Object.keys(op.config || {}).join(", ")})`);
112
125
  break;
113
126
  default:
@@ -456,10 +469,17 @@ async function validateWorkflowGraph(workflowId, graph, scope = {}, includeConfi
456
469
  method: "POST",
457
470
  json: { graph, ...identity },
458
471
  });
472
+ // The graph in the answer is the graph as the API accepted it: a setting that was sent and is
473
+ // not in it would be left out of a save without an error. Said here, before anything is saved.
474
+ const lost = (0, feature_config_1.lostSettings)(graph, result?.graph);
475
+ const checked = {
476
+ ...result,
477
+ ...(lost.dropped.length > 0 ? { dropped_config_keys: lost.dropped, note: (0, feature_config_1.droppedSettingsNote)(lost, "dry run") } : {}),
478
+ };
459
479
  if (includeConfig || !result?.graph)
460
- return result;
480
+ return checked;
461
481
  return {
462
- ...result,
482
+ ...checked,
463
483
  graph: summarizeGraph(result.graph),
464
484
  config_summarized: true,
465
485
  hint: "Large feature config values are summarized. Pass include_config:true to return them verbatim.",
@@ -473,28 +493,25 @@ async function validateWorkflowGraph(workflowId, graph, scope = {}, includeConfi
473
493
  async function createWorkflowDraft(workflowId, scope = {}) {
474
494
  return inScope(workflowId, scope, (wf) => (0, config_1.apiRequest)((0, config_1.orgAppPath)(`/verification-settings/${(0, security_1.pathSegment)(wf.uuid, "workflow_id")}/create-draft/`), { method: "POST" }));
475
495
  }
476
- /** The graph as the backend STORED it, or null when it could not be re-read. Deliberately has no
477
- * fallback to the graph we sent: returning the intent as if it were the result is how "I removed
478
- * those fields" survived a save that kept them. */
479
- async function persistedGraph(uuid) {
480
- try {
481
- const res = await (0, config_1.apiRequest)((0, config_1.orgAppPath)(`/verification-settings/${(0, security_1.pathSegment)(uuid, "workflow_id")}/workflow-graph/`));
482
- return res?.graph ?? res ?? null;
483
- }
484
- catch {
485
- return null;
486
- }
496
+ /** Whether a stored config value holds what a merge asked for. A merged map must keep every entry
497
+ * of the map that was submitted, the ones the edit did not mention included (extra entries the API
498
+ * adds are fine); any other value must equal the op's. */
499
+ function holdsRequested(stored, submitted, op, key) {
500
+ const requested = op.config[key];
501
+ if (op.replace || !isPlainObject(requested) || !isPlainObject(submitted))
502
+ return (0, node_util_1.isDeepStrictEqual)(stored, requested);
503
+ return isPlainObject(stored) && Object.entries(submitted).every(([entry, value]) => (0, node_util_1.isDeepStrictEqual)(stored[entry], value));
487
504
  }
488
505
  /** Config keys a merge_node_config op asked for that the STORED graph does not match. Reported as
489
506
  * UNCONFIRMED rather than dropped: the backend may legitimately normalise a value it accepted, so
490
507
  * the honest claim is "re-read this before telling the user it changed" — which is the check that
491
508
  * was missing when seven registry fields were reported removed and were still being collected. */
492
- function unconfirmedConfigKeys(stored, operations) {
509
+ function unconfirmedConfigKeys(stored, operations, submitted) {
493
510
  const nodes = stored?.nodes ?? {};
494
511
  return operations.flatMap((op) => op.op !== "merge_node_config" || !op.config || !op.node_id
495
512
  ? []
496
513
  : Object.keys(op.config)
497
- .filter((key) => !(0, node_util_1.isDeepStrictEqual)(nodes[op.node_id]?.config?.[key], op.config[key]))
514
+ .filter((key) => !holdsRequested(nodes[op.node_id]?.config?.[key], submitted?.nodes?.[op.node_id]?.config?.[key], op, key))
498
515
  .map((key) => `${op.node_id}.config.${key}`));
499
516
  }
500
517
  /** What the caller may claim about a save. Names the version_uuid a publish has to target, because
@@ -508,10 +525,30 @@ function readBackNote(stored, published, versionUuid) {
508
525
  }
509
526
  if (published)
510
527
  return `Saved and published — version ${versionUuid} is live for new sessions.`;
511
- return (`Saved to DRAFT version ${versionUuid}, which is NOT live. Publish it with ` +
528
+ return (`Saved to DRAFT version ${versionUuid}, which is NOT live; pass that version_uuid to later ` +
529
+ `edits too, they build on this draft. Publish it with ` +
512
530
  `didit_workflow_publish({ workflow_id: "${versionUuid}" }) — passing the stable workflow_id ` +
513
531
  `instead targets the version that is already published. Existing sessions are unaffected.`);
514
532
  }
533
+ /**
534
+ * The save's note, led by what was lost on the way in. `heldBack`: a publish was asked for and not
535
+ * done. `unverified`: settings were sent and what was stored could not be read.
536
+ */
537
+ function lostNote(lost, heldBack, saved, unverified = false) {
538
+ return [
539
+ heldBack
540
+ ? lost.dropped.length > 0
541
+ ? "NOT published, because the version does not hold everything that was asked for."
542
+ : "NOT published, because what the API stored could not be checked."
543
+ : "",
544
+ (0, feature_config_1.droppedSettingsNote)(lost),
545
+ unverified ? feature_config_1.UNVERIFIED_SETTINGS_NOTE : "",
546
+ (0, feature_config_1.unconfirmedSettingsNote)(lost),
547
+ saved,
548
+ ]
549
+ .filter(Boolean)
550
+ .join(" ");
551
+ }
515
552
  /** PATCH one version to published and report the status the API CONFIRMS, never the one we asked
516
553
  * for. A body carrying no status (204, bare success) means the PATCH did not error but nothing
517
554
  * read it back, so it is reported as unconfirmed instead of being dressed up as a read-back. */
@@ -561,7 +598,9 @@ async function publishWorkflow(workflowId, scope = {}) {
561
598
  version_uuid: target,
562
599
  status,
563
600
  published: live,
601
+ is_live_version: live,
564
602
  status_confirmed: confirmed,
603
+ ids_note: settings_1.WORKFLOW_IDS_NOTE,
565
604
  note: live
566
605
  ? `Version ${target} is live for new sessions. Existing sessions are unaffected.`
567
606
  : `The API reports status "${status}" for version ${target} after the publish — it is NOT ` +
@@ -591,8 +630,13 @@ async function setWorkflowGraph(workflowId, graph, publish = false, scope = {})
591
630
  method: "PUT",
592
631
  json: { graph },
593
632
  });
594
- const stored = await persistedGraph(targetUuid);
595
- const published = publish ? (await publishVersion(targetUuid)).status === "published" : false;
633
+ const stored = await (0, settings_1.storedWorkflowGraph)(targetUuid);
634
+ // A version that lost a setting on the way in is not put live (see lostSettings).
635
+ const lost = (0, feature_config_1.lostSettings)(graph, stored);
636
+ // Settings were sent and what was stored could not be read: nothing was compared, so nothing goes live.
637
+ const unverified = stored === null && (0, feature_config_1.carriesSettings)(graph);
638
+ const heldBack = publish && (lost.dropped.length > 0 || unverified);
639
+ const published = publish && !heldBack ? (await publishVersion(targetUuid)).status === "published" : false;
596
640
  return {
597
641
  workflow_id: workflowId,
598
642
  version_uuid: targetUuid,
@@ -603,10 +647,28 @@ async function setWorkflowGraph(workflowId, graph, publish = false, scope = {})
603
647
  status: published ? "published" : "draft",
604
648
  graph_read_back: stored !== null,
605
649
  ...(stored ? { graph: summarizeGraph(stored) } : {}),
606
- note: readBackNote(stored, published, targetUuid),
650
+ ...(lost.dropped.length > 0 ? { dropped_config_keys: lost.dropped } : {}),
651
+ ...(lost.unconfirmed.length > 0 ? { unconfirmed_config_keys: lost.unconfirmed } : {}),
652
+ ...(unverified ? { settings_verified: false } : {}),
653
+ note: lostNote(lost, heldBack, readBackNote(stored, published, targetUuid), unverified),
607
654
  };
608
655
  });
609
656
  }
657
+ /** The draft an edit reads AND saves. create-draft is idempotent (max 1 draft per workflow group):
658
+ * it hands back the draft that already holds earlier edits, or clones the live version when there
659
+ * is none. Reading the published graph and saving it over that draft reverted every earlier edit
660
+ * while each save reported applied:true (prod 14-nov: age 21 and expiry REVIEW flip-flopped 3×). */
661
+ async function draftToEdit(wf) {
662
+ if (String(wf.status ?? "").toLowerCase() === "draft")
663
+ return { uuid: wf.uuid, created: false };
664
+ const draft = await (0, config_1.apiRequest)((0, config_1.orgAppPath)(`/verification-settings/${(0, security_1.pathSegment)(wf.uuid, "workflow_id")}/create-draft/`), {
665
+ method: "POST",
666
+ });
667
+ const uuid = draft?.uuid ?? draft?.workflow_id;
668
+ if (!uuid)
669
+ throw new Error(`Could not resolve the draft version of ${wf.uuid} to edit; nothing was saved.`);
670
+ return { uuid, created: true };
671
+ }
610
672
  /** Edit a workflow's graph with small OPERATIONS instead of resending the whole thing. The MCP
611
673
  * fetches the full current graph SERVER-SIDE, applies the ops, validates, and (auto-drafting a
612
674
  * published workflow) saves it — so huge feature configs (documents_allowed, poa lists, phone
@@ -618,21 +680,23 @@ async function editWorkflowGraph(workflowId, operations, publish = false, scope
618
680
  }
619
681
  const { organizationId, applicationId, workflow } = await (0, search_1.resolveWorkflowScope)(workflowId, scope.organization_id, scope.application_id);
620
682
  return (0, orgapp_1.runForScope)(organizationId, applicationId, async () => {
621
- // 1. Fetch the FULL current graph server-side (allow-lists included; never sent by the model).
622
- const current = await (0, config_1.apiRequest)((0, config_1.orgAppPath)(`/verification-settings/${(0, security_1.pathSegment)(workflow.uuid, "workflow_id")}/workflow-graph/`));
683
+ // 1. The DRAFT the edit lands on (the live published version is never mutated).
684
+ const { uuid: targetUuid, created: createdDraft } = await draftToEdit(workflow);
685
+ // 2. Fetch that draft's FULL graph server-side (allow-lists included; never sent by the model).
686
+ const current = await (0, config_1.apiRequest)((0, config_1.orgAppPath)(`/verification-settings/${(0, security_1.pathSegment)(targetUuid, "workflow_id")}/workflow-graph/`));
623
687
  const baseGraph = current?.graph ?? current;
624
- // 2. Apply the small ops in memory, then normalize branch catch-alls to explicit else branches.
688
+ // 3. Apply the small ops in memory, then normalize branch catch-alls to explicit else branches.
625
689
  const { graph: merged, changes } = applyGraphOps(baseGraph, operations);
626
690
  (0, feature_config_1.normalizeFeatureConfigs)(merged);
627
691
  normalizeBranchElse(merged);
628
692
  (0, feature_config_1.resolveBranchRuleNodeIds)(merged);
629
693
  (0, feature_config_1.assertKycKybSegregation)(merged);
630
- // 3. Dry-run validate server-side. Return cleanly on failure — never save a broken graph.
694
+ // 4. Dry-run validate server-side. Return cleanly on failure — never save a broken graph.
631
695
  let validation;
632
696
  try {
633
697
  validation = await (0, config_1.apiRequest)((0, config_1.orgAppPath)(`/workflow-graph/validate/`), {
634
698
  method: "POST",
635
- json: { graph: merged, workflow_uuid: workflow.uuid },
699
+ json: { graph: merged, workflow_uuid: targetUuid },
636
700
  });
637
701
  }
638
702
  catch (e) {
@@ -646,40 +710,44 @@ async function editWorkflowGraph(workflowId, operations, publish = false, scope
646
710
  note: "Validation failed — nothing was saved. Fix the reported issues and retry.",
647
711
  };
648
712
  }
649
- // 4. Apply to a DRAFT (the live published version is never mutated).
650
- let targetUuid = workflow.uuid;
651
- let createdDraft = false;
652
- if (String(workflow.status ?? "").toLowerCase() !== "draft") {
653
- const draft = await (0, config_1.apiRequest)((0, config_1.orgAppPath)(`/verification-settings/${(0, security_1.pathSegment)(workflow.uuid, "workflow_id")}/create-draft/`), { method: "POST" });
654
- targetUuid = draft?.uuid ?? draft?.workflow_id ?? targetUuid;
655
- createdDraft = true;
656
- }
713
+ // 5. Save to the draft the graph was read from.
657
714
  await (0, config_1.apiRequest)((0, config_1.orgAppPath)(`/verification-settings/${(0, security_1.pathSegment)(targetUuid, "workflow_id")}/workflow-graph/`), {
658
715
  method: "PUT",
659
716
  json: { graph: merged },
660
717
  });
661
- const stored = await persistedGraph(targetUuid);
662
- const unconfirmed = stored ? unconfirmedConfigKeys(stored, operations) : [];
663
- const published = publish ? (await publishVersion(targetUuid)).status === "published" : false;
718
+ const stored = await (0, settings_1.storedWorkflowGraph)(targetUuid);
719
+ // Two different answers: a key the API does not know was left out (dropped), a key it knows
720
+ // was stored with another value than the one asked for (unconfirmed).
721
+ const lost = (0, feature_config_1.lostSettings)(merged, stored);
722
+ const unconfirmed = [
723
+ ...new Set([...(stored ? unconfirmedConfigKeys(stored, operations, merged) : []), ...lost.unconfirmed]),
724
+ ].filter((key) => !lost.dropped.includes(key));
725
+ const unverified = stored === null && operations.some(feature_config_1.operationCarriesSettings);
726
+ const heldBack = publish && (lost.dropped.length > 0 || unverified);
727
+ const published = publish && !heldBack ? (await publishVersion(targetUuid)).status === "published" : false;
664
728
  return {
665
729
  applied: true,
666
730
  changes,
667
- workflow_id: workflowId,
731
+ workflow_id: workflow.workflow_id ?? workflowId,
668
732
  version_uuid: targetUuid,
669
733
  organization_id: organizationId,
670
734
  application_id: applicationId,
671
735
  created_draft: createdDraft,
672
736
  published,
737
+ is_live_version: published,
673
738
  status: published ? "published" : "draft",
739
+ ids_note: settings_1.WORKFLOW_IDS_NOTE,
674
740
  node_count: Object.keys(merged.nodes || {}).length,
675
741
  graph_read_back: stored !== null,
676
742
  ...(stored ? { graph: summarizeGraph(stored) } : {}),
743
+ ...(lost.dropped.length > 0 ? { dropped_config_keys: lost.dropped } : {}),
677
744
  ...(unconfirmed.length > 0 ? { unconfirmed_config_keys: unconfirmed } : {}),
678
- note: unconfirmed.length > 0
745
+ ...(unverified ? { settings_verified: false } : {}),
746
+ note: lostNote({ ...lost, unconfirmed: [] }, heldBack, unconfirmed.length > 0
679
747
  ? `The stored graph does NOT match what was requested for ${unconfirmed.join(", ")}. ` +
680
748
  `Re-read those with didit_workflow_get_graph before telling the user they changed. ` +
681
749
  readBackNote(stored, published, targetUuid)
682
- : readBackNote(stored, published, targetUuid),
750
+ : readBackNote(stored, published, targetUuid), unverified),
683
751
  };
684
752
  });
685
753
  }