@antcde/connect-ts 0.4.27-rc.9 → 0.4.28-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/build/AntConnect.d.ts +4 -0
  2. package/build/AntConnect.d.ts.map +1 -1
  3. package/build/AntConnect.js +4 -0
  4. package/build/comms/signal.d.ts +1 -0
  5. package/build/comms/signal.d.ts.map +1 -1
  6. package/build/comms/signal.js +1 -0
  7. package/build/comms/signalFilePreviewTypes.d.ts +65 -0
  8. package/build/comms/signalFilePreviewTypes.d.ts.map +1 -0
  9. package/build/comms/signalFilePreviewTypes.js +9 -0
  10. package/build/comms/signalRouteTypes.d.ts +38 -0
  11. package/build/comms/signalRouteTypes.d.ts.map +1 -0
  12. package/build/comms/signalRouteTypes.js +8 -0
  13. package/build/comms/signalTypes.d.ts +11 -46
  14. package/build/comms/signalTypes.d.ts.map +1 -1
  15. package/build/index.d.ts +26 -2
  16. package/build/index.d.ts.map +1 -1
  17. package/build/index.js +5 -0
  18. package/build/service-runtime.d.ts +1 -1
  19. package/build/service-runtime.d.ts.map +1 -1
  20. package/build/service-runtime.js +1 -1
  21. package/build/service-types.d.ts +3 -1
  22. package/build/service-types.d.ts.map +1 -1
  23. package/build/services/ProjectService.d.ts +0 -1
  24. package/build/services/ProjectService.d.ts.map +1 -1
  25. package/build/services/TaskService.d.ts +6 -1
  26. package/build/services/TaskService.d.ts.map +1 -1
  27. package/build/services/TaskService.js +1 -1
  28. package/build/services/TaskService.requests.d.ts +61 -0
  29. package/build/services/TaskService.requests.d.ts.map +1 -0
  30. package/build/services/TaskService.requests.js +1 -0
  31. package/build/services/TaskService.types.d.ts +2 -51
  32. package/build/services/TaskService.types.d.ts.map +1 -1
  33. package/build/services/TaskServiceQueries.d.ts +9 -1
  34. package/build/services/TaskServiceQueries.d.ts.map +1 -1
  35. package/build/services/TaskServiceQueries.js +12 -1
  36. package/build/services/Webhook/ConfigService.d.ts +31 -1
  37. package/build/services/Webhook/ConfigService.d.ts.map +1 -1
  38. package/build/services/Webhook/ConfigService.js +1 -1
  39. package/build/services/Webhook/EventService.d.ts +117 -0
  40. package/build/services/Webhook/EventService.d.ts.map +1 -1
  41. package/build/services/Webhook/TriggerChaining.d.ts +45 -0
  42. package/build/services/Webhook/TriggerChaining.d.ts.map +1 -0
  43. package/build/services/Webhook/TriggerChaining.js +1 -0
  44. package/build/services/Webhook/TriggerDataset.types.d.ts +160 -0
  45. package/build/services/Webhook/TriggerDataset.types.d.ts.map +1 -0
  46. package/build/services/Webhook/TriggerDataset.types.js +74 -0
  47. package/build/services/Webhook/TriggerDatasetColumns.d.ts +72 -0
  48. package/build/services/Webhook/TriggerDatasetColumns.d.ts.map +1 -0
  49. package/build/services/Webhook/TriggerDatasetColumns.js +116 -0
  50. package/build/services/Webhook/TriggerDatasetResponses.types.d.ts +158 -0
  51. package/build/services/Webhook/TriggerDatasetResponses.types.d.ts.map +1 -0
  52. package/build/services/Webhook/TriggerDatasetResponses.types.js +98 -0
  53. package/build/services/Webhook/TriggerDatasetSourceService.d.ts +180 -0
  54. package/build/services/Webhook/TriggerDatasetSourceService.d.ts.map +1 -0
  55. package/build/services/Webhook/TriggerDatasetSourceService.js +23 -0
  56. package/build/services/Webhook/TriggerDispatch.types.d.ts +89 -0
  57. package/build/services/Webhook/TriggerDispatch.types.d.ts.map +1 -0
  58. package/build/services/Webhook/TriggerDispatch.types.js +24 -0
  59. package/build/services/Webhook/TriggerDivergence.d.ts +30 -0
  60. package/build/services/Webhook/TriggerDivergence.d.ts.map +1 -0
  61. package/build/services/Webhook/TriggerDivergence.js +25 -0
  62. package/build/services/Webhook/TriggerFailedRuns.types.d.ts +57 -0
  63. package/build/services/Webhook/TriggerFailedRuns.types.d.ts.map +1 -0
  64. package/build/services/Webhook/TriggerFailedRuns.types.js +1 -0
  65. package/build/services/Webhook/TriggerHistoryService.d.ts +88 -18
  66. package/build/services/Webhook/TriggerHistoryService.d.ts.map +1 -1
  67. package/build/services/Webhook/TriggerLastRun.types.d.ts +80 -0
  68. package/build/services/Webhook/TriggerLastRun.types.d.ts.map +1 -0
  69. package/build/services/Webhook/TriggerLastRun.types.js +1 -0
  70. package/build/services/Webhook/TriggerRefusalDetail.types.d.ts +63 -0
  71. package/build/services/Webhook/TriggerRefusalDetail.types.d.ts.map +1 -0
  72. package/build/services/Webhook/TriggerRefusalDetail.types.js +12 -0
  73. package/build/services/Webhook/TriggerRequest.types.d.ts +77 -0
  74. package/build/services/Webhook/TriggerRequest.types.d.ts.map +1 -0
  75. package/build/services/Webhook/TriggerRequest.types.js +1 -0
  76. package/build/services/Webhook/TriggerSearch.types.d.ts +42 -0
  77. package/build/services/Webhook/TriggerSearch.types.d.ts.map +1 -0
  78. package/build/services/Webhook/TriggerSearch.types.js +1 -0
  79. package/build/services/Webhook/TriggerService.d.ts +158 -150
  80. package/build/services/Webhook/TriggerService.d.ts.map +1 -1
  81. package/build/services/Webhook/TriggerService.js +0 -24
  82. package/build/services/Webhook/TriggerTimeline.types.d.ts +42 -0
  83. package/build/services/Webhook/TriggerTimeline.types.d.ts.map +1 -0
  84. package/build/services/Webhook/TriggerTimeline.types.js +1 -0
  85. package/build/services/Webhook/TriggerVersion.types.d.ts +107 -0
  86. package/build/services/Webhook/TriggerVersion.types.d.ts.map +1 -0
  87. package/build/services/Webhook/TriggerVersion.types.js +1 -0
  88. package/build/services/Webhook/TriggerVersionService.d.ts +64 -0
  89. package/build/services/Webhook/TriggerVersionService.d.ts.map +1 -0
  90. package/build/services/Webhook/TriggerVersionService.js +21 -0
  91. package/package.json +11 -10
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The three trigger actions that RETURN data (AAD-967).
3
+ *
4
+ * These are not new endpoints. They are `payload` shapes for an ordinary trigger,
5
+ * dispatched through the ordinary dispatch URL. What is new is the split below.
6
+ *
7
+ * Response and refusal shapes live in `TriggerDatasetResponses.types.ts`.
8
+ *
9
+ * ## Frozen publisher config vs caller parameters — the load-bearing distinction
10
+ *
11
+ * Everything in a `*Payload` type is **frozen publisher configuration**, stored on
12
+ * the trigger and read from there at dispatch. The dispatcher merges a caller's
13
+ * request body ABOVE the stored config, so an action reading its source from the
14
+ * request body would let a caller repoint it — these actions deliberately do not.
15
+ *
16
+ * A caller can therefore change **nothing structural**: not the table, not the
17
+ * file, not the script, not the column selection. The only dataset field a caller
18
+ * controls is `limit`, and only downward — see {@link DatasetCallerParams}.
19
+ *
20
+ * A UI that blurs this will mislead a publisher about what they are selling. Show
21
+ * the payload fields as "fixed for every caller" and `limit` as "the caller may
22
+ * ask for fewer".
23
+ */
24
+ /** Narrow an event code to one of the three dataset actions. */
25
+ export function isDatasetAction(code) {
26
+ return code === 'ReturnTableDataEvent'
27
+ || code === 'ReturnFileDataEvent'
28
+ || code === 'TransformWithScriptEvent';
29
+ }
30
+ /**
31
+ * Whether a dataset action can run on a trigger with `read_only` set.
32
+ *
33
+ * Only the script transform cannot: it executes user code with real credentials,
34
+ * so it is classified as a write however read-shaped it looks.
35
+ */
36
+ export function isReadOnlyCompatible(code) {
37
+ return code !== 'TransformWithScriptEvent';
38
+ }
39
+ /**
40
+ * The payload guards below exist because `TriggerVersion.payload` is `unknown` and
41
+ * {@link DatasetActionPayload} carries no discriminant — so reading a released
42
+ * version's frozen config would otherwise need an `as` cast, which this repo
43
+ * forbids.
44
+ *
45
+ * `Event.code` remains the authority on which action a trigger is; these narrow
46
+ * the payload once you know that. Order matters: `script_id` is the only key
47
+ * unique to one shape, because `TransformWithScriptPayload` may also carry
48
+ * `table_id` or `dms_file_id`.
49
+ */
50
+ function asRecord(payload) {
51
+ return (typeof payload === 'object' && payload !== null)
52
+ ? payload
53
+ : null;
54
+ }
55
+ /** Narrow an unknown payload to `TransformWithScriptEvent`'s config. */
56
+ export function isTransformWithScriptPayload(payload) {
57
+ const body = asRecord(payload);
58
+ return body !== null && typeof body.script_id === 'string';
59
+ }
60
+ /** Narrow an unknown payload to `ReturnTableDataEvent`'s config. */
61
+ export function isReturnTableDataPayload(payload) {
62
+ const body = asRecord(payload);
63
+ return body !== null
64
+ && typeof body.script_id !== 'string'
65
+ && typeof body.table_id === 'string'
66
+ && Array.isArray(body.columns);
67
+ }
68
+ /** Narrow an unknown payload to `ReturnFileDataEvent`'s config. */
69
+ export function isReturnFileDataPayload(payload) {
70
+ const body = asRecord(payload);
71
+ return body !== null
72
+ && typeof body.script_id !== 'string'
73
+ && typeof body.dms_file_id === 'string';
74
+ }
@@ -0,0 +1,72 @@
1
+ import type { DatasetColumnType } from './TriggerDataset.types';
2
+ /**
3
+ * The rules for declaring a dataset column's published key and type.
4
+ *
5
+ * These live next to the types they narrow rather than in a UI package on
6
+ * purpose: they are interpretations of the AAD-967 contract, and the exhaustive
7
+ * records below are what make a new backend column type or refusal reason fail
8
+ * the BUILD instead of falling silently through a default. A UI library would
9
+ * put that guarantee in the wrong place, and every consumer would need its own
10
+ * copy of the same eleven strings.
11
+ */
12
+ /**
13
+ * Every publishable column type, as a runtime lookup.
14
+ *
15
+ * Annotated rather than inferred so the compiler rejects a missing key and a
16
+ * stray one alike — adding a member to {@link DatasetColumnType} without adding
17
+ * it here fails to build.
18
+ */
19
+ export declare const DATASET_COLUMN_TYPES: Record<DatasetColumnType, true>;
20
+ /**
21
+ * Is this a column type a dataset may publish?
22
+ *
23
+ * ⚠️ `hasOwnProperty.call`, AND NEITHER OF THE TWO OBVIOUS ALTERNATIVES. `in`
24
+ * answers true for every inherited key, so `isDatasetColumnType('toString')` used
25
+ * to report a publishable column type. `Object.hasOwn` is the rule's preferred
26
+ * form and this package's TS lib predates it — swapping it in compiles under
27
+ * `tsc -p` and then fails the Python schema generator, which builds its own
28
+ * program from these files. Hence the disable rather than the autofix.
29
+ */
30
+ export declare function isDatasetColumnType(type: string): type is DatasetColumnType;
31
+ /**
32
+ * Keys a publisher may not claim.
33
+ *
34
+ * `id` is reserved because every dataset row leads with it — the record id for a
35
+ * table, the 1-based line number for a file. A publisher who maps their own
36
+ * column to `id` would silently shadow it.
37
+ */
38
+ export declare const RESERVED_DATASET_KEYS: readonly string[];
39
+ /** Case-insensitive: `ID` collides with the reserved `id` just as surely. */
40
+ export declare function isReservedDatasetKey(key: string): boolean;
41
+ /** Letters, digits, underscore and hyphen. Anything else is not a usable key. */
42
+ export declare function isValidDatasetKey(key: string): boolean;
43
+ /**
44
+ * A reasonable published key for a source column or file header.
45
+ *
46
+ * Only a starting point — the publisher owns the final name, because it is the
47
+ * buyer's contract.
48
+ */
49
+ export declare function defaultDatasetKeyFor(name: string): string;
50
+ /** Why a published key is unusable. `null` means it is fine. */
51
+ export type DatasetKeyError = 'required' | 'reserved' | 'invalid' | 'duplicate';
52
+ /**
53
+ * Validate one published key.
54
+ *
55
+ * ⚠️ **The order of these checks is the message a user sees**, and it is not
56
+ * arbitrary. A blank key is `required`, never `invalid` — telling someone their
57
+ * empty field contains illegal characters sends them looking for a character
58
+ * that is not there. Reserved beats invalid for the same reason: `id` is a
59
+ * perfectly well-formed key, so "invalid" would be a lie about why it was
60
+ * refused. Duplicate is last because it is the only one that depends on the
61
+ * other rows rather than on this key alone.
62
+ */
63
+ export declare function datasetKeyError(key: string, duplicates: ReadonlySet<string>): DatasetKeyError | null;
64
+ /**
65
+ * Which of these keys appear more than once.
66
+ *
67
+ * Blank keys are excluded: several unfilled rows are not a name collision, and
68
+ * flagging them as duplicates would report the same problem twice under the
69
+ * wrong name.
70
+ */
71
+ export declare function duplicateDatasetKeys(keys: readonly string[]): Set<string>;
72
+ //# sourceMappingURL=TriggerDatasetColumns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TriggerDatasetColumns.d.ts","sourceRoot":"","sources":["../../../src/services/Webhook/TriggerDatasetColumns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D;;;;;;;;;GASG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAWhE,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,iBAAiB,CAG3E;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAW,CAAA;AAE9D,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMzD;AAED,gEAAgE;AAChE,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,CAAA;AAE/E;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,eAAe,GAAG,IAAI,CAWpG;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAazE"}
@@ -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
+ }