@antcde/connect-ts 0.4.27 → 0.4.28-rc.2
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/build/AntConnect.d.ts +4 -0
- package/build/AntConnect.d.ts.map +1 -1
- package/build/AntConnect.js +4 -0
- package/build/comms/signal.d.ts +1 -0
- package/build/comms/signal.d.ts.map +1 -1
- package/build/comms/signal.js +1 -0
- package/build/comms/signalFilePreviewTypes.d.ts +65 -0
- package/build/comms/signalFilePreviewTypes.d.ts.map +1 -0
- package/build/comms/signalFilePreviewTypes.js +9 -0
- package/build/comms/signalRouteTypes.d.ts +38 -0
- package/build/comms/signalRouteTypes.d.ts.map +1 -0
- package/build/comms/signalRouteTypes.js +8 -0
- package/build/comms/signalTypes.d.ts +11 -46
- package/build/comms/signalTypes.d.ts.map +1 -1
- package/build/index.d.ts +26 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -0
- package/build/service-runtime.d.ts +1 -1
- package/build/service-runtime.d.ts.map +1 -1
- package/build/service-runtime.js +1 -1
- package/build/service-types-app.d.ts +1 -1
- package/build/service-types-app.d.ts.map +1 -1
- package/build/service-types.d.ts +3 -1
- package/build/service-types.d.ts.map +1 -1
- package/build/services/AppService/factory/assignments.d.ts +13 -0
- package/build/services/AppService/factory/assignments.d.ts.map +1 -1
- package/build/services/AppService/factory/assignments.js +5 -0
- package/build/services/AppService/factory/resourceAccess.d.ts +1 -1
- package/build/services/AppService/factory/resourceAccess.d.ts.map +1 -1
- package/build/services/AppService/factory/resourceAccess.js +16 -0
- package/build/services/AppService/factory/resourceAssignments.d.ts +26 -2
- package/build/services/AppService/factory/resourceAssignments.d.ts.map +1 -1
- package/build/services/AppService/factory/resourceAssignments.js +2 -0
- package/build/services/AppService/factory/resourceEntitlementActions.d.ts +42 -0
- package/build/services/AppService/factory/resourceEntitlementActions.d.ts.map +1 -0
- package/build/services/AppService/factory/resourceEntitlementActions.js +10 -0
- package/build/services/AppService/factory/resources.d.ts +15 -28
- package/build/services/AppService/factory/resources.d.ts.map +1 -1
- package/build/services/AppService/factory/resources.js +2 -5
- package/build/services/AppService/factory/subscriptions.d.ts +1 -1
- package/build/services/AppService/factory/subscriptions.d.ts.map +1 -1
- package/build/services/AppService/factory/subscriptions.js +1 -1
- package/build/services/AppService/types/accessBlocks.d.ts +64 -0
- package/build/services/AppService/types/accessBlocks.d.ts.map +1 -0
- package/build/services/AppService/types/accessBlocks.js +5 -0
- package/build/services/AppService/types/app.d.ts +46 -1
- package/build/services/AppService/types/app.d.ts.map +1 -1
- package/build/services/AppService/types/appList.d.ts +17 -1
- package/build/services/AppService/types/appList.d.ts.map +1 -1
- package/build/services/AppService/types/appScopes.d.ts +56 -0
- package/build/services/AppService/types/appScopes.d.ts.map +1 -1
- package/build/services/AppService/types/resourceAssignments.d.ts +20 -0
- package/build/services/AppService/types/resourceAssignments.d.ts.map +1 -1
- package/build/services/AppService/types/resourceEntitlements.d.ts +33 -1
- package/build/services/AppService/types/resourceEntitlements.d.ts.map +1 -1
- package/build/services/AppService/types/resourceReleases.d.ts +14 -0
- package/build/services/AppService/types/resourceReleases.d.ts.map +1 -1
- package/build/services/AppService/types/resourceRequests.d.ts +29 -1
- package/build/services/AppService/types/resourceRequests.d.ts.map +1 -1
- package/build/services/AppService/types/seats.d.ts +48 -63
- package/build/services/AppService/types/seats.d.ts.map +1 -1
- package/build/services/AppService/types/seats.js +0 -2
- package/build/services/AppService/types/sellableResources.d.ts +10 -1
- package/build/services/AppService/types/sellableResources.d.ts.map +1 -1
- package/build/services/AppService/types/subscriptions.d.ts +6 -1
- package/build/services/AppService/types/subscriptions.d.ts.map +1 -1
- package/build/services/AppService/types.d.ts +1 -0
- package/build/services/AppService/types.d.ts.map +1 -1
- package/build/services/AppService/types.js +1 -0
- package/build/services/LicenseService.d.ts +1 -1
- package/build/services/LicenseService.d.ts.map +1 -1
- package/build/services/LicenseService.js +3 -1
- package/build/services/ProjectService.d.ts +0 -1
- package/build/services/ProjectService.d.ts.map +1 -1
- package/build/services/TaskService.d.ts +6 -1
- package/build/services/TaskService.d.ts.map +1 -1
- package/build/services/TaskService.js +1 -1
- package/build/services/TaskServiceQueries.d.ts +9 -1
- package/build/services/TaskServiceQueries.d.ts.map +1 -1
- package/build/services/TaskServiceQueries.js +12 -1
- package/build/services/Webhook/ConfigService.d.ts +31 -1
- package/build/services/Webhook/ConfigService.d.ts.map +1 -1
- package/build/services/Webhook/ConfigService.js +1 -1
- package/build/services/Webhook/EventService.d.ts +117 -0
- package/build/services/Webhook/EventService.d.ts.map +1 -1
- package/build/services/Webhook/TriggerChaining.d.ts +45 -0
- package/build/services/Webhook/TriggerChaining.d.ts.map +1 -0
- package/build/services/Webhook/TriggerChaining.js +1 -0
- package/build/services/Webhook/TriggerDataset.types.d.ts +160 -0
- package/build/services/Webhook/TriggerDataset.types.d.ts.map +1 -0
- package/build/services/Webhook/TriggerDataset.types.js +74 -0
- package/build/services/Webhook/TriggerDatasetColumns.d.ts +72 -0
- package/build/services/Webhook/TriggerDatasetColumns.d.ts.map +1 -0
- package/build/services/Webhook/TriggerDatasetColumns.js +116 -0
- package/build/services/Webhook/TriggerDatasetResponses.types.d.ts +158 -0
- package/build/services/Webhook/TriggerDatasetResponses.types.d.ts.map +1 -0
- package/build/services/Webhook/TriggerDatasetResponses.types.js +98 -0
- package/build/services/Webhook/TriggerDatasetSourceService.d.ts +180 -0
- package/build/services/Webhook/TriggerDatasetSourceService.d.ts.map +1 -0
- package/build/services/Webhook/TriggerDatasetSourceService.js +23 -0
- package/build/services/Webhook/TriggerDispatch.types.d.ts +89 -0
- package/build/services/Webhook/TriggerDispatch.types.d.ts.map +1 -0
- package/build/services/Webhook/TriggerDispatch.types.js +24 -0
- package/build/services/Webhook/TriggerDivergence.d.ts +30 -0
- package/build/services/Webhook/TriggerDivergence.d.ts.map +1 -0
- package/build/services/Webhook/TriggerDivergence.js +25 -0
- package/build/services/Webhook/TriggerFailedRuns.types.d.ts +57 -0
- package/build/services/Webhook/TriggerFailedRuns.types.d.ts.map +1 -0
- package/build/services/Webhook/TriggerFailedRuns.types.js +1 -0
- package/build/services/Webhook/TriggerHistoryService.d.ts +88 -18
- package/build/services/Webhook/TriggerHistoryService.d.ts.map +1 -1
- package/build/services/Webhook/TriggerLastRun.types.d.ts +80 -0
- package/build/services/Webhook/TriggerLastRun.types.d.ts.map +1 -0
- package/build/services/Webhook/TriggerLastRun.types.js +1 -0
- package/build/services/Webhook/TriggerRefusalDetail.types.d.ts +63 -0
- package/build/services/Webhook/TriggerRefusalDetail.types.d.ts.map +1 -0
- package/build/services/Webhook/TriggerRefusalDetail.types.js +12 -0
- package/build/services/Webhook/TriggerRequest.types.d.ts +77 -0
- package/build/services/Webhook/TriggerRequest.types.d.ts.map +1 -0
- package/build/services/Webhook/TriggerRequest.types.js +1 -0
- package/build/services/Webhook/TriggerSearch.types.d.ts +42 -0
- package/build/services/Webhook/TriggerSearch.types.d.ts.map +1 -0
- package/build/services/Webhook/TriggerSearch.types.js +1 -0
- package/build/services/Webhook/TriggerService.d.ts +158 -150
- package/build/services/Webhook/TriggerService.d.ts.map +1 -1
- package/build/services/Webhook/TriggerService.js +0 -24
- package/build/services/Webhook/TriggerTimeline.types.d.ts +42 -0
- package/build/services/Webhook/TriggerTimeline.types.d.ts.map +1 -0
- package/build/services/Webhook/TriggerTimeline.types.js +1 -0
- package/build/services/Webhook/TriggerVersion.types.d.ts +93 -0
- package/build/services/Webhook/TriggerVersion.types.d.ts.map +1 -0
- package/build/services/Webhook/TriggerVersion.types.js +1 -0
- package/build/services/Webhook/TriggerVersionService.d.ts +56 -0
- package/build/services/Webhook/TriggerVersionService.d.ts.map +1 -0
- package/build/services/Webhook/TriggerVersionService.js +20 -0
- package/package.json +8 -7
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules for declaring a dataset column's published key and type.
|
|
3
|
+
*
|
|
4
|
+
* These live next to the types they narrow rather than in a UI package on
|
|
5
|
+
* purpose: they are interpretations of the AAD-967 contract, and the exhaustive
|
|
6
|
+
* records below are what make a new backend column type or refusal reason fail
|
|
7
|
+
* the BUILD instead of falling silently through a default. A UI library would
|
|
8
|
+
* put that guarantee in the wrong place, and every consumer would need its own
|
|
9
|
+
* copy of the same eleven strings.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Every publishable column type, as a runtime lookup.
|
|
13
|
+
*
|
|
14
|
+
* Annotated rather than inferred so the compiler rejects a missing key and a
|
|
15
|
+
* stray one alike — adding a member to {@link DatasetColumnType} without adding
|
|
16
|
+
* it here fails to build.
|
|
17
|
+
*/
|
|
18
|
+
export const DATASET_COLUMN_TYPES = {
|
|
19
|
+
boolean: true,
|
|
20
|
+
integer: true,
|
|
21
|
+
float: true,
|
|
22
|
+
textfield: true,
|
|
23
|
+
link: true,
|
|
24
|
+
email: true,
|
|
25
|
+
text: true,
|
|
26
|
+
dropdown: true,
|
|
27
|
+
sbscode: true,
|
|
28
|
+
date: true,
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Is this a column type a dataset may publish?
|
|
32
|
+
*
|
|
33
|
+
* ⚠️ `hasOwnProperty.call`, AND NEITHER OF THE TWO OBVIOUS ALTERNATIVES. `in`
|
|
34
|
+
* answers true for every inherited key, so `isDatasetColumnType('toString')` used
|
|
35
|
+
* to report a publishable column type. `Object.hasOwn` is the rule's preferred
|
|
36
|
+
* form and this package's TS lib predates it — swapping it in compiles under
|
|
37
|
+
* `tsc -p` and then fails the Python schema generator, which builds its own
|
|
38
|
+
* program from these files. Hence the disable rather than the autofix.
|
|
39
|
+
*/
|
|
40
|
+
export function isDatasetColumnType(type) {
|
|
41
|
+
// eslint-disable-next-line e18e/prefer-object-has-own -- Object.hasOwn is not in this package's TS lib; see above
|
|
42
|
+
return Object.prototype.hasOwnProperty.call(DATASET_COLUMN_TYPES, type);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Keys a publisher may not claim.
|
|
46
|
+
*
|
|
47
|
+
* `id` is reserved because every dataset row leads with it — the record id for a
|
|
48
|
+
* table, the 1-based line number for a file. A publisher who maps their own
|
|
49
|
+
* column to `id` would silently shadow it.
|
|
50
|
+
*/
|
|
51
|
+
export const RESERVED_DATASET_KEYS = ['id'];
|
|
52
|
+
/** Case-insensitive: `ID` collides with the reserved `id` just as surely. */
|
|
53
|
+
export function isReservedDatasetKey(key) {
|
|
54
|
+
return RESERVED_DATASET_KEYS.includes(key.trim().toLowerCase());
|
|
55
|
+
}
|
|
56
|
+
/** Letters, digits, underscore and hyphen. Anything else is not a usable key. */
|
|
57
|
+
export function isValidDatasetKey(key) {
|
|
58
|
+
return /^[\w-]+$/.test(key);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A reasonable published key for a source column or file header.
|
|
62
|
+
*
|
|
63
|
+
* Only a starting point — the publisher owns the final name, because it is the
|
|
64
|
+
* buyer's contract.
|
|
65
|
+
*/
|
|
66
|
+
export function defaultDatasetKeyFor(name) {
|
|
67
|
+
return name
|
|
68
|
+
.trim()
|
|
69
|
+
.toLowerCase()
|
|
70
|
+
.replace(/[^a-z0-9]+/g, '_')
|
|
71
|
+
.replace(/^_+|_+$/g, '');
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Validate one published key.
|
|
75
|
+
*
|
|
76
|
+
* ⚠️ **The order of these checks is the message a user sees**, and it is not
|
|
77
|
+
* arbitrary. A blank key is `required`, never `invalid` — telling someone their
|
|
78
|
+
* empty field contains illegal characters sends them looking for a character
|
|
79
|
+
* that is not there. Reserved beats invalid for the same reason: `id` is a
|
|
80
|
+
* perfectly well-formed key, so "invalid" would be a lie about why it was
|
|
81
|
+
* refused. Duplicate is last because it is the only one that depends on the
|
|
82
|
+
* other rows rather than on this key alone.
|
|
83
|
+
*/
|
|
84
|
+
export function datasetKeyError(key, duplicates) {
|
|
85
|
+
const trimmed = key.trim();
|
|
86
|
+
if (!trimmed)
|
|
87
|
+
return 'required';
|
|
88
|
+
if (isReservedDatasetKey(trimmed))
|
|
89
|
+
return 'reserved';
|
|
90
|
+
if (!isValidDatasetKey(trimmed))
|
|
91
|
+
return 'invalid';
|
|
92
|
+
if (duplicates.has(trimmed))
|
|
93
|
+
return 'duplicate';
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Which of these keys appear more than once.
|
|
98
|
+
*
|
|
99
|
+
* Blank keys are excluded: several unfilled rows are not a name collision, and
|
|
100
|
+
* flagging them as duplicates would report the same problem twice under the
|
|
101
|
+
* wrong name.
|
|
102
|
+
*/
|
|
103
|
+
export function duplicateDatasetKeys(keys) {
|
|
104
|
+
const seen = new Set();
|
|
105
|
+
const dupes = new Set();
|
|
106
|
+
for (const raw of keys) {
|
|
107
|
+
const key = raw.trim();
|
|
108
|
+
if (!key)
|
|
109
|
+
continue;
|
|
110
|
+
if (seen.has(key))
|
|
111
|
+
dupes.add(key);
|
|
112
|
+
else
|
|
113
|
+
seen.add(key);
|
|
114
|
+
}
|
|
115
|
+
return dupes;
|
|
116
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a dataset action ANSWERS with (AAD-967) — successful shapes and refusals.
|
|
3
|
+
*
|
|
4
|
+
* Split from `TriggerDataset.types.ts`, which carries the frozen publisher config
|
|
5
|
+
* a caller cannot repoint. This file is the wire side: what comes back, and how a
|
|
6
|
+
* refusal is told apart from an empty result.
|
|
7
|
+
*/
|
|
8
|
+
/** Rows returned by a dataset action. */
|
|
9
|
+
export interface DatasetRows {
|
|
10
|
+
/** Buyer-facing keys, in the publisher's declared order. */
|
|
11
|
+
keys: string[];
|
|
12
|
+
/** Each row leads with `id` — the record id, or the 1-based line for a file. */
|
|
13
|
+
rows: Array<Record<string, unknown>>;
|
|
14
|
+
/** How many rows are in THIS response, not how many exist. */
|
|
15
|
+
row_count: number;
|
|
16
|
+
/**
|
|
17
|
+
* There was more data than `limit` allowed.
|
|
18
|
+
*
|
|
19
|
+
* Too much data is never an error for these actions — you get the rows up to
|
|
20
|
+
* the limit plus this flag. Say so in the UI; a silently short answer that looks
|
|
21
|
+
* complete is the failure this flag exists to prevent.
|
|
22
|
+
*/
|
|
23
|
+
truncated: boolean;
|
|
24
|
+
/** The limit actually applied, after clamping. */
|
|
25
|
+
limit: number;
|
|
26
|
+
}
|
|
27
|
+
/** `ReturnFileDataEvent` in `raw` mode. */
|
|
28
|
+
export interface DatasetRawFile {
|
|
29
|
+
/** No DMS id, no storage token, no project or licence id — by design. */
|
|
30
|
+
file: {
|
|
31
|
+
name: string;
|
|
32
|
+
extension: string;
|
|
33
|
+
mime: string;
|
|
34
|
+
size: number | string;
|
|
35
|
+
};
|
|
36
|
+
/** Short-lived and signed. Carries no credential, so its lifetime IS the grant. */
|
|
37
|
+
download_url: string;
|
|
38
|
+
expires_in_seconds: number;
|
|
39
|
+
}
|
|
40
|
+
/** `TransformWithScriptEvent` with `response_mode: 'envelope'`. */
|
|
41
|
+
export interface TransformRunEnvelope {
|
|
42
|
+
task_id: string;
|
|
43
|
+
status: string;
|
|
44
|
+
exit_code: number | null;
|
|
45
|
+
/** Whatever the script emitted via its `__ANT_RESULT__:` sentinel. */
|
|
46
|
+
result: unknown;
|
|
47
|
+
stdout_tail: string;
|
|
48
|
+
meta: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* ⚠️ **Every dataset dispatch is wrapped**, even though all three actions run
|
|
52
|
+
* synchronously and inline.
|
|
53
|
+
*
|
|
54
|
+
* The dispatcher decides the envelope from whether the payload carries an `async`
|
|
55
|
+
* key, and only the older `RunScriptEvent` sets one — so these actions are
|
|
56
|
+
* reported through the async-shaped envelope regardless. Read `response`, not the
|
|
57
|
+
* top level. Not worth changing: it would move the response shape of every
|
|
58
|
+
* existing action.
|
|
59
|
+
*/
|
|
60
|
+
export interface DatasetDispatchEnvelope<T> {
|
|
61
|
+
response: T | null;
|
|
62
|
+
error: string | null;
|
|
63
|
+
}
|
|
64
|
+
/** Why a dataset action refused to serve. */
|
|
65
|
+
export type DatasetRefusalReason = 'invalid_payload_config' | 'byte_limit_exceeded' | 'source_table_missing' | 'upload_source_missing' | 'unsupported_upload_format' | 'malformed_upload' | 'row_shape_mismatch' | 'value_type_mismatch' | 'unpublishable_column_type'
|
|
66
|
+
/**
|
|
67
|
+
* An OPERATOR fault: the deployment's ceilings are unusable. Must NOT be shown
|
|
68
|
+
* to a publisher as "your dataset is too big" — that sends them hunting through
|
|
69
|
+
* their own data for a problem in the environment.
|
|
70
|
+
*
|
|
71
|
+
* The string still says `snapshot` deliberately: it is persisted in existing
|
|
72
|
+
* rows, and changing it would break reading them.
|
|
73
|
+
*/
|
|
74
|
+
| 'snapshot_limits_misconfigured' | 'internal_error';
|
|
75
|
+
/**
|
|
76
|
+
* Every refusal reason, as a runtime lookup.
|
|
77
|
+
*
|
|
78
|
+
* Annotated `Record<DatasetRefusalReason, true>` rather than inferred, so the
|
|
79
|
+
* compiler rejects both a missing key and a stray one: adding a member to
|
|
80
|
+
* {@link DatasetRefusalReason} without adding it here fails to build. That is the
|
|
81
|
+
* point — a reason nobody mapped must not fail silently.
|
|
82
|
+
*/
|
|
83
|
+
export declare const DATASET_REFUSAL_REASONS: Record<DatasetRefusalReason, true>;
|
|
84
|
+
/**
|
|
85
|
+
* A dataset action refused to serve.
|
|
86
|
+
*
|
|
87
|
+
* ⚠️ Arrives as a NON-2xx response, so it surfaces as a rejected request — read it
|
|
88
|
+
* off the error body, not the resolved value. It sits inside the dispatch
|
|
89
|
+
* envelope: `error.response.data.response`.
|
|
90
|
+
*
|
|
91
|
+
* **Branch on `reason`, never on the HTTP status.** There are only two statuses —
|
|
92
|
+
* 422 for anything the publisher or the data is responsible for, 5xx for
|
|
93
|
+
* `snapshot_limits_misconfigured` and `internal_error` — so the status cannot tell
|
|
94
|
+
* you what to say.
|
|
95
|
+
*
|
|
96
|
+
* `message` is a caller-safe sentence. The detailed one, which names columns and
|
|
97
|
+
* table ids, is deliberately withheld and only reaches the execution history the
|
|
98
|
+
* publisher can read. Do not expect it here.
|
|
99
|
+
*
|
|
100
|
+
* ⚠️ **Never render this as an empty result.** "This file is gone" and "this
|
|
101
|
+
* dataset has no rows" look identical to a user and call for opposite actions.
|
|
102
|
+
*/
|
|
103
|
+
export interface DatasetRefusedResult {
|
|
104
|
+
dataset_refused: true;
|
|
105
|
+
reason: DatasetRefusalReason;
|
|
106
|
+
message: string;
|
|
107
|
+
/** Informational — branch on `reason`. */
|
|
108
|
+
status_code: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Type guard: is this a refused dataset dispatch?
|
|
112
|
+
*
|
|
113
|
+
* Accepts either the dispatch envelope or the inner body, so it can be pointed
|
|
114
|
+
* straight at `error.response?.data` without unwrapping first.
|
|
115
|
+
*
|
|
116
|
+
* ⚠️ **This is a deliberately loose narrow, and the looseness is load-bearing.**
|
|
117
|
+
* It accepts any string `reason` rather than only the eleven known ones, so that a
|
|
118
|
+
* reason a newer backend adds is still recognised AS a refusal instead of falling
|
|
119
|
+
* through to "empty result" — which is the one failure mode this whole contract
|
|
120
|
+
* exists to prevent.
|
|
121
|
+
*
|
|
122
|
+
* The cost is that the narrowed type is optimistic: `reason` may be a string
|
|
123
|
+
* outside {@link DatasetRefusalReason}, and `message` may be absent. So:
|
|
124
|
+
*
|
|
125
|
+
* - Give every `switch (reason)` a `default:` arm, and map unknown reasons to a
|
|
126
|
+
* generic sentence rather than letting them fall into a specific one.
|
|
127
|
+
* - Do NOT trust {@link isOperatorFault} alone to classify an unrecognised
|
|
128
|
+
* reason — it answers `false`, which reads as "the publisher's fault". Check
|
|
129
|
+
* membership with {@link DATASET_REFUSAL_REASONS} first when the distinction
|
|
130
|
+
* drives what you tell someone.
|
|
131
|
+
*/
|
|
132
|
+
export declare function isDatasetRefused(result: unknown): result is DatasetRefusedResult;
|
|
133
|
+
/**
|
|
134
|
+
* Narrow a stored or received response to {@link DatasetRows}.
|
|
135
|
+
*
|
|
136
|
+
* ⚠️ **DELIBERATELY DOES NOT REQUIRE `rows` TO BE INTACT.** A run recorded in the
|
|
137
|
+
* execution history has `stored_response_truncated: true` for essentially every
|
|
138
|
+
* dataset action — the stored copy of `rows` is elided to save database space, and
|
|
139
|
+
* arrives with a `"... (2 more items truncated)"` string sitting in the array. The
|
|
140
|
+
* caller still received everything.
|
|
141
|
+
*
|
|
142
|
+
* `row_count` is a SCALAR recorded beside the array and is never elided, so it
|
|
143
|
+
* stays true across that shrinking. Reading `rows.length` instead would report a
|
|
144
|
+
* five-row answer as two — which is why this guard checks the count and not the
|
|
145
|
+
* array, and why any caller should read `row_count` rather than measuring `rows`.
|
|
146
|
+
*/
|
|
147
|
+
export declare function isDatasetRows(response: unknown): response is DatasetRows;
|
|
148
|
+
/** Is this a reason this build of the SDK knows about? */
|
|
149
|
+
export declare function isKnownRefusalReason(reason: string): reason is DatasetRefusalReason;
|
|
150
|
+
/**
|
|
151
|
+
* Is this reason the operator's fault rather than the publisher's?
|
|
152
|
+
*
|
|
153
|
+
* ⚠️ Answers `false` for an unrecognised reason, which reads as "the publisher's
|
|
154
|
+
* fault". Guard with {@link isKnownRefusalReason} when that distinction is what
|
|
155
|
+
* you are about to tell someone.
|
|
156
|
+
*/
|
|
157
|
+
export declare function isOperatorFault(reason: DatasetRefusalReason): boolean;
|
|
158
|
+
//# sourceMappingURL=TriggerDatasetResponses.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TriggerDatasetResponses.types.d.ts","sourceRoot":"","sources":["../../../src/services/Webhook/TriggerDatasetResponses.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,gFAAgF;IAChF,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACpC,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAA;IACjB;;;;;;OAMG;IACH,SAAS,EAAE,OAAO,CAAA;IAClB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAA;CACd;AAED,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,yEAAyE;IACzE,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAA;QACZ,SAAS,EAAE,MAAM,CAAA;QACjB,IAAI,EAAE,MAAM,CAAA;QACZ,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAA;IACD,mFAAmF;IACnF,YAAY,EAAE,MAAM,CAAA;IACpB,kBAAkB,EAAE,MAAM,CAAA;CAC3B;AAED,mEAAmE;AACnE,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,sEAAsE;IACtE,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC;IACxC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAA;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,6CAA6C;AAC7C,MAAM,MAAM,oBAAoB,GAC1B,wBAAwB,GACxB,qBAAqB,GACrB,sBAAsB,GACtB,uBAAuB,GACvB,2BAA2B,GAC3B,kBAAkB,GAClB,oBAAoB,GACpB,qBAAqB,GACrB,2BAA2B;AAC7B;;;;;;;GAOG;GACD,+BAA+B,GAC/B,gBAAgB,CAAA;AAEtB;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAYtE,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,IAAI,CAAA;IACrB,MAAM,EAAE,oBAAoB,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;IACf,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,oBAAoB,CAQhF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,WAAW,CAKxE;AAED,0DAA0D;AAC1D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,oBAAoB,CAOnF;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAErE"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a dataset action ANSWERS with (AAD-967) — successful shapes and refusals.
|
|
3
|
+
*
|
|
4
|
+
* Split from `TriggerDataset.types.ts`, which carries the frozen publisher config
|
|
5
|
+
* a caller cannot repoint. This file is the wire side: what comes back, and how a
|
|
6
|
+
* refusal is told apart from an empty result.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Every refusal reason, as a runtime lookup.
|
|
10
|
+
*
|
|
11
|
+
* Annotated `Record<DatasetRefusalReason, true>` rather than inferred, so the
|
|
12
|
+
* compiler rejects both a missing key and a stray one: adding a member to
|
|
13
|
+
* {@link DatasetRefusalReason} without adding it here fails to build. That is the
|
|
14
|
+
* point — a reason nobody mapped must not fail silently.
|
|
15
|
+
*/
|
|
16
|
+
export const DATASET_REFUSAL_REASONS = {
|
|
17
|
+
invalid_payload_config: true,
|
|
18
|
+
byte_limit_exceeded: true,
|
|
19
|
+
source_table_missing: true,
|
|
20
|
+
upload_source_missing: true,
|
|
21
|
+
unsupported_upload_format: true,
|
|
22
|
+
malformed_upload: true,
|
|
23
|
+
row_shape_mismatch: true,
|
|
24
|
+
value_type_mismatch: true,
|
|
25
|
+
unpublishable_column_type: true,
|
|
26
|
+
snapshot_limits_misconfigured: true,
|
|
27
|
+
internal_error: true,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Type guard: is this a refused dataset dispatch?
|
|
31
|
+
*
|
|
32
|
+
* Accepts either the dispatch envelope or the inner body, so it can be pointed
|
|
33
|
+
* straight at `error.response?.data` without unwrapping first.
|
|
34
|
+
*
|
|
35
|
+
* ⚠️ **This is a deliberately loose narrow, and the looseness is load-bearing.**
|
|
36
|
+
* It accepts any string `reason` rather than only the eleven known ones, so that a
|
|
37
|
+
* reason a newer backend adds is still recognised AS a refusal instead of falling
|
|
38
|
+
* through to "empty result" — which is the one failure mode this whole contract
|
|
39
|
+
* exists to prevent.
|
|
40
|
+
*
|
|
41
|
+
* The cost is that the narrowed type is optimistic: `reason` may be a string
|
|
42
|
+
* outside {@link DatasetRefusalReason}, and `message` may be absent. So:
|
|
43
|
+
*
|
|
44
|
+
* - Give every `switch (reason)` a `default:` arm, and map unknown reasons to a
|
|
45
|
+
* generic sentence rather than letting them fall into a specific one.
|
|
46
|
+
* - Do NOT trust {@link isOperatorFault} alone to classify an unrecognised
|
|
47
|
+
* reason — it answers `false`, which reads as "the publisher's fault". Check
|
|
48
|
+
* membership with {@link DATASET_REFUSAL_REASONS} first when the distinction
|
|
49
|
+
* drives what you tell someone.
|
|
50
|
+
*/
|
|
51
|
+
export function isDatasetRefused(result) {
|
|
52
|
+
if (typeof result !== 'object' || result === null)
|
|
53
|
+
return false;
|
|
54
|
+
const envelope = result;
|
|
55
|
+
const body = (typeof envelope.response === 'object' && envelope.response !== null)
|
|
56
|
+
? envelope.response
|
|
57
|
+
: envelope;
|
|
58
|
+
return body.dataset_refused === true && typeof body.reason === 'string';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Narrow a stored or received response to {@link DatasetRows}.
|
|
62
|
+
*
|
|
63
|
+
* ⚠️ **DELIBERATELY DOES NOT REQUIRE `rows` TO BE INTACT.** A run recorded in the
|
|
64
|
+
* execution history has `stored_response_truncated: true` for essentially every
|
|
65
|
+
* dataset action — the stored copy of `rows` is elided to save database space, and
|
|
66
|
+
* arrives with a `"... (2 more items truncated)"` string sitting in the array. The
|
|
67
|
+
* caller still received everything.
|
|
68
|
+
*
|
|
69
|
+
* `row_count` is a SCALAR recorded beside the array and is never elided, so it
|
|
70
|
+
* stays true across that shrinking. Reading `rows.length` instead would report a
|
|
71
|
+
* five-row answer as two — which is why this guard checks the count and not the
|
|
72
|
+
* array, and why any caller should read `row_count` rather than measuring `rows`.
|
|
73
|
+
*/
|
|
74
|
+
export function isDatasetRows(response) {
|
|
75
|
+
if (typeof response !== 'object' || response === null)
|
|
76
|
+
return false;
|
|
77
|
+
const body = response;
|
|
78
|
+
return typeof body.row_count === 'number' && Array.isArray(body.keys);
|
|
79
|
+
}
|
|
80
|
+
/** Is this a reason this build of the SDK knows about? */
|
|
81
|
+
export function isKnownRefusalReason(reason) {
|
|
82
|
+
// `hasOwnProperty.call`, not `in` and not `Object.hasOwn`: `in` accepts every
|
|
83
|
+
// inherited key (`'constructor'` read as a known reason), and this package's TS
|
|
84
|
+
// lib predates `Object.hasOwn` — which `tsc -p` tolerates and the Python schema
|
|
85
|
+
// generator does not.
|
|
86
|
+
// eslint-disable-next-line e18e/prefer-object-has-own -- see above
|
|
87
|
+
return Object.prototype.hasOwnProperty.call(DATASET_REFUSAL_REASONS, reason);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Is this reason the operator's fault rather than the publisher's?
|
|
91
|
+
*
|
|
92
|
+
* ⚠️ Answers `false` for an unrecognised reason, which reads as "the publisher's
|
|
93
|
+
* fault". Guard with {@link isKnownRefusalReason} when that distinction is what
|
|
94
|
+
* you are about to tell someone.
|
|
95
|
+
*/
|
|
96
|
+
export function isOperatorFault(reason) {
|
|
97
|
+
return reason === 'snapshot_limits_misconfigured' || reason === 'internal_error';
|
|
98
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { DataWrapper } from '../../types';
|
|
2
|
+
import type { DatasetColumnType, DatasetFileColumn, DatasetFileFormat } from './TriggerDataset.types';
|
|
3
|
+
import type { AntHttpClient } from "../../AntHttpClient";
|
|
4
|
+
/**
|
|
5
|
+
* Reading a candidate dataset source before anything is declared.
|
|
6
|
+
*
|
|
7
|
+
* Configuring a file-sourced dataset means declaring which columns it publishes and
|
|
8
|
+
* what type each one is. Nothing exposed a DMS file's headers, so the alternative was
|
|
9
|
+
* typing them from memory — which turns `row_shape_mismatch` and `value_type_mismatch`
|
|
10
|
+
* from edge cases into the expected outcome on a file the platform could simply read.
|
|
11
|
+
*
|
|
12
|
+
* The backend parses the file with the SAME reader the dispatch uses, so a proposal
|
|
13
|
+
* accepted unchanged cannot then be refused by the action.
|
|
14
|
+
*/
|
|
15
|
+
/** One column the backend proposes, before the publisher confirms it. */
|
|
16
|
+
export interface DatasetFileColumnProposal {
|
|
17
|
+
/** The header exactly as it appears in the file. */
|
|
18
|
+
source_key: string;
|
|
19
|
+
/** A suggested published key, already made safe (`"unit price"` -> `"unit_price"`). */
|
|
20
|
+
key: string;
|
|
21
|
+
/** The raw header again, for display. */
|
|
22
|
+
label: string;
|
|
23
|
+
/**
|
|
24
|
+
* A PROPOSAL, never a schema. The publisher confirms or overrides it and the
|
|
25
|
+
* version stores their answer — which is what keeps a file's schema declared
|
|
26
|
+
* rather than inferred.
|
|
27
|
+
*
|
|
28
|
+
* Every ambiguity resolves to text on purpose. A text column that could have been
|
|
29
|
+
* an integer costs one click; an integer that should have been text turns `01223`
|
|
30
|
+
* into `1223` and silently corrupts a postcode in a dataset somebody paid for.
|
|
31
|
+
*/
|
|
32
|
+
proposed_type: DatasetColumnType;
|
|
33
|
+
/**
|
|
34
|
+
* How many sampled rows were empty for this column. Surfaced so a publisher can
|
|
35
|
+
* see WHY a column came back as text — usually one stray value rather than a
|
|
36
|
+
* genuinely mixed column.
|
|
37
|
+
*/
|
|
38
|
+
null_count: number;
|
|
39
|
+
/** Advisory only; authoritative nullability is measured from the served data. */
|
|
40
|
+
nullable: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Which file a proposal is about — enough to LABEL a trigger that is already
|
|
44
|
+
* configured.
|
|
45
|
+
*
|
|
46
|
+
* A saved `ReturnFileDataEvent` carries only a `dms_file_id`, and every per-file DMS
|
|
47
|
+
* endpoint is addressed by the file's TOKEN rather than its id — so there is no
|
|
48
|
+
* client-side way to turn that id into a name. Without this, a configured trigger can
|
|
49
|
+
* only render the raw uuid.
|
|
50
|
+
*
|
|
51
|
+
* Not the same shape as `DatasetRawFile`'s `file` (in `TriggerDatasetResponses.types`),
|
|
52
|
+
* and the difference is
|
|
53
|
+
* deliberate rather than an oversight: that one answers a BUYER dispatching a trigger
|
|
54
|
+
* and withholds every internal id, whereas this answers a PUBLISHER who already
|
|
55
|
+
* passed the DMS view check on this exact file and supplied its id to get here.
|
|
56
|
+
*/
|
|
57
|
+
export interface DatasetSourceFile {
|
|
58
|
+
id: string;
|
|
59
|
+
/**
|
|
60
|
+
* ⚠️ **The BASE NAME — the extension is NOT included.**
|
|
61
|
+
*
|
|
62
|
+
* Mirrors the `DmsFile` columns and {@link DatasetRawFile}'s `file`, which split
|
|
63
|
+
* them the same way. To display the filename, join them yourself and guard the
|
|
64
|
+
* empty case, because a file with no extension yields a trailing dot:
|
|
65
|
+
*
|
|
66
|
+
* ```ts
|
|
67
|
+
* const label = file.extension ? `${file.name}.${file.extension}` : file.name
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
name: string;
|
|
71
|
+
/** No leading dot. `''` for a file with no extension. */
|
|
72
|
+
extension: string;
|
|
73
|
+
/** `''` when the DMS recorded none. */
|
|
74
|
+
mime: string;
|
|
75
|
+
/** Bytes. Compare against the deployment's byte ceiling. */
|
|
76
|
+
size: number;
|
|
77
|
+
/** The immediate parent folder, or `null` for a file at the DMS root. */
|
|
78
|
+
folder_id: string | null;
|
|
79
|
+
/**
|
|
80
|
+
* Ancestor folder NAMES, outermost first — `[]` at the DMS root.
|
|
81
|
+
*
|
|
82
|
+
* Display only: these are names rather than ids, and the chain is not
|
|
83
|
+
* re-authorised folder by folder. Use `folder_id` if you need to navigate.
|
|
84
|
+
*/
|
|
85
|
+
folder_path: string[];
|
|
86
|
+
/**
|
|
87
|
+
* ⚠️ **`null` means the file is LICENCE-scoped**, and this is what selects which
|
|
88
|
+
* DMS routes address it: licence-scoped files go through the licence DMS endpoints,
|
|
89
|
+
* project-scoped ones through the project endpoints. Picking the wrong family
|
|
90
|
+
* yields a 404, which is the same branch the backend makes when it signs a
|
|
91
|
+
* raw-mode download URL.
|
|
92
|
+
*/
|
|
93
|
+
project_id: string | null;
|
|
94
|
+
license_id: string;
|
|
95
|
+
}
|
|
96
|
+
export interface DatasetFileProposal {
|
|
97
|
+
/**
|
|
98
|
+
* The file these columns came from.
|
|
99
|
+
*
|
|
100
|
+
* REQUIRED rather than optional: the endpoint returns it on every 2xx, and a
|
|
101
|
+
* refusal is not a `DatasetFileProposal` at all — it arrives as a non-2xx narrowed
|
|
102
|
+
* by `isDatasetRefused`. Marking it optional would buy nothing and cost every call
|
|
103
|
+
* site a permanent optional-chain for a field that is always there.
|
|
104
|
+
*
|
|
105
|
+
* One thing it does NOT cover: a refusal body carries no file, so a file over the
|
|
106
|
+
* byte ceiling cannot be labelled from this call. That is deliberate backend-side —
|
|
107
|
+
* the refusal body is byte-identical to a dispatch refusal's, and a dispatch
|
|
108
|
+
* refusal answers a buyer.
|
|
109
|
+
*/
|
|
110
|
+
file: DatasetSourceFile;
|
|
111
|
+
/**
|
|
112
|
+
* What the file was actually parsed as.
|
|
113
|
+
*
|
|
114
|
+
* Echoed because it may have been INFERRED from the extension. Re-deriving it
|
|
115
|
+
* client-side risks disagreeing with what was parsed, and then declaring a shape
|
|
116
|
+
* the dispatch refuses.
|
|
117
|
+
*/
|
|
118
|
+
format: DatasetFileFormat;
|
|
119
|
+
/** Exact, not estimated. Compare it against the row ceiling. */
|
|
120
|
+
row_count: number;
|
|
121
|
+
columns: DatasetFileColumnProposal[];
|
|
122
|
+
/** Capped by the deployment's preview-rows setting. Keyed by `source_key`, unprojected. */
|
|
123
|
+
sample: Array<Record<string, unknown>>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Turn a proposal into the column declaration a trigger payload carries.
|
|
127
|
+
*
|
|
128
|
+
* The whole point of the endpoint is that this conversion is not retyped per call
|
|
129
|
+
* site — and `key` is the buyer-facing contract, so validate it (see
|
|
130
|
+
* `isValidDatasetKey` / `isReservedDatasetKey`) before storing a publisher's override.
|
|
131
|
+
*/
|
|
132
|
+
export declare function toFileColumn(proposal: DatasetFileColumnProposal): DatasetFileColumn;
|
|
133
|
+
export interface TriggerDatasetSourceService {
|
|
134
|
+
/**
|
|
135
|
+
* Propose the columns of a DMS file.
|
|
136
|
+
*
|
|
137
|
+
* Read-only and idempotent — safe to call every time a publisher picks a file.
|
|
138
|
+
*
|
|
139
|
+
* Authorised by DMS RBAC, so a file the caller cannot open through the DMS answers
|
|
140
|
+
* **403** here too and reveals neither headers nor sampled values. A trashed or
|
|
141
|
+
* unknown file is **404**.
|
|
142
|
+
*
|
|
143
|
+
* A refusal arrives as a non-2xx with the same `reason` vocabulary as a dispatch
|
|
144
|
+
* refusal, so `isDatasetRefused` narrows it — but the body is at the TOP LEVEL, not
|
|
145
|
+
* inside the `{ response, error }` dispatch envelope. Reachable reasons:
|
|
146
|
+
* `unsupported_upload_format`, `malformed_upload`, `row_shape_mismatch`,
|
|
147
|
+
* `value_type_mismatch`, `byte_limit_exceeded`, `upload_source_missing` (a folder,
|
|
148
|
+
* an external link, or bytes that are gone), and the operator-fault
|
|
149
|
+
* `snapshot_limits_misconfigured`.
|
|
150
|
+
*
|
|
151
|
+
* `format` overrides the file's extension; omit it to let the backend infer.
|
|
152
|
+
*/
|
|
153
|
+
proposeFileColumns: (dmsFileId: string, format?: DatasetFileFormat) => Promise<DataWrapper<DatasetFileProposal>>;
|
|
154
|
+
/**
|
|
155
|
+
* Name and locate a DMS file WITHOUT reading it.
|
|
156
|
+
*
|
|
157
|
+
* ⚠️ **Use this to render a label, not {@link proposeFileColumns}.** That one has
|
|
158
|
+
* to open the file to propose columns, which means it opens up to the byte
|
|
159
|
+
* ceiling, infers a type per column and samples rows — and, decisively, **it
|
|
160
|
+
* REFUSES a file it cannot read and the refusal carries no `file` object.**
|
|
161
|
+
* Over the ceiling, an external link, a folder: all non-2xx, no name. That is
|
|
162
|
+
* exactly the misconfigured trigger a publisher is diagnosing, so the one case
|
|
163
|
+
* where the label matters most is the case the proposal cannot answer.
|
|
164
|
+
*
|
|
165
|
+
* This inherits NONE of that. No ceiling check, no format resolution, no
|
|
166
|
+
* `reason` vocabulary — so it names a folder, an oversized file and an external
|
|
167
|
+
* link just as readily as a parseable CSV. Assume a name is available whenever
|
|
168
|
+
* the caller may see the file.
|
|
169
|
+
*
|
|
170
|
+
* What it does share is the gate: `DmsFilePolicy::view`, identical to the columns
|
|
171
|
+
* endpoint. **403** when the caller may not see the file, **404** when there is
|
|
172
|
+
* no such file or it has been trashed. Those are the only failure modes.
|
|
173
|
+
*
|
|
174
|
+
* The descriptor is byte-identical to `DatasetFileProposal.file`, from one
|
|
175
|
+
* implementation, so a label cannot differ by which endpoint a screen called.
|
|
176
|
+
*/
|
|
177
|
+
describeFile: (dmsFileId: string) => Promise<DataWrapper<DatasetSourceFile>>;
|
|
178
|
+
}
|
|
179
|
+
export declare function createTriggerDatasetSourceService(httpClient: AntHttpClient): TriggerDatasetSourceService;
|
|
180
|
+
//# sourceMappingURL=TriggerDatasetSourceService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TriggerDatasetSourceService.d.ts","sourceRoot":"","sources":["../../../src/services/Webhook/TriggerDatasetSourceService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AACrG,OAAO,KAAK,EAAE,aAAa,EAAE,4BAAuB;AAEpD;;;;;;;;;;GAUG;AAEH,yEAAyE;AACzE,MAAM,WAAW,yBAAyB;IACxC,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAA;IAClB,uFAAuF;IACvF,GAAG,EAAE,MAAM,CAAA;IACX,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;;;OAQG;IACH,aAAa,EAAE,iBAAiB,CAAA;IAChC;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB,iFAAiF;IACjF,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV;;;;;;;;;;OAUG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAA;IACjB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAA;IACZ,yEAAyE;IACzE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB;;;;;OAKG;IACH,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;;;;OAYG;IACH,IAAI,EAAE,iBAAiB,CAAA;IACvB;;;;;;OAMG;IACH,MAAM,EAAE,iBAAiB,CAAA;IACzB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,yBAAyB,EAAE,CAAA;IACpC,2FAA2F;IAC3F,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,yBAAyB,GAAG,iBAAiB,CAOnF;AAED,MAAM,WAAW,2BAA2B;IAC1C;;;;;;;;;;;;;;;;;;OAkBG;IACH,kBAAkB,EAAE,CAClB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,iBAAiB,KACvB,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAA;IAE9C;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAA;CAC7E;AAED,wBAAgB,iCAAiC,CAAC,UAAU,EAAE,aAAa,GAAG,2BAA2B,CAUxG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn a proposal into the column declaration a trigger payload carries.
|
|
3
|
+
*
|
|
4
|
+
* The whole point of the endpoint is that this conversion is not retyped per call
|
|
5
|
+
* site — and `key` is the buyer-facing contract, so validate it (see
|
|
6
|
+
* `isValidDatasetKey` / `isReservedDatasetKey`) before storing a publisher's override.
|
|
7
|
+
*/
|
|
8
|
+
export function toFileColumn(proposal) {
|
|
9
|
+
return {
|
|
10
|
+
source_key: proposal.source_key,
|
|
11
|
+
key: proposal.key,
|
|
12
|
+
label: proposal.label,
|
|
13
|
+
type: proposal.proposed_type,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function createTriggerDatasetSourceService(httpClient) {
|
|
17
|
+
return {
|
|
18
|
+
proposeFileColumns: (dmsFileId, format) => httpClient.get(`/webhook/dataset-sources/${dmsFileId}/columns`, {
|
|
19
|
+
params: format === undefined ? undefined : { format },
|
|
20
|
+
}),
|
|
21
|
+
describeFile: (dmsFileId) => httpClient.get(`/webhook/dataset-sources/${dmsFileId}`),
|
|
22
|
+
};
|
|
23
|
+
}
|