@daeda/mcp-pro 0.1.36 → 0.1.37
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.
- package/dist/index.js +1275 -409
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
-
import { Effect as
|
|
6
|
+
import { Effect as Effect119, Layer as Layer10, pipe as pipe98 } from "effect";
|
|
7
7
|
|
|
8
8
|
// src/plugins/crm-data.ts
|
|
9
9
|
import { Effect, pipe } from "effect";
|
|
@@ -8409,7 +8409,7 @@ Use "all" to get everything at once.`,
|
|
|
8409
8409
|
}
|
|
8410
8410
|
|
|
8411
8411
|
// src/tools/build_plan.ts
|
|
8412
|
-
import { z as
|
|
8412
|
+
import { z as z82 } from "zod";
|
|
8413
8413
|
|
|
8414
8414
|
// src/tools/draft_state.ts
|
|
8415
8415
|
var drafts = /* @__PURE__ */ new Map();
|
|
@@ -8448,10 +8448,10 @@ var clearDraft = (portalId) => {
|
|
|
8448
8448
|
};
|
|
8449
8449
|
|
|
8450
8450
|
// src/pure/operation-conversion.ts
|
|
8451
|
-
import { z as
|
|
8451
|
+
import { z as z81 } from "zod";
|
|
8452
8452
|
|
|
8453
8453
|
// ../shared/types/plan.ts
|
|
8454
|
-
import { z as
|
|
8454
|
+
import { z as z80 } from "zod";
|
|
8455
8455
|
|
|
8456
8456
|
// ../shared/operations/create-property/meta.ts
|
|
8457
8457
|
import { z as z27 } from "zod";
|
|
@@ -8776,8 +8776,8 @@ var createPropertyMeta = {
|
|
|
8776
8776
|
]
|
|
8777
8777
|
}
|
|
8778
8778
|
},
|
|
8779
|
-
toNested: (description,
|
|
8780
|
-
const { object_type, property_description, ...rest } =
|
|
8779
|
+
toNested: (description, fields51) => {
|
|
8780
|
+
const { object_type, property_description, ...rest } = fields51;
|
|
8781
8781
|
const property = {
|
|
8782
8782
|
...rest,
|
|
8783
8783
|
...property_description !== void 0 ? { description: property_description } : {}
|
|
@@ -8786,7 +8786,7 @@ var createPropertyMeta = {
|
|
|
8786
8786
|
type: "create_property",
|
|
8787
8787
|
object_type,
|
|
8788
8788
|
description,
|
|
8789
|
-
...typeof
|
|
8789
|
+
...typeof fields51.ref === "string" ? { ref: fields51.ref } : {},
|
|
8790
8790
|
property
|
|
8791
8791
|
};
|
|
8792
8792
|
},
|
|
@@ -8853,8 +8853,8 @@ var updatePropertyMeta = {
|
|
|
8853
8853
|
]
|
|
8854
8854
|
}
|
|
8855
8855
|
},
|
|
8856
|
-
toNested: (description,
|
|
8857
|
-
const { object_type, property_name, new_label, new_description, new_group_name, options: options2, ...rest } =
|
|
8856
|
+
toNested: (description, fields51) => {
|
|
8857
|
+
const { object_type, property_name, new_label, new_description, new_group_name, options: options2, ...rest } = fields51;
|
|
8858
8858
|
const updates = {};
|
|
8859
8859
|
if (new_label !== void 0) updates.label = new_label;
|
|
8860
8860
|
if (new_description !== void 0) updates.description = new_description;
|
|
@@ -8908,7 +8908,7 @@ var deletePropertyMeta = {
|
|
|
8908
8908
|
example: {
|
|
8909
8909
|
fields: { object_type: "contacts", property_name: "old_custom_field" }
|
|
8910
8910
|
},
|
|
8911
|
-
toNested: (description,
|
|
8911
|
+
toNested: (description, fields51) => ({ type: "delete_property", description, ...fields51 }),
|
|
8912
8912
|
requiredScopes: (op) => [getWriteScope(op.object_type)],
|
|
8913
8913
|
getSummary: (op) => `Delete Property \u2014 ${capitalize(op.object_type)}: ${String(op.property_name)}`,
|
|
8914
8914
|
getResourceUrl: () => null,
|
|
@@ -8953,13 +8953,13 @@ var createPropertyGroupMeta = {
|
|
|
8953
8953
|
display_order: 1
|
|
8954
8954
|
}
|
|
8955
8955
|
},
|
|
8956
|
-
toNested: (description,
|
|
8957
|
-
const { object_type, name, label, display_order } =
|
|
8956
|
+
toNested: (description, fields51) => {
|
|
8957
|
+
const { object_type, name, label, display_order } = fields51;
|
|
8958
8958
|
return {
|
|
8959
8959
|
type: "create_property_group",
|
|
8960
8960
|
object_type,
|
|
8961
8961
|
description,
|
|
8962
|
-
...typeof
|
|
8962
|
+
...typeof fields51.ref === "string" ? { ref: fields51.ref } : {},
|
|
8963
8963
|
group: {
|
|
8964
8964
|
name,
|
|
8965
8965
|
label,
|
|
@@ -9020,8 +9020,8 @@ var updatePropertyGroupMeta = {
|
|
|
9020
9020
|
new_label: "Sales Fields"
|
|
9021
9021
|
}
|
|
9022
9022
|
},
|
|
9023
|
-
toNested: (description,
|
|
9024
|
-
const { object_type, group_name, new_label, new_display_order } =
|
|
9023
|
+
toNested: (description, fields51) => {
|
|
9024
|
+
const { object_type, group_name, new_label, new_display_order } = fields51;
|
|
9025
9025
|
const updates = {};
|
|
9026
9026
|
if (new_label !== void 0) updates.label = new_label;
|
|
9027
9027
|
if (new_display_order !== void 0) updates.display_order = new_display_order;
|
|
@@ -9070,7 +9070,7 @@ var deletePropertyGroupMeta = {
|
|
|
9070
9070
|
example: {
|
|
9071
9071
|
fields: { object_type: "contacts", group_name: "old_custom_group" }
|
|
9072
9072
|
},
|
|
9073
|
-
toNested: (description,
|
|
9073
|
+
toNested: (description, fields51) => ({ type: "delete_property_group", description, ...fields51 }),
|
|
9074
9074
|
requiredScopes: (op) => [getWriteScope(op.object_type)],
|
|
9075
9075
|
getSummary: (op) => `Delete Property Group \u2014 ${capitalize(op.object_type)}: ${String(op.group_name)}`,
|
|
9076
9076
|
getResourceUrl: () => null,
|
|
@@ -9131,13 +9131,13 @@ var createPipelineMeta = {
|
|
|
9131
9131
|
]
|
|
9132
9132
|
}
|
|
9133
9133
|
},
|
|
9134
|
-
toNested: (description,
|
|
9135
|
-
const { object_type, label, display_order, stages, ...rest } =
|
|
9134
|
+
toNested: (description, fields51) => {
|
|
9135
|
+
const { object_type, label, display_order, stages, ...rest } = fields51;
|
|
9136
9136
|
return {
|
|
9137
9137
|
type: "create_pipeline",
|
|
9138
9138
|
object_type,
|
|
9139
9139
|
description,
|
|
9140
|
-
...typeof
|
|
9140
|
+
...typeof fields51.ref === "string" ? { ref: fields51.ref } : {},
|
|
9141
9141
|
pipeline: { label, display_order, stages, ...rest }
|
|
9142
9142
|
};
|
|
9143
9143
|
},
|
|
@@ -9209,8 +9209,8 @@ var updatePipelineMeta = {
|
|
|
9209
9209
|
stages_to_add: [{ label: "Discovery", display_order: 0, metadata: { probability: "0.1" } }]
|
|
9210
9210
|
}
|
|
9211
9211
|
},
|
|
9212
|
-
toNested: (description,
|
|
9213
|
-
const { object_type, pipeline_id, new_label, new_display_order, stages_to_update, stages_to_add, stage_ids_to_remove, ...rest } =
|
|
9212
|
+
toNested: (description, fields51) => {
|
|
9213
|
+
const { object_type, pipeline_id, new_label, new_display_order, stages_to_update, stages_to_add, stage_ids_to_remove, ...rest } = fields51;
|
|
9214
9214
|
const updates = {};
|
|
9215
9215
|
if (new_label !== void 0) updates.label = new_label;
|
|
9216
9216
|
if (new_display_order !== void 0) updates.display_order = new_display_order;
|
|
@@ -9276,7 +9276,7 @@ var deletePipelineMeta = {
|
|
|
9276
9276
|
pipeline_id: "12345"
|
|
9277
9277
|
}
|
|
9278
9278
|
},
|
|
9279
|
-
toNested: (description,
|
|
9279
|
+
toNested: (description, fields51) => ({ type: "delete_pipeline", description, ...fields51 }),
|
|
9280
9280
|
requiredScopes: (op) => [getWriteScope(op.object_type)],
|
|
9281
9281
|
getSummary: (op) => `Delete Pipeline \u2014 ${capitalize(op.object_type)}: ${String(op.pipeline_id)}`,
|
|
9282
9282
|
getResourceUrl: () => null,
|
|
@@ -9327,14 +9327,14 @@ var createAssociationLabelMeta = {
|
|
|
9327
9327
|
inverse_label: "Billed Company"
|
|
9328
9328
|
}
|
|
9329
9329
|
},
|
|
9330
|
-
toNested: (description,
|
|
9331
|
-
const { from_object_type, to_object_type, name, label, inverse_label, ...rest } =
|
|
9330
|
+
toNested: (description, fields51) => {
|
|
9331
|
+
const { from_object_type, to_object_type, name, label, inverse_label, ...rest } = fields51;
|
|
9332
9332
|
return {
|
|
9333
9333
|
type: "create_association_label",
|
|
9334
9334
|
from_object_type,
|
|
9335
9335
|
to_object_type,
|
|
9336
9336
|
description,
|
|
9337
|
-
...typeof
|
|
9337
|
+
...typeof fields51.ref === "string" ? { ref: fields51.ref } : {},
|
|
9338
9338
|
association_label: { name, label, inverse_label, ...rest }
|
|
9339
9339
|
};
|
|
9340
9340
|
},
|
|
@@ -9395,8 +9395,8 @@ var updateAssociationLabelMeta = {
|
|
|
9395
9395
|
new_label: "Primary Billing Contact"
|
|
9396
9396
|
}
|
|
9397
9397
|
},
|
|
9398
|
-
toNested: (description,
|
|
9399
|
-
const { from_object_type, to_object_type, association_type_id, new_label, new_inverse_label, ...rest } =
|
|
9398
|
+
toNested: (description, fields51) => {
|
|
9399
|
+
const { from_object_type, to_object_type, association_type_id, new_label, new_inverse_label, ...rest } = fields51;
|
|
9400
9400
|
const updates = { label: new_label };
|
|
9401
9401
|
if (new_inverse_label !== void 0) updates.inverse_label = new_inverse_label;
|
|
9402
9402
|
return {
|
|
@@ -9459,7 +9459,7 @@ var deleteAssociationLabelMeta = {
|
|
|
9459
9459
|
association_type_id: 42
|
|
9460
9460
|
}
|
|
9461
9461
|
},
|
|
9462
|
-
toNested: (description,
|
|
9462
|
+
toNested: (description, fields51) => ({ type: "delete_association_label", description, ...fields51 }),
|
|
9463
9463
|
requiredScopes: (op) => [getWriteScope(op.from_object_type), getWriteScope(op.to_object_type)],
|
|
9464
9464
|
getSummary: (op) => `Delete Association Label \u2014 ${capitalize(op.from_object_type)} \u2192 ${capitalize(op.to_object_type)}`,
|
|
9465
9465
|
getResourceUrl: () => null,
|
|
@@ -9510,13 +9510,13 @@ var batchUpdateAssociationsMeta = {
|
|
|
9510
9510
|
]
|
|
9511
9511
|
}
|
|
9512
9512
|
},
|
|
9513
|
-
toNested: (description,
|
|
9513
|
+
toNested: (description, fields51) => ({
|
|
9514
9514
|
type: "batch_update_associations",
|
|
9515
9515
|
description,
|
|
9516
|
-
from_object_type:
|
|
9517
|
-
to_object_type:
|
|
9518
|
-
new_association_type_id:
|
|
9519
|
-
associations:
|
|
9516
|
+
from_object_type: fields51.from_object_type,
|
|
9517
|
+
to_object_type: fields51.to_object_type,
|
|
9518
|
+
new_association_type_id: fields51.new_association_type_id,
|
|
9519
|
+
associations: fields51.associations
|
|
9520
9520
|
}),
|
|
9521
9521
|
requiredScopes: (op) => [getWriteScope(op.from_object_type), getWriteScope(op.to_object_type)],
|
|
9522
9522
|
getSummary: (op) => `Batch Update Associations \u2014 ${capitalize(op.from_object_type)} \u2192 ${capitalize(op.to_object_type)}: ${op.associations.length}`,
|
|
@@ -9567,11 +9567,11 @@ var batchCreateRecordsMeta = {
|
|
|
9567
9567
|
]
|
|
9568
9568
|
}
|
|
9569
9569
|
},
|
|
9570
|
-
toNested: (description,
|
|
9570
|
+
toNested: (description, fields51) => ({
|
|
9571
9571
|
type: "batch_create_records",
|
|
9572
|
-
object_type:
|
|
9572
|
+
object_type: fields51.object_type,
|
|
9573
9573
|
description,
|
|
9574
|
-
records:
|
|
9574
|
+
records: fields51.records
|
|
9575
9575
|
}),
|
|
9576
9576
|
requiredScopes: (op) => [getWriteScope(op.object_type)],
|
|
9577
9577
|
getSummary: (op) => `Batch Create \u2014 ${capitalize(op.object_type)}: ${op.records.length} record${op.records.length === 1 ? "" : "s"}`,
|
|
@@ -9625,11 +9625,11 @@ var batchUpdateRecordsMeta = {
|
|
|
9625
9625
|
]
|
|
9626
9626
|
}
|
|
9627
9627
|
},
|
|
9628
|
-
toNested: (description,
|
|
9628
|
+
toNested: (description, fields51) => ({
|
|
9629
9629
|
type: "batch_update_records",
|
|
9630
|
-
object_type:
|
|
9630
|
+
object_type: fields51.object_type,
|
|
9631
9631
|
description,
|
|
9632
|
-
records:
|
|
9632
|
+
records: fields51.records
|
|
9633
9633
|
}),
|
|
9634
9634
|
requiredScopes: (op) => [getWriteScope(op.object_type)],
|
|
9635
9635
|
getSummary: (op) => `Batch Update \u2014 ${capitalize(op.object_type)}: ${op.records.length} record${op.records.length === 1 ? "" : "s"}`,
|
|
@@ -9672,11 +9672,11 @@ var batchDeleteRecordsMeta = {
|
|
|
9672
9672
|
record_ids: ["101", "102", "103"]
|
|
9673
9673
|
}
|
|
9674
9674
|
},
|
|
9675
|
-
toNested: (description,
|
|
9675
|
+
toNested: (description, fields51) => ({
|
|
9676
9676
|
type: "batch_delete_records",
|
|
9677
|
-
object_type:
|
|
9677
|
+
object_type: fields51.object_type,
|
|
9678
9678
|
description,
|
|
9679
|
-
record_ids:
|
|
9679
|
+
record_ids: fields51.record_ids
|
|
9680
9680
|
}),
|
|
9681
9681
|
requiredScopes: (op) => [getWriteScope(op.object_type)],
|
|
9682
9682
|
getSummary: (op) => `Batch Delete \u2014 ${capitalize(op.object_type)}: ${op.record_ids.length} record${op.record_ids.length === 1 ? "" : "s"}`,
|
|
@@ -9745,10 +9745,10 @@ var batchCreateNotesMeta = {
|
|
|
9745
9745
|
]
|
|
9746
9746
|
}
|
|
9747
9747
|
},
|
|
9748
|
-
toNested: (description,
|
|
9748
|
+
toNested: (description, fields51) => ({
|
|
9749
9749
|
type: "batch_create_notes",
|
|
9750
9750
|
description,
|
|
9751
|
-
notes:
|
|
9751
|
+
notes: fields51.notes
|
|
9752
9752
|
}),
|
|
9753
9753
|
requiredScopes: () => [getWriteScope("notes")],
|
|
9754
9754
|
getSummary: (op) => `Batch Create Notes: ${op.notes.length} note${op.notes.length === 1 ? "" : "s"}`,
|
|
@@ -9806,10 +9806,10 @@ var batchUpdateNotesMeta = {
|
|
|
9806
9806
|
]
|
|
9807
9807
|
}
|
|
9808
9808
|
},
|
|
9809
|
-
toNested: (description,
|
|
9809
|
+
toNested: (description, fields51) => ({
|
|
9810
9810
|
type: "batch_update_notes",
|
|
9811
9811
|
description,
|
|
9812
|
-
notes:
|
|
9812
|
+
notes: fields51.notes
|
|
9813
9813
|
}),
|
|
9814
9814
|
requiredScopes: () => [getWriteScope("notes")],
|
|
9815
9815
|
getSummary: (op) => `Batch Update Notes: ${op.notes.length} note${op.notes.length === 1 ? "" : "s"}`,
|
|
@@ -9851,10 +9851,10 @@ var batchDeleteNotesMeta = {
|
|
|
9851
9851
|
note_ids: ["9001", "9002"]
|
|
9852
9852
|
}
|
|
9853
9853
|
},
|
|
9854
|
-
toNested: (description,
|
|
9854
|
+
toNested: (description, fields51) => ({
|
|
9855
9855
|
type: "batch_delete_notes",
|
|
9856
9856
|
description,
|
|
9857
|
-
note_ids:
|
|
9857
|
+
note_ids: fields51.note_ids
|
|
9858
9858
|
}),
|
|
9859
9859
|
requiredScopes: () => [getWriteScope("notes")],
|
|
9860
9860
|
getSummary: (op) => `Batch Delete Notes: ${op.note_ids.length} note${op.note_ids.length === 1 ? "" : "s"}`,
|
|
@@ -9928,10 +9928,10 @@ var batchCreateTasksMeta = {
|
|
|
9928
9928
|
]
|
|
9929
9929
|
}
|
|
9930
9930
|
},
|
|
9931
|
-
toNested: (description,
|
|
9931
|
+
toNested: (description, fields51) => ({
|
|
9932
9932
|
type: "batch_create_tasks",
|
|
9933
9933
|
description,
|
|
9934
|
-
tasks:
|
|
9934
|
+
tasks: fields51.tasks
|
|
9935
9935
|
}),
|
|
9936
9936
|
requiredScopes: () => [getWriteScope("tasks")],
|
|
9937
9937
|
getSummary: (op) => `Batch Create Tasks: ${op.tasks.length} task${op.tasks.length === 1 ? "" : "s"}`,
|
|
@@ -9992,10 +9992,10 @@ var batchUpdateTasksMeta = {
|
|
|
9992
9992
|
]
|
|
9993
9993
|
}
|
|
9994
9994
|
},
|
|
9995
|
-
toNested: (description,
|
|
9995
|
+
toNested: (description, fields51) => ({
|
|
9996
9996
|
type: "batch_update_tasks",
|
|
9997
9997
|
description,
|
|
9998
|
-
tasks:
|
|
9998
|
+
tasks: fields51.tasks
|
|
9999
9999
|
}),
|
|
10000
10000
|
requiredScopes: () => [getWriteScope("tasks")],
|
|
10001
10001
|
getSummary: (op) => `Batch Update Tasks: ${op.tasks.length} task${op.tasks.length === 1 ? "" : "s"}`,
|
|
@@ -10037,10 +10037,10 @@ var batchDeleteTasksMeta = {
|
|
|
10037
10037
|
task_ids: ["501", "502"]
|
|
10038
10038
|
}
|
|
10039
10039
|
},
|
|
10040
|
-
toNested: (description,
|
|
10040
|
+
toNested: (description, fields51) => ({
|
|
10041
10041
|
type: "batch_delete_tasks",
|
|
10042
10042
|
description,
|
|
10043
|
-
task_ids:
|
|
10043
|
+
task_ids: fields51.task_ids
|
|
10044
10044
|
}),
|
|
10045
10045
|
requiredScopes: () => [getWriteScope("tasks")],
|
|
10046
10046
|
getSummary: (op) => `Batch Delete Tasks: ${op.task_ids.length} task${op.task_ids.length === 1 ? "" : "s"}`,
|
|
@@ -10082,10 +10082,10 @@ var batchCompleteTasksMeta = {
|
|
|
10082
10082
|
task_ids: ["501", "502"]
|
|
10083
10083
|
}
|
|
10084
10084
|
},
|
|
10085
|
-
toNested: (description,
|
|
10085
|
+
toNested: (description, fields51) => ({
|
|
10086
10086
|
type: "batch_complete_tasks",
|
|
10087
10087
|
description,
|
|
10088
|
-
task_ids:
|
|
10088
|
+
task_ids: fields51.task_ids
|
|
10089
10089
|
}),
|
|
10090
10090
|
requiredScopes: () => [getWriteScope("tasks")],
|
|
10091
10091
|
getSummary: (op) => `Batch Complete Tasks: ${op.task_ids.length} task${op.task_ids.length === 1 ? "" : "s"}`,
|
|
@@ -10143,10 +10143,10 @@ var batchUpdateCompleteTasksMeta = {
|
|
|
10143
10143
|
]
|
|
10144
10144
|
}
|
|
10145
10145
|
},
|
|
10146
|
-
toNested: (description,
|
|
10146
|
+
toNested: (description, fields51) => ({
|
|
10147
10147
|
type: "batch_update_complete_tasks",
|
|
10148
10148
|
description,
|
|
10149
|
-
tasks:
|
|
10149
|
+
tasks: fields51.tasks
|
|
10150
10150
|
}),
|
|
10151
10151
|
requiredScopes: () => [getWriteScope("tasks")],
|
|
10152
10152
|
getSummary: (op) => `Batch Update Completed Tasks: ${op.tasks.length} task${op.tasks.length === 1 ? "" : "s"}`,
|
|
@@ -10189,10 +10189,10 @@ var batchDeleteCompleteTasksMeta = {
|
|
|
10189
10189
|
task_ids: ["501", "502"]
|
|
10190
10190
|
}
|
|
10191
10191
|
},
|
|
10192
|
-
toNested: (description,
|
|
10192
|
+
toNested: (description, fields51) => ({
|
|
10193
10193
|
type: "batch_delete_complete_tasks",
|
|
10194
10194
|
description,
|
|
10195
|
-
task_ids:
|
|
10195
|
+
task_ids: fields51.task_ids
|
|
10196
10196
|
}),
|
|
10197
10197
|
requiredScopes: () => [getWriteScope("tasks")],
|
|
10198
10198
|
getSummary: (op) => `Batch Delete Completed Tasks: ${op.task_ids.length} task${op.task_ids.length === 1 ? "" : "s"}`,
|
|
@@ -10270,10 +10270,10 @@ var batchCreateEmailLogsMeta = {
|
|
|
10270
10270
|
]
|
|
10271
10271
|
}
|
|
10272
10272
|
},
|
|
10273
|
-
toNested: (description,
|
|
10273
|
+
toNested: (description, fields51) => ({
|
|
10274
10274
|
type: "batch_create_email_logs",
|
|
10275
10275
|
description,
|
|
10276
|
-
email_logs:
|
|
10276
|
+
email_logs: fields51.email_logs
|
|
10277
10277
|
}),
|
|
10278
10278
|
requiredScopes: () => [getWriteScope("emails")],
|
|
10279
10279
|
getSummary: (op) => `Batch Create Email Logs: ${op.email_logs.length} email log${op.email_logs.length === 1 ? "" : "s"}`,
|
|
@@ -10334,10 +10334,10 @@ var batchUpdateEmailLogsMeta = {
|
|
|
10334
10334
|
]
|
|
10335
10335
|
}
|
|
10336
10336
|
},
|
|
10337
|
-
toNested: (description,
|
|
10337
|
+
toNested: (description, fields51) => ({
|
|
10338
10338
|
type: "batch_update_email_logs",
|
|
10339
10339
|
description,
|
|
10340
|
-
email_logs:
|
|
10340
|
+
email_logs: fields51.email_logs
|
|
10341
10341
|
}),
|
|
10342
10342
|
requiredScopes: () => [getWriteScope("emails")],
|
|
10343
10343
|
getSummary: (op) => `Batch Update Email Logs: ${op.email_logs.length} email log${op.email_logs.length === 1 ? "" : "s"}`,
|
|
@@ -10379,10 +10379,10 @@ var batchDeleteEmailLogsMeta = {
|
|
|
10379
10379
|
email_log_ids: ["8001", "8002"]
|
|
10380
10380
|
}
|
|
10381
10381
|
},
|
|
10382
|
-
toNested: (description,
|
|
10382
|
+
toNested: (description, fields51) => ({
|
|
10383
10383
|
type: "batch_delete_email_logs",
|
|
10384
10384
|
description,
|
|
10385
|
-
email_log_ids:
|
|
10385
|
+
email_log_ids: fields51.email_log_ids
|
|
10386
10386
|
}),
|
|
10387
10387
|
requiredScopes: () => [getWriteScope("emails")],
|
|
10388
10388
|
getSummary: (op) => `Batch Delete Email Logs: ${op.email_log_ids.length} email log${op.email_log_ids.length === 1 ? "" : "s"}`,
|
|
@@ -10493,16 +10493,16 @@ For DYNAMIC lists, provide filter_branch with the HubSpot filter definition. The
|
|
|
10493
10493
|
}
|
|
10494
10494
|
}
|
|
10495
10495
|
},
|
|
10496
|
-
toNested: (description,
|
|
10496
|
+
toNested: (description, fields51) => {
|
|
10497
10497
|
const base = {
|
|
10498
10498
|
type: "create_list",
|
|
10499
10499
|
description,
|
|
10500
|
-
...typeof
|
|
10501
|
-
name:
|
|
10502
|
-
object_type_id:
|
|
10503
|
-
processing_type:
|
|
10500
|
+
...typeof fields51.ref === "string" ? { ref: fields51.ref } : {},
|
|
10501
|
+
name: fields51.name,
|
|
10502
|
+
object_type_id: fields51.object_type_id,
|
|
10503
|
+
processing_type: fields51.processing_type
|
|
10504
10504
|
};
|
|
10505
|
-
if (
|
|
10505
|
+
if (fields51.filter_branch) base.filter_branch = fields51.filter_branch;
|
|
10506
10506
|
return base;
|
|
10507
10507
|
},
|
|
10508
10508
|
requiredScopes: () => ["crm.lists.write"],
|
|
@@ -10548,7 +10548,7 @@ var deleteListMeta = {
|
|
|
10548
10548
|
list_id: "12345"
|
|
10549
10549
|
}
|
|
10550
10550
|
},
|
|
10551
|
-
toNested: (description,
|
|
10551
|
+
toNested: (description, fields51) => ({ type: "delete_list", description, ...fields51 }),
|
|
10552
10552
|
requiredScopes: () => ["crm.lists.write"],
|
|
10553
10553
|
getSummary: (op) => `Delete List \u2014 ${String(op.list_id)}`,
|
|
10554
10554
|
getResourceUrl: () => null,
|
|
@@ -10621,7 +10621,7 @@ var createCustomObjectMeta = {
|
|
|
10621
10621
|
associated_objects: ["contacts", "companies"]
|
|
10622
10622
|
}
|
|
10623
10623
|
},
|
|
10624
|
-
toNested: (description,
|
|
10624
|
+
toNested: (description, fields51) => {
|
|
10625
10625
|
const {
|
|
10626
10626
|
ref,
|
|
10627
10627
|
name,
|
|
@@ -10631,7 +10631,7 @@ var createCustomObjectMeta = {
|
|
|
10631
10631
|
required_properties,
|
|
10632
10632
|
associated_objects,
|
|
10633
10633
|
...rest
|
|
10634
|
-
} =
|
|
10634
|
+
} = fields51;
|
|
10635
10635
|
const properties = rest.properties ?? [];
|
|
10636
10636
|
const mappedProperties = properties.map((p) => ({
|
|
10637
10637
|
...p,
|
|
@@ -10699,14 +10699,14 @@ var updateCustomObjectMeta = {
|
|
|
10699
10699
|
new_plural_label: "Projects"
|
|
10700
10700
|
}
|
|
10701
10701
|
},
|
|
10702
|
-
toNested: (description,
|
|
10702
|
+
toNested: (description, fields51) => {
|
|
10703
10703
|
const {
|
|
10704
10704
|
object_type,
|
|
10705
10705
|
new_singular_label,
|
|
10706
10706
|
new_plural_label,
|
|
10707
10707
|
new_primary_display_property,
|
|
10708
10708
|
new_required_properties
|
|
10709
|
-
} =
|
|
10709
|
+
} = fields51;
|
|
10710
10710
|
return {
|
|
10711
10711
|
type: "update_custom_object",
|
|
10712
10712
|
description,
|
|
@@ -10766,10 +10766,10 @@ var deleteCustomObjectMeta = {
|
|
|
10766
10766
|
example: {
|
|
10767
10767
|
fields: { object_type: "2-12345678" }
|
|
10768
10768
|
},
|
|
10769
|
-
toNested: (description,
|
|
10769
|
+
toNested: (description, fields51) => ({
|
|
10770
10770
|
type: "delete_custom_object",
|
|
10771
10771
|
description,
|
|
10772
|
-
object_type:
|
|
10772
|
+
object_type: fields51.object_type
|
|
10773
10773
|
}),
|
|
10774
10774
|
requiredScopes: () => [...SCHEMA_WRITE_SCOPES],
|
|
10775
10775
|
getSummary: (op) => `Delete Custom Object \u2014 ${String(op.object_type)}`,
|
|
@@ -10808,12 +10808,12 @@ var updateListMeta = {
|
|
|
10808
10808
|
new_name: "High Value Leads Q2"
|
|
10809
10809
|
}
|
|
10810
10810
|
},
|
|
10811
|
-
toNested: (description,
|
|
10811
|
+
toNested: (description, fields51) => ({
|
|
10812
10812
|
type: "update_list",
|
|
10813
10813
|
description,
|
|
10814
|
-
list_id:
|
|
10814
|
+
list_id: fields51.list_id,
|
|
10815
10815
|
updates: {
|
|
10816
|
-
...
|
|
10816
|
+
...fields51.new_name !== void 0 && { name: fields51.new_name }
|
|
10817
10817
|
}
|
|
10818
10818
|
}),
|
|
10819
10819
|
requiredScopes: () => [LIST_WRITE_SCOPE],
|
|
@@ -10852,11 +10852,11 @@ var addListMembersMeta = {
|
|
|
10852
10852
|
record_ids: ["101", "102", "103"]
|
|
10853
10853
|
}
|
|
10854
10854
|
},
|
|
10855
|
-
toNested: (description,
|
|
10855
|
+
toNested: (description, fields51) => ({
|
|
10856
10856
|
type: "add_list_members",
|
|
10857
10857
|
description,
|
|
10858
|
-
list_id:
|
|
10859
|
-
record_ids:
|
|
10858
|
+
list_id: fields51.list_id,
|
|
10859
|
+
record_ids: fields51.record_ids
|
|
10860
10860
|
}),
|
|
10861
10861
|
requiredScopes: () => [LIST_WRITE_SCOPE],
|
|
10862
10862
|
getSummary: (op) => `Add List Members \u2014 List ${String(op.list_id)}: ${op.record_ids.length} records`,
|
|
@@ -10894,11 +10894,11 @@ var removeListMembersMeta = {
|
|
|
10894
10894
|
record_ids: ["101", "102"]
|
|
10895
10895
|
}
|
|
10896
10896
|
},
|
|
10897
|
-
toNested: (description,
|
|
10897
|
+
toNested: (description, fields51) => ({
|
|
10898
10898
|
type: "remove_list_members",
|
|
10899
10899
|
description,
|
|
10900
|
-
list_id:
|
|
10901
|
-
record_ids:
|
|
10900
|
+
list_id: fields51.list_id,
|
|
10901
|
+
record_ids: fields51.record_ids
|
|
10902
10902
|
}),
|
|
10903
10903
|
requiredScopes: () => [LIST_WRITE_SCOPE],
|
|
10904
10904
|
getSummary: (op) => `Remove List Members \u2014 List ${String(op.list_id)}: ${op.record_ids.length} records`,
|
|
@@ -10947,12 +10947,12 @@ var batchCreateAssociationsMeta = {
|
|
|
10947
10947
|
]
|
|
10948
10948
|
}
|
|
10949
10949
|
},
|
|
10950
|
-
toNested: (description,
|
|
10950
|
+
toNested: (description, fields51) => ({
|
|
10951
10951
|
type: "batch_create_associations",
|
|
10952
10952
|
description,
|
|
10953
|
-
from_object_type:
|
|
10954
|
-
to_object_type:
|
|
10955
|
-
associations:
|
|
10953
|
+
from_object_type: fields51.from_object_type,
|
|
10954
|
+
to_object_type: fields51.to_object_type,
|
|
10955
|
+
associations: fields51.associations
|
|
10956
10956
|
}),
|
|
10957
10957
|
requiredScopes: (op) => [getWriteScope(op.from_object_type), getWriteScope(op.to_object_type)],
|
|
10958
10958
|
getSummary: (op) => `Batch Create Associations \u2014 ${capitalize(op.from_object_type)} \u2192 ${capitalize(op.to_object_type)}: ${op.associations.length}`,
|
|
@@ -11001,12 +11001,12 @@ var batchDeleteAssociationsMeta = {
|
|
|
11001
11001
|
]
|
|
11002
11002
|
}
|
|
11003
11003
|
},
|
|
11004
|
-
toNested: (description,
|
|
11004
|
+
toNested: (description, fields51) => ({
|
|
11005
11005
|
type: "batch_delete_associations",
|
|
11006
11006
|
description,
|
|
11007
|
-
from_object_type:
|
|
11008
|
-
to_object_type:
|
|
11009
|
-
associations:
|
|
11007
|
+
from_object_type: fields51.from_object_type,
|
|
11008
|
+
to_object_type: fields51.to_object_type,
|
|
11009
|
+
associations: fields51.associations
|
|
11010
11010
|
}),
|
|
11011
11011
|
requiredScopes: (op) => [getWriteScope(op.from_object_type), getWriteScope(op.to_object_type)],
|
|
11012
11012
|
getSummary: (op) => `Batch Delete Associations \u2014 ${capitalize(op.from_object_type)} \u2192 ${capitalize(op.to_object_type)}: ${op.associations.length}`,
|
|
@@ -11048,12 +11048,12 @@ var mergeRecordsMeta = {
|
|
|
11048
11048
|
merge_id: "102"
|
|
11049
11049
|
}
|
|
11050
11050
|
},
|
|
11051
|
-
toNested: (description,
|
|
11051
|
+
toNested: (description, fields51) => ({
|
|
11052
11052
|
type: "merge_records",
|
|
11053
11053
|
description,
|
|
11054
|
-
object_type:
|
|
11055
|
-
primary_id:
|
|
11056
|
-
merge_id:
|
|
11054
|
+
object_type: fields51.object_type,
|
|
11055
|
+
primary_id: fields51.primary_id,
|
|
11056
|
+
merge_id: fields51.merge_id
|
|
11057
11057
|
}),
|
|
11058
11058
|
requiredScopes: (op) => [getWriteScope(op.object_type)],
|
|
11059
11059
|
getSummary: (op) => `Merge \u2014 ${capitalize(op.object_type)}: ${op.merge_id} \u2192 ${op.primary_id}`,
|
|
@@ -11098,12 +11098,12 @@ var batchAssignOwnerMeta = {
|
|
|
11098
11098
|
record_ids: ["101", "102", "103"]
|
|
11099
11099
|
}
|
|
11100
11100
|
},
|
|
11101
|
-
toNested: (description,
|
|
11101
|
+
toNested: (description, fields51) => ({
|
|
11102
11102
|
type: "batch_assign_owner",
|
|
11103
11103
|
description,
|
|
11104
|
-
object_type:
|
|
11105
|
-
owner_id:
|
|
11106
|
-
record_ids:
|
|
11104
|
+
object_type: fields51.object_type,
|
|
11105
|
+
owner_id: fields51.owner_id,
|
|
11106
|
+
record_ids: fields51.record_ids
|
|
11107
11107
|
}),
|
|
11108
11108
|
requiredScopes: (op) => [getWriteScope(op.object_type)],
|
|
11109
11109
|
getSummary: (op) => `Assign Owner \u2014 ${capitalize(op.object_type)}: ${op.record_ids.length} records \u2192 owner ${op.owner_id}`,
|
|
@@ -11154,7 +11154,7 @@ var createSnippetMeta = {
|
|
|
11154
11154
|
shortcut: "meetingfu"
|
|
11155
11155
|
}
|
|
11156
11156
|
},
|
|
11157
|
-
toNested: (description,
|
|
11157
|
+
toNested: (description, fields51) => ({ type: "create_snippet", description, ...fields51 }),
|
|
11158
11158
|
requiredScopes: () => [],
|
|
11159
11159
|
getSummary: (op) => `Create Snippet \u2014 ${op.name}`,
|
|
11160
11160
|
getResourceUrl: (portalId, op) => `${HUBSPOT_BASE}/snippets/${portalId}/?q=${encodeURIComponent(op.name)}`,
|
|
@@ -11201,7 +11201,7 @@ var updateSnippetMeta = {
|
|
|
11201
11201
|
body: "Updated body text..."
|
|
11202
11202
|
}
|
|
11203
11203
|
},
|
|
11204
|
-
toNested: (description,
|
|
11204
|
+
toNested: (description, fields51) => ({ type: "update_snippet", description, ...fields51 }),
|
|
11205
11205
|
requiredScopes: () => [],
|
|
11206
11206
|
getSummary: (op) => `Update Snippet \u2014 ${op.name ?? `#${op.content_id}`}`,
|
|
11207
11207
|
getResourceUrl: (portalId, op) => `${HUBSPOT_BASE}/snippets/${portalId}/?q=${encodeURIComponent(op.name ?? "")}`,
|
|
@@ -11234,7 +11234,7 @@ var deleteSnippetMeta = {
|
|
|
11234
11234
|
example: {
|
|
11235
11235
|
fields: { content_id: 12345 }
|
|
11236
11236
|
},
|
|
11237
|
-
toNested: (description,
|
|
11237
|
+
toNested: (description, fields51) => ({ type: "delete_snippet", description, ...fields51 }),
|
|
11238
11238
|
requiredScopes: () => [],
|
|
11239
11239
|
getSummary: (op) => `Delete Snippet \u2014 #${op.content_id}`,
|
|
11240
11240
|
getResourceUrl: () => null,
|
|
@@ -11350,9 +11350,9 @@ var SingleConnectionActionBaseSchema = z70.object({
|
|
|
11350
11350
|
connection: WorkflowConnectionSchema.optional(),
|
|
11351
11351
|
type: z70.literal("SINGLE_CONNECTION")
|
|
11352
11352
|
}).passthrough();
|
|
11353
|
-
var buildSingleConnectionActionSchema = (actionTypeId,
|
|
11353
|
+
var buildSingleConnectionActionSchema = (actionTypeId, fields51) => SingleConnectionActionBaseSchema.extend({
|
|
11354
11354
|
actionTypeId: z70.literal(actionTypeId),
|
|
11355
|
-
fields:
|
|
11355
|
+
fields: fields51
|
|
11356
11356
|
});
|
|
11357
11357
|
var BooleanStringSchema = z70.enum(["true", "false"]);
|
|
11358
11358
|
var DelayForSetAmountOfTimeActionSchema = buildSingleConnectionActionSchema("0-1", z70.object({
|
|
@@ -15021,11 +15021,11 @@ var createWorkflowMeta = {
|
|
|
15021
15021
|
}
|
|
15022
15022
|
}
|
|
15023
15023
|
},
|
|
15024
|
-
toNested: (description,
|
|
15024
|
+
toNested: (description, fields51) => ({
|
|
15025
15025
|
type: "create_workflow",
|
|
15026
15026
|
description,
|
|
15027
|
-
...typeof
|
|
15028
|
-
...
|
|
15027
|
+
...typeof fields51.ref === "string" ? { ref: fields51.ref } : {},
|
|
15028
|
+
...fields51
|
|
15029
15029
|
}),
|
|
15030
15030
|
requiredScopes: () => ["automation"],
|
|
15031
15031
|
getSummary: (op) => `Create Workflow \u2014 ${op.name}`,
|
|
@@ -15089,10 +15089,10 @@ var updateWorkflowMeta = {
|
|
|
15089
15089
|
name: "Updated workflow name"
|
|
15090
15090
|
}
|
|
15091
15091
|
},
|
|
15092
|
-
toNested: (description,
|
|
15092
|
+
toNested: (description, fields51) => ({
|
|
15093
15093
|
type: "update_workflow",
|
|
15094
15094
|
description,
|
|
15095
|
-
...
|
|
15095
|
+
...fields51
|
|
15096
15096
|
}),
|
|
15097
15097
|
requiredScopes: () => ["automation"],
|
|
15098
15098
|
getSummary: (op) => `Update Workflow \u2014 ${String(op.workflow_id)}${op.name ? ` (${op.name})` : ""}`,
|
|
@@ -15134,10 +15134,10 @@ var setWorkflowEnabledMeta = {
|
|
|
15134
15134
|
enabled: true
|
|
15135
15135
|
}
|
|
15136
15136
|
},
|
|
15137
|
-
toNested: (description,
|
|
15137
|
+
toNested: (description, fields51) => ({
|
|
15138
15138
|
type: "set_workflow_enabled",
|
|
15139
15139
|
description,
|
|
15140
|
-
...
|
|
15140
|
+
...fields51
|
|
15141
15141
|
}),
|
|
15142
15142
|
requiredScopes: () => ["automation"],
|
|
15143
15143
|
getSummary: (op) => `${op.enabled ? "Enable" : "Disable"} Workflow \u2014 ${String(op.workflow_id)}`,
|
|
@@ -15173,10 +15173,10 @@ var deleteWorkflowMeta = {
|
|
|
15173
15173
|
workflow_id: "1734596242"
|
|
15174
15174
|
}
|
|
15175
15175
|
},
|
|
15176
|
-
toNested: (description,
|
|
15176
|
+
toNested: (description, fields51) => ({
|
|
15177
15177
|
type: "delete_workflow",
|
|
15178
15178
|
description,
|
|
15179
|
-
...
|
|
15179
|
+
...fields51
|
|
15180
15180
|
}),
|
|
15181
15181
|
requiredScopes: () => ["automation"],
|
|
15182
15182
|
getSummary: (op) => `Delete Workflow \u2014 ${String(op.workflow_id)}`,
|
|
@@ -15189,8 +15189,297 @@ var deleteWorkflowMeta = {
|
|
|
15189
15189
|
}
|
|
15190
15190
|
};
|
|
15191
15191
|
|
|
15192
|
+
// ../shared/operations/create-form/meta.ts
|
|
15193
|
+
import { z as z77 } from "zod";
|
|
15194
|
+
|
|
15195
|
+
// ../shared/operations/form-shared.ts
|
|
15196
|
+
import { z as z76 } from "zod";
|
|
15197
|
+
var NonEmptyString = z76.string().min(1);
|
|
15198
|
+
var FormOptionSchema = z76.object({
|
|
15199
|
+
label: NonEmptyString,
|
|
15200
|
+
value: NonEmptyString,
|
|
15201
|
+
description: z76.string().optional(),
|
|
15202
|
+
displayOrder: z76.number().int().optional()
|
|
15203
|
+
}).passthrough();
|
|
15204
|
+
var FormDependentConditionSchema = z76.object({
|
|
15205
|
+
operator: NonEmptyString,
|
|
15206
|
+
rangeStart: z76.string().optional(),
|
|
15207
|
+
rangeEnd: z76.string().optional(),
|
|
15208
|
+
value: z76.string().optional(),
|
|
15209
|
+
values: z76.array(z76.string()).optional()
|
|
15210
|
+
}).passthrough();
|
|
15211
|
+
var FormFieldDependencySchema = z76.object({
|
|
15212
|
+
dependentCondition: FormDependentConditionSchema,
|
|
15213
|
+
dependentField: z76.record(z76.string(), z76.unknown())
|
|
15214
|
+
}).passthrough();
|
|
15215
|
+
var FormFieldValidationSchema = z76.object({
|
|
15216
|
+
blockedEmailDomains: z76.array(z76.string()).optional(),
|
|
15217
|
+
useDefaultBlockList: z76.boolean().optional()
|
|
15218
|
+
}).passthrough();
|
|
15219
|
+
var FormFieldSchema = z76.object({
|
|
15220
|
+
objectTypeId: NonEmptyString,
|
|
15221
|
+
name: NonEmptyString,
|
|
15222
|
+
label: NonEmptyString,
|
|
15223
|
+
fieldType: NonEmptyString,
|
|
15224
|
+
required: z76.boolean().optional(),
|
|
15225
|
+
hidden: z76.boolean().optional(),
|
|
15226
|
+
defaultValue: z76.string().optional(),
|
|
15227
|
+
description: z76.string().optional(),
|
|
15228
|
+
placeholder: z76.string().optional(),
|
|
15229
|
+
dependentFields: z76.array(FormFieldDependencySchema).optional(),
|
|
15230
|
+
validation: FormFieldValidationSchema.optional(),
|
|
15231
|
+
options: z76.array(FormOptionSchema).optional()
|
|
15232
|
+
}).passthrough();
|
|
15233
|
+
var FormFieldGroupSchema = z76.object({
|
|
15234
|
+
groupType: z76.string().optional(),
|
|
15235
|
+
richTextType: z76.string().optional(),
|
|
15236
|
+
richText: z76.string().optional(),
|
|
15237
|
+
fields: z76.array(FormFieldSchema).optional()
|
|
15238
|
+
}).passthrough();
|
|
15239
|
+
var FormLifecycleStageSchema = z76.object({
|
|
15240
|
+
objectTypeId: NonEmptyString,
|
|
15241
|
+
value: NonEmptyString
|
|
15242
|
+
}).passthrough();
|
|
15243
|
+
var FormPostSubmitActionSchema = z76.object({
|
|
15244
|
+
type: NonEmptyString,
|
|
15245
|
+
value: z76.string()
|
|
15246
|
+
}).passthrough();
|
|
15247
|
+
var FormConfigurationSchema = z76.object({
|
|
15248
|
+
allowLinkToResetKnownValues: z76.boolean().optional(),
|
|
15249
|
+
archivable: z76.boolean().optional(),
|
|
15250
|
+
cloneable: z76.boolean().optional(),
|
|
15251
|
+
createNewContactForNewEmail: z76.boolean().optional(),
|
|
15252
|
+
editable: z76.boolean().optional(),
|
|
15253
|
+
embedType: z76.string().optional(),
|
|
15254
|
+
language: z76.string().optional(),
|
|
15255
|
+
lifecycleStages: z76.array(FormLifecycleStageSchema).optional(),
|
|
15256
|
+
notifyContactOwner: z76.boolean().optional(),
|
|
15257
|
+
notifyRecipients: z76.array(z76.string()).optional(),
|
|
15258
|
+
postSubmitAction: FormPostSubmitActionSchema.optional(),
|
|
15259
|
+
prePopulateKnownValues: z76.boolean().optional(),
|
|
15260
|
+
recaptchaEnabled: z76.boolean().optional()
|
|
15261
|
+
}).passthrough();
|
|
15262
|
+
var FormStyleSchema = z76.object({
|
|
15263
|
+
backgroundWidth: z76.string().optional(),
|
|
15264
|
+
fontFamily: z76.string().optional(),
|
|
15265
|
+
helpTextColor: z76.string().optional(),
|
|
15266
|
+
helpTextSize: z76.string().optional(),
|
|
15267
|
+
labelTextColor: z76.string().optional(),
|
|
15268
|
+
labelTextSize: z76.string().optional(),
|
|
15269
|
+
legalConsentTextColor: z76.string().optional(),
|
|
15270
|
+
legalConsentTextSize: z76.string().optional(),
|
|
15271
|
+
submitAlignment: z76.string().optional(),
|
|
15272
|
+
submitColor: z76.string().optional(),
|
|
15273
|
+
submitFontColor: z76.string().optional(),
|
|
15274
|
+
submitSize: z76.string().optional()
|
|
15275
|
+
}).passthrough();
|
|
15276
|
+
var FormDisplayOptionsSchema = z76.object({
|
|
15277
|
+
renderRawHtml: z76.boolean().optional(),
|
|
15278
|
+
cssClass: z76.string().nullable().optional(),
|
|
15279
|
+
submitButtonText: z76.string().optional(),
|
|
15280
|
+
theme: z76.string().optional(),
|
|
15281
|
+
style: FormStyleSchema.optional()
|
|
15282
|
+
}).passthrough();
|
|
15283
|
+
var FormCommunicationsCheckboxSchema = z76.object({
|
|
15284
|
+
required: z76.boolean().optional(),
|
|
15285
|
+
subscriptionTypeId: z76.number().int().optional(),
|
|
15286
|
+
label: z76.string().optional()
|
|
15287
|
+
}).passthrough();
|
|
15288
|
+
var BaseLegalConsentSchema = z76.object({
|
|
15289
|
+
communicationConsentText: z76.string().optional(),
|
|
15290
|
+
communicationsCheckboxes: z76.array(FormCommunicationsCheckboxSchema).optional(),
|
|
15291
|
+
consentToProcessText: z76.string().optional(),
|
|
15292
|
+
consentToProcessCheckboxLabel: z76.string().optional(),
|
|
15293
|
+
privacyText: z76.string().optional()
|
|
15294
|
+
}).passthrough();
|
|
15295
|
+
var FormLegalConsentOptionsSchema = z76.discriminatedUnion("type", [
|
|
15296
|
+
BaseLegalConsentSchema.extend({ type: z76.literal("none") }),
|
|
15297
|
+
BaseLegalConsentSchema.extend({ type: z76.literal("legitimate_interest") }),
|
|
15298
|
+
BaseLegalConsentSchema.extend({ type: z76.literal("explicit_consent_to_process") }),
|
|
15299
|
+
BaseLegalConsentSchema.extend({ type: z76.literal("implicit_consent_to_process") })
|
|
15300
|
+
]);
|
|
15301
|
+
var CreateFormDefinitionSchema = z76.object({
|
|
15302
|
+
formType: z76.literal("hubspot"),
|
|
15303
|
+
name: NonEmptyString,
|
|
15304
|
+
createdAt: NonEmptyString,
|
|
15305
|
+
fieldGroups: z76.array(FormFieldGroupSchema).min(1),
|
|
15306
|
+
configuration: FormConfigurationSchema,
|
|
15307
|
+
displayOptions: FormDisplayOptionsSchema.optional(),
|
|
15308
|
+
legalConsentOptions: FormLegalConsentOptionsSchema.optional()
|
|
15309
|
+
}).passthrough();
|
|
15310
|
+
var UpdateFormDefinitionSchema = z76.object({
|
|
15311
|
+
name: NonEmptyString.optional(),
|
|
15312
|
+
fieldGroups: z76.array(FormFieldGroupSchema).min(1).optional(),
|
|
15313
|
+
configuration: FormConfigurationSchema.optional(),
|
|
15314
|
+
displayOptions: FormDisplayOptionsSchema.optional(),
|
|
15315
|
+
legalConsentOptions: FormLegalConsentOptionsSchema.optional()
|
|
15316
|
+
}).passthrough();
|
|
15317
|
+
var validateFormFieldGroups = (fieldGroups, operationIndex) => {
|
|
15318
|
+
const issues = [];
|
|
15319
|
+
fieldGroups.forEach((group, groupIndex) => {
|
|
15320
|
+
const richText = group.richText?.trim() ?? "";
|
|
15321
|
+
const fields51 = group.fields ?? [];
|
|
15322
|
+
if (fields51.length === 0 && richText.length === 0) {
|
|
15323
|
+
issues.push({
|
|
15324
|
+
severity: "error",
|
|
15325
|
+
operation_index: operationIndex,
|
|
15326
|
+
code: "FORM_GROUP_EMPTY",
|
|
15327
|
+
message: `Field group ${groupIndex + 1} must contain at least one field or non-empty richText`
|
|
15328
|
+
});
|
|
15329
|
+
}
|
|
15330
|
+
fields51.forEach((field, fieldIndex) => {
|
|
15331
|
+
if (field.fieldType === "email" && field.validation === void 0) {
|
|
15332
|
+
issues.push({
|
|
15333
|
+
severity: "error",
|
|
15334
|
+
operation_index: operationIndex,
|
|
15335
|
+
code: "FORM_EMAIL_FIELD_MISSING_VALIDATION",
|
|
15336
|
+
message: `Field group ${groupIndex + 1}, field ${fieldIndex + 1} uses fieldType 'email' and must include validation`
|
|
15337
|
+
});
|
|
15338
|
+
}
|
|
15339
|
+
});
|
|
15340
|
+
});
|
|
15341
|
+
return issues;
|
|
15342
|
+
};
|
|
15343
|
+
|
|
15344
|
+
// ../shared/operations/create-form/meta.ts
|
|
15345
|
+
var CreateFormOperationSchema = z77.object({
|
|
15346
|
+
type: z77.literal("create_form"),
|
|
15347
|
+
description: z77.string().min(1),
|
|
15348
|
+
ref: z77.string().min(1).optional(),
|
|
15349
|
+
definition: CreateFormDefinitionSchema
|
|
15350
|
+
});
|
|
15351
|
+
var fields48 = [
|
|
15352
|
+
{
|
|
15353
|
+
name: "definition",
|
|
15354
|
+
type: "object",
|
|
15355
|
+
required: true,
|
|
15356
|
+
description: "HubSpot create-form payload",
|
|
15357
|
+
shape: "{ formType: 'hubspot', name, createdAt, fieldGroups[], configuration, displayOptions?, legalConsentOptions? }"
|
|
15358
|
+
}
|
|
15359
|
+
];
|
|
15360
|
+
var createFormMeta = {
|
|
15361
|
+
type: "create_form",
|
|
15362
|
+
category: "create",
|
|
15363
|
+
executionMode: "hubspot",
|
|
15364
|
+
summary: "Create a HubSpot form",
|
|
15365
|
+
description: "Create a HubSpot marketing form. Live validation confirms formType, createdAt, configuration, and email-field validation handling against the current Forms API.",
|
|
15366
|
+
fields: fields48,
|
|
15367
|
+
example: {
|
|
15368
|
+
fields: {
|
|
15369
|
+
ref: "form.newsletter_signup",
|
|
15370
|
+
definition: {
|
|
15371
|
+
formType: "hubspot",
|
|
15372
|
+
name: "Newsletter Signup",
|
|
15373
|
+
createdAt: "2026-03-24T00:00:00.000Z",
|
|
15374
|
+
configuration: {},
|
|
15375
|
+
fieldGroups: [
|
|
15376
|
+
{
|
|
15377
|
+
fields: [
|
|
15378
|
+
{
|
|
15379
|
+
objectTypeId: "0-1",
|
|
15380
|
+
name: "email",
|
|
15381
|
+
label: "Email",
|
|
15382
|
+
fieldType: "email",
|
|
15383
|
+
required: true,
|
|
15384
|
+
validation: {}
|
|
15385
|
+
}
|
|
15386
|
+
]
|
|
15387
|
+
}
|
|
15388
|
+
]
|
|
15389
|
+
}
|
|
15390
|
+
}
|
|
15391
|
+
},
|
|
15392
|
+
toNested: (description, fields51) => ({ type: "create_form", description, ...fields51 }),
|
|
15393
|
+
requiredScopes: () => ["forms"],
|
|
15394
|
+
getSummary: (op) => `Create Form \u2014 ${op.definition.name}`,
|
|
15395
|
+
getResourceUrl: (portalId, _op, result) => result?.affected_ids?.[0] ? `${HUBSPOT_BASE}/forms/${portalId}/editor/${result.affected_ids[0]}` : null,
|
|
15396
|
+
renderDetails: (op) => ({
|
|
15397
|
+
rows: [
|
|
15398
|
+
{ label: "Name", value: op.definition.name },
|
|
15399
|
+
{ label: "Form Type", value: op.definition.formType },
|
|
15400
|
+
{ label: "Field Groups", value: String(op.definition.fieldGroups.length) }
|
|
15401
|
+
]
|
|
15402
|
+
})
|
|
15403
|
+
};
|
|
15404
|
+
|
|
15405
|
+
// ../shared/operations/update-form/meta.ts
|
|
15406
|
+
import { z as z78 } from "zod";
|
|
15407
|
+
var UpdateFormOperationSchema = z78.object({
|
|
15408
|
+
type: z78.literal("update_form"),
|
|
15409
|
+
description: z78.string().min(1),
|
|
15410
|
+
form_id: StringOrPlanRefSchema,
|
|
15411
|
+
updates: UpdateFormDefinitionSchema
|
|
15412
|
+
});
|
|
15413
|
+
var fields49 = [
|
|
15414
|
+
{ name: "form_id", type: "string", required: true, description: "Form ID to update" },
|
|
15415
|
+
{
|
|
15416
|
+
name: "updates",
|
|
15417
|
+
type: "object",
|
|
15418
|
+
required: true,
|
|
15419
|
+
description: "Partial form patch payload",
|
|
15420
|
+
shape: "{ name?, fieldGroups?, configuration?, displayOptions?, legalConsentOptions? }"
|
|
15421
|
+
}
|
|
15422
|
+
];
|
|
15423
|
+
var updateFormMeta = {
|
|
15424
|
+
type: "update_form",
|
|
15425
|
+
category: "update",
|
|
15426
|
+
executionMode: "hubspot",
|
|
15427
|
+
summary: "Update a HubSpot form",
|
|
15428
|
+
description: "Patch selected fields on an existing HubSpot form. This operation uses the partial PATCH semantics, not the full PUT replacement endpoint.",
|
|
15429
|
+
fields: fields49,
|
|
15430
|
+
example: {
|
|
15431
|
+
fields: {
|
|
15432
|
+
form_id: "6eae0163-5362-4c0e-809c-b99a18678adc",
|
|
15433
|
+
updates: {
|
|
15434
|
+
name: "Newsletter Signup (Updated)"
|
|
15435
|
+
}
|
|
15436
|
+
}
|
|
15437
|
+
},
|
|
15438
|
+
toNested: (description, fields51) => ({ type: "update_form", description, ...fields51 }),
|
|
15439
|
+
requiredScopes: () => ["forms"],
|
|
15440
|
+
getSummary: (op) => `Update Form \u2014 ${op.updates.name ?? `#${op.form_id}`}`,
|
|
15441
|
+
getResourceUrl: (portalId, op) => `${HUBSPOT_BASE}/forms/${portalId}/editor/${encodeURIComponent(String(op.form_id))}`,
|
|
15442
|
+
renderDetails: (op) => ({
|
|
15443
|
+
rows: [
|
|
15444
|
+
{ label: "Form ID", value: String(op.form_id) },
|
|
15445
|
+
...op.updates.name ? [{ label: "Name", value: op.updates.name }] : []
|
|
15446
|
+
]
|
|
15447
|
+
})
|
|
15448
|
+
};
|
|
15449
|
+
|
|
15450
|
+
// ../shared/operations/delete-form/meta.ts
|
|
15451
|
+
import { z as z79 } from "zod";
|
|
15452
|
+
var DeleteFormOperationSchema = z79.object({
|
|
15453
|
+
type: z79.literal("delete_form"),
|
|
15454
|
+
description: z79.string().min(1),
|
|
15455
|
+
form_id: StringOrPlanRefSchema
|
|
15456
|
+
});
|
|
15457
|
+
var fields50 = [
|
|
15458
|
+
{ name: "form_id", type: "string", required: true, description: "Form ID to archive" }
|
|
15459
|
+
];
|
|
15460
|
+
var deleteFormMeta = {
|
|
15461
|
+
type: "delete_form",
|
|
15462
|
+
category: "delete",
|
|
15463
|
+
executionMode: "hubspot",
|
|
15464
|
+
summary: "Archive a HubSpot form",
|
|
15465
|
+
description: "Archive a HubSpot form by ID using the Forms API DELETE endpoint. The form remains retrievable with archived=true.",
|
|
15466
|
+
fields: fields50,
|
|
15467
|
+
example: {
|
|
15468
|
+
fields: {
|
|
15469
|
+
form_id: "6eae0163-5362-4c0e-809c-b99a18678adc"
|
|
15470
|
+
}
|
|
15471
|
+
},
|
|
15472
|
+
toNested: (description, fields51) => ({ type: "delete_form", description, ...fields51 }),
|
|
15473
|
+
requiredScopes: () => ["forms"],
|
|
15474
|
+
getSummary: (op) => `Delete Form \u2014 #${op.form_id}`,
|
|
15475
|
+
getResourceUrl: () => null,
|
|
15476
|
+
renderDetails: (op) => ({
|
|
15477
|
+
rows: [{ label: "Form ID", value: String(op.form_id) }]
|
|
15478
|
+
})
|
|
15479
|
+
};
|
|
15480
|
+
|
|
15192
15481
|
// ../shared/types/plan.ts
|
|
15193
|
-
var OperationSchema =
|
|
15482
|
+
var OperationSchema = z80.discriminatedUnion("type", [
|
|
15194
15483
|
CreatePropertyOperationSchema,
|
|
15195
15484
|
CreatePipelineOperationSchema,
|
|
15196
15485
|
CreateAssociationLabelOperationSchema,
|
|
@@ -15237,12 +15526,15 @@ var OperationSchema = z76.discriminatedUnion("type", [
|
|
|
15237
15526
|
CreateWorkflowOperationSchema,
|
|
15238
15527
|
UpdateWorkflowOperationSchema,
|
|
15239
15528
|
SetWorkflowEnabledOperationSchema,
|
|
15240
|
-
DeleteWorkflowOperationSchema
|
|
15529
|
+
DeleteWorkflowOperationSchema,
|
|
15530
|
+
CreateFormOperationSchema,
|
|
15531
|
+
UpdateFormOperationSchema,
|
|
15532
|
+
DeleteFormOperationSchema
|
|
15241
15533
|
]);
|
|
15242
|
-
var WritePlanInputSchema =
|
|
15243
|
-
title:
|
|
15244
|
-
description:
|
|
15245
|
-
operations:
|
|
15534
|
+
var WritePlanInputSchema = z80.object({
|
|
15535
|
+
title: z80.string().min(1),
|
|
15536
|
+
description: z80.string().min(1),
|
|
15537
|
+
operations: z80.array(OperationSchema).min(1)
|
|
15246
15538
|
});
|
|
15247
15539
|
|
|
15248
15540
|
// ../shared/operations/create-property/index.ts
|
|
@@ -15498,6 +15790,16 @@ var getOrCreateWorkflowState = (ctx, workflowId) => {
|
|
|
15498
15790
|
ctx.workflowsById.set(workflowId, created);
|
|
15499
15791
|
return created;
|
|
15500
15792
|
};
|
|
15793
|
+
var getOrCreateFormState = (ctx, formId) => {
|
|
15794
|
+
const existing = ctx.formsById.get(formId);
|
|
15795
|
+
if (existing) return existing;
|
|
15796
|
+
const created = {
|
|
15797
|
+
created: false,
|
|
15798
|
+
deleted: false
|
|
15799
|
+
};
|
|
15800
|
+
ctx.formsById.set(formId, created);
|
|
15801
|
+
return created;
|
|
15802
|
+
};
|
|
15501
15803
|
var nextSyntheticMapKey = (prefix, size) => `${prefix}:${size + 1}`;
|
|
15502
15804
|
var nextSyntheticNegativeId = (size) => -(size + 1);
|
|
15503
15805
|
var createPlanValidationContext = () => ({
|
|
@@ -15515,6 +15817,7 @@ var createPlanValidationContext = () => ({
|
|
|
15515
15817
|
deleted: /* @__PURE__ */ new Set()
|
|
15516
15818
|
},
|
|
15517
15819
|
workflowsById: /* @__PURE__ */ new Map(),
|
|
15820
|
+
formsById: /* @__PURE__ */ new Map(),
|
|
15518
15821
|
declaredRefs: /* @__PURE__ */ new Map()
|
|
15519
15822
|
});
|
|
15520
15823
|
var projectCreatedPropertyGroup = (ctx, objectType, groupName) => {
|
|
@@ -15747,6 +16050,33 @@ var projectCreatedWorkflow = (ctx, workflowId, workflow) => {
|
|
|
15747
16050
|
});
|
|
15748
16051
|
return ctx;
|
|
15749
16052
|
};
|
|
16053
|
+
var projectCreatedForm = (ctx, formId, form) => {
|
|
16054
|
+
ctx.formsById.set(formId, {
|
|
16055
|
+
created: true,
|
|
16056
|
+
deleted: false,
|
|
16057
|
+
name: form.name,
|
|
16058
|
+
formType: form.formType,
|
|
16059
|
+
archived: form.archived
|
|
16060
|
+
});
|
|
16061
|
+
return ctx;
|
|
16062
|
+
};
|
|
16063
|
+
var projectUpdatedForm = (ctx, formId, updates) => {
|
|
16064
|
+
const existing = getOrCreateFormState(ctx, formId);
|
|
16065
|
+
ctx.formsById.set(formId, {
|
|
16066
|
+
...existing,
|
|
16067
|
+
...updates
|
|
16068
|
+
});
|
|
16069
|
+
return ctx;
|
|
16070
|
+
};
|
|
16071
|
+
var projectDeletedForm = (ctx, formId) => {
|
|
16072
|
+
const existing = getOrCreateFormState(ctx, formId);
|
|
16073
|
+
ctx.formsById.set(formId, {
|
|
16074
|
+
...existing,
|
|
16075
|
+
deleted: true,
|
|
16076
|
+
archived: true
|
|
16077
|
+
});
|
|
16078
|
+
return ctx;
|
|
16079
|
+
};
|
|
15750
16080
|
var getEffectivePropertyGroups = (ctx, objectType, liveGroupNames) => {
|
|
15751
16081
|
const groups = new Set(liveGroupNames);
|
|
15752
16082
|
const delta = ctx.propertyGroupsByObjectType.get(objectType);
|
|
@@ -15943,6 +16273,27 @@ var getEffectiveWorkflow = (ctx, workflowId, liveWorkflow) => {
|
|
|
15943
16273
|
...projected.isEnabled !== void 0 ? { isEnabled: projected.isEnabled } : {}
|
|
15944
16274
|
};
|
|
15945
16275
|
};
|
|
16276
|
+
var getEffectiveForm = (ctx, formId, liveForm) => {
|
|
16277
|
+
const projected = ctx.formsById.get(formId);
|
|
16278
|
+
if (!projected) return liveForm;
|
|
16279
|
+
if (projected.deleted) return void 0;
|
|
16280
|
+
return {
|
|
16281
|
+
...liveForm,
|
|
16282
|
+
...projected.name !== void 0 ? { name: projected.name } : {},
|
|
16283
|
+
...projected.archived !== void 0 ? { archived: projected.archived } : {},
|
|
16284
|
+
...projected.formType !== void 0 ? { formType: projected.formType } : {}
|
|
16285
|
+
};
|
|
16286
|
+
};
|
|
16287
|
+
var getProjectedForm = (ctx, formId) => {
|
|
16288
|
+
const projected = ctx.formsById.get(formId);
|
|
16289
|
+
if (!projected || projected.deleted || !projected.created) return void 0;
|
|
16290
|
+
return {
|
|
16291
|
+
id: formId,
|
|
16292
|
+
name: projected.name,
|
|
16293
|
+
archived: projected.archived,
|
|
16294
|
+
formType: projected.formType
|
|
16295
|
+
};
|
|
16296
|
+
};
|
|
15946
16297
|
|
|
15947
16298
|
// ../shared/pure/conditional-options-task.ts
|
|
15948
16299
|
var formatObjectType = (objectType) => objectType.charAt(0).toUpperCase() + objectType.slice(1);
|
|
@@ -22050,11 +22401,11 @@ var collectActionNextActionIds = (action) => {
|
|
|
22050
22401
|
var validateStaticValueType = (params) => {
|
|
22051
22402
|
const { action, actionId, operationIndex } = params;
|
|
22052
22403
|
const issues = [];
|
|
22053
|
-
const
|
|
22054
|
-
if (!
|
|
22404
|
+
const fields51 = action.fields;
|
|
22405
|
+
if (!fields51) return issues;
|
|
22055
22406
|
const actionTypeId = action.actionTypeId ?? "";
|
|
22056
22407
|
if (actionTypeId === "0-5") {
|
|
22057
|
-
const value =
|
|
22408
|
+
const value = fields51.value;
|
|
22058
22409
|
if (isRecord(value) && "staticValue" in value && value.type !== "STATIC_VALUE") {
|
|
22059
22410
|
issues.push({
|
|
22060
22411
|
severity: "error",
|
|
@@ -22065,7 +22416,7 @@ var validateStaticValueType = (params) => {
|
|
|
22065
22416
|
}
|
|
22066
22417
|
}
|
|
22067
22418
|
if (actionTypeId === "0-14") {
|
|
22068
|
-
const properties =
|
|
22419
|
+
const properties = fields51.properties;
|
|
22069
22420
|
if (Array.isArray(properties)) {
|
|
22070
22421
|
for (const prop of properties) {
|
|
22071
22422
|
if (!isRecord(prop)) continue;
|
|
@@ -22083,7 +22434,7 @@ var validateStaticValueType = (params) => {
|
|
|
22083
22434
|
}
|
|
22084
22435
|
}
|
|
22085
22436
|
if (actionTypeId === "0-35") {
|
|
22086
|
-
const date =
|
|
22437
|
+
const date = fields51.date;
|
|
22087
22438
|
if (isRecord(date) && "staticValue" in date && date.type !== "STATIC_VALUE") {
|
|
22088
22439
|
issues.push({
|
|
22089
22440
|
severity: "error",
|
|
@@ -22098,10 +22449,10 @@ var validateStaticValueType = (params) => {
|
|
|
22098
22449
|
var validateDelayUntilDateAction = (params) => {
|
|
22099
22450
|
const { action, actionId, operationIndex } = params;
|
|
22100
22451
|
if (action.actionTypeId !== "0-35") return [];
|
|
22101
|
-
const
|
|
22102
|
-
if (!
|
|
22452
|
+
const fields51 = action.fields;
|
|
22453
|
+
if (!fields51) return [];
|
|
22103
22454
|
const issues = [];
|
|
22104
|
-
const timeUnit =
|
|
22455
|
+
const timeUnit = fields51.time_unit;
|
|
22105
22456
|
if (timeUnit !== void 0 && timeUnit !== "DAYS" && timeUnit !== "HOURS" && timeUnit !== "MINUTES") {
|
|
22106
22457
|
issues.push({
|
|
22107
22458
|
severity: "error",
|
|
@@ -22110,7 +22461,7 @@ var validateDelayUntilDateAction = (params) => {
|
|
|
22110
22461
|
message: `Action '${actionId || "<missing>"}' (0-35 delay until date) has invalid time_unit '${String(timeUnit)}'. Use DAYS, HOURS, or MINUTES.`
|
|
22111
22462
|
});
|
|
22112
22463
|
}
|
|
22113
|
-
const timeOfDay =
|
|
22464
|
+
const timeOfDay = fields51.time_of_day;
|
|
22114
22465
|
if (!isRecord(timeOfDay)) return issues;
|
|
22115
22466
|
if (!isIntegerInRange(timeOfDay.hour, 0, 23) || !isIntegerInRange(timeOfDay.minute, 0, 59)) {
|
|
22116
22467
|
issues.push({
|
|
@@ -22161,10 +22512,10 @@ var validateDelayUntilDateBranching = (params) => {
|
|
|
22161
22512
|
var validateRotateToOwnerAction = (params) => {
|
|
22162
22513
|
const { action, actionId, operationIndex } = params;
|
|
22163
22514
|
if (action.actionTypeId !== "0-11") return [];
|
|
22164
|
-
const
|
|
22165
|
-
if (!
|
|
22515
|
+
const fields51 = action.fields;
|
|
22516
|
+
if (!fields51) return [];
|
|
22166
22517
|
const issues = [];
|
|
22167
|
-
const overwrite =
|
|
22518
|
+
const overwrite = fields51.overwrite_current_owner;
|
|
22168
22519
|
if (overwrite !== void 0 && overwrite !== "true" && overwrite !== "false") {
|
|
22169
22520
|
issues.push({
|
|
22170
22521
|
severity: "error",
|
|
@@ -22173,7 +22524,7 @@ var validateRotateToOwnerAction = (params) => {
|
|
|
22173
22524
|
message: `Action '${actionId || "<missing>"}' (0-11 rotate to owner) has invalid overwrite_current_owner '${String(overwrite)}'. Use 'true' or 'false'.`
|
|
22174
22525
|
});
|
|
22175
22526
|
}
|
|
22176
|
-
const userIds =
|
|
22527
|
+
const userIds = fields51.user_ids;
|
|
22177
22528
|
if (userIds !== void 0 && !Array.isArray(userIds)) {
|
|
22178
22529
|
issues.push({
|
|
22179
22530
|
severity: "error",
|
|
@@ -22188,11 +22539,11 @@ var validateCreateTaskAssociations = (params) => {
|
|
|
22188
22539
|
const { action, actionId, operationIndex, context } = params;
|
|
22189
22540
|
if (action.actionTypeId !== "0-3") return [];
|
|
22190
22541
|
if (context?.workflowType !== "CONTACT_FLOW") return [];
|
|
22191
|
-
const
|
|
22192
|
-
if (!
|
|
22542
|
+
const fields51 = action.fields;
|
|
22543
|
+
if (!fields51) return [];
|
|
22193
22544
|
const issues = [];
|
|
22194
|
-
const useExplicitAssociations =
|
|
22195
|
-
const associations =
|
|
22545
|
+
const useExplicitAssociations = fields51.use_explicit_associations;
|
|
22546
|
+
const associations = fields51.associations;
|
|
22196
22547
|
const hasValidEnrolledContactAssociation = Array.isArray(associations) && associations.some((entry) => {
|
|
22197
22548
|
if (!isRecord(entry)) return false;
|
|
22198
22549
|
const target = isRecord(entry.target) ? entry.target : void 0;
|
|
@@ -22355,9 +22706,9 @@ var validateWorkflowActions = (params) => {
|
|
|
22355
22706
|
var collectWorkflowAssociatedPropertyActionRefs = (actions) => actions.flatMap((action) => {
|
|
22356
22707
|
const actionTypeId = typeof action.actionTypeId === "string" ? action.actionTypeId : "";
|
|
22357
22708
|
if (actionTypeId !== "0-5") return [];
|
|
22358
|
-
const
|
|
22359
|
-
const association = isRecord(
|
|
22360
|
-
const propertyName = typeof
|
|
22709
|
+
const fields51 = isRecord(action.fields) ? action.fields : void 0;
|
|
22710
|
+
const association = isRecord(fields51?.association) ? fields51.association : void 0;
|
|
22711
|
+
const propertyName = typeof fields51?.property === "string" ? fields51.property : typeof fields51?.property_name === "string" ? fields51.property_name : void 0;
|
|
22361
22712
|
const associationTypeId = typeof association?.associationTypeId === "number" ? association.associationTypeId : void 0;
|
|
22362
22713
|
if (!propertyName || associationTypeId === void 0) return [];
|
|
22363
22714
|
return [{
|
|
@@ -22536,6 +22887,60 @@ var validateWorkflowRefinementFilters = (params) => {
|
|
|
22536
22887
|
};
|
|
22537
22888
|
|
|
22538
22889
|
// ../shared/pure/workflow-validation/structure.ts
|
|
22890
|
+
var getNestedNextActionId2 = (value) => {
|
|
22891
|
+
if (!isRecord(value)) return void 0;
|
|
22892
|
+
if (typeof value.nextActionId === "string") return value.nextActionId;
|
|
22893
|
+
const connection = isRecord(value.connection) ? value.connection : void 0;
|
|
22894
|
+
return typeof connection?.nextActionId === "string" ? connection.nextActionId : void 0;
|
|
22895
|
+
};
|
|
22896
|
+
var collectActionNextActionIds2 = (action) => {
|
|
22897
|
+
const nextActionIds = [];
|
|
22898
|
+
if (action.connection?.nextActionId) {
|
|
22899
|
+
nextActionIds.push(action.connection.nextActionId);
|
|
22900
|
+
}
|
|
22901
|
+
for (const branch of action.staticBranches ?? []) {
|
|
22902
|
+
const nextActionId = getNestedNextActionId2(branch);
|
|
22903
|
+
if (nextActionId) nextActionIds.push(nextActionId);
|
|
22904
|
+
}
|
|
22905
|
+
for (const branch of action.listBranches ?? []) {
|
|
22906
|
+
const nextActionId = getNestedNextActionId2(branch);
|
|
22907
|
+
if (nextActionId) nextActionIds.push(nextActionId);
|
|
22908
|
+
}
|
|
22909
|
+
for (const branch of action.testBranches ?? []) {
|
|
22910
|
+
const nextActionId = getNestedNextActionId2(branch);
|
|
22911
|
+
if (nextActionId) nextActionIds.push(nextActionId);
|
|
22912
|
+
}
|
|
22913
|
+
const defaultBranchNextActionId = getNestedNextActionId2(action.defaultBranch);
|
|
22914
|
+
if (defaultBranchNextActionId) {
|
|
22915
|
+
nextActionIds.push(defaultBranchNextActionId);
|
|
22916
|
+
}
|
|
22917
|
+
return nextActionIds;
|
|
22918
|
+
};
|
|
22919
|
+
var validateWorkflowTreeShape = (params) => {
|
|
22920
|
+
const { actions, operationIndex } = params;
|
|
22921
|
+
const inboundRefs = /* @__PURE__ */ new Map();
|
|
22922
|
+
for (const rawAction of actions ?? []) {
|
|
22923
|
+
if (!isRecord(rawAction)) continue;
|
|
22924
|
+
const action = rawAction;
|
|
22925
|
+
const sourceActionId = typeof action.actionId === "string" ? action.actionId : "<missing>";
|
|
22926
|
+
for (const nextActionId of collectActionNextActionIds2(action)) {
|
|
22927
|
+
const sources = inboundRefs.get(nextActionId) ?? /* @__PURE__ */ new Set();
|
|
22928
|
+
sources.add(sourceActionId);
|
|
22929
|
+
inboundRefs.set(nextActionId, sources);
|
|
22930
|
+
}
|
|
22931
|
+
}
|
|
22932
|
+
const issues = [];
|
|
22933
|
+
for (const [targetActionId, sourceActionIds] of inboundRefs.entries()) {
|
|
22934
|
+
if (sourceActionIds.size <= 1) continue;
|
|
22935
|
+
issues.push({
|
|
22936
|
+
severity: "error",
|
|
22937
|
+
operation_index: operationIndex,
|
|
22938
|
+
code: "WORKFLOW_GRAPH_NOT_TREE_SHAPED",
|
|
22939
|
+
message: `Action '${targetActionId}' has multiple inbound connections from [${[...sourceActionIds].sort().join(", ")}]. HubSpot workflow creation rejects reconverging graphs; duplicate the downstream action chain instead of merging branches.`
|
|
22940
|
+
});
|
|
22941
|
+
}
|
|
22942
|
+
return issues;
|
|
22943
|
+
};
|
|
22539
22944
|
var validateWorkflowStructure = (params) => {
|
|
22540
22945
|
const { actions, enrollmentCriteria, operationIndex } = params;
|
|
22541
22946
|
const issues = [];
|
|
@@ -22564,6 +22969,7 @@ var validateWorkflowStructure = (params) => {
|
|
|
22564
22969
|
const enrollmentCriteriaRecord = isRecord(enrollmentCriteria) ? enrollmentCriteria : void 0;
|
|
22565
22970
|
issues.push(...validateWorkflowEventTypeIds({ enrollmentCriteria: enrollmentCriteriaRecord, operationIndex }));
|
|
22566
22971
|
issues.push(...validateWorkflowRefinementFilters({ enrollmentCriteria: enrollmentCriteriaRecord, operationIndex }));
|
|
22972
|
+
issues.push(...validateWorkflowTreeShape({ actions, operationIndex }));
|
|
22567
22973
|
return issues;
|
|
22568
22974
|
};
|
|
22569
22975
|
|
|
@@ -22576,25 +22982,25 @@ var injectStaticValueType = (value) => {
|
|
|
22576
22982
|
return value;
|
|
22577
22983
|
};
|
|
22578
22984
|
var normalizeWorkflowActionValues = (actions) => actions.map((action) => {
|
|
22579
|
-
const
|
|
22580
|
-
if (!
|
|
22985
|
+
const fields51 = isRecord(action.fields) ? action.fields : void 0;
|
|
22986
|
+
if (!fields51) return { ...action };
|
|
22581
22987
|
const actionTypeId = typeof action.actionTypeId === "string" ? action.actionTypeId : "";
|
|
22582
22988
|
if (actionTypeId === "0-5") {
|
|
22583
22989
|
const {
|
|
22584
22990
|
property,
|
|
22585
22991
|
property_name,
|
|
22586
22992
|
...restFields
|
|
22587
|
-
} =
|
|
22993
|
+
} = fields51;
|
|
22588
22994
|
const canonicalPropertyName = typeof property_name === "string" && property_name.length > 0 ? property_name : typeof property === "string" && property.length > 0 ? property : void 0;
|
|
22589
22995
|
const normalizedFields = canonicalPropertyName ? { ...restFields, property_name: canonicalPropertyName, value: injectStaticValueType(restFields.value) } : { ...restFields, value: injectStaticValueType(restFields.value) };
|
|
22590
22996
|
return { ...action, fields: normalizedFields };
|
|
22591
22997
|
}
|
|
22592
|
-
if (actionTypeId === "0-14" && Array.isArray(
|
|
22998
|
+
if (actionTypeId === "0-14" && Array.isArray(fields51.properties)) {
|
|
22593
22999
|
return {
|
|
22594
23000
|
...action,
|
|
22595
23001
|
fields: {
|
|
22596
|
-
...
|
|
22597
|
-
properties:
|
|
23002
|
+
...fields51,
|
|
23003
|
+
properties: fields51.properties.map((prop) => {
|
|
22598
23004
|
if (!isRecord(prop)) return prop;
|
|
22599
23005
|
return { ...prop, value: injectStaticValueType(prop.value) };
|
|
22600
23006
|
})
|
|
@@ -22604,7 +23010,7 @@ var normalizeWorkflowActionValues = (actions) => actions.map((action) => {
|
|
|
22604
23010
|
if (actionTypeId === "0-35") {
|
|
22605
23011
|
return {
|
|
22606
23012
|
...action,
|
|
22607
|
-
fields: { ...
|
|
23013
|
+
fields: { ...fields51, date: injectStaticValueType(fields51.date) }
|
|
22608
23014
|
};
|
|
22609
23015
|
}
|
|
22610
23016
|
return { ...action };
|
|
@@ -22623,10 +23029,10 @@ var fromDirectionKey = (directionKey) => {
|
|
|
22623
23029
|
var collectWorkflowPropertyActionRefs = (actions) => actions.flatMap((action) => {
|
|
22624
23030
|
const actionTypeId = typeof action.actionTypeId === "string" ? action.actionTypeId : "";
|
|
22625
23031
|
if (actionTypeId !== "0-5") return [];
|
|
22626
|
-
const
|
|
22627
|
-
const association = typeof
|
|
22628
|
-
const value = typeof
|
|
22629
|
-
const propertyName = typeof
|
|
23032
|
+
const fields51 = typeof action.fields === "object" && action.fields !== null ? action.fields : void 0;
|
|
23033
|
+
const association = typeof fields51?.association === "object" && fields51.association !== null ? fields51.association : void 0;
|
|
23034
|
+
const value = typeof fields51?.value === "object" && fields51.value !== null ? fields51.value : void 0;
|
|
23035
|
+
const propertyName = typeof fields51?.property === "string" ? fields51.property : typeof fields51?.property_name === "string" ? fields51.property_name : void 0;
|
|
22630
23036
|
if (!propertyName) return [];
|
|
22631
23037
|
return [{
|
|
22632
23038
|
actionId: typeof action.actionId === "string" ? action.actionId : "<missing>",
|
|
@@ -22637,58 +23043,58 @@ var collectWorkflowPropertyActionRefs = (actions) => actions.flatMap((action) =>
|
|
|
22637
23043
|
});
|
|
22638
23044
|
var collectRotateToOwnerActions = (actions) => actions.flatMap((action) => {
|
|
22639
23045
|
if (typeof action.actionTypeId !== "string" || action.actionTypeId !== "0-11") return [];
|
|
22640
|
-
const
|
|
22641
|
-
if (!
|
|
23046
|
+
const fields51 = typeof action.fields === "object" && action.fields !== null ? action.fields : void 0;
|
|
23047
|
+
if (!fields51 || !Array.isArray(fields51.user_ids)) return [];
|
|
22642
23048
|
return [{
|
|
22643
23049
|
actionId: typeof action.actionId === "string" ? action.actionId : "<missing>",
|
|
22644
|
-
userIds:
|
|
23050
|
+
userIds: fields51.user_ids.filter((id) => typeof id === "string")
|
|
22645
23051
|
}];
|
|
22646
23052
|
});
|
|
22647
23053
|
var collectWorkflowTargetActions = (actions) => actions.flatMap((action) => {
|
|
22648
23054
|
if (typeof action.actionTypeId !== "string" || action.actionTypeId !== "0-15") return [];
|
|
22649
|
-
const
|
|
22650
|
-
if (!
|
|
23055
|
+
const fields51 = typeof action.fields === "object" && action.fields !== null ? action.fields : void 0;
|
|
23056
|
+
if (!fields51 || typeof fields51.flow_id !== "string" || fields51.flow_id.length === 0) return [];
|
|
22651
23057
|
return [{
|
|
22652
23058
|
actionId: typeof action.actionId === "string" ? action.actionId : "<missing>",
|
|
22653
|
-
flowId:
|
|
23059
|
+
flowId: fields51.flow_id
|
|
22654
23060
|
}];
|
|
22655
23061
|
});
|
|
22656
23062
|
var collectSequenceActions = (actions) => actions.flatMap((action) => {
|
|
22657
23063
|
if (typeof action.actionTypeId !== "string" || action.actionTypeId !== "0-46510720") return [];
|
|
22658
|
-
const
|
|
22659
|
-
if (!
|
|
23064
|
+
const fields51 = typeof action.fields === "object" && action.fields !== null ? action.fields : void 0;
|
|
23065
|
+
if (!fields51 || typeof fields51.sequenceId !== "string" || fields51.sequenceId.length === 0) return [];
|
|
22660
23066
|
return [{
|
|
22661
23067
|
actionId: typeof action.actionId === "string" ? action.actionId : "<missing>",
|
|
22662
|
-
sequenceId:
|
|
23068
|
+
sequenceId: fields51.sequenceId
|
|
22663
23069
|
}];
|
|
22664
23070
|
});
|
|
22665
23071
|
var collectSubscriptionDefinitionActions = (actions) => actions.flatMap((action) => {
|
|
22666
23072
|
if (typeof action.actionTypeId !== "string" || action.actionTypeId !== "0-43347357") return [];
|
|
22667
|
-
const
|
|
22668
|
-
if (!
|
|
23073
|
+
const fields51 = typeof action.fields === "object" && action.fields !== null ? action.fields : void 0;
|
|
23074
|
+
if (!fields51 || typeof fields51.subscriptionId !== "string" || fields51.subscriptionId.length === 0) return [];
|
|
22669
23075
|
return [{
|
|
22670
23076
|
actionId: typeof action.actionId === "string" ? action.actionId : "<missing>",
|
|
22671
|
-
subscriptionId:
|
|
23077
|
+
subscriptionId: fields51.subscriptionId
|
|
22672
23078
|
}];
|
|
22673
23079
|
});
|
|
22674
23080
|
var collectInboxActions = (actions) => actions.flatMap((action) => {
|
|
22675
23081
|
if (typeof action.actionTypeId !== "string" || action.actionTypeId !== "0-44475148") return [];
|
|
22676
|
-
const
|
|
22677
|
-
if (!
|
|
23082
|
+
const fields51 = typeof action.fields === "object" && action.fields !== null ? action.fields : void 0;
|
|
23083
|
+
if (!fields51 || typeof fields51["Target Inbox"] !== "string" || fields51["Target Inbox"].length === 0) return [];
|
|
22678
23084
|
return [{
|
|
22679
23085
|
actionId: typeof action.actionId === "string" ? action.actionId : "<missing>",
|
|
22680
|
-
inboxId:
|
|
23086
|
+
inboxId: fields51["Target Inbox"]
|
|
22681
23087
|
}];
|
|
22682
23088
|
});
|
|
22683
23089
|
var collectAssociationLabelActions = (actions) => actions.flatMap((action) => {
|
|
22684
23090
|
if (typeof action.actionTypeId !== "string") return [];
|
|
22685
23091
|
if (!["0-63189541", "0-73444249", "0-61139476"].includes(action.actionTypeId)) return [];
|
|
22686
|
-
const
|
|
22687
|
-
const fromObjectType = typeof
|
|
22688
|
-
const toObjectType = typeof
|
|
22689
|
-
if (!
|
|
23092
|
+
const fields51 = typeof action.fields === "object" && action.fields !== null ? action.fields : void 0;
|
|
23093
|
+
const fromObjectType = typeof fields51?.fromObjectType === "string" ? fields51.fromObjectType : void 0;
|
|
23094
|
+
const toObjectType = typeof fields51?.toObjectType === "string" ? fields51.toObjectType : void 0;
|
|
23095
|
+
if (!fields51 || !fromObjectType || !toObjectType) return [];
|
|
22690
23096
|
const fieldName = action.actionTypeId === "0-61139476" ? "labelToRemove" : "labelToApply";
|
|
22691
|
-
const rawId =
|
|
23097
|
+
const rawId = fields51[fieldName];
|
|
22692
23098
|
if (typeof rawId !== "string" || rawId.length === 0) return [];
|
|
22693
23099
|
return [{
|
|
22694
23100
|
actionId: typeof action.actionId === "string" ? action.actionId : "<missing>",
|
|
@@ -24142,10 +24548,453 @@ var deleteWorkflowHandler = {
|
|
|
24142
24548
|
}
|
|
24143
24549
|
};
|
|
24144
24550
|
|
|
24145
|
-
// ../shared/operations/
|
|
24551
|
+
// ../shared/operations/create-form/index.ts
|
|
24146
24552
|
import { Effect as Effect112, pipe as pipe93 } from "effect";
|
|
24147
|
-
var
|
|
24553
|
+
var createFormHandler = {
|
|
24554
|
+
type: "create_form",
|
|
24555
|
+
validate: (op, index) => validateFormFieldGroups(op.definition.fieldGroups, index),
|
|
24556
|
+
validateEffectful: (op, index, ctx) => pipe93(
|
|
24557
|
+
HubSpotService,
|
|
24558
|
+
Effect112.flatMap((hs) => hs.getForms),
|
|
24559
|
+
Effect112.map((forms) => {
|
|
24560
|
+
const issues = [];
|
|
24561
|
+
const existing = forms.find(
|
|
24562
|
+
(form) => form.name?.trim().toLowerCase() === op.definition.name.trim().toLowerCase() && form.archived !== true
|
|
24563
|
+
);
|
|
24564
|
+
if (existing) {
|
|
24565
|
+
issues.push({
|
|
24566
|
+
severity: "warning",
|
|
24567
|
+
operation_index: index,
|
|
24568
|
+
code: "FORM_NAME_ALREADY_EXISTS",
|
|
24569
|
+
message: `An active form named '${op.definition.name}' already exists`
|
|
24570
|
+
});
|
|
24571
|
+
}
|
|
24572
|
+
const validationCtx = ctx ?? createPlanValidationContext();
|
|
24573
|
+
for (const [, projected] of validationCtx.formsById) {
|
|
24574
|
+
if (projected.deleted || !projected.name) continue;
|
|
24575
|
+
if (projected.name.trim().toLowerCase() === op.definition.name.trim().toLowerCase()) {
|
|
24576
|
+
issues.push({
|
|
24577
|
+
severity: "warning",
|
|
24578
|
+
operation_index: index,
|
|
24579
|
+
code: "FORM_NAME_DUPLICATED_IN_PLAN",
|
|
24580
|
+
message: `Another form in this plan already uses the name '${op.definition.name}'`
|
|
24581
|
+
});
|
|
24582
|
+
break;
|
|
24583
|
+
}
|
|
24584
|
+
}
|
|
24585
|
+
return issues;
|
|
24586
|
+
}),
|
|
24587
|
+
catchAllToWarning(
|
|
24588
|
+
"VALIDATION_API_UNAVAILABLE",
|
|
24589
|
+
index,
|
|
24590
|
+
"Unable to verify existing forms during validation (API error)"
|
|
24591
|
+
)
|
|
24592
|
+
),
|
|
24593
|
+
preCheck: (op, index, seen) => pipe93(
|
|
24594
|
+
HubSpotService,
|
|
24595
|
+
Effect112.flatMap((hs) => hs.getForms),
|
|
24596
|
+
Effect112.map((forms) => {
|
|
24597
|
+
const { issues, add } = makeDedupAdder(seen);
|
|
24598
|
+
const existing = forms.find(
|
|
24599
|
+
(form) => form.name?.trim().toLowerCase() === op.definition.name.trim().toLowerCase() && form.archived !== true
|
|
24600
|
+
);
|
|
24601
|
+
if (existing) {
|
|
24602
|
+
add({
|
|
24603
|
+
severity: "warning",
|
|
24604
|
+
operation_index: index,
|
|
24605
|
+
code: "FORM_CREATED_SINCE_SUBMISSION",
|
|
24606
|
+
message: `An active form named '${op.definition.name}' now exists \u2014 it may have been created since this plan was submitted`
|
|
24607
|
+
});
|
|
24608
|
+
}
|
|
24609
|
+
return issues;
|
|
24610
|
+
}),
|
|
24611
|
+
catchAllToWarning(
|
|
24612
|
+
"PRECHECK_UNAVAILABLE",
|
|
24613
|
+
index,
|
|
24614
|
+
"Unable to verify existing forms before execution (API error)"
|
|
24615
|
+
)
|
|
24616
|
+
),
|
|
24617
|
+
declarePlanRefs: (op, index, ctx) => declarePlanRef(ctx, {
|
|
24618
|
+
ref: op.ref,
|
|
24619
|
+
sourceOperationIndex: index,
|
|
24620
|
+
kind: "form",
|
|
24621
|
+
primitive: "string",
|
|
24622
|
+
projectedValue: op.ref ? makeSyntheticStringRefValue("form", index) : void 0
|
|
24623
|
+
}),
|
|
24624
|
+
projectValidationState: (op, index, ctx) => projectCreatedForm(ctx, makeSyntheticStringRefValue("form", index), {
|
|
24625
|
+
name: op.definition.name,
|
|
24626
|
+
formType: op.definition.formType,
|
|
24627
|
+
archived: false
|
|
24628
|
+
}),
|
|
24629
|
+
execute: (op, index) => pipe93(
|
|
24630
|
+
HubSpotService,
|
|
24631
|
+
Effect112.flatMap((hs) => hs.createForm(op.definition)),
|
|
24632
|
+
Effect112.map((form) => ({
|
|
24633
|
+
index,
|
|
24634
|
+
type: "create_form",
|
|
24635
|
+
status: "success",
|
|
24636
|
+
records_affected: 1,
|
|
24637
|
+
affected_ids: form.id ? [form.id] : []
|
|
24638
|
+
})),
|
|
24639
|
+
catchAllToFailed("create_form", index)
|
|
24640
|
+
),
|
|
24641
|
+
collectOutputRefs: (op, _index, result) => collectSingleOutputRef(op.ref, "form", "string", result.affected_ids?.[0]),
|
|
24642
|
+
postCheck: (op, index, result) => {
|
|
24643
|
+
if (result.status !== "success" || !result.affected_ids?.[0]) return Effect112.succeed([]);
|
|
24644
|
+
const formId = result.affected_ids[0];
|
|
24645
|
+
return pipe93(
|
|
24646
|
+
HubSpotService,
|
|
24647
|
+
Effect112.flatMap((hs) => hs.getForm(formId)),
|
|
24648
|
+
Effect112.map((form) => {
|
|
24649
|
+
const issues = [];
|
|
24650
|
+
if (form.name !== op.definition.name) {
|
|
24651
|
+
issues.push({
|
|
24652
|
+
severity: "warning",
|
|
24653
|
+
operation_index: index,
|
|
24654
|
+
code: "POSTCHECK_FORM_NAME_MISMATCH",
|
|
24655
|
+
message: `Form '${formId}' was created but its name is '${form.name ?? ""}' instead of '${op.definition.name}'`
|
|
24656
|
+
});
|
|
24657
|
+
}
|
|
24658
|
+
return issues;
|
|
24659
|
+
}),
|
|
24660
|
+
catchAllToWarning(
|
|
24661
|
+
"POSTCHECK_UNAVAILABLE",
|
|
24662
|
+
index,
|
|
24663
|
+
`Unable to verify created form '${formId}' after execution`
|
|
24664
|
+
)
|
|
24665
|
+
);
|
|
24666
|
+
}
|
|
24667
|
+
};
|
|
24668
|
+
|
|
24669
|
+
// ../shared/operations/update-form/index.ts
|
|
24670
|
+
import { Effect as Effect113, pipe as pipe94 } from "effect";
|
|
24671
|
+
var hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
24672
|
+
var updateFormHandler = {
|
|
24673
|
+
type: "update_form",
|
|
24674
|
+
validate: (op, index) => {
|
|
24675
|
+
const issues = [];
|
|
24676
|
+
const hasRecognizedUpdate = op.updates.name !== void 0 || op.updates.fieldGroups !== void 0 || op.updates.configuration !== void 0 || op.updates.displayOptions !== void 0 || op.updates.legalConsentOptions !== void 0;
|
|
24677
|
+
if (!hasRecognizedUpdate) {
|
|
24678
|
+
issues.push({
|
|
24679
|
+
severity: "error",
|
|
24680
|
+
operation_index: index,
|
|
24681
|
+
code: "FORM_UPDATE_EMPTY",
|
|
24682
|
+
message: "update_form requires at least one supported field in updates"
|
|
24683
|
+
});
|
|
24684
|
+
}
|
|
24685
|
+
if (hasOwn(op.updates, "archived")) {
|
|
24686
|
+
issues.push({
|
|
24687
|
+
severity: "error",
|
|
24688
|
+
operation_index: index,
|
|
24689
|
+
code: "FORM_UPDATE_ARCHIVE_UNSUPPORTED",
|
|
24690
|
+
message: "Archiving via update_form is not supported reliably; use delete_form instead"
|
|
24691
|
+
});
|
|
24692
|
+
}
|
|
24693
|
+
if (op.updates.fieldGroups) {
|
|
24694
|
+
issues.push(...validateFormFieldGroups(op.updates.fieldGroups, index));
|
|
24695
|
+
}
|
|
24696
|
+
return issues;
|
|
24697
|
+
},
|
|
24698
|
+
validateEffectful: (op, index, ctx) => {
|
|
24699
|
+
const formId = coercePlanRefStringValue(op.form_id);
|
|
24700
|
+
const projected = ctx ? getProjectedForm(ctx, formId) : void 0;
|
|
24701
|
+
if (projected) return Effect113.succeed([]);
|
|
24702
|
+
return pipe94(
|
|
24703
|
+
HubSpotService,
|
|
24704
|
+
Effect113.flatMap((hs) => hs.getForm(formId)),
|
|
24705
|
+
Effect113.map(
|
|
24706
|
+
(form) => getEffectiveForm(ctx ?? createPlanValidationContext(), formId, form) ? [] : [{
|
|
24707
|
+
severity: "error",
|
|
24708
|
+
operation_index: index,
|
|
24709
|
+
code: "FORM_NOT_FOUND",
|
|
24710
|
+
message: `Form '${formId}' does not exist \u2014 cannot update a non-existent form`
|
|
24711
|
+
}]
|
|
24712
|
+
),
|
|
24713
|
+
Effect113.catchAll(
|
|
24714
|
+
() => Effect113.succeed([{
|
|
24715
|
+
severity: "error",
|
|
24716
|
+
operation_index: index,
|
|
24717
|
+
code: "FORM_NOT_FOUND",
|
|
24718
|
+
message: `Form '${formId}' does not exist \u2014 cannot update a non-existent form`
|
|
24719
|
+
}])
|
|
24720
|
+
)
|
|
24721
|
+
);
|
|
24722
|
+
},
|
|
24723
|
+
resolvePlanRefsForValidation: (op, index, ctx) => {
|
|
24724
|
+
const result = resolveStringFieldForValidation(op.form_id, {
|
|
24725
|
+
ctx,
|
|
24726
|
+
operationIndex: index,
|
|
24727
|
+
fieldLabel: "form_id",
|
|
24728
|
+
kinds: ["form"]
|
|
24729
|
+
});
|
|
24730
|
+
if (!result.ok) return { op, issues: result.issues };
|
|
24731
|
+
return {
|
|
24732
|
+
op: {
|
|
24733
|
+
...op,
|
|
24734
|
+
form_id: result.value
|
|
24735
|
+
},
|
|
24736
|
+
issues: []
|
|
24737
|
+
};
|
|
24738
|
+
},
|
|
24739
|
+
preCheck: (op, index, seen, ctx) => {
|
|
24740
|
+
const formId = coercePlanRefStringValue(op.form_id);
|
|
24741
|
+
if (ctx && getProjectedForm(ctx, formId)) {
|
|
24742
|
+
return Effect113.succeed([]);
|
|
24743
|
+
}
|
|
24744
|
+
return pipe94(
|
|
24745
|
+
HubSpotService,
|
|
24746
|
+
Effect113.flatMap((hs) => hs.getForm(formId)),
|
|
24747
|
+
Effect113.map((form) => {
|
|
24748
|
+
const { issues, add } = makeDedupAdder(seen);
|
|
24749
|
+
if (!getEffectiveForm(ctx ?? createPlanValidationContext(), formId, form)) {
|
|
24750
|
+
add({
|
|
24751
|
+
severity: "warning",
|
|
24752
|
+
operation_index: index,
|
|
24753
|
+
code: "FORM_ALREADY_DELETED",
|
|
24754
|
+
message: `Form '${formId}' no longer exists \u2014 it may have already been deleted`
|
|
24755
|
+
});
|
|
24756
|
+
}
|
|
24757
|
+
return issues;
|
|
24758
|
+
}),
|
|
24759
|
+
Effect113.catchAll(() => {
|
|
24760
|
+
const { issues, add } = makeDedupAdder(seen);
|
|
24761
|
+
add({
|
|
24762
|
+
severity: "warning",
|
|
24763
|
+
operation_index: index,
|
|
24764
|
+
code: "FORM_ALREADY_DELETED",
|
|
24765
|
+
message: `Form '${formId}' no longer exists \u2014 it may have already been deleted`
|
|
24766
|
+
});
|
|
24767
|
+
return Effect113.succeed(issues);
|
|
24768
|
+
})
|
|
24769
|
+
);
|
|
24770
|
+
},
|
|
24771
|
+
resolvePlanRefsForExecution: (op, index, ctx) => {
|
|
24772
|
+
const result = resolveStringFieldForExecution(op.form_id, {
|
|
24773
|
+
ctx,
|
|
24774
|
+
operationIndex: index,
|
|
24775
|
+
operationType: op.type,
|
|
24776
|
+
fieldLabel: "form_id",
|
|
24777
|
+
kinds: ["form"]
|
|
24778
|
+
});
|
|
24779
|
+
if (!result.ok) return result;
|
|
24780
|
+
return {
|
|
24781
|
+
ok: true,
|
|
24782
|
+
op: {
|
|
24783
|
+
...op,
|
|
24784
|
+
form_id: result.value
|
|
24785
|
+
}
|
|
24786
|
+
};
|
|
24787
|
+
},
|
|
24788
|
+
projectValidationState: (op, _index, ctx) => projectUpdatedForm(ctx, coercePlanRefStringValue(op.form_id), {
|
|
24789
|
+
...op.updates.name !== void 0 ? { name: op.updates.name } : {}
|
|
24790
|
+
}),
|
|
24791
|
+
execute: (op, index) => pipe94(
|
|
24792
|
+
HubSpotService,
|
|
24793
|
+
Effect113.flatMap(
|
|
24794
|
+
(hs) => hs.updateForm(coercePlanRefStringValue(op.form_id), op.updates)
|
|
24795
|
+
),
|
|
24796
|
+
Effect113.map((form) => ({
|
|
24797
|
+
index,
|
|
24798
|
+
type: "update_form",
|
|
24799
|
+
status: "success",
|
|
24800
|
+
records_affected: 1,
|
|
24801
|
+
affected_ids: form.id ? [form.id] : [coercePlanRefStringValue(op.form_id)]
|
|
24802
|
+
})),
|
|
24803
|
+
catchAllToFailed("update_form", index)
|
|
24804
|
+
),
|
|
24805
|
+
postCheck: (op, index, result) => {
|
|
24806
|
+
if (result.status !== "success") return Effect113.succeed([]);
|
|
24807
|
+
const formId = coercePlanRefStringValue(op.form_id);
|
|
24808
|
+
return pipe94(
|
|
24809
|
+
HubSpotService,
|
|
24810
|
+
Effect113.flatMap((hs) => hs.getForm(formId)),
|
|
24811
|
+
Effect113.map((form) => {
|
|
24812
|
+
const issues = [];
|
|
24813
|
+
if (op.updates.name !== void 0 && form.name !== op.updates.name) {
|
|
24814
|
+
issues.push({
|
|
24815
|
+
severity: "warning",
|
|
24816
|
+
operation_index: index,
|
|
24817
|
+
code: "POSTCHECK_FORM_NAME_MISMATCH",
|
|
24818
|
+
message: `Form '${formId}' name is '${form.name ?? ""}' instead of '${op.updates.name}' after update`
|
|
24819
|
+
});
|
|
24820
|
+
}
|
|
24821
|
+
return issues;
|
|
24822
|
+
}),
|
|
24823
|
+
catchAllToWarning(
|
|
24824
|
+
"POSTCHECK_UNAVAILABLE",
|
|
24825
|
+
index,
|
|
24826
|
+
`Unable to verify updated form '${formId}' after execution`
|
|
24827
|
+
)
|
|
24828
|
+
);
|
|
24829
|
+
}
|
|
24830
|
+
};
|
|
24831
|
+
|
|
24832
|
+
// ../shared/operations/delete-form/index.ts
|
|
24833
|
+
import { Effect as Effect114, pipe as pipe95 } from "effect";
|
|
24834
|
+
var deleteFormHandler = {
|
|
24835
|
+
type: "delete_form",
|
|
24836
|
+
validate: () => [],
|
|
24837
|
+
validateEffectful: (op, index, ctx) => {
|
|
24838
|
+
const formId = coercePlanRefStringValue(op.form_id);
|
|
24839
|
+
const projected = ctx ? getProjectedForm(ctx, formId) : void 0;
|
|
24840
|
+
if (projected) return Effect114.succeed([]);
|
|
24841
|
+
return pipe95(
|
|
24842
|
+
HubSpotService,
|
|
24843
|
+
Effect114.flatMap((hs) => hs.getForm(formId)),
|
|
24844
|
+
Effect114.map(
|
|
24845
|
+
(form) => getEffectiveForm(ctx ?? createPlanValidationContext(), formId, form) ? [] : [{
|
|
24846
|
+
severity: "error",
|
|
24847
|
+
operation_index: index,
|
|
24848
|
+
code: "FORM_NOT_FOUND",
|
|
24849
|
+
message: `Form '${formId}' does not exist \u2014 cannot delete a non-existent form`
|
|
24850
|
+
}]
|
|
24851
|
+
),
|
|
24852
|
+
Effect114.catchAll(
|
|
24853
|
+
() => Effect114.succeed([{
|
|
24854
|
+
severity: "error",
|
|
24855
|
+
operation_index: index,
|
|
24856
|
+
code: "FORM_NOT_FOUND",
|
|
24857
|
+
message: `Form '${formId}' does not exist \u2014 cannot delete a non-existent form`
|
|
24858
|
+
}])
|
|
24859
|
+
)
|
|
24860
|
+
);
|
|
24861
|
+
},
|
|
24862
|
+
resolvePlanRefsForValidation: (op, index, ctx) => {
|
|
24863
|
+
const result = resolveStringFieldForValidation(op.form_id, {
|
|
24864
|
+
ctx,
|
|
24865
|
+
operationIndex: index,
|
|
24866
|
+
fieldLabel: "form_id",
|
|
24867
|
+
kinds: ["form"]
|
|
24868
|
+
});
|
|
24869
|
+
if (!result.ok) return { op, issues: result.issues };
|
|
24870
|
+
return {
|
|
24871
|
+
op: {
|
|
24872
|
+
...op,
|
|
24873
|
+
form_id: result.value
|
|
24874
|
+
},
|
|
24875
|
+
issues: []
|
|
24876
|
+
};
|
|
24877
|
+
},
|
|
24878
|
+
preCheck: (op, index, seen, ctx) => {
|
|
24879
|
+
const formId = coercePlanRefStringValue(op.form_id);
|
|
24880
|
+
if (ctx && getProjectedForm(ctx, formId)) {
|
|
24881
|
+
return Effect114.succeed([]);
|
|
24882
|
+
}
|
|
24883
|
+
return pipe95(
|
|
24884
|
+
HubSpotService,
|
|
24885
|
+
Effect114.flatMap((hs) => hs.getForm(formId)),
|
|
24886
|
+
Effect114.map((form) => {
|
|
24887
|
+
const { issues, add } = makeDedupAdder(seen);
|
|
24888
|
+
if (!getEffectiveForm(ctx ?? createPlanValidationContext(), formId, form)) {
|
|
24889
|
+
add({
|
|
24890
|
+
severity: "warning",
|
|
24891
|
+
operation_index: index,
|
|
24892
|
+
code: "FORM_ALREADY_ARCHIVED",
|
|
24893
|
+
message: `Form '${formId}' no longer exists in active forms \u2014 it may have already been archived`
|
|
24894
|
+
});
|
|
24895
|
+
}
|
|
24896
|
+
return issues;
|
|
24897
|
+
}),
|
|
24898
|
+
Effect114.catchAll(() => {
|
|
24899
|
+
const { issues, add } = makeDedupAdder(seen);
|
|
24900
|
+
add({
|
|
24901
|
+
severity: "warning",
|
|
24902
|
+
operation_index: index,
|
|
24903
|
+
code: "FORM_ALREADY_ARCHIVED",
|
|
24904
|
+
message: `Form '${formId}' no longer exists in active forms \u2014 it may have already been archived`
|
|
24905
|
+
});
|
|
24906
|
+
return Effect114.succeed(issues);
|
|
24907
|
+
})
|
|
24908
|
+
);
|
|
24909
|
+
},
|
|
24910
|
+
resolvePlanRefsForExecution: (op, index, ctx) => {
|
|
24911
|
+
const result = resolveStringFieldForExecution(op.form_id, {
|
|
24912
|
+
ctx,
|
|
24913
|
+
operationIndex: index,
|
|
24914
|
+
operationType: op.type,
|
|
24915
|
+
fieldLabel: "form_id",
|
|
24916
|
+
kinds: ["form"]
|
|
24917
|
+
});
|
|
24918
|
+
if (!result.ok) return result;
|
|
24919
|
+
return {
|
|
24920
|
+
ok: true,
|
|
24921
|
+
op: {
|
|
24922
|
+
...op,
|
|
24923
|
+
form_id: result.value
|
|
24924
|
+
}
|
|
24925
|
+
};
|
|
24926
|
+
},
|
|
24927
|
+
projectValidationState: (op, _index, ctx) => projectDeletedForm(ctx, coercePlanRefStringValue(op.form_id)),
|
|
24928
|
+
execute: (op, index) => pipe95(
|
|
24929
|
+
HubSpotService,
|
|
24930
|
+
Effect114.flatMap((hs) => hs.deleteForm(coercePlanRefStringValue(op.form_id))),
|
|
24931
|
+
Effect114.map(() => ({
|
|
24932
|
+
index,
|
|
24933
|
+
type: "delete_form",
|
|
24934
|
+
status: "success",
|
|
24935
|
+
records_affected: 1,
|
|
24936
|
+
affected_ids: [coercePlanRefStringValue(op.form_id)]
|
|
24937
|
+
})),
|
|
24938
|
+
catchAllToFailed("delete_form", index)
|
|
24939
|
+
),
|
|
24940
|
+
postCheck: (op, index, result) => {
|
|
24941
|
+
if (result.status !== "success") return Effect114.succeed([]);
|
|
24942
|
+
const formId = coercePlanRefStringValue(op.form_id);
|
|
24943
|
+
return pipe95(
|
|
24944
|
+
HubSpotService,
|
|
24945
|
+
Effect114.flatMap((hs) => hs.getForm(formId)),
|
|
24946
|
+
Effect114.map(() => [{
|
|
24947
|
+
severity: "warning",
|
|
24948
|
+
operation_index: index,
|
|
24949
|
+
code: "POSTCHECK_FORM_STILL_ACTIVE",
|
|
24950
|
+
message: `Form '${formId}' still exists in active forms after delete_form`
|
|
24951
|
+
}]),
|
|
24952
|
+
Effect114.catchAll(() => Effect114.succeed([]))
|
|
24953
|
+
);
|
|
24954
|
+
}
|
|
24955
|
+
};
|
|
24956
|
+
|
|
24957
|
+
// ../shared/operations/framework/dispatcher.ts
|
|
24958
|
+
import { Duration as Duration2, Effect as Effect115, pipe as pipe96 } from "effect";
|
|
24959
|
+
var DEFAULT_REF_READINESS_WAIT_MS = 5e3;
|
|
24960
|
+
var DEFAULT_REF_READINESS_MAX_ATTEMPTS = 3;
|
|
24961
|
+
var operationConsumesRuntimeRef = (value) => {
|
|
24962
|
+
if (isPlanRefValue(value)) return true;
|
|
24963
|
+
if (Array.isArray(value)) return value.some(operationConsumesRuntimeRef);
|
|
24964
|
+
if (value && typeof value === "object") {
|
|
24965
|
+
return Object.values(value).some(operationConsumesRuntimeRef);
|
|
24966
|
+
}
|
|
24967
|
+
return false;
|
|
24968
|
+
};
|
|
24969
|
+
var parseOperationFailureError = (error) => {
|
|
24970
|
+
if (!error) return null;
|
|
24971
|
+
try {
|
|
24972
|
+
const parsed = JSON.parse(error);
|
|
24973
|
+
return {
|
|
24974
|
+
code: typeof parsed.code === "number" ? parsed.code : void 0,
|
|
24975
|
+
category: typeof parsed.category === "string" ? parsed.category : void 0,
|
|
24976
|
+
subCategory: typeof parsed.subCategory === "string" ? parsed.subCategory : void 0,
|
|
24977
|
+
message: typeof parsed.message === "string" ? parsed.message : void 0
|
|
24978
|
+
};
|
|
24979
|
+
} catch {
|
|
24980
|
+
return null;
|
|
24981
|
+
}
|
|
24982
|
+
};
|
|
24983
|
+
var isRetryableResolvedRefFailure = (result) => {
|
|
24984
|
+
if (result.status !== "failed") return false;
|
|
24985
|
+
const parsed = parseOperationFailureError(result.error);
|
|
24986
|
+
if (!parsed || parsed.code !== 404) return false;
|
|
24987
|
+
if (parsed.category === "NOT_FOUND") return true;
|
|
24988
|
+
if (parsed.subCategory === "FlowApiStandardFriendlyError.EXISTING_CRM_OBJECT_NOT_FOUND_FOR_UPDATE") {
|
|
24989
|
+
return true;
|
|
24990
|
+
}
|
|
24991
|
+
return parsed.message?.toLowerCase().includes("not found") ?? false;
|
|
24992
|
+
};
|
|
24993
|
+
var refReadinessDelay = (waitMs) => waitMs > 0 ? Effect115.sleep(Duration2.millis(waitMs)) : Effect115.void;
|
|
24994
|
+
var buildDispatcher = (handlers, options2) => {
|
|
24148
24995
|
const map = new Map(handlers.map((h) => [h.type, h]));
|
|
24996
|
+
const refReadinessWaitMs = options2?.refReadinessWaitMs ?? DEFAULT_REF_READINESS_WAIT_MS;
|
|
24997
|
+
const refReadinessMaxAttempts = options2?.refReadinessMaxAttempts ?? DEFAULT_REF_READINESS_MAX_ATTEMPTS;
|
|
24149
24998
|
const getHandler = (type) => {
|
|
24150
24999
|
const h = map.get(type);
|
|
24151
25000
|
if (!h) throw new Error(`No handler registered for operation type: ${type}`);
|
|
@@ -24154,42 +25003,42 @@ var buildDispatcher = (handlers) => {
|
|
|
24154
25003
|
const validateOperation2 = (op, index) => getHandler(op.type).validate(op, index);
|
|
24155
25004
|
const getHandlerSafe = (type, index) => {
|
|
24156
25005
|
const h = map.get(type);
|
|
24157
|
-
return h ?
|
|
25006
|
+
return h ? Effect115.succeed(h) : Effect115.fail([{ severity: "error", operation_index: index, code: "UNKNOWN_OPERATION_TYPE", message: `No handler registered for operation type: ${type}` }]);
|
|
24158
25007
|
};
|
|
24159
|
-
const validateOperationEffectful2 = (op, index, ctx) =>
|
|
25008
|
+
const validateOperationEffectful2 = (op, index, ctx) => pipe96(
|
|
24160
25009
|
getHandlerSafe(op.type, index),
|
|
24161
|
-
|
|
24162
|
-
|
|
25010
|
+
Effect115.flatMap((h) => h.validateEffectful(op, index, ctx)),
|
|
25011
|
+
Effect115.catchAll((issues) => Effect115.succeed(issues))
|
|
24163
25012
|
);
|
|
24164
|
-
const preCheckOperation2 = (op, index, seen, ctx) =>
|
|
25013
|
+
const preCheckOperation2 = (op, index, seen, ctx) => pipe96(
|
|
24165
25014
|
getHandlerSafe(op.type, index),
|
|
24166
|
-
|
|
24167
|
-
|
|
25015
|
+
Effect115.flatMap((h) => h.preCheck(op, index, seen, ctx)),
|
|
25016
|
+
Effect115.catchAll((issues) => Effect115.succeed(issues))
|
|
24168
25017
|
);
|
|
24169
|
-
const projectOperationValidationState = (op, index, ctx) =>
|
|
25018
|
+
const projectOperationValidationState = (op, index, ctx) => pipe96(
|
|
24170
25019
|
getHandlerSafe(op.type, index),
|
|
24171
|
-
|
|
25020
|
+
Effect115.match({
|
|
24172
25021
|
onFailure: () => ctx,
|
|
24173
25022
|
onSuccess: (handler) => handler.projectValidationState?.(op, index, ctx) ?? ctx
|
|
24174
25023
|
})
|
|
24175
25024
|
);
|
|
24176
|
-
const declareOperationPlanRefs = (op, index, ctx) =>
|
|
25025
|
+
const declareOperationPlanRefs = (op, index, ctx) => pipe96(
|
|
24177
25026
|
getHandlerSafe(op.type, index),
|
|
24178
|
-
|
|
25027
|
+
Effect115.match({
|
|
24179
25028
|
onFailure: (issues) => issues,
|
|
24180
25029
|
onSuccess: (handler) => handler.declarePlanRefs?.(op, index, ctx) ?? []
|
|
24181
25030
|
})
|
|
24182
25031
|
);
|
|
24183
|
-
const resolveOperationRefsForValidation = (op, index, ctx) =>
|
|
25032
|
+
const resolveOperationRefsForValidation = (op, index, ctx) => pipe96(
|
|
24184
25033
|
getHandlerSafe(op.type, index),
|
|
24185
|
-
|
|
25034
|
+
Effect115.match({
|
|
24186
25035
|
onFailure: (issues) => ({ op, issues }),
|
|
24187
25036
|
onSuccess: (handler) => handler.resolvePlanRefsForValidation?.(op, index, ctx) ?? { op, issues: [] }
|
|
24188
25037
|
})
|
|
24189
25038
|
);
|
|
24190
|
-
const resolveOperationRefsForExecution = (op, index, ctx) =>
|
|
25039
|
+
const resolveOperationRefsForExecution = (op, index, ctx) => pipe96(
|
|
24191
25040
|
getHandlerSafe(op.type, index),
|
|
24192
|
-
|
|
25041
|
+
Effect115.match({
|
|
24193
25042
|
onFailure: () => ({
|
|
24194
25043
|
ok: false,
|
|
24195
25044
|
result: {
|
|
@@ -24203,52 +25052,63 @@ var buildDispatcher = (handlers) => {
|
|
|
24203
25052
|
onSuccess: (handler) => handler.resolvePlanRefsForExecution?.(op, index, ctx) ?? { ok: true, op }
|
|
24204
25053
|
})
|
|
24205
25054
|
);
|
|
24206
|
-
const collectOperationOutputRefs = (op, index, result) =>
|
|
25055
|
+
const collectOperationOutputRefs = (op, index, result) => pipe96(
|
|
24207
25056
|
getHandlerSafe(op.type, index),
|
|
24208
|
-
|
|
25057
|
+
Effect115.match({
|
|
24209
25058
|
onFailure: () => [],
|
|
24210
25059
|
onSuccess: (handler) => handler.collectOutputRefs?.(op, index, result) ?? []
|
|
24211
25060
|
})
|
|
24212
25061
|
);
|
|
24213
|
-
const executeOperation2 = (op, index) =>
|
|
25062
|
+
const executeOperation2 = (op, index) => pipe96(
|
|
24214
25063
|
getHandlerSafe(op.type, index),
|
|
24215
|
-
|
|
24216
|
-
|
|
25064
|
+
Effect115.flatMap((h) => h.execute(op, index)),
|
|
25065
|
+
Effect115.catchAll(() => Effect115.succeed({ index, type: op.type, status: "failed", records_affected: 0, error: `No handler registered for operation type: ${op.type}` }))
|
|
24217
25066
|
);
|
|
24218
|
-
const
|
|
25067
|
+
const executeOperationWithResolvedRefReadiness = (originalOp, resolvedOp, index) => {
|
|
25068
|
+
const shouldApplyReadinessWait = operationConsumesRuntimeRef(originalOp);
|
|
25069
|
+
const runAttempt = (attempt) => pipe96(
|
|
25070
|
+
shouldApplyReadinessWait ? refReadinessDelay(refReadinessWaitMs) : Effect115.void,
|
|
25071
|
+
Effect115.flatMap(() => executeOperation2(resolvedOp, index)),
|
|
25072
|
+
Effect115.flatMap(
|
|
25073
|
+
(result) => shouldApplyReadinessWait && attempt < refReadinessMaxAttempts && isRetryableResolvedRefFailure(result) ? runAttempt(attempt + 1) : Effect115.succeed(result)
|
|
25074
|
+
)
|
|
25075
|
+
);
|
|
25076
|
+
return runAttempt(1);
|
|
25077
|
+
};
|
|
25078
|
+
const postCheckOperation2 = (op, index, result) => pipe96(
|
|
24219
25079
|
getHandlerSafe(op.type, index),
|
|
24220
|
-
|
|
24221
|
-
|
|
25080
|
+
Effect115.flatMap((h) => h.postCheck(op, index, result)),
|
|
25081
|
+
Effect115.catchAll((issues) => Effect115.succeed(issues))
|
|
24222
25082
|
);
|
|
24223
25083
|
const validatePlan2 = (operations) => operations.flatMap((op, i) => validateOperation2(op, i));
|
|
24224
|
-
const validatePlanEffectful2 = (operations) =>
|
|
24225
|
-
|
|
25084
|
+
const validatePlanEffectful2 = (operations) => pipe96(
|
|
25085
|
+
Effect115.forEach(
|
|
24226
25086
|
operations,
|
|
24227
25087
|
(op, i) => validateOperationEffectful2(op, i),
|
|
24228
25088
|
{ concurrency: 5 }
|
|
24229
25089
|
),
|
|
24230
|
-
|
|
25090
|
+
Effect115.map((results) => results.flat())
|
|
24231
25091
|
);
|
|
24232
|
-
const preCheckPlan2 = (operations) =>
|
|
24233
|
-
|
|
25092
|
+
const preCheckPlan2 = (operations) => pipe96(
|
|
25093
|
+
Effect115.forEach(
|
|
24234
25094
|
operations,
|
|
24235
25095
|
(op, i) => preCheckOperation2(op, i),
|
|
24236
25096
|
{ concurrency: 5 }
|
|
24237
25097
|
),
|
|
24238
|
-
|
|
25098
|
+
Effect115.map((results) => results.flat())
|
|
24239
25099
|
);
|
|
24240
25100
|
const validatePlanDraftChecks2 = (operations) => {
|
|
24241
|
-
let declarationProgram =
|
|
25101
|
+
let declarationProgram = Effect115.succeed({
|
|
24242
25102
|
ctx: createPlanValidationContext(),
|
|
24243
25103
|
issues: []
|
|
24244
25104
|
});
|
|
24245
25105
|
for (const [index, operation] of operations.entries()) {
|
|
24246
|
-
declarationProgram =
|
|
25106
|
+
declarationProgram = pipe96(
|
|
24247
25107
|
declarationProgram,
|
|
24248
|
-
|
|
24249
|
-
(state) =>
|
|
25108
|
+
Effect115.flatMap(
|
|
25109
|
+
(state) => pipe96(
|
|
24250
25110
|
getHandlerSafe(operation.type, index),
|
|
24251
|
-
|
|
25111
|
+
Effect115.match({
|
|
24252
25112
|
onFailure: () => ({
|
|
24253
25113
|
ctx: state.ctx,
|
|
24254
25114
|
issues: state.issues
|
|
@@ -24265,48 +25125,48 @@ var buildDispatcher = (handlers) => {
|
|
|
24265
25125
|
)
|
|
24266
25126
|
);
|
|
24267
25127
|
}
|
|
24268
|
-
return
|
|
25128
|
+
return pipe96(
|
|
24269
25129
|
declarationProgram,
|
|
24270
|
-
|
|
24271
|
-
let program =
|
|
25130
|
+
Effect115.flatMap((declarationState) => {
|
|
25131
|
+
let program = Effect115.succeed({
|
|
24272
25132
|
ctx: declarationState.ctx,
|
|
24273
25133
|
seen: /* @__PURE__ */ new Set(),
|
|
24274
25134
|
issues: declarationState.issues
|
|
24275
25135
|
});
|
|
24276
25136
|
for (const [index, operation] of operations.entries()) {
|
|
24277
|
-
program =
|
|
25137
|
+
program = pipe96(
|
|
24278
25138
|
program,
|
|
24279
|
-
|
|
24280
|
-
(state) =>
|
|
25139
|
+
Effect115.flatMap(
|
|
25140
|
+
(state) => pipe96(
|
|
24281
25141
|
getHandlerSafe(operation.type, index),
|
|
24282
|
-
|
|
24283
|
-
onFailure: (issues) =>
|
|
25142
|
+
Effect115.matchEffect({
|
|
25143
|
+
onFailure: (issues) => Effect115.succeed({
|
|
24284
25144
|
...state,
|
|
24285
25145
|
issues: [...state.issues, ...issues]
|
|
24286
25146
|
}),
|
|
24287
|
-
onSuccess: (handler) =>
|
|
25147
|
+
onSuccess: (handler) => pipe96(
|
|
24288
25148
|
resolveOperationRefsForValidation(operation, index, state.ctx),
|
|
24289
|
-
|
|
25149
|
+
Effect115.flatMap(({ op: resolvedOperation, issues: resolutionIssues }) => {
|
|
24290
25150
|
const accumulatedIssues = [
|
|
24291
25151
|
...state.issues,
|
|
24292
25152
|
...resolutionIssues
|
|
24293
25153
|
];
|
|
24294
25154
|
if (resolutionIssues.some((issue) => issue.severity === "error")) {
|
|
24295
|
-
return
|
|
25155
|
+
return Effect115.succeed({
|
|
24296
25156
|
ctx: state.ctx,
|
|
24297
25157
|
seen: state.seen,
|
|
24298
25158
|
issues: accumulatedIssues
|
|
24299
25159
|
});
|
|
24300
25160
|
}
|
|
24301
|
-
return
|
|
24302
|
-
|
|
25161
|
+
return pipe96(
|
|
25162
|
+
Effect115.all([
|
|
24303
25163
|
handler.validateEffectful(resolvedOperation, index, state.ctx),
|
|
24304
25164
|
handler.preCheck(resolvedOperation, index, state.seen, state.ctx)
|
|
24305
25165
|
]),
|
|
24306
|
-
|
|
24307
|
-
([validationIssues, preCheckIssues]) =>
|
|
25166
|
+
Effect115.flatMap(
|
|
25167
|
+
([validationIssues, preCheckIssues]) => pipe96(
|
|
24308
25168
|
projectOperationValidationState(resolvedOperation, index, state.ctx),
|
|
24309
|
-
|
|
25169
|
+
Effect115.map((nextCtx) => ({
|
|
24310
25170
|
ctx: nextCtx,
|
|
24311
25171
|
seen: state.seen,
|
|
24312
25172
|
issues: [...accumulatedIssues, ...validationIssues, ...preCheckIssues]
|
|
@@ -24321,19 +25181,19 @@ var buildDispatcher = (handlers) => {
|
|
|
24321
25181
|
)
|
|
24322
25182
|
);
|
|
24323
25183
|
}
|
|
24324
|
-
return
|
|
25184
|
+
return pipe96(program, Effect115.map((state) => state.issues));
|
|
24325
25185
|
})
|
|
24326
25186
|
);
|
|
24327
25187
|
};
|
|
24328
25188
|
const executePlan2 = (operations) => {
|
|
24329
|
-
let declarationProgram =
|
|
25189
|
+
let declarationProgram = Effect115.succeed(/* @__PURE__ */ new Map());
|
|
24330
25190
|
for (const [index, operation] of operations.entries()) {
|
|
24331
|
-
declarationProgram =
|
|
25191
|
+
declarationProgram = pipe96(
|
|
24332
25192
|
declarationProgram,
|
|
24333
|
-
|
|
24334
|
-
(declaredRefs) =>
|
|
25193
|
+
Effect115.flatMap(
|
|
25194
|
+
(declaredRefs) => pipe96(
|
|
24335
25195
|
getHandlerSafe(operation.type, index),
|
|
24336
|
-
|
|
25196
|
+
Effect115.match({
|
|
24337
25197
|
onFailure: () => declaredRefs,
|
|
24338
25198
|
onSuccess: () => {
|
|
24339
25199
|
map.get(operation.type)?.declarePlanRefs?.(operation, index, {
|
|
@@ -24347,10 +25207,10 @@ var buildDispatcher = (handlers) => {
|
|
|
24347
25207
|
)
|
|
24348
25208
|
);
|
|
24349
25209
|
}
|
|
24350
|
-
return
|
|
25210
|
+
return pipe96(
|
|
24351
25211
|
declarationProgram,
|
|
24352
|
-
|
|
24353
|
-
let program =
|
|
25212
|
+
Effect115.flatMap((declaredRefs) => {
|
|
25213
|
+
let program = Effect115.succeed({
|
|
24354
25214
|
ctx: {
|
|
24355
25215
|
declaredRefs,
|
|
24356
25216
|
outputsByRef: /* @__PURE__ */ new Map(),
|
|
@@ -24359,13 +25219,13 @@ var buildDispatcher = (handlers) => {
|
|
|
24359
25219
|
results: []
|
|
24360
25220
|
});
|
|
24361
25221
|
for (const [index, operation] of operations.entries()) {
|
|
24362
|
-
program =
|
|
25222
|
+
program = pipe96(
|
|
24363
25223
|
program,
|
|
24364
|
-
|
|
24365
|
-
(state) =>
|
|
25224
|
+
Effect115.flatMap(
|
|
25225
|
+
(state) => pipe96(
|
|
24366
25226
|
getHandlerSafe(operation.type, index),
|
|
24367
|
-
|
|
24368
|
-
onFailure: () =>
|
|
25227
|
+
Effect115.matchEffect({
|
|
25228
|
+
onFailure: () => Effect115.succeed({
|
|
24369
25229
|
ctx: state.ctx,
|
|
24370
25230
|
results: [
|
|
24371
25231
|
...state.results,
|
|
@@ -24378,22 +25238,22 @@ var buildDispatcher = (handlers) => {
|
|
|
24378
25238
|
}
|
|
24379
25239
|
]
|
|
24380
25240
|
}),
|
|
24381
|
-
onSuccess: (handler) =>
|
|
25241
|
+
onSuccess: (handler) => pipe96(
|
|
24382
25242
|
resolveOperationRefsForExecution(operation, index, state.ctx),
|
|
24383
|
-
|
|
25243
|
+
Effect115.flatMap((resolved) => {
|
|
24384
25244
|
if (!resolved.ok) {
|
|
24385
25245
|
state.ctx.resultsByIndex.set(index, resolved.result);
|
|
24386
|
-
return
|
|
25246
|
+
return Effect115.succeed({
|
|
24387
25247
|
ctx: state.ctx,
|
|
24388
25248
|
results: [...state.results, resolved.result]
|
|
24389
25249
|
});
|
|
24390
25250
|
}
|
|
24391
|
-
return
|
|
24392
|
-
|
|
24393
|
-
|
|
24394
|
-
(result) =>
|
|
25251
|
+
return pipe96(
|
|
25252
|
+
executeOperationWithResolvedRefReadiness(operation, resolved.op, index),
|
|
25253
|
+
Effect115.flatMap(
|
|
25254
|
+
(result) => pipe96(
|
|
24395
25255
|
collectOperationOutputRefs(resolved.op, index, result),
|
|
24396
|
-
|
|
25256
|
+
Effect115.map((outputs) => {
|
|
24397
25257
|
const nextResult = outputs.length > 0 ? { ...result, outputs } : result;
|
|
24398
25258
|
if (nextResult.outputs) {
|
|
24399
25259
|
for (const output of nextResult.outputs) {
|
|
@@ -24416,21 +25276,21 @@ var buildDispatcher = (handlers) => {
|
|
|
24416
25276
|
)
|
|
24417
25277
|
);
|
|
24418
25278
|
}
|
|
24419
|
-
return
|
|
25279
|
+
return pipe96(program, Effect115.map((state) => state.results));
|
|
24420
25280
|
})
|
|
24421
25281
|
);
|
|
24422
25282
|
};
|
|
24423
|
-
const postCheckPlan2 = (operations, results) =>
|
|
24424
|
-
|
|
25283
|
+
const postCheckPlan2 = (operations, results) => pipe96(
|
|
25284
|
+
Effect115.forEach(
|
|
24425
25285
|
operations,
|
|
24426
25286
|
(op, i) => {
|
|
24427
25287
|
const result = results[i];
|
|
24428
|
-
if (!result) return
|
|
25288
|
+
if (!result) return Effect115.succeed([]);
|
|
24429
25289
|
return postCheckOperation2(op, i, result);
|
|
24430
25290
|
},
|
|
24431
25291
|
{ concurrency: 3 }
|
|
24432
25292
|
),
|
|
24433
|
-
|
|
25293
|
+
Effect115.map((issueArrays) => issueArrays.flat())
|
|
24434
25294
|
);
|
|
24435
25295
|
return {
|
|
24436
25296
|
validateOperation: validateOperation2,
|
|
@@ -24499,7 +25359,10 @@ var _ALL_HANDLERS = [
|
|
|
24499
25359
|
createWorkflowHandler,
|
|
24500
25360
|
updateWorkflowHandler,
|
|
24501
25361
|
setWorkflowEnabledHandler,
|
|
24502
|
-
deleteWorkflowHandler
|
|
25362
|
+
deleteWorkflowHandler,
|
|
25363
|
+
createFormHandler,
|
|
25364
|
+
updateFormHandler,
|
|
25365
|
+
deleteFormHandler
|
|
24503
25366
|
];
|
|
24504
25367
|
var _ALL_METAS = [
|
|
24505
25368
|
createPropertyMeta,
|
|
@@ -24548,7 +25411,10 @@ var _ALL_METAS = [
|
|
|
24548
25411
|
createWorkflowMeta,
|
|
24549
25412
|
updateWorkflowMeta,
|
|
24550
25413
|
setWorkflowEnabledMeta,
|
|
24551
|
-
deleteWorkflowMeta
|
|
25414
|
+
deleteWorkflowMeta,
|
|
25415
|
+
createFormMeta,
|
|
25416
|
+
updateFormMeta,
|
|
25417
|
+
deleteFormMeta
|
|
24552
25418
|
];
|
|
24553
25419
|
var ALL_HANDLERS = _ALL_HANDLERS;
|
|
24554
25420
|
var ALL_METAS = _ALL_METAS;
|
|
@@ -24609,10 +25475,10 @@ var formatOperationDetail = (def) => {
|
|
|
24609
25475
|
};
|
|
24610
25476
|
|
|
24611
25477
|
// src/pure/operation-conversion.ts
|
|
24612
|
-
var FlatOperationSchema =
|
|
24613
|
-
type:
|
|
24614
|
-
description:
|
|
24615
|
-
fields:
|
|
25478
|
+
var FlatOperationSchema = z81.object({
|
|
25479
|
+
type: z81.string().describe("Operation type (use describe_operations to see available types)"),
|
|
25480
|
+
description: z81.string().describe("What this operation does"),
|
|
25481
|
+
fields: z81.record(z81.string(), z81.unknown()).describe("Operation-specific fields (use describe_operations to see the required fields for each type)")
|
|
24616
25482
|
});
|
|
24617
25483
|
var nestOperation = (flat) => {
|
|
24618
25484
|
const def = getOperationDef(flat.type);
|
|
@@ -24648,9 +25514,9 @@ var convertAndValidateOperations = (operations, startIndex = 1) => {
|
|
|
24648
25514
|
|
|
24649
25515
|
// src/tools/build_plan.ts
|
|
24650
25516
|
var OPERATION_TYPE_COUNT = OPERATION_REGISTRY.length;
|
|
24651
|
-
var EditSchema =
|
|
24652
|
-
action:
|
|
24653
|
-
index:
|
|
25517
|
+
var EditSchema = z82.object({
|
|
25518
|
+
action: z82.enum(["replace", "remove"]).describe("'replace' swaps an operation, 'remove' deletes it"),
|
|
25519
|
+
index: z82.number().int().min(1).describe("1-based operation index"),
|
|
24654
25520
|
operation: FlatOperationSchema.optional().describe("Required for replace, ignored for remove")
|
|
24655
25521
|
});
|
|
24656
25522
|
var summariseFields = (op) => {
|
|
@@ -24763,12 +25629,12 @@ WORKFLOW:
|
|
|
24763
25629
|
4. submit_plan (dry_run: true) - Validate without saving (optional)
|
|
24764
25630
|
5. submit_plan - Submit after user confirms`,
|
|
24765
25631
|
inputSchema: {
|
|
24766
|
-
title:
|
|
24767
|
-
description:
|
|
24768
|
-
operations:
|
|
24769
|
-
edits:
|
|
24770
|
-
force:
|
|
24771
|
-
portalIds:
|
|
25632
|
+
title: z82.string().optional().describe("Short, descriptive title (required when creating a new draft)"),
|
|
25633
|
+
description: z82.string().optional().describe("Detailed explanation of what the plan does and why (required when creating a new draft)"),
|
|
25634
|
+
operations: z82.array(FlatOperationSchema).optional().describe("Operations to add to targeted draft(s)"),
|
|
25635
|
+
edits: z82.array(EditSchema).optional().describe("Edits to apply: replace or remove operations by 1-based index"),
|
|
25636
|
+
force: z82.boolean().optional().describe("If true, discard targeted draft(s) and start fresh"),
|
|
25637
|
+
portalIds: z82.array(z82.number()).optional().describe("Optional explicit portal IDs to target. If provided, responses are keyed by portal ID.")
|
|
24772
25638
|
}
|
|
24773
25639
|
}, async ({ title, description, operations, edits, force, portalIds }) => {
|
|
24774
25640
|
const portalResolution = resolvePortalIds(
|
|
@@ -24936,7 +25802,7 @@ Use describe_operations to see the required fields for each operation type.`
|
|
|
24936
25802
|
}
|
|
24937
25803
|
|
|
24938
25804
|
// src/tools/describe_operations.ts
|
|
24939
|
-
import { z as
|
|
25805
|
+
import { z as z83 } from "zod";
|
|
24940
25806
|
var OPERATION_TYPE_COUNT2 = OPERATION_REGISTRY.length;
|
|
24941
25807
|
function registerDescribeOperationsTool(server2) {
|
|
24942
25808
|
server2.registerTool("describe_operations", {
|
|
@@ -24949,7 +25815,7 @@ Use cases:
|
|
|
24949
25815
|
- Call with no arguments to list all available operation types.
|
|
24950
25816
|
- Call with specific types to see their full field schemas and examples.`,
|
|
24951
25817
|
inputSchema: {
|
|
24952
|
-
operation_types:
|
|
25818
|
+
operation_types: z83.array(z83.string()).optional().describe("Operation types to describe (e.g. ['create_property', 'delete_pipeline']). Omit to list all available types.")
|
|
24953
25819
|
}
|
|
24954
25820
|
}, async ({ operation_types }) => {
|
|
24955
25821
|
if (!operation_types || operation_types.length === 0) {
|
|
@@ -24974,8 +25840,8 @@ Call describe_operations with no arguments to see all available types.`);
|
|
|
24974
25840
|
}
|
|
24975
25841
|
|
|
24976
25842
|
// src/tools/submit_plan.ts
|
|
24977
|
-
import { z as
|
|
24978
|
-
import { Effect as
|
|
25843
|
+
import { z as z84 } from "zod";
|
|
25844
|
+
import { Effect as Effect116 } from "effect";
|
|
24979
25845
|
var formatFixHint = (issue, summary) => {
|
|
24980
25846
|
const opNum = issue.operation_index + 1;
|
|
24981
25847
|
const opInfo = summary?.operations[issue.operation_index];
|
|
@@ -25028,7 +25894,7 @@ var submitPortalDraft = async (portalId, dryRun, deps) => {
|
|
|
25028
25894
|
};
|
|
25029
25895
|
}
|
|
25030
25896
|
try {
|
|
25031
|
-
const response = await
|
|
25897
|
+
const response = await Effect116.runPromise(
|
|
25032
25898
|
deps.ws.sendPlanCreate(portalId, {
|
|
25033
25899
|
title: draft.title,
|
|
25034
25900
|
description: draft.description,
|
|
@@ -25198,8 +26064,8 @@ RECOMMENDED WORKFLOW:
|
|
|
25198
26064
|
4. Fix any issues with build_plan(edits: [...])
|
|
25199
26065
|
5. Call submit_plan() to save after user confirms`,
|
|
25200
26066
|
inputSchema: {
|
|
25201
|
-
dry_run:
|
|
25202
|
-
portalIds:
|
|
26067
|
+
dry_run: z84.boolean().optional().describe("If true, validate only without saving. Defaults to false."),
|
|
26068
|
+
portalIds: z84.array(z84.number()).optional().describe("Optional explicit portal IDs to submit. If provided, results are keyed by portal ID.")
|
|
25203
26069
|
}
|
|
25204
26070
|
}, async ({ dry_run, portalIds }) => {
|
|
25205
26071
|
const portalResolution = resolvePortalIds(
|
|
@@ -25242,8 +26108,8 @@ RECOMMENDED WORKFLOW:
|
|
|
25242
26108
|
}
|
|
25243
26109
|
|
|
25244
26110
|
// src/tools/get_plans.ts
|
|
25245
|
-
import { z as
|
|
25246
|
-
import { Effect as
|
|
26111
|
+
import { z as z85 } from "zod";
|
|
26112
|
+
import { Effect as Effect117 } from "effect";
|
|
25247
26113
|
var serialiseDraft2 = (portalId) => {
|
|
25248
26114
|
const draft = getDraft(portalId);
|
|
25249
26115
|
if (!draft) return null;
|
|
@@ -25271,8 +26137,8 @@ Statuses:
|
|
|
25271
26137
|
- FAILED: Execution failed
|
|
25272
26138
|
- REJECTED: User rejected the plan`,
|
|
25273
26139
|
inputSchema: {
|
|
25274
|
-
status:
|
|
25275
|
-
portalIds:
|
|
26140
|
+
status: z85.enum(["DRAFT", "REJECTED", "EXECUTING", "EXECUTED", "FAILED"]).optional().describe("Filter by plan status. Omit to show all plans."),
|
|
26141
|
+
portalIds: z85.array(z85.number()).optional().describe("Optional explicit portal IDs. If provided, results are keyed by portal ID.")
|
|
25276
26142
|
}
|
|
25277
26143
|
}, async ({ status, portalIds }) => {
|
|
25278
26144
|
const portalResolution = resolvePortalIds(
|
|
@@ -25293,7 +26159,7 @@ Statuses:
|
|
|
25293
26159
|
for (const portalId2 of targetPortalIds) {
|
|
25294
26160
|
const draft2 = serialiseDraft2(portalId2);
|
|
25295
26161
|
try {
|
|
25296
|
-
const response = await
|
|
26162
|
+
const response = await Effect117.runPromise(
|
|
25297
26163
|
deps.ws.sendPlanList(portalId2, status)
|
|
25298
26164
|
);
|
|
25299
26165
|
if (!response.success) {
|
|
@@ -25325,7 +26191,7 @@ Statuses:
|
|
|
25325
26191
|
const portalId = targetPortalIds[0];
|
|
25326
26192
|
const draft = serialiseDraft2(portalId);
|
|
25327
26193
|
try {
|
|
25328
|
-
const response = await
|
|
26194
|
+
const response = await Effect117.runPromise(
|
|
25329
26195
|
deps.ws.sendPlanList(portalId, status)
|
|
25330
26196
|
);
|
|
25331
26197
|
if (!response.success) {
|
|
@@ -25397,7 +26263,7 @@ var shouldSubscribeAfterDiffComplete = (portalId, selectedPortalId2, success) =>
|
|
|
25397
26263
|
|
|
25398
26264
|
// src/effects/ensure-fresh.ts
|
|
25399
26265
|
import fs13 from "fs";
|
|
25400
|
-
import { Effect as
|
|
26266
|
+
import { Effect as Effect118, pipe as pipe97 } from "effect";
|
|
25401
26267
|
var DEFAULT_MAX_AGE_MS = 3e5;
|
|
25402
26268
|
var DEFAULT_QUEUE_DRAIN_TIMEOUT_MS = 12e4;
|
|
25403
26269
|
var DEFAULT_DIFF_TIMEOUT_MS = 3e4;
|
|
@@ -25475,11 +26341,11 @@ var sleep2 = (ms) => new Promise((resolve) => {
|
|
|
25475
26341
|
var waitForPortalSyncedAtAfter = (portalFileState, portalId, sinceMs, timeoutMs) => (async () => {
|
|
25476
26342
|
const startedAt = Date.now();
|
|
25477
26343
|
while (Date.now() - startedAt <= timeoutMs) {
|
|
25478
|
-
const syncedAtMs = await
|
|
25479
|
-
|
|
26344
|
+
const syncedAtMs = await Effect118.runPromise(
|
|
26345
|
+
pipe97(
|
|
25480
26346
|
portalFileState.get(portalId),
|
|
25481
|
-
|
|
25482
|
-
|
|
26347
|
+
Effect118.map((state) => state.syncedAt.getTime()),
|
|
26348
|
+
Effect118.catchAll(() => Effect118.succeed(0))
|
|
25483
26349
|
)
|
|
25484
26350
|
);
|
|
25485
26351
|
if (syncedAtMs > sinceMs) {
|
|
@@ -25495,22 +26361,22 @@ var makeEnsureFresh = (deps, options2) => createEnsureFresh(
|
|
|
25495
26361
|
isPortalSyncEnabled: deps.isPortalSyncEnabled,
|
|
25496
26362
|
waitForPortalDrain,
|
|
25497
26363
|
hasLocalDatabase: (portalId) => fs13.existsSync(dbPath(portalId)),
|
|
25498
|
-
getFreshnessCheckedAt: (portalId) =>
|
|
25499
|
-
|
|
26364
|
+
getFreshnessCheckedAt: (portalId) => Effect118.runPromise(
|
|
26365
|
+
pipe97(
|
|
25500
26366
|
deps.portalData.getMetadata(portalId, LAST_DIFF_CHECKED_AT_KEY),
|
|
25501
|
-
|
|
26367
|
+
Effect118.map((value) => parseDate(value))
|
|
25502
26368
|
)
|
|
25503
26369
|
),
|
|
25504
|
-
getObjectSyncTimes: (portalId) =>
|
|
25505
|
-
sendSyncDiff: (portalId, lastSyncTimes) =>
|
|
26370
|
+
getObjectSyncTimes: (portalId) => Effect118.runPromise(deps.portalData.getObjectSyncTimes(portalId)),
|
|
26371
|
+
sendSyncDiff: (portalId, lastSyncTimes) => Effect118.runPromise(
|
|
25506
26372
|
deps.ws.sendSyncDiff(portalId, lastSyncTimes).pipe(
|
|
25507
|
-
|
|
26373
|
+
Effect118.mapError(
|
|
25508
26374
|
(error) => error instanceof Error ? error : new Error(`Failed to request sync diff for portal ${portalId}`)
|
|
25509
26375
|
)
|
|
25510
26376
|
)
|
|
25511
26377
|
).then(() => void 0),
|
|
25512
26378
|
waitForDiffCompletion: (portalId, sinceMs, timeoutMs) => waitForPortalSyncedAtAfter(deps.portalFileState, portalId, sinceMs, timeoutMs),
|
|
25513
|
-
setFreshnessCheckedAt: (portalId, checkedAt) =>
|
|
26379
|
+
setFreshnessCheckedAt: (portalId, checkedAt) => Effect118.runPromise(
|
|
25514
26380
|
deps.portalData.setMetadata(portalId, LAST_DIFF_CHECKED_AT_KEY, checkedAt.toISOString())
|
|
25515
26381
|
).then(() => void 0)
|
|
25516
26382
|
},
|
|
@@ -25571,7 +26437,7 @@ if (!TEST_HEADLESS_MODE) {
|
|
|
25571
26437
|
}
|
|
25572
26438
|
});
|
|
25573
26439
|
}
|
|
25574
|
-
var mainProgram =
|
|
26440
|
+
var mainProgram = Effect119.gen(function* () {
|
|
25575
26441
|
const ws = yield* WebSocketService;
|
|
25576
26442
|
const config = yield* ConfigService;
|
|
25577
26443
|
const duckDb = yield* DuckDBInterfaceService;
|
|
@@ -25579,18 +26445,18 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25579
26445
|
const portalData = yield* PortalDataService;
|
|
25580
26446
|
const portalFileState = yield* PortalFileStateService;
|
|
25581
26447
|
const getPortalId = () => getSelectedPortalId(config);
|
|
25582
|
-
const getClientState2 = () =>
|
|
26448
|
+
const getClientState2 = () => Effect119.runSync(config.load());
|
|
25583
26449
|
const saveClientState = (updater) => {
|
|
25584
26450
|
const nextState = updater(getClientState2());
|
|
25585
|
-
|
|
26451
|
+
Effect119.runSync(config.save(nextState));
|
|
25586
26452
|
return nextState;
|
|
25587
26453
|
};
|
|
25588
|
-
const getPortals = () =>
|
|
26454
|
+
const getPortals = () => Effect119.runSync(ws.getPortals());
|
|
25589
26455
|
const isPortalSyncActive = (portalId) => isPortalSyncEnabled(getClientState2(), portalId);
|
|
25590
|
-
const getConnectionType = () =>
|
|
25591
|
-
|
|
26456
|
+
const getConnectionType = () => Effect119.runSync(
|
|
26457
|
+
pipe98(
|
|
25592
26458
|
duckDb.getConnectionType,
|
|
25593
|
-
|
|
26459
|
+
Effect119.catchAll(() => Effect119.succeed("READ_ONLY"))
|
|
25594
26460
|
)
|
|
25595
26461
|
);
|
|
25596
26462
|
const isMasterClient = () => getConnectionType() === "MASTER";
|
|
@@ -25608,10 +26474,10 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25608
26474
|
const handoffSelectedPortal = (nextPortalId) => {
|
|
25609
26475
|
const previousPortalId = getSelectedPortalId(config);
|
|
25610
26476
|
if (previousPortalId !== null && previousPortalId !== nextPortalId) {
|
|
25611
|
-
|
|
25612
|
-
|
|
26477
|
+
Effect119.runSync(
|
|
26478
|
+
pipe98(
|
|
25613
26479
|
ws.sendSyncUnsubscribe(previousPortalId),
|
|
25614
|
-
|
|
26480
|
+
Effect119.catchAll(() => Effect119.void)
|
|
25615
26481
|
)
|
|
25616
26482
|
);
|
|
25617
26483
|
}
|
|
@@ -25623,7 +26489,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25623
26489
|
if (!isPortalSyncEnabled(nextState, nextPortalId)) {
|
|
25624
26490
|
return "stale_local_only";
|
|
25625
26491
|
}
|
|
25626
|
-
|
|
26492
|
+
Effect119.runFork(pipe98(ws.sendSyncFull(nextPortalId), Effect119.catchAll(() => Effect119.void)));
|
|
25627
26493
|
return "syncing";
|
|
25628
26494
|
};
|
|
25629
26495
|
registerPortalSelection(server, { ws, config, handoffSelectedPortal });
|
|
@@ -25640,7 +26506,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25640
26506
|
ensureFresh
|
|
25641
26507
|
});
|
|
25642
26508
|
registerStatusTool(server, {
|
|
25643
|
-
getConnectionState: () =>
|
|
26509
|
+
getConnectionState: () => Effect119.runSync(ws.getState()),
|
|
25644
26510
|
isMasterClient,
|
|
25645
26511
|
getPortals,
|
|
25646
26512
|
getSelectedPortalId: getPortalId,
|
|
@@ -25664,7 +26530,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25664
26530
|
actions.push(`Removed ${removed} pending portal sync job(s).`);
|
|
25665
26531
|
}
|
|
25666
26532
|
if (isSelected) {
|
|
25667
|
-
|
|
26533
|
+
Effect119.runSync(pipe98(ws.sendSyncUnsubscribe(portalId), Effect119.catchAll(() => Effect119.void)));
|
|
25668
26534
|
actions.push("Stopped real-time subscription for the selected portal.");
|
|
25669
26535
|
}
|
|
25670
26536
|
}
|
|
@@ -25684,7 +26550,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25684
26550
|
}
|
|
25685
26551
|
if (!previousControl.enabled && nextControl.enabled) {
|
|
25686
26552
|
if (isMasterClient()) {
|
|
25687
|
-
|
|
26553
|
+
Effect119.runFork(pipe98(ws.sendSyncFull(portalId), Effect119.catchAll(() => Effect119.void)));
|
|
25688
26554
|
if (!DISABLE_PLUGIN_SYNC) {
|
|
25689
26555
|
triggerPluginSync(portalId);
|
|
25690
26556
|
}
|
|
@@ -25694,7 +26560,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25694
26560
|
}
|
|
25695
26561
|
} else if (refreshArtifacts && nextControl.enabled) {
|
|
25696
26562
|
if (isMasterClient()) {
|
|
25697
|
-
|
|
26563
|
+
Effect119.runFork(pipe98(ws.sendSyncFull(portalId), Effect119.catchAll(() => Effect119.void)));
|
|
25698
26564
|
actions.push("Requested fresh artifact manifest.");
|
|
25699
26565
|
} else {
|
|
25700
26566
|
actions.push("Refresh requested, but this client is read-only so no sync was started.");
|
|
@@ -25702,7 +26568,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25702
26568
|
}
|
|
25703
26569
|
const filtersChanged = previousControl.enabled === nextControl.enabled && previousControl.disabledArtifacts.join("\0") !== nextControl.disabledArtifacts.join("\0");
|
|
25704
26570
|
if (isSelected && nextControl.enabled && filtersChanged && !refreshArtifacts) {
|
|
25705
|
-
|
|
26571
|
+
Effect119.runSync(pipe98(ws.sendSyncUnsubscribe(portalId), Effect119.catchAll(() => Effect119.void)));
|
|
25706
26572
|
runDiffFlow(portalId);
|
|
25707
26573
|
actions.push("Restarted selected portal live sync to apply artifact filters.");
|
|
25708
26574
|
}
|
|
@@ -25731,24 +26597,24 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25731
26597
|
yield* config.save(state);
|
|
25732
26598
|
setSelectedPortal(state.selectedPortalId);
|
|
25733
26599
|
if (DISABLE_PLUGIN_SYNC) {
|
|
25734
|
-
yield*
|
|
26600
|
+
yield* Effect119.sync(
|
|
25735
26601
|
() => console.error("[startup] Plugin sync disabled via MCP_CLIENT_DISABLE_PLUGIN_SYNC")
|
|
25736
26602
|
);
|
|
25737
26603
|
}
|
|
25738
26604
|
if (DISABLE_DIFF_FOLLOWUP) {
|
|
25739
|
-
yield*
|
|
26605
|
+
yield* Effect119.sync(
|
|
25740
26606
|
() => console.error("[startup] Diff follow-up disabled via MCP_CLIENT_DISABLE_DIFF_FOLLOWUP")
|
|
25741
26607
|
);
|
|
25742
26608
|
}
|
|
25743
26609
|
if (TEST_HEADLESS_MODE) {
|
|
25744
|
-
yield*
|
|
26610
|
+
yield* Effect119.sync(
|
|
25745
26611
|
() => console.error("[startup] Headless mode enabled via MCP_CLIENT_TEST_HEADLESS")
|
|
25746
26612
|
);
|
|
25747
26613
|
}
|
|
25748
26614
|
if (state.selectedPortalId !== null) {
|
|
25749
|
-
const cached = yield* portalFileState.load(state.selectedPortalId).pipe(
|
|
26615
|
+
const cached = yield* portalFileState.load(state.selectedPortalId).pipe(Effect119.catchAll(() => Effect119.succeed(null)));
|
|
25750
26616
|
if (cached !== null) {
|
|
25751
|
-
yield*
|
|
26617
|
+
yield* Effect119.sync(
|
|
25752
26618
|
() => console.error(`[startup] Loaded ${cached.artifacts.length} cached artifacts for portal ${state.selectedPortalId}`)
|
|
25753
26619
|
);
|
|
25754
26620
|
}
|
|
@@ -25779,24 +26645,24 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25779
26645
|
return;
|
|
25780
26646
|
}
|
|
25781
26647
|
pendingPortalFollowUps.add(portalId);
|
|
25782
|
-
|
|
25783
|
-
|
|
25784
|
-
|
|
25785
|
-
|
|
25786
|
-
(drained) => drained ?
|
|
26648
|
+
Effect119.runFork(
|
|
26649
|
+
pipe98(
|
|
26650
|
+
Effect119.promise(() => waitForPortalDrain(portalId, QUEUE_DRAIN_TIMEOUT_MS)),
|
|
26651
|
+
Effect119.flatMap(
|
|
26652
|
+
(drained) => drained ? Effect119.sync(() => {
|
|
25787
26653
|
console.error(`[live-sync] Queue drained for portal ${portalId} after ${source} \u2014 triggering diff flow`);
|
|
25788
26654
|
runDiffFlow(portalId);
|
|
25789
|
-
}) :
|
|
26655
|
+
}) : Effect119.sync(
|
|
25790
26656
|
() => console.error(`[live-sync] Timed out waiting for portal ${portalId} queue drain after ${source}`)
|
|
25791
26657
|
)
|
|
25792
26658
|
),
|
|
25793
|
-
|
|
25794
|
-
|
|
26659
|
+
Effect119.ensuring(
|
|
26660
|
+
Effect119.sync(() => {
|
|
25795
26661
|
pendingPortalFollowUps.delete(portalId);
|
|
25796
26662
|
})
|
|
25797
26663
|
),
|
|
25798
|
-
|
|
25799
|
-
(error) =>
|
|
26664
|
+
Effect119.catchAll(
|
|
26665
|
+
(error) => Effect119.sync(() => {
|
|
25800
26666
|
console.error(`[live-sync] Failed post-queue follow-up for portal ${portalId}:`, error);
|
|
25801
26667
|
})
|
|
25802
26668
|
)
|
|
@@ -25815,12 +26681,12 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25815
26681
|
console.error(`[live-sync] Skipping subscribe for portal ${portalId} because portal sync is disabled`);
|
|
25816
26682
|
return;
|
|
25817
26683
|
}
|
|
25818
|
-
|
|
25819
|
-
|
|
25820
|
-
|
|
26684
|
+
Effect119.runFork(
|
|
26685
|
+
pipe98(
|
|
26686
|
+
Effect119.all({
|
|
25821
26687
|
workflowState: duckDb.getWorkflowStateSummary(portalId).pipe(
|
|
25822
|
-
|
|
25823
|
-
(error) =>
|
|
26688
|
+
Effect119.catchAll(
|
|
26689
|
+
(error) => Effect119.sync(() => {
|
|
25824
26690
|
console.error(
|
|
25825
26691
|
`[live-sync] Failed to read workflow state summary for portal ${portalId}; subscribing with empty state:`,
|
|
25826
26692
|
error
|
|
@@ -25830,8 +26696,8 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25830
26696
|
)
|
|
25831
26697
|
),
|
|
25832
26698
|
propertyDefinitionState: duckDb.getPropertyDefinitionStateSummary(portalId).pipe(
|
|
25833
|
-
|
|
25834
|
-
(error) =>
|
|
26699
|
+
Effect119.catchAll(
|
|
26700
|
+
(error) => Effect119.sync(() => {
|
|
25835
26701
|
console.error(
|
|
25836
26702
|
`[live-sync] Failed to read property definition state summary for portal ${portalId}; subscribing with empty state:`,
|
|
25837
26703
|
error
|
|
@@ -25841,8 +26707,8 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25841
26707
|
)
|
|
25842
26708
|
),
|
|
25843
26709
|
objectSyncTimes: portalData.getObjectSyncTimes(portalId).pipe(
|
|
25844
|
-
|
|
25845
|
-
(error) =>
|
|
26710
|
+
Effect119.catchAll(
|
|
26711
|
+
(error) => Effect119.sync(() => {
|
|
25846
26712
|
console.error(
|
|
25847
26713
|
`[live-sync] Failed to read object sync times for portal ${portalId}; subscribing with empty object filter:`,
|
|
25848
26714
|
error
|
|
@@ -25852,7 +26718,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25852
26718
|
)
|
|
25853
26719
|
)
|
|
25854
26720
|
}),
|
|
25855
|
-
|
|
26721
|
+
Effect119.flatMap(
|
|
25856
26722
|
({ workflowState, propertyDefinitionState, objectSyncTimes }) => ws.sendSyncSubscribe(
|
|
25857
26723
|
portalId,
|
|
25858
26724
|
workflowState,
|
|
@@ -25860,7 +26726,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25860
26726
|
filterEnabledObjectTypes(getClientState2(), portalId, Object.keys(objectSyncTimes))
|
|
25861
26727
|
)
|
|
25862
26728
|
),
|
|
25863
|
-
|
|
26729
|
+
Effect119.catchAll(() => Effect119.void)
|
|
25864
26730
|
)
|
|
25865
26731
|
);
|
|
25866
26732
|
};
|
|
@@ -25873,25 +26739,25 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25873
26739
|
console.error(`[live-sync] Skipping catch-up diff for portal ${portalId} because portal sync is disabled`);
|
|
25874
26740
|
return;
|
|
25875
26741
|
}
|
|
25876
|
-
|
|
26742
|
+
pipe98(
|
|
25877
26743
|
portalData.getObjectSyncTimes(portalId),
|
|
25878
|
-
|
|
25879
|
-
|
|
26744
|
+
Effect119.catchAll(() => Effect119.succeed({})),
|
|
26745
|
+
Effect119.flatMap((syncTimes) => {
|
|
25880
26746
|
const filteredSyncTimes = filterEnabledSyncTimes(getClientState2(), portalId, syncTimes);
|
|
25881
26747
|
const count = Object.keys(filteredSyncTimes).length;
|
|
25882
26748
|
if (count === 0) {
|
|
25883
|
-
return
|
|
26749
|
+
return Effect119.sync(() => {
|
|
25884
26750
|
console.error(`[live-sync] No enabled object watermarks found in DuckDB for portal ${portalId}, skipping diff`);
|
|
25885
26751
|
});
|
|
25886
26752
|
}
|
|
25887
|
-
return
|
|
25888
|
-
|
|
26753
|
+
return pipe98(
|
|
26754
|
+
Effect119.sync(() => {
|
|
25889
26755
|
console.error(`[live-sync] Triggering catch-up diff for portal ${portalId} with ${count} enabled object types: ${JSON.stringify(filteredSyncTimes)}`);
|
|
25890
26756
|
}),
|
|
25891
|
-
|
|
26757
|
+
Effect119.flatMap(() => pipe98(ws.sendSyncDiff(portalId, filteredSyncTimes), Effect119.catchAll(() => Effect119.void)))
|
|
25892
26758
|
);
|
|
25893
26759
|
}),
|
|
25894
|
-
|
|
26760
|
+
Effect119.runFork
|
|
25895
26761
|
);
|
|
25896
26762
|
};
|
|
25897
26763
|
const triggerDiffThenSubscribe = (portalId) => {
|
|
@@ -25903,26 +26769,26 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25903
26769
|
console.error(`[live-sync] Skipping catch-up diff/subscription for portal ${portalId} because portal sync is disabled`);
|
|
25904
26770
|
return;
|
|
25905
26771
|
}
|
|
25906
|
-
|
|
26772
|
+
pipe98(
|
|
25907
26773
|
portalData.getObjectSyncTimes(portalId),
|
|
25908
|
-
|
|
25909
|
-
|
|
26774
|
+
Effect119.catchAll(() => Effect119.succeed({})),
|
|
26775
|
+
Effect119.flatMap((syncTimes) => {
|
|
25910
26776
|
const filteredSyncTimes = filterEnabledSyncTimes(getClientState2(), portalId, syncTimes);
|
|
25911
26777
|
const count = Object.keys(filteredSyncTimes).length;
|
|
25912
26778
|
if (count === 0) {
|
|
25913
|
-
return
|
|
26779
|
+
return Effect119.sync(() => {
|
|
25914
26780
|
console.error(`[live-sync] No enabled object watermarks found in DuckDB for portal ${portalId}, subscribing directly`);
|
|
25915
26781
|
subscribeIfStillSelected(portalId);
|
|
25916
26782
|
});
|
|
25917
26783
|
}
|
|
25918
|
-
return
|
|
25919
|
-
|
|
26784
|
+
return pipe98(
|
|
26785
|
+
Effect119.sync(() => {
|
|
25920
26786
|
console.error(`[live-sync] Triggering catch-up diff for portal ${portalId} with ${count} enabled object types: ${JSON.stringify(filteredSyncTimes)}`);
|
|
25921
26787
|
}),
|
|
25922
|
-
|
|
26788
|
+
Effect119.flatMap(() => pipe98(ws.sendSyncDiff(portalId, filteredSyncTimes), Effect119.catchAll(() => Effect119.void)))
|
|
25923
26789
|
);
|
|
25924
26790
|
}),
|
|
25925
|
-
|
|
26791
|
+
Effect119.runFork
|
|
25926
26792
|
);
|
|
25927
26793
|
};
|
|
25928
26794
|
const makeSyncLayer = (portalId) => {
|
|
@@ -25955,44 +26821,44 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
25955
26821
|
return;
|
|
25956
26822
|
}
|
|
25957
26823
|
const syncLayer = makeSyncLayer(portalId);
|
|
25958
|
-
|
|
25959
|
-
|
|
26824
|
+
Effect119.runFork(
|
|
26825
|
+
pipe98(
|
|
25960
26826
|
portalData.getMetadata(portalId, LAST_PLUGIN_SYNC_ALL_KEY),
|
|
25961
|
-
|
|
25962
|
-
|
|
26827
|
+
Effect119.bindTo("lastSyncAll"),
|
|
26828
|
+
Effect119.tap(({ lastSyncAll }) => {
|
|
25963
26829
|
if (!shouldRunPluginSync(lastSyncAll)) {
|
|
25964
|
-
return
|
|
26830
|
+
return Effect119.sync(
|
|
25965
26831
|
() => console.error(`[plugin-sync] Skipping plugin sync for portal ${portalId} (debounce \u2014 last sync: ${lastSyncAll})`)
|
|
25966
26832
|
);
|
|
25967
26833
|
}
|
|
25968
|
-
return
|
|
26834
|
+
return pipe98(
|
|
25969
26835
|
portalFileState.resetStuckPlugins(portalId),
|
|
25970
|
-
|
|
25971
|
-
|
|
26836
|
+
Effect119.catchAll(() => Effect119.void),
|
|
26837
|
+
Effect119.tap(() => Effect119.sync(
|
|
25972
26838
|
() => console.error(`[plugin-sync] Starting message plugin sync for portal ${portalId}`)
|
|
25973
26839
|
)),
|
|
25974
|
-
|
|
25975
|
-
() =>
|
|
26840
|
+
Effect119.flatMap(
|
|
26841
|
+
() => pipe98(
|
|
25976
26842
|
SyncService,
|
|
25977
|
-
|
|
25978
|
-
|
|
26843
|
+
Effect119.flatMap((sync) => sync.syncMessagePlugins(portalId)),
|
|
26844
|
+
Effect119.provide(syncLayer)
|
|
25979
26845
|
)
|
|
25980
26846
|
),
|
|
25981
|
-
|
|
26847
|
+
Effect119.flatMap(
|
|
25982
26848
|
() => portalData.setMetadata(portalId, LAST_PLUGIN_SYNC_ALL_KEY, (/* @__PURE__ */ new Date()).toISOString())
|
|
25983
26849
|
),
|
|
25984
|
-
|
|
26850
|
+
Effect119.tap(() => Effect119.sync(
|
|
25985
26851
|
() => console.error(`[plugin-sync] Completed message plugin sync for portal ${portalId}`)
|
|
25986
26852
|
)),
|
|
25987
|
-
|
|
25988
|
-
(error) =>
|
|
26853
|
+
Effect119.catchAll(
|
|
26854
|
+
(error) => Effect119.sync(
|
|
25989
26855
|
() => console.error(`[plugin-sync] Failed for portal ${portalId}:`, error)
|
|
25990
26856
|
)
|
|
25991
26857
|
)
|
|
25992
26858
|
);
|
|
25993
26859
|
}),
|
|
25994
|
-
|
|
25995
|
-
(error) =>
|
|
26860
|
+
Effect119.catchAll(
|
|
26861
|
+
(error) => Effect119.sync(
|
|
25996
26862
|
() => console.error(`[plugin-sync] Failed to check debounce for portal ${portalId}:`, error)
|
|
25997
26863
|
)
|
|
25998
26864
|
)
|
|
@@ -26000,19 +26866,19 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26000
26866
|
);
|
|
26001
26867
|
};
|
|
26002
26868
|
configureArtifactQueue(
|
|
26003
|
-
(portalId, artifact) => !isMasterClient() ?
|
|
26869
|
+
(portalId, artifact) => !isMasterClient() ? Effect119.sync(() => {
|
|
26004
26870
|
logReadOnlySkip(`artifact queue ingest (${artifact.object_type})`, portalId);
|
|
26005
26871
|
return true;
|
|
26006
|
-
}) : !isArtifactSyncEnabled(getClientState2(), portalId, artifact.object_type) ?
|
|
26872
|
+
}) : !isArtifactSyncEnabled(getClientState2(), portalId, artifact.object_type) ? Effect119.sync(() => {
|
|
26007
26873
|
console.error(
|
|
26008
26874
|
`[artifact-queue] Skipping ${artifact.object_type} for portal ${portalId} because sync is disabled`
|
|
26009
26875
|
);
|
|
26010
26876
|
return true;
|
|
26011
|
-
}) :
|
|
26877
|
+
}) : pipe98(
|
|
26012
26878
|
SyncService,
|
|
26013
|
-
|
|
26014
|
-
|
|
26015
|
-
|
|
26879
|
+
Effect119.flatMap((sync) => sync.syncArtifacts(portalId, [artifact], [artifact.object_type])),
|
|
26880
|
+
Effect119.flatMap(() => portalFileState.get(portalId)),
|
|
26881
|
+
Effect119.map((portal) => {
|
|
26016
26882
|
const status = portal.artifacts.find((a) => a.object_type === artifact.object_type)?.status;
|
|
26017
26883
|
if (status !== "SYNCED" && status !== "PARTIAL") {
|
|
26018
26884
|
console.error(
|
|
@@ -26021,8 +26887,8 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26021
26887
|
}
|
|
26022
26888
|
return status === "SYNCED" || status === "PARTIAL";
|
|
26023
26889
|
}),
|
|
26024
|
-
|
|
26025
|
-
(err) =>
|
|
26890
|
+
Effect119.catchAll(
|
|
26891
|
+
(err) => Effect119.sync(() => {
|
|
26026
26892
|
console.error(
|
|
26027
26893
|
`[artifact-queue] Failed ingest for portal ${portalId} artifact ${artifact.object_type}:`,
|
|
26028
26894
|
err
|
|
@@ -26030,7 +26896,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26030
26896
|
return false;
|
|
26031
26897
|
})
|
|
26032
26898
|
),
|
|
26033
|
-
|
|
26899
|
+
Effect119.provide(makeSyncLayer(portalId))
|
|
26034
26900
|
)
|
|
26035
26901
|
);
|
|
26036
26902
|
yield* ws.registerHandlers({
|
|
@@ -26040,15 +26906,15 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26040
26906
|
return;
|
|
26041
26907
|
}
|
|
26042
26908
|
const incomingWithStatus = artifacts.map((a) => ({ ...a, status: "NOT_STARTED", error: null }));
|
|
26043
|
-
const updated =
|
|
26909
|
+
const updated = pipe98(
|
|
26044
26910
|
portalFileState.setArtifacts(portalId, incomingWithStatus),
|
|
26045
|
-
|
|
26046
|
-
(s) =>
|
|
26911
|
+
Effect119.tap(
|
|
26912
|
+
(s) => Effect119.sync(
|
|
26047
26913
|
() => console.error(`[sync:full] Saved ${s.artifacts.length} artifacts for portal ${portalId}`)
|
|
26048
26914
|
)
|
|
26049
26915
|
),
|
|
26050
|
-
|
|
26051
|
-
|
|
26916
|
+
Effect119.catchAll(() => Effect119.succeed(null)),
|
|
26917
|
+
Effect119.runSync
|
|
26052
26918
|
);
|
|
26053
26919
|
if (!updated) return;
|
|
26054
26920
|
const enabledArtifacts = filterEnabledArtifacts(getClientState2(), portalId, incomingWithStatus);
|
|
@@ -26077,10 +26943,10 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26077
26943
|
const newWithStatus = artifacts.map((a) => ({ ...a, status: "NOT_STARTED", error: null }));
|
|
26078
26944
|
const enabledArtifacts = filterEnabledArtifacts(getClientState2(), portalId, newWithStatus);
|
|
26079
26945
|
const objectTypesToSync = enabledArtifacts.map((a) => a.object_type);
|
|
26080
|
-
const merged =
|
|
26946
|
+
const merged = pipe98(
|
|
26081
26947
|
portalFileState.mergeArtifacts(portalId, newWithStatus),
|
|
26082
|
-
|
|
26083
|
-
|
|
26948
|
+
Effect119.catchAll(() => Effect119.succeed(null)),
|
|
26949
|
+
Effect119.runSync
|
|
26084
26950
|
);
|
|
26085
26951
|
if (!merged) return;
|
|
26086
26952
|
const toSync = filterUnsyncedArtifacts(merged.artifacts, new Set(objectTypesToSync));
|
|
@@ -26112,12 +26978,12 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26112
26978
|
console.error(`[diff-sync] No artifact plugin with processDiffBatch for ${batch.object_type}`);
|
|
26113
26979
|
return;
|
|
26114
26980
|
}
|
|
26115
|
-
|
|
26981
|
+
pipe98(
|
|
26116
26982
|
plugin.processDiffBatch({ portalData, fileDownload, ws, portalFileState, portalId }, batch),
|
|
26117
|
-
|
|
26118
|
-
(err) =>
|
|
26983
|
+
Effect119.catchAll(
|
|
26984
|
+
(err) => Effect119.sync(() => console.error(`[diff-sync] Error processing batch:`, err))
|
|
26119
26985
|
),
|
|
26120
|
-
|
|
26986
|
+
Effect119.runFork
|
|
26121
26987
|
);
|
|
26122
26988
|
},
|
|
26123
26989
|
onWorkflowDelta: (portalId, payload) => {
|
|
@@ -26135,17 +27001,17 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26135
27001
|
);
|
|
26136
27002
|
return;
|
|
26137
27003
|
}
|
|
26138
|
-
|
|
27004
|
+
pipe98(
|
|
26139
27005
|
portalData.applyWorkflowDelta({
|
|
26140
27006
|
portalId,
|
|
26141
27007
|
upserts: payload.upserts,
|
|
26142
27008
|
deletedWorkflowIds: payload.deleted_workflow_ids,
|
|
26143
27009
|
diffCursor: payload.server_time
|
|
26144
27010
|
}),
|
|
26145
|
-
|
|
26146
|
-
(err) =>
|
|
27011
|
+
Effect119.catchAll(
|
|
27012
|
+
(err) => Effect119.sync(() => console.error(`[workflow-delta] Error processing delta:`, err))
|
|
26147
27013
|
),
|
|
26148
|
-
|
|
27014
|
+
Effect119.runFork
|
|
26149
27015
|
);
|
|
26150
27016
|
},
|
|
26151
27017
|
onPropertyDefinitionsDelta: (portalId, payload) => {
|
|
@@ -26163,7 +27029,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26163
27029
|
);
|
|
26164
27030
|
return;
|
|
26165
27031
|
}
|
|
26166
|
-
|
|
27032
|
+
pipe98(
|
|
26167
27033
|
portalData.applyPropertyDefinitionsDelta({
|
|
26168
27034
|
portalId,
|
|
26169
27035
|
delta: {
|
|
@@ -26175,12 +27041,12 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26175
27041
|
serverTime: payload.server_time
|
|
26176
27042
|
}
|
|
26177
27043
|
}),
|
|
26178
|
-
|
|
26179
|
-
(err) =>
|
|
27044
|
+
Effect119.catchAll(
|
|
27045
|
+
(err) => Effect119.sync(
|
|
26180
27046
|
() => console.error(`[property-definitions-delta] Error processing delta:`, err)
|
|
26181
27047
|
)
|
|
26182
27048
|
),
|
|
26183
|
-
|
|
27049
|
+
Effect119.runFork
|
|
26184
27050
|
);
|
|
26185
27051
|
},
|
|
26186
27052
|
onDiffComplete: (portalId, payload) => {
|
|
@@ -26192,7 +27058,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26192
27058
|
console.error(`[live-sync] Catch-up diff failed for portal ${portalId}: ${payload.error ?? "unknown"}`);
|
|
26193
27059
|
return;
|
|
26194
27060
|
}
|
|
26195
|
-
|
|
27061
|
+
Effect119.runFork(pipe98(portalFileState.touchSyncedAt(portalId), Effect119.catchAll(() => Effect119.void)));
|
|
26196
27062
|
if (!isPortalSyncActive(portalId)) {
|
|
26197
27063
|
console.error(`[live-sync] Catch-up diff complete for portal ${portalId}, but portal sync is disabled so subscription will not restart`);
|
|
26198
27064
|
return;
|
|
@@ -26240,7 +27106,7 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26240
27106
|
}
|
|
26241
27107
|
console.error(`[live-sync] Registration complete \u2014 warming ${warmupPortalIds.length} enabled portal(s): ${warmupPortalIds.join(", ")}`);
|
|
26242
27108
|
for (const portalId of warmupPortalIds) {
|
|
26243
|
-
|
|
27109
|
+
Effect119.runFork(pipe98(ws.sendSyncFull(portalId), Effect119.catchAll(() => Effect119.void)));
|
|
26244
27110
|
}
|
|
26245
27111
|
if (DISABLE_PLUGIN_SYNC) {
|
|
26246
27112
|
console.error("[plugin-sync] Skipping plugin warmup sync for enabled portals (disabled by env flag)");
|
|
@@ -26276,20 +27142,20 @@ var mainProgram = Effect116.gen(function* () {
|
|
|
26276
27142
|
}
|
|
26277
27143
|
});
|
|
26278
27144
|
yield* ws.connect().pipe(
|
|
26279
|
-
|
|
27145
|
+
Effect119.catchAll((e) => Effect119.sync(() => console.error("WebSocket error:", e)))
|
|
26280
27146
|
);
|
|
26281
27147
|
if (!TEST_HEADLESS_MODE) {
|
|
26282
27148
|
const transport = new StdioServerTransport();
|
|
26283
|
-
yield*
|
|
26284
|
-
yield*
|
|
27149
|
+
yield* Effect119.promise(() => server.connect(transport));
|
|
27150
|
+
yield* Effect119.sync(() => console.error("MCP Pro Client server started"));
|
|
26285
27151
|
} else {
|
|
26286
|
-
yield*
|
|
27152
|
+
yield* Effect119.sync(() => console.error("MCP Pro Client runtime started (headless)"));
|
|
26287
27153
|
}
|
|
26288
|
-
yield*
|
|
27154
|
+
yield* Effect119.never;
|
|
26289
27155
|
});
|
|
26290
|
-
|
|
27156
|
+
pipe98(
|
|
26291
27157
|
mainProgram,
|
|
26292
|
-
|
|
27158
|
+
Effect119.provide((() => {
|
|
26293
27159
|
const portalDataDependencies = Layer10.mergeAll(
|
|
26294
27160
|
DuckDBInterfaceLive,
|
|
26295
27161
|
FileDownloadLive,
|
|
@@ -26302,7 +27168,7 @@ pipe95(
|
|
|
26302
27168
|
makePortalDataLive(portalDataDependencies)
|
|
26303
27169
|
);
|
|
26304
27170
|
})()),
|
|
26305
|
-
|
|
27171
|
+
Effect119.runPromise
|
|
26306
27172
|
).catch((error) => {
|
|
26307
27173
|
console.error("Fatal error:", error);
|
|
26308
27174
|
process.exit(1);
|