@reopt-ai/data-contract 0.1.0 → 0.2.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/dist/ingest.d.ts CHANGED
@@ -234,31 +234,31 @@ declare function reconcileIngestResponse(response: IngestResponse, sentCount: nu
234
234
  */
235
235
  declare const INGEST_ERROR_CODES: readonly ["unauthorized", "invalid_json", "payload_too_large", "empty_batch", "alias_unsupported", "project_without_organization", "validation_failed", "rate_limited", "quota_exceeded", "internal_error"];
236
236
  declare const zIngestErrorCode: z.ZodEnum<{
237
- unauthorized: "unauthorized";
238
237
  validation_failed: "validation_failed";
239
- rate_limited: "rate_limited";
240
- internal_error: "internal_error";
238
+ unauthorized: "unauthorized";
241
239
  invalid_json: "invalid_json";
242
240
  payload_too_large: "payload_too_large";
243
241
  empty_batch: "empty_batch";
244
242
  alias_unsupported: "alias_unsupported";
245
243
  project_without_organization: "project_without_organization";
244
+ rate_limited: "rate_limited";
246
245
  quota_exceeded: "quota_exceeded";
246
+ internal_error: "internal_error";
247
247
  }>;
248
248
  type IngestErrorCode = z.infer<typeof zIngestErrorCode>;
249
249
  declare const zIngestError: z.ZodObject<{
250
250
  status: z.ZodNumber;
251
251
  code: z.ZodEnum<{
252
- unauthorized: "unauthorized";
253
252
  validation_failed: "validation_failed";
254
- rate_limited: "rate_limited";
255
- internal_error: "internal_error";
253
+ unauthorized: "unauthorized";
256
254
  invalid_json: "invalid_json";
257
255
  payload_too_large: "payload_too_large";
258
256
  empty_batch: "empty_batch";
259
257
  alias_unsupported: "alias_unsupported";
260
258
  project_without_organization: "project_without_organization";
259
+ rate_limited: "rate_limited";
261
260
  quota_exceeded: "quota_exceeded";
261
+ internal_error: "internal_error";
262
262
  }>;
263
263
  error: z.ZodString;
264
264
  message: z.ZodOptional<z.ZodString>;
package/dist/query.cjs CHANGED
@@ -23,11 +23,11 @@
23
23
 
24
24
 
25
25
 
26
- var _chunkDHSMXB54cjs = require('./chunk-DHSMXB54.cjs');
26
+ var _chunkGCLUMVPAcjs = require('./chunk-GCLUMVPA.cjs');
27
27
 
28
28
 
29
29
 
30
- var _chunkZQVRSCTWcjs = require('./chunk-ZQVRSCTW.cjs');
30
+ var _chunkCSTC3ADGcjs = require('./chunk-CSTC3ADG.cjs');
31
31
 
32
32
 
33
33
 
@@ -55,5 +55,5 @@ var _chunkZQVRSCTWcjs = require('./chunk-ZQVRSCTW.cjs');
55
55
 
56
56
 
57
57
 
58
- exports.QUERY_API_PATHS = _chunkDHSMXB54cjs.QUERY_API_PATHS; exports.QUERY_ERROR_CODES = _chunkDHSMXB54cjs.QUERY_ERROR_CODES; exports.isValidTimeZone = _chunkDHSMXB54cjs.isValidTimeZone; exports.zChannelFilter = _chunkDHSMXB54cjs.zChannelFilter; exports.zDate = _chunkZQVRSCTWcjs.zDate; exports.zEventsTimeseriesData = _chunkDHSMXB54cjs.zEventsTimeseriesData; exports.zEventsTimeseriesInput = _chunkDHSMXB54cjs.zEventsTimeseriesInput; exports.zEventsTimeseriesResponse = _chunkDHSMXB54cjs.zEventsTimeseriesResponse; exports.zFunnelData = _chunkDHSMXB54cjs.zFunnelData; exports.zFunnelInput = _chunkDHSMXB54cjs.zFunnelInput; exports.zFunnelResponse = _chunkDHSMXB54cjs.zFunnelResponse; exports.zFunnelStep = _chunkDHSMXB54cjs.zFunnelStep; exports.zGranularity = _chunkDHSMXB54cjs.zGranularity; exports.zInstant = _chunkZQVRSCTWcjs.zInstant; exports.zQueryEnvelope = _chunkDHSMXB54cjs.zQueryEnvelope; exports.zQueryError = _chunkDHSMXB54cjs.zQueryError; exports.zQueryErrorCode = _chunkDHSMXB54cjs.zQueryErrorCode; exports.zQueryMeta = _chunkDHSMXB54cjs.zQueryMeta; exports.zRetentionCell = _chunkDHSMXB54cjs.zRetentionCell; exports.zRetentionData = _chunkDHSMXB54cjs.zRetentionData; exports.zRetentionInput = _chunkDHSMXB54cjs.zRetentionInput; exports.zRetentionInterval = _chunkDHSMXB54cjs.zRetentionInterval; exports.zRetentionResponse = _chunkDHSMXB54cjs.zRetentionResponse; exports.zTimeseriesBreakdown = _chunkDHSMXB54cjs.zTimeseriesBreakdown; exports.zTimeseriesPoint = _chunkDHSMXB54cjs.zTimeseriesPoint; exports.zTimezone = _chunkDHSMXB54cjs.zTimezone;
58
+ exports.QUERY_API_PATHS = _chunkGCLUMVPAcjs.QUERY_API_PATHS; exports.QUERY_ERROR_CODES = _chunkGCLUMVPAcjs.QUERY_ERROR_CODES; exports.isValidTimeZone = _chunkGCLUMVPAcjs.isValidTimeZone; exports.zChannelFilter = _chunkGCLUMVPAcjs.zChannelFilter; exports.zDate = _chunkCSTC3ADGcjs.zDate; exports.zEventsTimeseriesData = _chunkGCLUMVPAcjs.zEventsTimeseriesData; exports.zEventsTimeseriesInput = _chunkGCLUMVPAcjs.zEventsTimeseriesInput; exports.zEventsTimeseriesResponse = _chunkGCLUMVPAcjs.zEventsTimeseriesResponse; exports.zFunnelData = _chunkGCLUMVPAcjs.zFunnelData; exports.zFunnelInput = _chunkGCLUMVPAcjs.zFunnelInput; exports.zFunnelResponse = _chunkGCLUMVPAcjs.zFunnelResponse; exports.zFunnelStep = _chunkGCLUMVPAcjs.zFunnelStep; exports.zGranularity = _chunkGCLUMVPAcjs.zGranularity; exports.zInstant = _chunkCSTC3ADGcjs.zInstant; exports.zQueryEnvelope = _chunkGCLUMVPAcjs.zQueryEnvelope; exports.zQueryError = _chunkGCLUMVPAcjs.zQueryError; exports.zQueryErrorCode = _chunkGCLUMVPAcjs.zQueryErrorCode; exports.zQueryMeta = _chunkGCLUMVPAcjs.zQueryMeta; exports.zRetentionCell = _chunkGCLUMVPAcjs.zRetentionCell; exports.zRetentionData = _chunkGCLUMVPAcjs.zRetentionData; exports.zRetentionInput = _chunkGCLUMVPAcjs.zRetentionInput; exports.zRetentionInterval = _chunkGCLUMVPAcjs.zRetentionInterval; exports.zRetentionResponse = _chunkGCLUMVPAcjs.zRetentionResponse; exports.zTimeseriesBreakdown = _chunkGCLUMVPAcjs.zTimeseriesBreakdown; exports.zTimeseriesPoint = _chunkGCLUMVPAcjs.zTimeseriesPoint; exports.zTimezone = _chunkGCLUMVPAcjs.zTimezone;
59
59
  //# sourceMappingURL=query.cjs.map
package/dist/query.d.cts CHANGED
@@ -336,27 +336,27 @@ declare const zRetentionResponse: z.ZodObject<{
336
336
  type RetentionResponse = z.infer<typeof zRetentionResponse>;
337
337
  declare const QUERY_ERROR_CODES: readonly ["unauthorized", "project_scope_mismatch", "query_scope_missing", "validation_failed", "unsupported_combination", "rate_limited", "query_timeout", "internal_error"];
338
338
  declare const zQueryErrorCode: z.ZodEnum<{
339
+ validation_failed: "validation_failed";
339
340
  unauthorized: "unauthorized";
341
+ rate_limited: "rate_limited";
342
+ internal_error: "internal_error";
340
343
  project_scope_mismatch: "project_scope_mismatch";
341
344
  query_scope_missing: "query_scope_missing";
342
- validation_failed: "validation_failed";
343
345
  unsupported_combination: "unsupported_combination";
344
- rate_limited: "rate_limited";
345
346
  query_timeout: "query_timeout";
346
- internal_error: "internal_error";
347
347
  }>;
348
348
  type QueryErrorCode = z.infer<typeof zQueryErrorCode>;
349
349
  declare const zQueryError: z.ZodObject<{
350
350
  status: z.ZodNumber;
351
351
  code: z.ZodEnum<{
352
+ validation_failed: "validation_failed";
352
353
  unauthorized: "unauthorized";
354
+ rate_limited: "rate_limited";
355
+ internal_error: "internal_error";
353
356
  project_scope_mismatch: "project_scope_mismatch";
354
357
  query_scope_missing: "query_scope_missing";
355
- validation_failed: "validation_failed";
356
358
  unsupported_combination: "unsupported_combination";
357
- rate_limited: "rate_limited";
358
359
  query_timeout: "query_timeout";
359
- internal_error: "internal_error";
360
360
  }>;
361
361
  error: z.ZodString;
362
362
  message: z.ZodOptional<z.ZodString>;
package/dist/query.d.ts CHANGED
@@ -336,27 +336,27 @@ declare const zRetentionResponse: z.ZodObject<{
336
336
  type RetentionResponse = z.infer<typeof zRetentionResponse>;
337
337
  declare const QUERY_ERROR_CODES: readonly ["unauthorized", "project_scope_mismatch", "query_scope_missing", "validation_failed", "unsupported_combination", "rate_limited", "query_timeout", "internal_error"];
338
338
  declare const zQueryErrorCode: z.ZodEnum<{
339
+ validation_failed: "validation_failed";
339
340
  unauthorized: "unauthorized";
341
+ rate_limited: "rate_limited";
342
+ internal_error: "internal_error";
340
343
  project_scope_mismatch: "project_scope_mismatch";
341
344
  query_scope_missing: "query_scope_missing";
342
- validation_failed: "validation_failed";
343
345
  unsupported_combination: "unsupported_combination";
344
- rate_limited: "rate_limited";
345
346
  query_timeout: "query_timeout";
346
- internal_error: "internal_error";
347
347
  }>;
348
348
  type QueryErrorCode = z.infer<typeof zQueryErrorCode>;
349
349
  declare const zQueryError: z.ZodObject<{
350
350
  status: z.ZodNumber;
351
351
  code: z.ZodEnum<{
352
+ validation_failed: "validation_failed";
352
353
  unauthorized: "unauthorized";
354
+ rate_limited: "rate_limited";
355
+ internal_error: "internal_error";
353
356
  project_scope_mismatch: "project_scope_mismatch";
354
357
  query_scope_missing: "query_scope_missing";
355
- validation_failed: "validation_failed";
356
358
  unsupported_combination: "unsupported_combination";
357
- rate_limited: "rate_limited";
358
359
  query_timeout: "query_timeout";
359
- internal_error: "internal_error";
360
360
  }>;
361
361
  error: z.ZodString;
362
362
  message: z.ZodOptional<z.ZodString>;
package/dist/query.js CHANGED
@@ -23,11 +23,11 @@ import {
23
23
  zTimeseriesBreakdown,
24
24
  zTimeseriesPoint,
25
25
  zTimezone
26
- } from "./chunk-SJYY42BP.js";
26
+ } from "./chunk-SC7TFGTO.js";
27
27
  import {
28
28
  zDate,
29
29
  zInstant
30
- } from "./chunk-IAOPUBJU.js";
30
+ } from "./chunk-IKOEYZVT.js";
31
31
  export {
32
32
  QUERY_API_PATHS,
33
33
  QUERY_ERROR_CODES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reopt-ai/data-contract",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Wire contract (zod schemas + typed client) for the reopt-data ingest and query APIs",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,6 +30,11 @@
30
30
  "import": "./dist/query.js",
31
31
  "require": "./dist/query.cjs"
32
32
  },
33
+ "./control": {
34
+ "types": "./dist/control.d.ts",
35
+ "import": "./dist/control.js",
36
+ "require": "./dist/control.cjs"
37
+ },
33
38
  "./client": {
34
39
  "types": "./dist/client.d.ts",
35
40
  "import": "./dist/client.js",
@@ -42,21 +47,21 @@
42
47
  "files": [
43
48
  "dist"
44
49
  ],
45
- "scripts": {
46
- "build": "tsup",
47
- "check-types": "tsc --noEmit",
48
- "dev": "tsup --watch",
49
- "lint": "oxlint .",
50
- "test": "pnpm run build && tsx --test src/__tests__/ingest.test.ts src/__tests__/query.test.ts src/__tests__/client.test.ts src/__tests__/package-identity.test.ts"
51
- },
52
50
  "dependencies": {
53
51
  "zod": "^4.4.3"
54
52
  },
55
53
  "devDependencies": {
56
- "@repo/typescript-config": "workspace:*",
57
54
  "@types/node": "^22.20.1",
58
55
  "tsup": "^8.5.1",
59
56
  "tsx": "^4.23.12",
60
- "typescript": "^5.9.3"
57
+ "typescript": "^5.9.3",
58
+ "@repo/typescript-config": "0.0.0"
59
+ },
60
+ "scripts": {
61
+ "build": "tsup",
62
+ "check-types": "tsc --noEmit",
63
+ "dev": "tsup --watch",
64
+ "lint": "oxlint .",
65
+ "test": "pnpm run build && tsx --test src/__tests__/ingest.test.ts src/__tests__/query.test.ts src/__tests__/control.test.ts src/__tests__/client.test.ts src/__tests__/package-identity.test.ts"
61
66
  }
62
- }
67
+ }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/eric/reopt-ai/reopt-data/packages/data-contract/dist/chunk-ZQVRSCTW.cjs","../src/index.ts"],"names":[],"mappings":"AAAA;ACaA,0BAAkB;AAOX,IAAM,iBAAA,EAAmB,OAAA;AAGzB,IAAM,wBAAA,EAA0B,0BAAA;AAGhC,IAAM,iBAAA,EAAmB,iBAAA;AACzB,IAAM,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AAA,IAAmB,IAAA;AAAA,EAE/G;AACF,UAAA;ADzDA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,2aAAC","file":"/Users/eric/reopt-ai/reopt-data/packages/data-contract/dist/chunk-ZQVRSCTW.cjs","sourcesContent":[null,"/**\n * `@reopt-ai/data-contract` — the wire contract between reopt-data and its\n * server-credential consumers (RFC-0023).\n *\n * Subpaths:\n * `@reopt-ai/data-contract` this module — version, shared primitives, errors\n * `@reopt-ai/data-contract/ingest` POST /api/track request + response schemas\n * `@reopt-ai/data-contract/query` POST /api/v1/query/* request + response schemas\n * `@reopt-ai/data-contract/client` createDataClient() — typed fetch over both\n *\n * Only `/client` touches `fetch`; everything else is pure zod. The single\n * runtime dependency is zod, deliberately — consumers bundle this.\n */\nimport { z } from \"zod\";\n\n/**\n * Contract version. Bumped on any breaking change to a schema in this package.\n * The server echoes the version it was built against in `x-reopt-contract-version`;\n * `createDataClient` surfaces a mismatch rather than guessing.\n */\nexport const CONTRACT_VERSION = \"0.1.0\";\n\n/** Response header carrying the server's contract version. */\nexport const CONTRACT_VERSION_HEADER = \"x-reopt-contract-version\";\n\n/** Request header names shared by the ingest and query planes. */\nexport const CLIENT_ID_HEADER = \"reopt-client-id\";\nexport const CLIENT_SECRET_HEADER = \"reopt-client-secret\";\nexport const WRITE_KEY_HEADER = \"reopt-write-key\";\nexport const DEVICE_ID_HEADER = \"reopt-device-id\";\nexport const REQUEST_ID_HEADER = \"x-request-id\";\n\n/**\n * A UTC calendar date. Windows are inclusive on both ends and are widened\n * server-side to `startDate T00:00:00Z` .. `endDate T23:59:59Z`.\n */\nexport const zDate = z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"expected YYYY-MM-DD (UTC)\");\n\n/** ISO-8601 instant, as produced by `Date#toISOString()`. */\nexport const zInstant = z.string().min(20);\n\n/**\n * Client credentials. The same pair authenticates both planes; what a given\n * client may reach is decided server-side by `Client.scopes`\n * (`\"ingest\"` / `\"query\"` / `\"provision\"`).\n */\nexport interface ClientCredentials {\n clientId: string;\n clientSecret: string;\n}\n\n/**\n * Every non-2xx response from either plane, plus the two failures the client\n * itself raises (`contract_mismatch`, `network_error`).\n */\nexport class DataApiError extends Error {\n /**\n * Brand for {@link DataApiError.is}. A bundler that inlines this module into\n * more than one entry point produces two distinct classes, and `instanceof`\n * silently stops matching — the brand survives that, and realm boundaries.\n */\n readonly isDataApiError = true as const;\n\n readonly status: number;\n readonly code: string;\n readonly requestId?: string;\n /** Parsed from `Retry-After`, in milliseconds. Only set on 429. */\n readonly retryAfterMs?: number;\n /** zod issues for `validation_failed`, or the raw body when unparseable. */\n readonly details?: unknown;\n\n constructor(init: {\n message: string;\n status: number;\n code: string;\n requestId?: string;\n retryAfterMs?: number;\n details?: unknown;\n }) {\n super(init.message);\n this.name = \"DataApiError\";\n this.status = init.status;\n this.code = init.code;\n this.requestId = init.requestId;\n this.retryAfterMs = init.retryAfterMs;\n this.details = init.details;\n }\n\n /** 429 and 5xx are worth retrying; 4xx are the caller's fault and are not. */\n get retryable(): boolean {\n return this.status === 429 || this.status >= 500;\n }\n\n /**\n * Prefer this over `instanceof` in a `catch`. It holds even when the class\n * has been duplicated — across CJS entry points, across bundler chunks, or\n * across realms — where `instanceof` quietly returns false.\n */\n static is(value: unknown): value is DataApiError {\n return (\n value instanceof DataApiError ||\n (typeof value === \"object\" && value !== null && (value as { isDataApiError?: unknown }).isDataApiError === true)\n );\n }\n}\n"]}