@dataworks-technology/data 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -3
- package/dist/index.cjs +48918 -224
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -36
- package/dist/index.d.ts +92 -36
- package/dist/index.js +48942 -214
- package/dist/index.js.map +1 -1
- package/dist/schema.cjs +72 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +1 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +42 -0
- package/dist/schema.js.map +1 -0
- package/package.json +14 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { validateMetric, filterValidMetrics } from '@dataworks/sdk/client';
|
|
2
|
+
export { filterValidMetrics, validateMetric } from '@dataworks/sdk/client';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Public types for @dataworks-technology/data.
|
|
3
6
|
*
|
|
@@ -19,7 +22,34 @@ interface DataClientConfig {
|
|
|
19
22
|
errorUrl: string;
|
|
20
23
|
/** AppSync Events API endpoint for real-time subscriptions */
|
|
21
24
|
realtimeUrl: string;
|
|
25
|
+
/** AppSync GraphQL HTTP endpoint for query/mutate/subscribeGraphQL (e.g. https://{id}.appsync-api.{region}.amazonaws.com/graphql) */
|
|
26
|
+
graphqlUrl?: string;
|
|
27
|
+
}
|
|
28
|
+
/** GraphQL authentication strategy for API calls. */
|
|
29
|
+
type GraphQLAuthMode = "auto" | "cognito" | "apiKey";
|
|
30
|
+
/** Optional per-operation controls for GraphQL query/mutation/subscription calls. */
|
|
31
|
+
interface GraphQLOperationOptions {
|
|
32
|
+
/** Auth mode selection. auto prefers Cognito token, then apiKey if configured. */
|
|
33
|
+
authMode?: GraphQLAuthMode;
|
|
34
|
+
/** Additional request headers merged into auth headers. */
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
}
|
|
37
|
+
/** GraphQL error shape returned by AppSync-compliant APIs. */
|
|
38
|
+
interface GraphQLError {
|
|
39
|
+
message: string;
|
|
40
|
+
path?: ReadonlyArray<string | number>;
|
|
41
|
+
extensions?: Record<string, unknown>;
|
|
22
42
|
}
|
|
43
|
+
/** Data SDK error for GraphQL operation failures. */
|
|
44
|
+
interface GraphQLClientError {
|
|
45
|
+
message: string;
|
|
46
|
+
errors?: GraphQLError[];
|
|
47
|
+
cause?: Error;
|
|
48
|
+
}
|
|
49
|
+
/** Callback for GraphQL subscription payloads. */
|
|
50
|
+
type GraphQLSubscriptionHandler<T = unknown> = (payload: T) => void;
|
|
51
|
+
/** Callback for GraphQL subscription errors. */
|
|
52
|
+
type GraphQLSubscriptionErrorHandler = (error: GraphQLClientError) => void;
|
|
23
53
|
/** Credentials returned from a successful login. */
|
|
24
54
|
interface LoginResult {
|
|
25
55
|
accessToken: string;
|
|
@@ -30,8 +60,8 @@ interface LoginResult {
|
|
|
30
60
|
}
|
|
31
61
|
/** A single metric data point to ingest. */
|
|
32
62
|
interface Metric {
|
|
33
|
-
/** Unique athlete identifier */
|
|
34
|
-
|
|
63
|
+
/** Unique athlete public identifier */
|
|
64
|
+
athletePublicId: string;
|
|
35
65
|
/** Metric name (e.g. "heartrate", "speed", "power") */
|
|
36
66
|
metric: string;
|
|
37
67
|
/** Metric value — number or string */
|
|
@@ -41,7 +71,7 @@ interface Metric {
|
|
|
41
71
|
}
|
|
42
72
|
/** Validated metric item (all fields confirmed present and correct). */
|
|
43
73
|
interface MetricItem {
|
|
44
|
-
|
|
74
|
+
athletePublicId: string;
|
|
45
75
|
metric: string;
|
|
46
76
|
value: unknown;
|
|
47
77
|
timestamp: number;
|
|
@@ -49,22 +79,22 @@ interface MetricItem {
|
|
|
49
79
|
/** Loosely-typed input for validation — all fields are unknown. */
|
|
50
80
|
interface RawMetricItem {
|
|
51
81
|
metric: unknown;
|
|
52
|
-
|
|
82
|
+
athletePublicId: unknown;
|
|
53
83
|
value: unknown;
|
|
54
84
|
timestamp: unknown;
|
|
55
85
|
}
|
|
56
86
|
/** Payload shape for metric ingestion. */
|
|
57
87
|
interface MetricsPayload {
|
|
58
|
-
|
|
59
|
-
|
|
88
|
+
eventPublicId: string;
|
|
89
|
+
datasetDatasourcePublicId: string;
|
|
60
90
|
metrics: MetricItem[];
|
|
61
91
|
}
|
|
62
92
|
/** Error report to send to the Data Engine. */
|
|
63
93
|
interface ErrorReport {
|
|
64
|
-
/** Dataset-datasource identifier */
|
|
65
|
-
|
|
66
|
-
/** Athlete identifier */
|
|
67
|
-
|
|
94
|
+
/** Dataset-datasource public identifier */
|
|
95
|
+
datasetDatasourcePublicId: string;
|
|
96
|
+
/** Athlete public identifier */
|
|
97
|
+
athletePublicId: string;
|
|
68
98
|
/** Client identifier */
|
|
69
99
|
clientId: number;
|
|
70
100
|
/** Short error title */
|
|
@@ -175,11 +205,38 @@ declare class MetricValidationError extends Error {
|
|
|
175
205
|
constructor(message: string, dropped: DroppedMetric[]);
|
|
176
206
|
}
|
|
177
207
|
|
|
208
|
+
/**
|
|
209
|
+
* DataClient — the public entry point for external developers using the Dataworks Data Engine.
|
|
210
|
+
*
|
|
211
|
+
* Handles authentication, metric ingestion, error reporting, and real-time subscriptions.
|
|
212
|
+
* All SDK foundation code (@dataworks/sdk) is bundled at build time — consumers install
|
|
213
|
+
* only @dataworks-technology/data with zero transitive dependencies.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* import { DataClient } from "@dataworks-technology/data";
|
|
218
|
+
*
|
|
219
|
+
* const dataworks = new DataClient({
|
|
220
|
+
* cognitoEndpoint: "https://cognito-idp.eu-west-1.amazonaws.com/",
|
|
221
|
+
* clientId: "abc123",
|
|
222
|
+
* ingestUrl: "https://dev-realtime.dataworks.live",
|
|
223
|
+
* errorUrl: "https://dev-realtime-errors.dataworks.live",
|
|
224
|
+
* realtimeUrl: "https://dev-event-api.dataworks.live",
|
|
225
|
+
* });
|
|
226
|
+
*
|
|
227
|
+
* await dataworks.login("graeme", "password123");
|
|
228
|
+
* await dataworks.ingest([{ athletePublicId: "1", metric: "heartrate_calculated", value: 172, timestamp: Date.now() / 1000 }], "evt1", "ds1");
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* @module @dataworks-technology/data
|
|
232
|
+
*/
|
|
233
|
+
|
|
178
234
|
declare class DataClient {
|
|
179
235
|
private readonly config;
|
|
180
236
|
private credentials;
|
|
181
237
|
private lastLoginUsername;
|
|
182
238
|
private refreshInFlight;
|
|
239
|
+
private apolloClient;
|
|
183
240
|
constructor(config: DataClientConfig);
|
|
184
241
|
/**
|
|
185
242
|
* Authenticate with the Dataworks platform using Cognito USER_PASSWORD_AUTH.
|
|
@@ -196,12 +253,12 @@ declare class DataClient {
|
|
|
196
253
|
* Validates each metric before sending — invalid metrics are dropped with warnings.
|
|
197
254
|
*
|
|
198
255
|
* @param metrics - Array of metric data points
|
|
199
|
-
* @param
|
|
200
|
-
* @param
|
|
256
|
+
* @param eventPublicId - Event public identifier
|
|
257
|
+
* @param datasetDatasourcePublicId - Dataset-datasource public identifier
|
|
201
258
|
* @throws Error if not authenticated or if the request fails
|
|
202
259
|
* @see https://data-sdk-docs.dataworks.live/ingesting-data
|
|
203
260
|
*/
|
|
204
|
-
ingest(metrics: Metric[],
|
|
261
|
+
ingest(metrics: Metric[], eventPublicId: string, datasetDatasourcePublicId: string): Promise<void>;
|
|
205
262
|
/**
|
|
206
263
|
* Ingest metrics with structured validation diagnostics.
|
|
207
264
|
*
|
|
@@ -211,7 +268,7 @@ declare class DataClient {
|
|
|
211
268
|
*
|
|
212
269
|
* @returns IngestResult with accepted/dropped counts and dropped reasons.
|
|
213
270
|
*/
|
|
214
|
-
ingestWithResult(metrics: Metric[],
|
|
271
|
+
ingestWithResult(metrics: Metric[], eventPublicId: string, datasetDatasourcePublicId: string, options?: IngestOptions): Promise<IngestResult>;
|
|
215
272
|
/**
|
|
216
273
|
* Report an error to the Dataworks Data Engine.
|
|
217
274
|
*
|
|
@@ -220,16 +277,30 @@ declare class DataClient {
|
|
|
220
277
|
* @see https://data-sdk-docs.dataworks.live/error-reporting
|
|
221
278
|
*/
|
|
222
279
|
reportError(error: ErrorReport): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Execute a typed GraphQL query against the Data AppSync API.
|
|
282
|
+
*/
|
|
283
|
+
query<TData = unknown, TVariables extends Record<string, unknown> = Record<string, unknown>>(query: string, variables?: TVariables, options?: GraphQLOperationOptions): Promise<TData>;
|
|
284
|
+
/**
|
|
285
|
+
* Execute a typed GraphQL mutation against the Data AppSync API.
|
|
286
|
+
*/
|
|
287
|
+
mutate<TData = unknown, TVariables extends Record<string, unknown> = Record<string, unknown>>(mutation: string, variables?: TVariables, options?: GraphQLOperationOptions): Promise<TData>;
|
|
288
|
+
/**
|
|
289
|
+
* Subscribe to a typed GraphQL subscription from the Data AppSync API.
|
|
290
|
+
*/
|
|
291
|
+
subscribeGraphQL<TData = unknown, TVariables extends Record<string, unknown> = Record<string, unknown>>(subscription: string, onEvent: GraphQLSubscriptionHandler<TData>, onError?: GraphQLSubscriptionErrorHandler, variables?: TVariables): Subscription;
|
|
292
|
+
private getApolloClient;
|
|
223
293
|
/**
|
|
224
294
|
* Subscribe to a real-time data channel on the AppSync Events API.
|
|
225
295
|
* Uses the Cognito JWT for authentication.
|
|
226
296
|
*
|
|
227
|
-
* Channel format: dataworks/{
|
|
297
|
+
* Channel format: dataworks/{datasetDatasourcePublicId}/{eventPublicId}/{metric}
|
|
228
298
|
* Use "*" for metric to receive all metrics for a dataset-datasource/event pair.
|
|
229
299
|
* Examples: "dataworks/1/1/heartrate", "dataworks/1/1/*".
|
|
230
300
|
*
|
|
231
301
|
* @param channel - Channel path to subscribe to
|
|
232
302
|
* @param onEvent - Callback invoked for each received event
|
|
303
|
+
* @param onError - Optional callback invoked on connection or protocol errors
|
|
233
304
|
* @returns Subscription handle with a close() method
|
|
234
305
|
* @throws Error if not authenticated
|
|
235
306
|
* @see https://data-sdk-docs.dataworks.live/real-time-subscriptions
|
|
@@ -239,12 +310,12 @@ declare class DataClient {
|
|
|
239
310
|
* Check whether a metric is valid before ingesting.
|
|
240
311
|
* Returns null if valid, or a human-readable reason string if invalid.
|
|
241
312
|
*/
|
|
242
|
-
static validateMetric:
|
|
313
|
+
static validateMetric: typeof validateMetric;
|
|
243
314
|
/**
|
|
244
315
|
* Filter an array of metrics, keeping only valid ones.
|
|
245
316
|
* Logs a warning for each dropped item.
|
|
246
317
|
*/
|
|
247
|
-
static filterValidMetrics:
|
|
318
|
+
static filterValidMetrics: typeof filterValidMetrics;
|
|
248
319
|
/** Returns true if the client has been authenticated via login(). */
|
|
249
320
|
get isAuthenticated(): boolean;
|
|
250
321
|
/** Returns the tenant from the last successful login, or null. */
|
|
@@ -259,24 +330,9 @@ declare class DataClient {
|
|
|
259
330
|
private requireIngestAuth;
|
|
260
331
|
private fetchWithAutoRefresh;
|
|
261
332
|
private refreshSession;
|
|
333
|
+
private getGraphQLHttpUrl;
|
|
334
|
+
private buildGraphQLHeaders;
|
|
335
|
+
private executeGraphQLOperation;
|
|
262
336
|
}
|
|
263
337
|
|
|
264
|
-
|
|
265
|
-
* Validation re-exports — thin wrappers around @dataworks/sdk/client validation.
|
|
266
|
-
* Declared locally so the published .d.ts is fully self-contained.
|
|
267
|
-
*
|
|
268
|
-
* @module @dataworks-technology/data
|
|
269
|
-
*/
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Check whether a metric is valid.
|
|
273
|
-
* Returns null if valid, or a human-readable reason string if invalid.
|
|
274
|
-
*/
|
|
275
|
-
declare const validateMetric: (m: RawMetricItem) => string | null;
|
|
276
|
-
/**
|
|
277
|
-
* Filter an array of metrics, keeping only valid ones.
|
|
278
|
-
* Logs a warning for each dropped item via the provided warn function.
|
|
279
|
-
*/
|
|
280
|
-
declare const filterValidMetrics: (metrics: RawMetricItem[], warn: (msg: string) => void) => MetricItem[];
|
|
281
|
-
|
|
282
|
-
export { DataClient, type DataClientConfig, type DroppedMetric, type ErrorHandler, type ErrorReport, type IngestOptions, type IngestResult, type LoginResult, type Metric, type MetricItem, MetricValidationError, type MetricsPayload, type RawMetricItem, type Subscription, type SubscriptionError, type SubscriptionEvent, type SubscriptionHandler, type SubscriptionMetric, type ValidationMode, filterValidMetrics, validateMetric };
|
|
338
|
+
export { DataClient, type DataClientConfig, type DroppedMetric, type ErrorHandler, type ErrorReport, type GraphQLAuthMode, type GraphQLClientError, type GraphQLError, type GraphQLOperationOptions, type GraphQLSubscriptionErrorHandler, type GraphQLSubscriptionHandler, type IngestOptions, type IngestResult, type LoginResult, type Metric, type MetricItem, MetricValidationError, type MetricsPayload, type RawMetricItem, type Subscription, type SubscriptionError, type SubscriptionEvent, type SubscriptionHandler, type SubscriptionMetric, type ValidationMode };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { validateMetric, filterValidMetrics } from '@dataworks/sdk/client';
|
|
2
|
+
export { filterValidMetrics, validateMetric } from '@dataworks/sdk/client';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Public types for @dataworks-technology/data.
|
|
3
6
|
*
|
|
@@ -19,7 +22,34 @@ interface DataClientConfig {
|
|
|
19
22
|
errorUrl: string;
|
|
20
23
|
/** AppSync Events API endpoint for real-time subscriptions */
|
|
21
24
|
realtimeUrl: string;
|
|
25
|
+
/** AppSync GraphQL HTTP endpoint for query/mutate/subscribeGraphQL (e.g. https://{id}.appsync-api.{region}.amazonaws.com/graphql) */
|
|
26
|
+
graphqlUrl?: string;
|
|
27
|
+
}
|
|
28
|
+
/** GraphQL authentication strategy for API calls. */
|
|
29
|
+
type GraphQLAuthMode = "auto" | "cognito" | "apiKey";
|
|
30
|
+
/** Optional per-operation controls for GraphQL query/mutation/subscription calls. */
|
|
31
|
+
interface GraphQLOperationOptions {
|
|
32
|
+
/** Auth mode selection. auto prefers Cognito token, then apiKey if configured. */
|
|
33
|
+
authMode?: GraphQLAuthMode;
|
|
34
|
+
/** Additional request headers merged into auth headers. */
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
}
|
|
37
|
+
/** GraphQL error shape returned by AppSync-compliant APIs. */
|
|
38
|
+
interface GraphQLError {
|
|
39
|
+
message: string;
|
|
40
|
+
path?: ReadonlyArray<string | number>;
|
|
41
|
+
extensions?: Record<string, unknown>;
|
|
22
42
|
}
|
|
43
|
+
/** Data SDK error for GraphQL operation failures. */
|
|
44
|
+
interface GraphQLClientError {
|
|
45
|
+
message: string;
|
|
46
|
+
errors?: GraphQLError[];
|
|
47
|
+
cause?: Error;
|
|
48
|
+
}
|
|
49
|
+
/** Callback for GraphQL subscription payloads. */
|
|
50
|
+
type GraphQLSubscriptionHandler<T = unknown> = (payload: T) => void;
|
|
51
|
+
/** Callback for GraphQL subscription errors. */
|
|
52
|
+
type GraphQLSubscriptionErrorHandler = (error: GraphQLClientError) => void;
|
|
23
53
|
/** Credentials returned from a successful login. */
|
|
24
54
|
interface LoginResult {
|
|
25
55
|
accessToken: string;
|
|
@@ -30,8 +60,8 @@ interface LoginResult {
|
|
|
30
60
|
}
|
|
31
61
|
/** A single metric data point to ingest. */
|
|
32
62
|
interface Metric {
|
|
33
|
-
/** Unique athlete identifier */
|
|
34
|
-
|
|
63
|
+
/** Unique athlete public identifier */
|
|
64
|
+
athletePublicId: string;
|
|
35
65
|
/** Metric name (e.g. "heartrate", "speed", "power") */
|
|
36
66
|
metric: string;
|
|
37
67
|
/** Metric value — number or string */
|
|
@@ -41,7 +71,7 @@ interface Metric {
|
|
|
41
71
|
}
|
|
42
72
|
/** Validated metric item (all fields confirmed present and correct). */
|
|
43
73
|
interface MetricItem {
|
|
44
|
-
|
|
74
|
+
athletePublicId: string;
|
|
45
75
|
metric: string;
|
|
46
76
|
value: unknown;
|
|
47
77
|
timestamp: number;
|
|
@@ -49,22 +79,22 @@ interface MetricItem {
|
|
|
49
79
|
/** Loosely-typed input for validation — all fields are unknown. */
|
|
50
80
|
interface RawMetricItem {
|
|
51
81
|
metric: unknown;
|
|
52
|
-
|
|
82
|
+
athletePublicId: unknown;
|
|
53
83
|
value: unknown;
|
|
54
84
|
timestamp: unknown;
|
|
55
85
|
}
|
|
56
86
|
/** Payload shape for metric ingestion. */
|
|
57
87
|
interface MetricsPayload {
|
|
58
|
-
|
|
59
|
-
|
|
88
|
+
eventPublicId: string;
|
|
89
|
+
datasetDatasourcePublicId: string;
|
|
60
90
|
metrics: MetricItem[];
|
|
61
91
|
}
|
|
62
92
|
/** Error report to send to the Data Engine. */
|
|
63
93
|
interface ErrorReport {
|
|
64
|
-
/** Dataset-datasource identifier */
|
|
65
|
-
|
|
66
|
-
/** Athlete identifier */
|
|
67
|
-
|
|
94
|
+
/** Dataset-datasource public identifier */
|
|
95
|
+
datasetDatasourcePublicId: string;
|
|
96
|
+
/** Athlete public identifier */
|
|
97
|
+
athletePublicId: string;
|
|
68
98
|
/** Client identifier */
|
|
69
99
|
clientId: number;
|
|
70
100
|
/** Short error title */
|
|
@@ -175,11 +205,38 @@ declare class MetricValidationError extends Error {
|
|
|
175
205
|
constructor(message: string, dropped: DroppedMetric[]);
|
|
176
206
|
}
|
|
177
207
|
|
|
208
|
+
/**
|
|
209
|
+
* DataClient — the public entry point for external developers using the Dataworks Data Engine.
|
|
210
|
+
*
|
|
211
|
+
* Handles authentication, metric ingestion, error reporting, and real-time subscriptions.
|
|
212
|
+
* All SDK foundation code (@dataworks/sdk) is bundled at build time — consumers install
|
|
213
|
+
* only @dataworks-technology/data with zero transitive dependencies.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```ts
|
|
217
|
+
* import { DataClient } from "@dataworks-technology/data";
|
|
218
|
+
*
|
|
219
|
+
* const dataworks = new DataClient({
|
|
220
|
+
* cognitoEndpoint: "https://cognito-idp.eu-west-1.amazonaws.com/",
|
|
221
|
+
* clientId: "abc123",
|
|
222
|
+
* ingestUrl: "https://dev-realtime.dataworks.live",
|
|
223
|
+
* errorUrl: "https://dev-realtime-errors.dataworks.live",
|
|
224
|
+
* realtimeUrl: "https://dev-event-api.dataworks.live",
|
|
225
|
+
* });
|
|
226
|
+
*
|
|
227
|
+
* await dataworks.login("graeme", "password123");
|
|
228
|
+
* await dataworks.ingest([{ athletePublicId: "1", metric: "heartrate_calculated", value: 172, timestamp: Date.now() / 1000 }], "evt1", "ds1");
|
|
229
|
+
* ```
|
|
230
|
+
*
|
|
231
|
+
* @module @dataworks-technology/data
|
|
232
|
+
*/
|
|
233
|
+
|
|
178
234
|
declare class DataClient {
|
|
179
235
|
private readonly config;
|
|
180
236
|
private credentials;
|
|
181
237
|
private lastLoginUsername;
|
|
182
238
|
private refreshInFlight;
|
|
239
|
+
private apolloClient;
|
|
183
240
|
constructor(config: DataClientConfig);
|
|
184
241
|
/**
|
|
185
242
|
* Authenticate with the Dataworks platform using Cognito USER_PASSWORD_AUTH.
|
|
@@ -196,12 +253,12 @@ declare class DataClient {
|
|
|
196
253
|
* Validates each metric before sending — invalid metrics are dropped with warnings.
|
|
197
254
|
*
|
|
198
255
|
* @param metrics - Array of metric data points
|
|
199
|
-
* @param
|
|
200
|
-
* @param
|
|
256
|
+
* @param eventPublicId - Event public identifier
|
|
257
|
+
* @param datasetDatasourcePublicId - Dataset-datasource public identifier
|
|
201
258
|
* @throws Error if not authenticated or if the request fails
|
|
202
259
|
* @see https://data-sdk-docs.dataworks.live/ingesting-data
|
|
203
260
|
*/
|
|
204
|
-
ingest(metrics: Metric[],
|
|
261
|
+
ingest(metrics: Metric[], eventPublicId: string, datasetDatasourcePublicId: string): Promise<void>;
|
|
205
262
|
/**
|
|
206
263
|
* Ingest metrics with structured validation diagnostics.
|
|
207
264
|
*
|
|
@@ -211,7 +268,7 @@ declare class DataClient {
|
|
|
211
268
|
*
|
|
212
269
|
* @returns IngestResult with accepted/dropped counts and dropped reasons.
|
|
213
270
|
*/
|
|
214
|
-
ingestWithResult(metrics: Metric[],
|
|
271
|
+
ingestWithResult(metrics: Metric[], eventPublicId: string, datasetDatasourcePublicId: string, options?: IngestOptions): Promise<IngestResult>;
|
|
215
272
|
/**
|
|
216
273
|
* Report an error to the Dataworks Data Engine.
|
|
217
274
|
*
|
|
@@ -220,16 +277,30 @@ declare class DataClient {
|
|
|
220
277
|
* @see https://data-sdk-docs.dataworks.live/error-reporting
|
|
221
278
|
*/
|
|
222
279
|
reportError(error: ErrorReport): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Execute a typed GraphQL query against the Data AppSync API.
|
|
282
|
+
*/
|
|
283
|
+
query<TData = unknown, TVariables extends Record<string, unknown> = Record<string, unknown>>(query: string, variables?: TVariables, options?: GraphQLOperationOptions): Promise<TData>;
|
|
284
|
+
/**
|
|
285
|
+
* Execute a typed GraphQL mutation against the Data AppSync API.
|
|
286
|
+
*/
|
|
287
|
+
mutate<TData = unknown, TVariables extends Record<string, unknown> = Record<string, unknown>>(mutation: string, variables?: TVariables, options?: GraphQLOperationOptions): Promise<TData>;
|
|
288
|
+
/**
|
|
289
|
+
* Subscribe to a typed GraphQL subscription from the Data AppSync API.
|
|
290
|
+
*/
|
|
291
|
+
subscribeGraphQL<TData = unknown, TVariables extends Record<string, unknown> = Record<string, unknown>>(subscription: string, onEvent: GraphQLSubscriptionHandler<TData>, onError?: GraphQLSubscriptionErrorHandler, variables?: TVariables): Subscription;
|
|
292
|
+
private getApolloClient;
|
|
223
293
|
/**
|
|
224
294
|
* Subscribe to a real-time data channel on the AppSync Events API.
|
|
225
295
|
* Uses the Cognito JWT for authentication.
|
|
226
296
|
*
|
|
227
|
-
* Channel format: dataworks/{
|
|
297
|
+
* Channel format: dataworks/{datasetDatasourcePublicId}/{eventPublicId}/{metric}
|
|
228
298
|
* Use "*" for metric to receive all metrics for a dataset-datasource/event pair.
|
|
229
299
|
* Examples: "dataworks/1/1/heartrate", "dataworks/1/1/*".
|
|
230
300
|
*
|
|
231
301
|
* @param channel - Channel path to subscribe to
|
|
232
302
|
* @param onEvent - Callback invoked for each received event
|
|
303
|
+
* @param onError - Optional callback invoked on connection or protocol errors
|
|
233
304
|
* @returns Subscription handle with a close() method
|
|
234
305
|
* @throws Error if not authenticated
|
|
235
306
|
* @see https://data-sdk-docs.dataworks.live/real-time-subscriptions
|
|
@@ -239,12 +310,12 @@ declare class DataClient {
|
|
|
239
310
|
* Check whether a metric is valid before ingesting.
|
|
240
311
|
* Returns null if valid, or a human-readable reason string if invalid.
|
|
241
312
|
*/
|
|
242
|
-
static validateMetric:
|
|
313
|
+
static validateMetric: typeof validateMetric;
|
|
243
314
|
/**
|
|
244
315
|
* Filter an array of metrics, keeping only valid ones.
|
|
245
316
|
* Logs a warning for each dropped item.
|
|
246
317
|
*/
|
|
247
|
-
static filterValidMetrics:
|
|
318
|
+
static filterValidMetrics: typeof filterValidMetrics;
|
|
248
319
|
/** Returns true if the client has been authenticated via login(). */
|
|
249
320
|
get isAuthenticated(): boolean;
|
|
250
321
|
/** Returns the tenant from the last successful login, or null. */
|
|
@@ -259,24 +330,9 @@ declare class DataClient {
|
|
|
259
330
|
private requireIngestAuth;
|
|
260
331
|
private fetchWithAutoRefresh;
|
|
261
332
|
private refreshSession;
|
|
333
|
+
private getGraphQLHttpUrl;
|
|
334
|
+
private buildGraphQLHeaders;
|
|
335
|
+
private executeGraphQLOperation;
|
|
262
336
|
}
|
|
263
337
|
|
|
264
|
-
|
|
265
|
-
* Validation re-exports — thin wrappers around @dataworks/sdk/client validation.
|
|
266
|
-
* Declared locally so the published .d.ts is fully self-contained.
|
|
267
|
-
*
|
|
268
|
-
* @module @dataworks-technology/data
|
|
269
|
-
*/
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Check whether a metric is valid.
|
|
273
|
-
* Returns null if valid, or a human-readable reason string if invalid.
|
|
274
|
-
*/
|
|
275
|
-
declare const validateMetric: (m: RawMetricItem) => string | null;
|
|
276
|
-
/**
|
|
277
|
-
* Filter an array of metrics, keeping only valid ones.
|
|
278
|
-
* Logs a warning for each dropped item via the provided warn function.
|
|
279
|
-
*/
|
|
280
|
-
declare const filterValidMetrics: (metrics: RawMetricItem[], warn: (msg: string) => void) => MetricItem[];
|
|
281
|
-
|
|
282
|
-
export { DataClient, type DataClientConfig, type DroppedMetric, type ErrorHandler, type ErrorReport, type IngestOptions, type IngestResult, type LoginResult, type Metric, type MetricItem, MetricValidationError, type MetricsPayload, type RawMetricItem, type Subscription, type SubscriptionError, type SubscriptionEvent, type SubscriptionHandler, type SubscriptionMetric, type ValidationMode, filterValidMetrics, validateMetric };
|
|
338
|
+
export { DataClient, type DataClientConfig, type DroppedMetric, type ErrorHandler, type ErrorReport, type GraphQLAuthMode, type GraphQLClientError, type GraphQLError, type GraphQLOperationOptions, type GraphQLSubscriptionErrorHandler, type GraphQLSubscriptionHandler, type IngestOptions, type IngestResult, type LoginResult, type Metric, type MetricItem, MetricValidationError, type MetricsPayload, type RawMetricItem, type Subscription, type SubscriptionError, type SubscriptionEvent, type SubscriptionHandler, type SubscriptionMetric, type ValidationMode };
|