@raytio/mcp-server 6.0.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/dist/tools/domains.js +1 -1
- package/dist/tools/domains.js.map +1 -1
- package/dist/tools/fnd/index.d.ts +0 -8
- package/dist/tools/fnd/index.d.ts.map +1 -1
- package/dist/tools/fnd/index.js +2 -9
- package/dist/tools/fnd/index.js.map +1 -1
- package/dist/tools/imports/index.d.ts +179 -0
- package/dist/tools/imports/index.d.ts.map +1 -0
- package/dist/tools/imports/index.js +100 -0
- package/dist/tools/imports/index.js.map +1 -0
- package/dist/tools/sfa/lead-import.d.ts +0 -10
- package/dist/tools/sfa/lead-import.d.ts.map +1 -1
- package/dist/tools/sfa/lead-import.js +11 -49
- package/dist/tools/sfa/lead-import.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -498,3 +498,51 @@ MIT
|
|
|
498
498
|
## Support
|
|
499
499
|
|
|
500
500
|
For issues or questions, please open an issue in the repository.
|
|
501
|
+
|
|
502
|
+
### Shared imports
|
|
503
|
+
|
|
504
|
+
Use the FND domain tools for COA values/combinations, SFA leads and daily rates.
|
|
505
|
+
`fnd_import_definitions` reads the server registry and availability.
|
|
506
|
+
`fnd_import_run_create` takes an existing authorised `source_id`,
|
|
507
|
+
`destination_org_id`, definition/version, strict domain context and an explicit
|
|
508
|
+
`processing_policy.partial_policy` (`NONE` or `INDEPENDENT_OBJECTS`). COA context
|
|
509
|
+
requires `structure_id` and `upsert_mode` (`CREATE_ONLY` or `REPLACE`), without a
|
|
510
|
+
ledger. Lead context requires `org_id`. Daily-rate context requires `rate_type`,
|
|
511
|
+
`date_from`, `date_to`, `currencies` and `upsert_mode`. The server checks all
|
|
512
|
+
source, tenant, domain and destination permissions using the caller identity.
|
|
513
|
+
|
|
514
|
+
For files, reserve evidence with `fnd_import_upload_reserve`, obtain its private
|
|
515
|
+
URL with `fnd_import_upload_url`, upload the exact bytes, then call
|
|
516
|
+
`fnd_import_upload_complete`. Set a saved ETL template or allowlisted field
|
|
517
|
+
transforms using `fnd_import_profile_set`, extract bounded chunks using the
|
|
518
|
+
server checkpoint, set reviewed reference mappings with
|
|
519
|
+
`fnd_import_mapping_set`, and seal the complete batch with `fnd_import_seal`.
|
|
520
|
+
For an external rate source, create a `FND_DAILY_RATES` run with its existing
|
|
521
|
+
API source ID and call `fnd_import_acquire`. Source registration/provider
|
|
522
|
+
configuration remains server-side: the inspected shared API has no source
|
|
523
|
+
registration endpoint. No tool accepts provider URLs, credentials, arbitrary
|
|
524
|
+
tables or executable functions.
|
|
525
|
+
|
|
526
|
+
Call `fnd_import_validate`, inspect the run/findings/results, then
|
|
527
|
+
`fnd_import_process` for the reviewed snapshot. Mutations require a stable
|
|
528
|
+
`idempotency_key`; retry identical requests with that key, including after
|
|
529
|
+
timeouts. Changed requests need a new key. Lifecycle commands require the
|
|
530
|
+
current run `expected_version`; seal/reference mapping commands require their
|
|
531
|
+
server version. Use `fnd_import_run_get` to restore a run and its batches, and
|
|
532
|
+
`fnd_import_objects_list`, `fnd_import_findings_list` and
|
|
533
|
+
`fnd_import_results_list` for bounded pages (`limit` 1–100, `offset` up to
|
|
534
|
+
100000). `fnd_import_pause`, `fnd_import_resume` and `fnd_import_cancel` retain
|
|
535
|
+
committed outcomes and use the same durable run ID.
|
|
536
|
+
|
|
537
|
+
A successful MCP response means the API command returned. Preserve its
|
|
538
|
+
`accepted`, run/operation/job identifiers and authoritative state; an accepted
|
|
539
|
+
async request does not mean a completed import. Lead import outcomes can be
|
|
540
|
+
`DEDUP_PENDING`, which is a handoff rather than completed deduplication or
|
|
541
|
+
promotion. Server findings expose safe messages rather than raw source evidence.
|
|
542
|
+
|
|
543
|
+
**6.0 migration:** `sfa_lead_import` now creates a shared `SFA_LEADS` run using
|
|
544
|
+
the same inputs as run creation except for the fixed definition code. Replace
|
|
545
|
+
legacy `tenant_id`, S3 coordinates, inline mappings and `trigger_dedup` with
|
|
546
|
+
the shared source/evidence/profile journey above. Enable the `fnd` domain to
|
|
547
|
+
continue a run created through the SFA tool. `fnd-readonly` remains limited
|
|
548
|
+
to its existing reference reads and does not advertise import commands.
|
package/dist/tools/domains.js
CHANGED
|
@@ -40,7 +40,7 @@ export const primaryDomains = [
|
|
|
40
40
|
{
|
|
41
41
|
id: 'fnd',
|
|
42
42
|
title: 'FND — Foundation',
|
|
43
|
-
summary: '
|
|
43
|
+
summary: 'Shared import lifecycle tools for COA, leads and daily rates, plus bounded reads for approved Foundation reference and configuration data — labels, entity labels, domains, locales, RUC enforcement, menus, notification topics, tenants, integration links, ETL templates, report templates, and documents (plus versions and attachments). Administrative, credentialed, and internal-permission FND tables remain excluded.',
|
|
44
44
|
tools: fndTools,
|
|
45
45
|
},
|
|
46
46
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domains.js","sourceRoot":"","sources":["../../src/tools/domains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAa5D,MAAM,CAAC,MAAM,cAAc,GAAoB;IAC7C;QACE,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,+BAA+B;QACtC,OAAO,EACL,+FAA+F;QACjG,KAAK,EAAE,QAAQ;KAChB;IACD;QACE,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O,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { Tool } from '../registry.js';
|
|
2
|
-
/**
|
|
3
|
-
* FND tool surface (WI-0003503).
|
|
4
|
-
*
|
|
5
|
-
* FND is a bounded-read-only module in this WI — every mutation on
|
|
6
|
-
* FND rows is either handled elsewhere (permission model → derived
|
|
7
|
-
* capabilities; job scheduling → workers) or awaits a dedicated
|
|
8
|
-
* semantic endpoint.
|
|
9
|
-
*/
|
|
10
2
|
export declare const fndTools: Tool[];
|
|
11
3
|
/** Read-only slice used by the `fnd-readonly` selectable sub-domain. */
|
|
12
4
|
export declare const fndReadOnlyTools: Tool[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/fnd/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/fnd/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAItC,eAAO,MAAM,QAAQ,EAAE,IAAI,EAA+C,CAAC;AAE3E,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,EAAE,IAAI,EAA0B,CAAC"}
|
package/dist/tools/fnd/index.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
+
import { importTools } from '../imports/index.js';
|
|
1
2
|
import { fndGeneratedReadTools } from './generated-reads.js';
|
|
2
|
-
|
|
3
|
-
* FND tool surface (WI-0003503).
|
|
4
|
-
*
|
|
5
|
-
* FND is a bounded-read-only module in this WI — every mutation on
|
|
6
|
-
* FND rows is either handled elsewhere (permission model → derived
|
|
7
|
-
* capabilities; job scheduling → workers) or awaits a dedicated
|
|
8
|
-
* semantic endpoint.
|
|
9
|
-
*/
|
|
10
|
-
export const fndTools = [...fndGeneratedReadTools];
|
|
3
|
+
export const fndTools = [...fndGeneratedReadTools, ...importTools];
|
|
11
4
|
/** Read-only slice used by the `fnd-readonly` selectable sub-domain. */
|
|
12
5
|
export const fndReadOnlyTools = fndGeneratedReadTools;
|
|
13
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/fnd/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/fnd/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,MAAM,CAAC,MAAM,QAAQ,GAAW,CAAC,GAAG,qBAAqB,EAAE,GAAG,WAAW,CAAC,CAAC;AAE3E,wEAAwE;AACxE,MAAM,CAAC,MAAM,gBAAgB,GAAW,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Tool } from '../registry.js';
|
|
3
|
+
export declare const leadRunSchema: z.ZodObject<{
|
|
4
|
+
context: z.ZodObject<{
|
|
5
|
+
org_id: z.ZodString;
|
|
6
|
+
}, "strict", z.ZodTypeAny, {
|
|
7
|
+
org_id: string;
|
|
8
|
+
}, {
|
|
9
|
+
org_id: string;
|
|
10
|
+
}>;
|
|
11
|
+
source_id: z.ZodString;
|
|
12
|
+
destination_org_id: z.ZodString;
|
|
13
|
+
definition_version: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
idempotency_key: z.ZodString;
|
|
15
|
+
processing_policy: z.ZodObject<{
|
|
16
|
+
partial_policy: z.ZodEnum<["NONE", "INDEPENDENT_OBJECTS"]>;
|
|
17
|
+
}, "strict", z.ZodTypeAny, {
|
|
18
|
+
partial_policy: "NONE" | "INDEPENDENT_OBJECTS";
|
|
19
|
+
}, {
|
|
20
|
+
partial_policy: "NONE" | "INDEPENDENT_OBJECTS";
|
|
21
|
+
}>;
|
|
22
|
+
}, "strict", z.ZodTypeAny, {
|
|
23
|
+
context: {
|
|
24
|
+
org_id: string;
|
|
25
|
+
};
|
|
26
|
+
source_id: string;
|
|
27
|
+
destination_org_id: string;
|
|
28
|
+
definition_version: number;
|
|
29
|
+
idempotency_key: string;
|
|
30
|
+
processing_policy: {
|
|
31
|
+
partial_policy: "NONE" | "INDEPENDENT_OBJECTS";
|
|
32
|
+
};
|
|
33
|
+
}, {
|
|
34
|
+
context: {
|
|
35
|
+
org_id: string;
|
|
36
|
+
};
|
|
37
|
+
source_id: string;
|
|
38
|
+
destination_org_id: string;
|
|
39
|
+
idempotency_key: string;
|
|
40
|
+
processing_policy: {
|
|
41
|
+
partial_policy: "NONE" | "INDEPENDENT_OBJECTS";
|
|
42
|
+
};
|
|
43
|
+
definition_version?: number | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
export declare const runCreateSchema: z.ZodEffects<z.ZodObject<{
|
|
46
|
+
definition_code: z.ZodEnum<["FGL_COA_VALUES", "FGL_COA_COMBINATIONS", "SFA_LEADS", "FND_DAILY_RATES"]>;
|
|
47
|
+
context: z.ZodUnion<[z.ZodObject<{
|
|
48
|
+
structure_id: z.ZodString;
|
|
49
|
+
upsert_mode: z.ZodEnum<["CREATE_ONLY", "REPLACE"]>;
|
|
50
|
+
}, "strict", z.ZodTypeAny, {
|
|
51
|
+
structure_id: string;
|
|
52
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
53
|
+
}, {
|
|
54
|
+
structure_id: string;
|
|
55
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
56
|
+
}>, z.ZodObject<{
|
|
57
|
+
org_id: z.ZodString;
|
|
58
|
+
}, "strict", z.ZodTypeAny, {
|
|
59
|
+
org_id: string;
|
|
60
|
+
}, {
|
|
61
|
+
org_id: string;
|
|
62
|
+
}>, z.ZodObject<{
|
|
63
|
+
rate_type: z.ZodString;
|
|
64
|
+
date_from: z.ZodString;
|
|
65
|
+
date_to: z.ZodString;
|
|
66
|
+
currencies: z.ZodArray<z.ZodString, "many">;
|
|
67
|
+
upsert_mode: z.ZodEnum<["CREATE_ONLY", "REPLACE"]>;
|
|
68
|
+
}, "strict", z.ZodTypeAny, {
|
|
69
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
70
|
+
rate_type: string;
|
|
71
|
+
date_from: string;
|
|
72
|
+
date_to: string;
|
|
73
|
+
currencies: string[];
|
|
74
|
+
}, {
|
|
75
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
76
|
+
rate_type: string;
|
|
77
|
+
date_from: string;
|
|
78
|
+
date_to: string;
|
|
79
|
+
currencies: string[];
|
|
80
|
+
}>]>;
|
|
81
|
+
source_id: z.ZodString;
|
|
82
|
+
destination_org_id: z.ZodString;
|
|
83
|
+
definition_version: z.ZodDefault<z.ZodNumber>;
|
|
84
|
+
idempotency_key: z.ZodString;
|
|
85
|
+
processing_policy: z.ZodObject<{
|
|
86
|
+
partial_policy: z.ZodEnum<["NONE", "INDEPENDENT_OBJECTS"]>;
|
|
87
|
+
}, "strict", z.ZodTypeAny, {
|
|
88
|
+
partial_policy: "NONE" | "INDEPENDENT_OBJECTS";
|
|
89
|
+
}, {
|
|
90
|
+
partial_policy: "NONE" | "INDEPENDENT_OBJECTS";
|
|
91
|
+
}>;
|
|
92
|
+
}, "strict", z.ZodTypeAny, {
|
|
93
|
+
context: {
|
|
94
|
+
structure_id: string;
|
|
95
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
96
|
+
} | {
|
|
97
|
+
org_id: string;
|
|
98
|
+
} | {
|
|
99
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
100
|
+
rate_type: string;
|
|
101
|
+
date_from: string;
|
|
102
|
+
date_to: string;
|
|
103
|
+
currencies: string[];
|
|
104
|
+
};
|
|
105
|
+
source_id: string;
|
|
106
|
+
destination_org_id: string;
|
|
107
|
+
definition_version: number;
|
|
108
|
+
idempotency_key: string;
|
|
109
|
+
processing_policy: {
|
|
110
|
+
partial_policy: "NONE" | "INDEPENDENT_OBJECTS";
|
|
111
|
+
};
|
|
112
|
+
definition_code: "FGL_COA_VALUES" | "FGL_COA_COMBINATIONS" | "SFA_LEADS" | "FND_DAILY_RATES";
|
|
113
|
+
}, {
|
|
114
|
+
context: {
|
|
115
|
+
structure_id: string;
|
|
116
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
117
|
+
} | {
|
|
118
|
+
org_id: string;
|
|
119
|
+
} | {
|
|
120
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
121
|
+
rate_type: string;
|
|
122
|
+
date_from: string;
|
|
123
|
+
date_to: string;
|
|
124
|
+
currencies: string[];
|
|
125
|
+
};
|
|
126
|
+
source_id: string;
|
|
127
|
+
destination_org_id: string;
|
|
128
|
+
idempotency_key: string;
|
|
129
|
+
processing_policy: {
|
|
130
|
+
partial_policy: "NONE" | "INDEPENDENT_OBJECTS";
|
|
131
|
+
};
|
|
132
|
+
definition_code: "FGL_COA_VALUES" | "FGL_COA_COMBINATIONS" | "SFA_LEADS" | "FND_DAILY_RATES";
|
|
133
|
+
definition_version?: number | undefined;
|
|
134
|
+
}>, {
|
|
135
|
+
context: {
|
|
136
|
+
structure_id: string;
|
|
137
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
138
|
+
} | {
|
|
139
|
+
org_id: string;
|
|
140
|
+
} | {
|
|
141
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
142
|
+
rate_type: string;
|
|
143
|
+
date_from: string;
|
|
144
|
+
date_to: string;
|
|
145
|
+
currencies: string[];
|
|
146
|
+
};
|
|
147
|
+
source_id: string;
|
|
148
|
+
destination_org_id: string;
|
|
149
|
+
definition_version: number;
|
|
150
|
+
idempotency_key: string;
|
|
151
|
+
processing_policy: {
|
|
152
|
+
partial_policy: "NONE" | "INDEPENDENT_OBJECTS";
|
|
153
|
+
};
|
|
154
|
+
definition_code: "FGL_COA_VALUES" | "FGL_COA_COMBINATIONS" | "SFA_LEADS" | "FND_DAILY_RATES";
|
|
155
|
+
}, {
|
|
156
|
+
context: {
|
|
157
|
+
structure_id: string;
|
|
158
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
159
|
+
} | {
|
|
160
|
+
org_id: string;
|
|
161
|
+
} | {
|
|
162
|
+
upsert_mode: "CREATE_ONLY" | "REPLACE";
|
|
163
|
+
rate_type: string;
|
|
164
|
+
date_from: string;
|
|
165
|
+
date_to: string;
|
|
166
|
+
currencies: string[];
|
|
167
|
+
};
|
|
168
|
+
source_id: string;
|
|
169
|
+
destination_org_id: string;
|
|
170
|
+
idempotency_key: string;
|
|
171
|
+
processing_policy: {
|
|
172
|
+
partial_policy: "NONE" | "INDEPENDENT_OBJECTS";
|
|
173
|
+
};
|
|
174
|
+
definition_code: "FGL_COA_VALUES" | "FGL_COA_COMBINATIONS" | "SFA_LEADS" | "FND_DAILY_RATES";
|
|
175
|
+
definition_version?: number | undefined;
|
|
176
|
+
}>;
|
|
177
|
+
export declare const importRunCreateTool: Tool;
|
|
178
|
+
export declare const importTools: Tool[];
|
|
179
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/imports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAgBtC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA+E,CAAC;AAU1G,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQ1B,CAAC;AA0CH,eAAO,MAAM,mBAAmB,MAES,CAAC;AAE1C,eAAO,MAAM,WAAW,EAAE,IAAI,EAsC7B,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { successResponse, errorResponse, API_ERROR } from '../types.js';
|
|
3
|
+
const id = z.string().uuid();
|
|
4
|
+
const key = z.string().min(1).max(255);
|
|
5
|
+
const version = z.number().int().min(1);
|
|
6
|
+
const partial = z.enum(['NONE', 'INDEPENDENT_OBJECTS']);
|
|
7
|
+
const upsert = z.enum(['CREATE_ONLY', 'REPLACE']);
|
|
8
|
+
const common = {
|
|
9
|
+
source_id: id.describe('Existing authorised source reference; credentials remain with the source owner'),
|
|
10
|
+
destination_org_id: id,
|
|
11
|
+
definition_version: version.default(1),
|
|
12
|
+
idempotency_key: key,
|
|
13
|
+
processing_policy: z.object({ partial_policy: partial }).strict(),
|
|
14
|
+
};
|
|
15
|
+
const coaContext = z.object({ structure_id: id, upsert_mode: upsert }).strict();
|
|
16
|
+
export const leadRunSchema = z.object({ ...common, context: z.object({ org_id: id }).strict() }).strict();
|
|
17
|
+
const contexts = {
|
|
18
|
+
FGL_COA_VALUES: coaContext,
|
|
19
|
+
FGL_COA_COMBINATIONS: coaContext,
|
|
20
|
+
SFA_LEADS: z.object({ org_id: id }).strict(),
|
|
21
|
+
FND_DAILY_RATES: z.object({
|
|
22
|
+
rate_type: z.string().min(1).max(30), date_from: z.string().date(), date_to: z.string().date(),
|
|
23
|
+
currencies: z.array(z.string().regex(/^[A-Z]{3}$/)).min(2).max(200), upsert_mode: upsert,
|
|
24
|
+
}).strict(),
|
|
25
|
+
};
|
|
26
|
+
export const runCreateSchema = z.object({
|
|
27
|
+
...common,
|
|
28
|
+
definition_code: z.enum(['FGL_COA_VALUES', 'FGL_COA_COMBINATIONS', 'SFA_LEADS', 'FND_DAILY_RATES']),
|
|
29
|
+
context: z.union([coaContext, contexts.SFA_LEADS, contexts.FND_DAILY_RATES]),
|
|
30
|
+
}).strict().superRefine((input, ctx) => {
|
|
31
|
+
if (!contexts[input.definition_code].safeParse(input.context).success) {
|
|
32
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['context'], message: 'Context must match the registered definition' });
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const run = { run_id: id };
|
|
36
|
+
const command = { ...run, idempotency_key: key };
|
|
37
|
+
const lifecycle = z.object({ ...command, expected_version: version, batch_id: id.optional(),
|
|
38
|
+
limit: z.number().int().min(1).max(100).default(25) }).strict();
|
|
39
|
+
const response = z.record(z.unknown());
|
|
40
|
+
/** Fixed shared routes only. The server owns permissions, snapshots and lifecycle. */
|
|
41
|
+
function endpoint(name, description, schema, route, read = false) {
|
|
42
|
+
return {
|
|
43
|
+
name, description,
|
|
44
|
+
inputSchema: schema,
|
|
45
|
+
sideEffect: read ? 'read_only' : 'command',
|
|
46
|
+
confirmation: 'none',
|
|
47
|
+
idempotency: read ? 'read_only' : 'explicit_key',
|
|
48
|
+
handler: async (args, ctx) => {
|
|
49
|
+
const parsed = schema.safeParse(args);
|
|
50
|
+
if (!parsed.success)
|
|
51
|
+
return errorResponse('IMPORT_VALIDATION', 'Invalid import request');
|
|
52
|
+
const input = parsed.data;
|
|
53
|
+
const { run_id: _runId, evidence_id: _evidenceId, ...body } = input;
|
|
54
|
+
// Evidence IDs are command data except when explicitly used in a URL.
|
|
55
|
+
if ('evidence_id' in input && !read)
|
|
56
|
+
body.evidence_id = input.evidence_id;
|
|
57
|
+
try {
|
|
58
|
+
const result = read
|
|
59
|
+
? await ctx.apiClient.get(`${ctx.apiClient.lambdaBasePath}${route(input)}`, {
|
|
60
|
+
query: Object.fromEntries(Object.entries(body).map(([k, v]) => [k, String(v)])),
|
|
61
|
+
})
|
|
62
|
+
: await ctx.apiClient.postLambda(route(input), body);
|
|
63
|
+
// Preserve authoritative accepted/state/job/operation fields; tool success
|
|
64
|
+
// means the command returned, never that native processing completed.
|
|
65
|
+
return successResponse(response.parse(result));
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// API errors can include source data. Do not copy upstream free text.
|
|
69
|
+
return errorResponse(API_ERROR, 'Shared import request failed; inspect the run before retrying with the same idempotency key');
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const runPath = (input) => `/imports/runs/${input.run_id}`;
|
|
75
|
+
const accepted = ' Returns the server receipt and durable identifiers; acceptance is not import completion. Retry identical input with the same idempotency_key; changed input requires a new key.';
|
|
76
|
+
export const importRunCreateTool = endpoint('fnd_import_run_create', 'Create a shared COA (no ledger), lead, or daily-rate import using an existing authorised source and explicit domain context.' + accepted, runCreateSchema, () => '/imports/runs');
|
|
77
|
+
export const importTools = [
|
|
78
|
+
endpoint('fnd_import_definitions', 'Discover authoritative registered import definitions, fields, context and availability.', z.object({}).strict(), () => '/imports/definitions', true),
|
|
79
|
+
importRunCreateTool,
|
|
80
|
+
endpoint('fnd_import_upload_reserve', 'Reserve private immutable evidence for a CSV or structured artifact.' + accepted, z.object({ ...command, generation: version.default(1), sha256: z.string().regex(/^[0-9a-f]{64}$/),
|
|
81
|
+
size_bytes: z.number().int().min(1).max(10485760), format: z.enum(['CSV', 'STRUCTURED']).default('CSV') }).strict(), i => `${runPath(i)}/uploads`),
|
|
82
|
+
endpoint('fnd_import_upload_url', 'Get a private upload URL for an existing reservation. Upload bytes before completing the evidence.', z.object({ ...run, evidence_id: id }).strict(), i => `${runPath(i)}/uploads/${i.evidence_id}/url`, true),
|
|
83
|
+
endpoint('fnd_import_upload_complete', 'Verify uploaded bytes and finalise immutable private evidence.' + accepted, z.object({ ...command, evidence_id: id }).strict(), i => `${runPath(i)}/uploads/complete`),
|
|
84
|
+
endpoint('fnd_import_extract', 'Parse and stage a bounded evidence chunk. Use the durable server checkpoint to continue; rejected records remain findings.' + accepted, z.object({ ...command, evidence_id: id, offset: z.number().int().min(0).max(10000).default(0) }).strict(), i => `${runPath(i)}/extract`),
|
|
85
|
+
endpoint('fnd_import_profile_set', 'Save field mappings using registered transforms, or select an existing ETL template. Changes after extraction require a new generation.' + accepted, z.object({ ...command, batch_id: id, template_id: id.nullable().optional(), source_key: z.string().max(128).nullable().optional(),
|
|
86
|
+
mappings: z.array(z.object({ source: z.string().max(255).nullable().optional(), target: z.string().min(1).max(64),
|
|
87
|
+
transform: z.enum(['SELECT', 'RENAME', 'CONSTANT', 'TRIM', 'EMPTY_TO_NULL', 'DEFAULT', 'PARSE_DECIMAL', 'PARSE_DATE', 'ENUM', 'REFERENCE_KEY']).default('SELECT'),
|
|
88
|
+
arguments: z.object({ value: z.union([z.string().max(4096), z.boolean(), z.null()]).optional(), format: z.string().max(64).optional(),
|
|
89
|
+
values: z.record(z.string().max(256)).optional() }).strict().default({}),
|
|
90
|
+
}).strict()).max(100).default([]) }).strict(), i => `${runPath(i)}/profiles`),
|
|
91
|
+
endpoint('fnd_import_mapping_set', 'Save a reviewed reference mapping; server checks target scope and mapping freeze.' + accepted, z.object({ ...command, source_entity_type: z.string().min(1).max(64), source_reference: z.string().min(1).max(255),
|
|
92
|
+
target_type: z.enum(['FGL_VALUE', 'FGL_COA_STRUCTURE']), target_id: id, expected_version: version }).strict(), i => `${runPath(i)}/mappings`),
|
|
93
|
+
endpoint('fnd_import_seal', 'Seal a complete batch generation using its expected version. Incomplete inputs block sealing.' + accepted, z.object({ ...command, batch_id: id, expected_version: version }).strict(), i => `${runPath(i)}/seal`),
|
|
94
|
+
endpoint('fnd_import_acquire', 'Acquire from the existing registered API source (including an external rate feed); provider credentials stay server-side.' + accepted, z.object({ ...command, generation: version.default(1) }).strict(), i => `${runPath(i)}/acquire`),
|
|
95
|
+
...['validate', 'process', 'pause', 'resume', 'cancel'].map(action => endpoint(`fnd_import_${action}`, `${action} a shared import with expected run version. Validation has no native writes; process uses the approved snapshot. Pause/cancel preserves committed outcomes. Lead handoff does not imply dedup completion.` + accepted, lifecycle, i => `${runPath(i)}/${action}`)),
|
|
96
|
+
...['run', 'objects', 'findings', 'results'].map(kind => endpoint(`fnd_import_${kind === 'run' ? 'run_get' : kind + '_list'}`, `Inspect durable import ${kind}; server-authorised bounded results. Findings contain safe diagnostics; lead handoff remains distinct from downstream completion.`, z.object({ ...run, ...(kind === 'run' ? {} : {
|
|
97
|
+
offset: z.number().int().min(0).max(100000).default(0), limit: z.number().int().min(1).max(100).default(50),
|
|
98
|
+
}) }).strict(), i => `${runPath(i)}${kind === 'run' ? '' : '/' + kind}`, true)),
|
|
99
|
+
];
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/imports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExE,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;AAC7B,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACvC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACxC,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;AACxD,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC;AAClD,MAAM,MAAM,GAAG;IACb,SAAS,EAAE,EAAE,CAAC,QAAQ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';
|
|
2
|
-
/**
|
|
3
|
-
* Calls the sfa-lead-import persist-functions Lambda
|
|
4
|
-
* (POST /persist/v2/sfa/lead/import).
|
|
5
|
-
*
|
|
6
|
-
* Triggers a CSV-from-S3 ingestion run: the Lambda reads the CSV, applies
|
|
7
|
-
* the provided column mapping to each record, and inserts one
|
|
8
|
-
* `t_sfa_lead_staging` row per record with `source_type='IMPORT'`. On
|
|
9
|
-
* success it enqueues a follow-up `sfa_lead_dedup` job to fire the
|
|
10
|
-
* dedup → promote chain.
|
|
11
|
-
*/
|
|
12
2
|
export declare const leadImportTool: Tool;
|
|
13
3
|
//# sourceMappingURL=lead-import.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lead-import.d.ts","sourceRoot":"","sources":["../../../src/tools/sfa/lead-import.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lead-import.d.ts","sourceRoot":"","sources":["../../../src/tools/sfa/lead-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAItC,eAAO,MAAM,cAAc,EAAE,IAY5B,CAAC"}
|
|
@@ -1,55 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
/**
|
|
4
|
-
* Calls the sfa-lead-import persist-functions Lambda
|
|
5
|
-
* (POST /persist/v2/sfa/lead/import).
|
|
6
|
-
*
|
|
7
|
-
* Triggers a CSV-from-S3 ingestion run: the Lambda reads the CSV, applies
|
|
8
|
-
* the provided column mapping to each record, and inserts one
|
|
9
|
-
* `t_sfa_lead_staging` row per record with `source_type='IMPORT'`. On
|
|
10
|
-
* success it enqueues a follow-up `sfa_lead_dedup` job to fire the
|
|
11
|
-
* dedup → promote chain.
|
|
12
|
-
*/
|
|
1
|
+
import { importRunCreateTool, leadRunSchema } from '../imports/index.js';
|
|
2
|
+
import { errorResponse } from '../types.js';
|
|
13
3
|
export const leadImportTool = {
|
|
14
4
|
name: 'sfa_lead_import',
|
|
15
|
-
description: '
|
|
16
|
-
inputSchema:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
column_mapping: z.record(z.string()).optional()
|
|
21
|
-
.describe('Mapping of CSV header → staging lead field. Unmapped columns are still kept on raw_payload.raw.'),
|
|
22
|
-
source_ref: z.string().optional()
|
|
23
|
-
.describe('Override for source_ref (defaults to the S3 key)'),
|
|
24
|
-
delimiter: z.string().optional().describe('CSV delimiter (default ",")'),
|
|
25
|
-
encoding: z.string().optional().describe('CSV file encoding (default "utf-8-sig")'),
|
|
26
|
-
trigger_dedup: z.boolean().optional()
|
|
27
|
-
.describe('When TRUE (default), enqueue a sfa_lead_dedup job on success'),
|
|
28
|
-
metadata: z.record(z.unknown()).optional()
|
|
29
|
-
.describe('Optional metadata stamped on every staging row'),
|
|
30
|
-
}),
|
|
5
|
+
description: 'Create a shared SFA_LEADS run with an existing authorised source and organisation context. Returns durable run/operation IDs, not completed leads. Use FND import upload, mapping, validation, processing and result tools to continue. Dedup handoff is distinct from downstream completion. Identical idempotency_key retries return the same receipt.',
|
|
6
|
+
inputSchema: leadRunSchema,
|
|
7
|
+
sideEffect: 'command',
|
|
8
|
+
confirmation: 'none',
|
|
9
|
+
idempotency: 'explicit_key',
|
|
31
10
|
handler: async (args, ctx) => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
s3_bucket: input.s3_bucket,
|
|
37
|
-
s3_key: input.s3_key,
|
|
38
|
-
};
|
|
39
|
-
const optional = [
|
|
40
|
-
'column_mapping', 'source_ref', 'delimiter', 'encoding',
|
|
41
|
-
'trigger_dedup', 'metadata',
|
|
42
|
-
];
|
|
43
|
-
for (const field of optional) {
|
|
44
|
-
if (input[field] !== undefined)
|
|
45
|
-
body[field] = input[field];
|
|
46
|
-
}
|
|
47
|
-
const result = await ctx.apiClient.postLambda('/sfa/lead/import', body);
|
|
48
|
-
return successResponse(result);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
return errorResponse(API_ERROR, `Failed to trigger SFA lead import: ${error.message}`);
|
|
52
|
-
}
|
|
11
|
+
const parsed = leadRunSchema.safeParse(args);
|
|
12
|
+
if (!parsed.success)
|
|
13
|
+
return errorResponse('IMPORT_VALIDATION', 'Invalid lead import request');
|
|
14
|
+
return importRunCreateTool.handler({ ...parsed.data, definition_code: 'SFA_LEADS' }, ctx);
|
|
53
15
|
},
|
|
54
16
|
};
|
|
55
17
|
//# sourceMappingURL=lead-import.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lead-import.js","sourceRoot":"","sources":["../../../src/tools/sfa/lead-import.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lead-import.js","sourceRoot":"","sources":["../../../src/tools/sfa/lead-import.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,cAAc,GAAS;IAClC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,0VAA0V;IACvW,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,MAAM;IACpB,WAAW,EAAE,cAAc;IAC3B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC3B,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,aAAa,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC;QAC9F,OAAO,mBAAmB,CAAC,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5F,CAAC;CACF,CAAC"}
|