@collective-intelligence/extensions-sdk 0.0.0-stage → 0.1.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 (64) hide show
  1. package/README.md +1276 -2
  2. package/dist/components/agents.d.ts +155 -0
  3. package/dist/components/authoring-core.d.ts +253 -0
  4. package/dist/components/base.d.ts +25 -0
  5. package/dist/components/catalog.d.ts +21 -0
  6. package/dist/components/connections.d.ts +52 -0
  7. package/dist/components/connector-instances.d.ts +142 -0
  8. package/dist/components/connectors.d.ts +408 -0
  9. package/dist/components/dataset-parser-validation.d.ts +2 -0
  10. package/dist/components/dataset-parser.d.ts +74 -0
  11. package/dist/components/datasets.d.ts +356 -0
  12. package/dist/components/declaration.d.ts +12 -0
  13. package/dist/components/executable-authoring.d.ts +27 -0
  14. package/dist/components/external-app-gateway.d.ts +7 -0
  15. package/dist/components/external-application.d.ts +17 -0
  16. package/dist/components/fields.d.ts +34 -0
  17. package/dist/components/knowledge-remote-reference.d.ts +7 -0
  18. package/dist/components/knowledge.d.ts +188 -0
  19. package/dist/components/lifecycle.d.ts +7 -0
  20. package/dist/components/metadata-authoring.d.ts +66 -0
  21. package/dist/components/notification-channel-capabilities.d.ts +7 -0
  22. package/dist/components/remote-tool-collection.d.ts +3 -0
  23. package/dist/components/studio.d.ts +48 -0
  24. package/dist/components/templates.d.ts +50 -0
  25. package/dist/components/tools.d.ts +138 -0
  26. package/dist/components/workflow-editor.d.ts +28 -0
  27. package/dist/components/workflow-node-authoring.d.ts +4 -0
  28. package/dist/components/workflow-ports.d.ts +26 -0
  29. package/dist/components/workflow-results.d.ts +75 -0
  30. package/dist/components/workflow-rules.d.ts +20 -0
  31. package/dist/components/workflow-schema.d.ts +22 -0
  32. package/dist/components/workflows.d.ts +529 -0
  33. package/dist/foundation/json.d.ts +8 -0
  34. package/dist/foundation/string-order.d.ts +2 -0
  35. package/dist/gateway/declarations.d.ts +69 -0
  36. package/dist/gateway/operation-contract.d.ts +29 -0
  37. package/dist/hosted/contributions.d.ts +52 -0
  38. package/dist/index.d.ts +69 -0
  39. package/dist/index.js +1 -0
  40. package/dist/package/canonical.d.ts +9 -0
  41. package/dist/package/connector-readers.d.ts +171 -0
  42. package/dist/package/definition.d.ts +31 -0
  43. package/dist/package/dependencies.d.ts +10 -0
  44. package/dist/package/instance-readers.d.ts +4 -0
  45. package/dist/package/knowledge-readers.d.ts +137 -0
  46. package/dist/package/manifest.d.ts +42 -0
  47. package/dist/package/parse-manifest.d.ts +3 -0
  48. package/dist/package/policy-readers.d.ts +17 -0
  49. package/dist/package/presentation-readers.d.ts +61 -0
  50. package/dist/package/primitive-readers.d.ts +678 -0
  51. package/dist/package/readers.d.ts +230 -0
  52. package/dist/package/template-readers.d.ts +37 -0
  53. package/dist/package/workflow-readers.d.ts +167 -0
  54. package/dist/release/archive.d.ts +11 -0
  55. package/dist/release/manifest.d.ts +66 -0
  56. package/dist/release/paths.d.ts +5 -0
  57. package/dist/release/stored-manifest.d.ts +13 -0
  58. package/dist/schema/forms.d.ts +117 -0
  59. package/dist/schema/knowledge-record.d.ts +16 -0
  60. package/dist/schema/normalization.d.ts +7 -0
  61. package/dist/schema/profiles.d.ts +45 -0
  62. package/dist/schema/projection.d.ts +59 -0
  63. package/dist/schema/source.d.ts +65 -0
  64. package/package.json +46 -4
@@ -0,0 +1,408 @@
1
+ import type { JsonObject, JsonValue } from "../foundation/json.js";
2
+ import type { PortableFormDefinition } from "../schema/forms.js";
3
+ import type { PackageSchemaProjection } from "../schema/projection.js";
4
+ import type { BindingScope, ConnectionReference, PackagePrimitiveBase } from "./base.js";
5
+ import type { DatasetParserDefinition } from "./dataset-parser.js";
6
+ /**
7
+ * Open package-owned contribution consumed by a host capability. The host
8
+ * routes by contribution identity and capability FQN; feature code never
9
+ * switches on provider names.
10
+ */
11
+ export type KnowledgeConnectorContribution = Readonly<{
12
+ capabilityFqn: string;
13
+ connectionSlot: string;
14
+ connectionTemplateFqn: string;
15
+ controlFqn?: string;
16
+ displayName: string;
17
+ fqn: string;
18
+ metadata?: JsonObject;
19
+ }>;
20
+ export type SetupInstructions = Readonly<{
21
+ links: readonly string[];
22
+ markdown: string;
23
+ }>;
24
+ export type ToolGuidance = Readonly<{
25
+ inputRequirementsSummary?: string;
26
+ useWhen?: string;
27
+ }>;
28
+ export type ToolDeclaration = PackagePrimitiveBase<"tool"> & Readonly<{
29
+ allowMultipleSkillBindings?: boolean;
30
+ autoActivate?: boolean;
31
+ autoInstantiate?: boolean;
32
+ bindingScopes?: readonly BindingScope[];
33
+ bindingSettings?: PortableFormDefinition;
34
+ capabilityType?: "delegate" | "external" | "read" | "write";
35
+ category?: string;
36
+ connectionRefs?: readonly ConnectionReference[];
37
+ effectKind?: "mutation" | "read_only";
38
+ input: PackageSchemaProjection;
39
+ isSingleton?: boolean;
40
+ output: PackageSchemaProjection;
41
+ settings?: PortableFormDefinition;
42
+ setupInstructions?: SetupInstructions;
43
+ toolCollectionFqns?: readonly string[];
44
+ toolGuidance?: ToolGuidance;
45
+ usageScopes?: readonly ("automation" | "chat" | "skill")[];
46
+ }>;
47
+ export type ToolCollectionDeclaration = PackagePrimitiveBase<"toolCollection"> & Readonly<{
48
+ category?: string;
49
+ tags?: readonly string[];
50
+ toolFqns: readonly string[];
51
+ }>;
52
+ export type DocumentsConnectorDeclaration = PackagePrimitiveBase<"documentsConnector"> & Readonly<{
53
+ connectionRefs?: readonly ConnectionReference[];
54
+ /** Provider name readers see, as in "Open in {providerDisplayName}". */
55
+ providerDisplayName?: string;
56
+ providerFamily: string;
57
+ }>;
58
+ /** One provider page; only a checkpoint token can replace the committed cursor. */
59
+ export type DocumentsDeltaRequest = Readonly<{
60
+ rootRemoteId: string;
61
+ committedCursor?: string;
62
+ continuation?: string;
63
+ }>;
64
+ type DocumentsDeltaItemFields = Readonly<{
65
+ contentHash?: string;
66
+ contentRevision?: string;
67
+ parentRemoteIds: readonly string[];
68
+ remoteFileId: string;
69
+ /** Live file metadata; omission means unobserved, null clears a previous source. */
70
+ source?: DocumentsSource | null;
71
+ title: string;
72
+ }>;
73
+ export type DocumentsDeltaItem = DocumentsDeltaItemFields & Readonly<{
74
+ deleted?: false;
75
+ kind: "file" | "folder";
76
+ } | {
77
+ deleted: true;
78
+ kind: "file" | "folder" | "unknown";
79
+ }>;
80
+ export type DocumentsDeltaPage = Readonly<{
81
+ items: readonly DocumentsDeltaItem[];
82
+ next: Readonly<{
83
+ kind: "continuation" | "checkpoint";
84
+ token: string;
85
+ }>;
86
+ }>;
87
+ /** Proven by the provider adapter with its resolved connection, never browser input. */
88
+ export type DocumentsRootAncestry = Readonly<{
89
+ ancestorRemoteIds: readonly string[];
90
+ /** Provider-native identity of the selected root, resolving aliases. */
91
+ canonicalRemoteRootId: string;
92
+ /** Selected root name reported by the provider, when available. */
93
+ displayName?: string;
94
+ /** Stable drive identity across credentials for the same remote scope. */
95
+ providerScopeKey: string;
96
+ remoteRootId: string;
97
+ /** Selected root browser URL reported by the provider, never synthesized. */
98
+ webUrl?: string;
99
+ }>;
100
+ /**
101
+ * Browsable drive. `remoteId` is the drive's root folder id, accepted as-is by
102
+ * `pull({ selectedRootRemoteIds })`, `proveRootAncestry`, and `listFolders`.
103
+ */
104
+ export type DocumentsDrive = Readonly<{
105
+ remoteId: string;
106
+ title: string;
107
+ kind: "personal" | "shared";
108
+ }>;
109
+ /** One provider page; `nextCursor` is absent on the last page. */
110
+ export type DocumentsDrivesPage = Readonly<{
111
+ items: readonly DocumentsDrive[];
112
+ nextCursor?: string;
113
+ }>;
114
+ /** Direct child folder; `remoteId` is selectable as a sync root as-is. */
115
+ export type DocumentsFolder = Readonly<{
116
+ remoteId: string;
117
+ title: string;
118
+ /** Set only when the provider reports it without an extra request. */
119
+ hasChildren?: boolean;
120
+ }>;
121
+ /** One provider page; `nextCursor` is absent on the last page. */
122
+ export type DocumentsFoldersPage = Readonly<{
123
+ items: readonly DocumentsFolder[];
124
+ nextCursor?: string;
125
+ }>;
126
+ /**
127
+ * Provider-reported browser destination for the original live file, not a stored
128
+ * Version or collection root. Never synthesize it from a remote ID. Hosts must
129
+ * authorize disclosure and validate the URL before opening; it grants no access.
130
+ */
131
+ export type DocumentsSource = Readonly<{
132
+ webUrl: string;
133
+ }>;
134
+ /** The bytes and actual stored representation after any provider export. */
135
+ export type DocumentsFetchedContent = Readonly<{
136
+ bytes: Uint8Array;
137
+ /** Omission means unobserved; null explicitly clears a previously known source. */
138
+ source?: DocumentsSource | null;
139
+ mimeType?: string;
140
+ extension?: string;
141
+ filename?: string;
142
+ }>;
143
+ export type DocumentsDeltaCursorExpired = Readonly<{
144
+ code: "cursor_expired";
145
+ message: string;
146
+ }>;
147
+ export type KnowledgeConnectorDeclaration = PackagePrimitiveBase<"knowledgeConnector"> & Readonly<{
148
+ autoActivate?: boolean;
149
+ /** Creates the singleton instance when the package is installed. */
150
+ autoInstantiate?: boolean;
151
+ bindingScopes?: readonly BindingScope[];
152
+ connectionRefs?: readonly ConnectionReference[];
153
+ contributions?: readonly KnowledgeConnectorContribution[];
154
+ defaultOutboundStrategy?: "local_first" | "remote_first";
155
+ defaultUpdateMode?: "full" | "partial";
156
+ discoveryDefaults?: KnowledgeConnectorDiscoveryDefaults;
157
+ /** Entity identity is provided by an adapter unless item metadata is declared. */
158
+ entityIdentityMode?: "adapter" | "item_metadata";
159
+ entitySchemaCapabilities?: readonly KnowledgeEntitySchemaCapability[];
160
+ isSingleton?: boolean;
161
+ /** Enables per-entity-binding outbound sync when the runtime implements it. */
162
+ outboundCapability?: "declared_and_enablable" | "none";
163
+ /** Suggested schedules for root bindings created from discovered remotes. */
164
+ recommendedImportSchedules?: readonly KnowledgePredefinedSchedule[];
165
+ relationSchemaCapabilities?: readonly KnowledgeRelationSchemaCapability[];
166
+ /** How hosts label and link references this connector imported. */
167
+ remoteReference?: KnowledgeConnectorRemoteReference;
168
+ settings?: PortableFormDefinition;
169
+ supportedBindingModes?: readonly ("external" | "managed")[];
170
+ }>;
171
+ /**
172
+ * Host presentation of one imported remote reference. `urlTemplate` is an
173
+ * `https://` URL whose placeholders the host fills from the remote ID:
174
+ * - `{remoteId}`: the remote ID, URI-component encoded.
175
+ * - `{remoteIdUuidHex}`: a UUID remote ID (hyphens optional) as 32 lowercase
176
+ * hex digits; any other remote ID gets no URL.
177
+ */
178
+ export type KnowledgeConnectorRemoteReference = Readonly<{
179
+ providerKey: string;
180
+ urlTemplate: string;
181
+ }>;
182
+ export type { ExternalDatasetProviderDeclaration, ManagedDatasetProviderDeclaration } from "./datasets.js";
183
+ export type DatasetParserDeclaration = PackagePrimitiveBase<"datasetParser"> & DatasetParserDefinition;
184
+ export type KnowledgePredefinedSchedule = Readonly<{
185
+ cronExpression: string;
186
+ enabled?: boolean;
187
+ importMode?: "delta" | "full";
188
+ label?: string;
189
+ rationale?: string;
190
+ timezone?: string;
191
+ }>;
192
+ /**
193
+ * JSON-only connector binding configuration persisted by the host.
194
+ *
195
+ * These keys are part of the package-to-host contract, not provider payload.
196
+ */
197
+ type ConnectorFieldMapRuleBase = Readonly<{
198
+ direction: "both" | "inbound" | "outbound";
199
+ local: string;
200
+ skipIfNull: boolean;
201
+ }>;
202
+ export type KnowledgeConnectorFieldMapRule = ConnectorFieldMapRuleBase & (Readonly<{
203
+ op: "path";
204
+ remote: string;
205
+ }> | Readonly<{
206
+ op: "cast";
207
+ remote: string;
208
+ falseValues?: readonly string[];
209
+ trueValues?: readonly string[];
210
+ }> | Readonly<{
211
+ op: "default";
212
+ remote?: string;
213
+ value: JsonValue;
214
+ }> | Readonly<{
215
+ op: "concat";
216
+ remote: readonly string[];
217
+ separator?: string;
218
+ }> | Readonly<{
219
+ discardEmpty?: boolean;
220
+ op: "split";
221
+ remote: string;
222
+ separators?: readonly string[];
223
+ trimItems?: boolean;
224
+ uniqueItems?: boolean;
225
+ }> | Readonly<{
226
+ latitudeKey?: string;
227
+ longitudeKey?: string;
228
+ op: "coordinates";
229
+ remote: readonly [string, string];
230
+ }> | Readonly<{
231
+ op: "transform";
232
+ remote: string;
233
+ transformerId: string;
234
+ }>);
235
+ export type KnowledgeConnectorBindingExtraConfig = Readonly<{
236
+ displayName: string | null;
237
+ enabled: boolean;
238
+ id: string;
239
+ includeInEntityEmbedding: boolean;
240
+ kind: "linked_text" | "file_source";
241
+ slotKey: string;
242
+ source: JsonObject;
243
+ }>;
244
+ export type KnowledgeEntitySchemaCapability = Readonly<{
245
+ extraPropsMode?: "ignore" | "import" | "inline";
246
+ fieldMap?: readonly KnowledgeConnectorFieldMapRule[];
247
+ fqn: string;
248
+ outboundStrategy?: "local_first" | "remote_first";
249
+ predefinedBindingExtras?: readonly KnowledgeConnectorBindingExtraConfig[];
250
+ predefinedBindingKey?: string;
251
+ predefinedBindingMode?: "external" | "managed";
252
+ predefinedBindingParentKey?: string;
253
+ predefinedBindingRemoteCollectionId?: string;
254
+ predefinedBindingRemoteCollectionName?: string;
255
+ predefinedSchedules?: readonly KnowledgePredefinedSchedule[];
256
+ supportedBindingModes?: readonly ("external" | "managed")[];
257
+ supportedSyncModes?: readonly ("delta" | "full")[];
258
+ supportsInbound?: boolean;
259
+ supportsOutbound?: boolean;
260
+ syncIntervalSeconds?: number | null;
261
+ updateMode?: "full" | "partial";
262
+ }>;
263
+ export type KnowledgeRelationSchemaCapability = Readonly<{
264
+ extraPropsMode?: "ignore" | "import" | "inline";
265
+ fieldMap?: readonly KnowledgeConnectorFieldMapRule[];
266
+ fqn: string;
267
+ outboundStrategy?: "local_first" | "remote_first";
268
+ predefinedBindingExtras?: readonly KnowledgeConnectorBindingExtraConfig[];
269
+ predefinedBindingKey?: string;
270
+ predefinedBindingMode?: "external" | "managed";
271
+ predefinedBindingParentEntityKey?: string;
272
+ predefinedBindingRelationImportMode?: "child_binding" | "relation_only";
273
+ predefinedBindingRemoteCollectionId?: string;
274
+ predefinedBindingRemoteCollectionName?: string;
275
+ predefinedBindingSourceEntityKey?: string;
276
+ predefinedBindingTargetEntityKey?: string;
277
+ predefinedSchedules?: readonly KnowledgePredefinedSchedule[];
278
+ supportedSyncModes?: readonly ("delta" | "full")[];
279
+ supportsInbound?: boolean;
280
+ supportsOutbound?: boolean;
281
+ syncIntervalSeconds?: number | null;
282
+ updateMode?: "full" | "partial";
283
+ }>;
284
+ /**
285
+ * A connector-scoped OAuth authorization-code provider. The declaration is
286
+ * portable metadata; its runtime factory supplies the executable provider.
287
+ */
288
+ export type KnowledgeConnectorOAuthDeclaration = PackagePrimitiveBase<"knowledgeConnectorOauth"> & Readonly<{
289
+ connectorFqn: string;
290
+ }>;
291
+ export type KnowledgeConnectorOAuthTokens = Readonly<{
292
+ accessToken?: string;
293
+ expiresAt?: number;
294
+ refreshToken: string;
295
+ }>;
296
+ /**
297
+ * JSON-only defaults applied when an operator turns a discovered remote into
298
+ * an entity binding. Keeping this in the declaration means both internal and
299
+ * future externally deployed packages share the same persisted contract.
300
+ */
301
+ export type KnowledgeConnectorDiscoveryDefaults = Readonly<{
302
+ extraPropsMode: "ignore" | "import" | "inline";
303
+ outboundStrategy: "local_first" | "remote_first";
304
+ supportedBindingModes: readonly ("external" | "managed")[];
305
+ supportedSyncModes: readonly ("delta" | "full")[];
306
+ supportsInbound: boolean;
307
+ supportsOutbound: boolean;
308
+ syncIntervalSeconds: number | null;
309
+ updateMode: "full" | "partial";
310
+ }>;
311
+ export type ConnectionDeclaration = PackagePrimitiveBase<"connection"> & Readonly<{
312
+ compatibility?: Readonly<{
313
+ auth?: string;
314
+ dialect?: string;
315
+ extensions?: JsonObject;
316
+ provider?: string;
317
+ }>;
318
+ credential: PortableFormDefinition;
319
+ /** Registration-only connections are created by their owning lifecycle. */
320
+ creationMode?: "self_service" | "registration_only";
321
+ defaultConnectionName: string;
322
+ discoveryMetadata?: Readonly<{
323
+ available: boolean;
324
+ label: string;
325
+ }>;
326
+ providerFamily: string;
327
+ secretFields?: readonly string[];
328
+ testMetadata?: Readonly<{
329
+ available: boolean;
330
+ label: string;
331
+ }>;
332
+ }>;
333
+ export type KnowledgeEntityAdapterDeclaration = PackagePrimitiveBase<"knowledgeEntityAdapter"> & Readonly<{
334
+ connectorFqn: string;
335
+ /** Exact schema FQN, or "*" for the connector-wide fallback adapter. */
336
+ entitySchemaFqn: string;
337
+ /** Opt in to provider-owned normalization of values read by inbound field maps. */
338
+ normalizesFieldMapValues?: boolean;
339
+ /** Opt in to post-field-map normalization; omitted flags support older runtimes. */
340
+ normalizesImportedData?: boolean;
341
+ }>;
342
+ export type KnowledgeRelationAdapterDeclaration = PackagePrimitiveBase<"knowledgeRelationAdapter"> & Readonly<{
343
+ connectorFqn: string;
344
+ relationSchemaFqn: string;
345
+ }>;
346
+ export type EventListenerDeclaration = PackagePrimitiveBase<"eventListener"> & Readonly<{
347
+ capabilities: readonly ("internal" | "poll" | "webhook")[];
348
+ eventKind: string;
349
+ /** State entry written when an operator configures a manual webhook token. */
350
+ manualWebhookState?: Readonly<{
351
+ keyFamily: string;
352
+ stateKey: string;
353
+ }>;
354
+ /** State entries the host may project into the listener runtime context. */
355
+ runtimeState?: readonly Readonly<{
356
+ keyFamily: string;
357
+ stateKey: string;
358
+ }>[];
359
+ safeOccurrenceFields?: readonly string[];
360
+ safeSelectorFields?: readonly string[];
361
+ /**
362
+ * Provider subscription handshake the host answers on this listener's
363
+ * webhook endpoints before callback admission. `echo_query_parameter`
364
+ * returns the named query parameter as `text/plain`.
365
+ */
366
+ webhookHandshake?: Readonly<{
367
+ kind: "echo_query_parameter";
368
+ parameter: string;
369
+ }>;
370
+ }>;
371
+ /** Canonical package-owned occurrence for durable internal ingress fan-out. */
372
+ export type EventListenerInternalOccurrence = Readonly<{
373
+ eventKey: string;
374
+ payload: JsonObject;
375
+ routeKeys: Readonly<Record<string, string>>;
376
+ safeSummary: JsonObject;
377
+ }>;
378
+ /** The package-owned result of one durable source-watch poll cycle. */
379
+ export type EventListenerPollResult = Readonly<{
380
+ /**
381
+ * Persist this only after every occurrence reaches the host's durable
382
+ * dispatch boundary. `null` deliberately represents an uninitialized
383
+ * listener cursor.
384
+ */
385
+ nextCheckpoint: JsonObject | null;
386
+ occurrences: readonly EventListenerInternalOccurrence[];
387
+ }>;
388
+ /** Input reconstructed by the host from one claimed source watch. */
389
+ export type EventListenerPollRequest = Readonly<{
390
+ checkpoint: JsonObject | null;
391
+ selector: JsonObject;
392
+ }>;
393
+ /** Raw callback data retained only until package-owned verification completes. */
394
+ export type EventListenerWebhookRequest = Readonly<{
395
+ readonly body: Uint8Array;
396
+ readonly headers: Readonly<Record<string, string>>;
397
+ }>;
398
+ /** Organization SSO metadata; the provider constructor remains a runtime sidecar. */
399
+ export type OrganizationSsoDeclaration = PackagePrimitiveBase<"organizationSso"> & Readonly<{
400
+ providerId: string;
401
+ connectionTemplateFqn: string;
402
+ requiredCredentialFields: readonly string[];
403
+ secretCredentialFields?: readonly string[];
404
+ setupGuide?: readonly Readonly<{
405
+ locale: string;
406
+ markdown: string;
407
+ }>[];
408
+ }>;
@@ -0,0 +1,2 @@
1
+ export declare const datasetParserFormat: (value: unknown, path: string) => string;
2
+ export declare const datasetParserVersion: (value: unknown, path: string) => string;
@@ -0,0 +1,74 @@
1
+ /** Portable file-parser vocabulary, independent of source connectors and hosts. */
2
+ export type DatasetParserDefinition = Readonly<{
3
+ format: string;
4
+ extensions: readonly string[];
5
+ mediaTypes: readonly string[];
6
+ parserVersion: string;
7
+ }>;
8
+ export type DatasetParserColumnType = "boolean" | "int64" | "float64" | "decimal" | "date" | "duration" | "json" | "timestamp" | "string";
9
+ export type DatasetParserField = Readonly<{
10
+ key: string;
11
+ label: string;
12
+ nullable: boolean;
13
+ type: DatasetParserColumnType;
14
+ }>;
15
+ export type DatasetParserDiagnostic = Readonly<{
16
+ code: "column_count";
17
+ actualColumnCount: number;
18
+ expectedColumnCount: number;
19
+ rowNumber: number;
20
+ }> | Readonly<{
21
+ code: "type_value";
22
+ expectedType: DatasetParserColumnType;
23
+ fieldKey: string;
24
+ maskedValue: string;
25
+ rowNumber: number;
26
+ }>;
27
+ export type DatasetParserRecordValue = boolean | number | string | null;
28
+ export type DatasetParserRecord = Readonly<Record<string, DatasetParserRecordValue>>;
29
+ export type DatasetParserAnalysis = Readonly<{
30
+ diagnostics: readonly DatasetParserDiagnostic[];
31
+ fields: readonly DatasetParserField[];
32
+ fingerprint: string;
33
+ rowCount: number;
34
+ }>;
35
+ export type DatasetParserRecords = Readonly<{
36
+ diagnostics: readonly DatasetParserDiagnostic[];
37
+ rows: readonly DatasetParserRecord[];
38
+ }>;
39
+ export type DatasetParserInput = Readonly<{
40
+ bytes: Uint8Array;
41
+ maxRows: number;
42
+ }>;
43
+ export type DatasetParserRecordsInput = DatasetParserInput & Readonly<{
44
+ fields: readonly DatasetParserField[];
45
+ }>;
46
+ /** Expected failures are values; rejected promises indicate unexpected failures. */
47
+ export type DatasetParserError = Readonly<{
48
+ _tag: "DatasetCsvParseError";
49
+ code: "empty_file" | "invalid_encoding" | "unexpected_quote" | "invalid_character_after_quote" | "unterminated_quoted_field";
50
+ message: string;
51
+ }> | Readonly<{
52
+ _tag: "DatasetCsvLimitExceededError";
53
+ actual: number;
54
+ limit: number;
55
+ unit: "bytes" | "rows";
56
+ }> | Readonly<{
57
+ _tag: "DatasetImportParseError";
58
+ format: string;
59
+ code: string;
60
+ message: string;
61
+ fieldKey?: string;
62
+ rowNumber?: number;
63
+ }>;
64
+ export type DatasetParserResult<Value> = Readonly<{
65
+ status: "success";
66
+ value: Value;
67
+ }> | Readonly<{
68
+ status: "failure";
69
+ error: DatasetParserError;
70
+ }>;
71
+ export interface DatasetParserImplementation {
72
+ readonly analyze: (input: DatasetParserInput) => DatasetParserResult<DatasetParserAnalysis> | PromiseLike<DatasetParserResult<DatasetParserAnalysis>>;
73
+ readonly parseRecords: (input: DatasetParserRecordsInput) => DatasetParserResult<DatasetParserRecords> | PromiseLike<DatasetParserResult<DatasetParserRecords>>;
74
+ }