@gscdump/sdk 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { GscdumpV1ErrorEnvelope, createGscdumpV1Protocol } from "@gscdump/contracts/v1";
2
1
  import { ZodTypeAny, z } from "zod";
2
+ import { GscdumpV1ErrorEnvelope, createGscdumpV1Protocol } from "@gscdump/contracts/v1/http";
3
3
  type MaybePromise<T> = T | Promise<T>;
4
4
  type ValueOf<T> = T[keyof T];
5
5
  type ValueOfUnion<T> = T extends unknown ? ValueOf<T> : never;
package/dist/v1/http.mjs CHANGED
@@ -1,4 +1,3 @@
1
- import { buildHttpOperationPath, createGscdumpV1Protocol } from "@gscdump/contracts/v1";
2
1
  var GscdumpV1Error = class extends Error {
3
2
  tag = "GscdumpV1Error";
4
3
  code;
@@ -105,13 +104,13 @@ function parseLocation(operation, location, value) {
105
104
  throw requestValidationError(operation.id, location, cause);
106
105
  }
107
106
  }
108
- function prepareRequest(surface, operation, input, options) {
107
+ function prepareRequest(buildOperationPath, surface, operation, input, options) {
109
108
  let path;
110
109
  if (operation.request.params === null) {
111
110
  assertAbsentLocation(operation.id, "params", input.params);
112
- path = buildHttpOperationPath(surface, operation);
111
+ path = buildOperationPath(surface, operation);
113
112
  } else try {
114
- path = buildHttpOperationPath(surface, operation, input.params);
113
+ path = buildOperationPath(surface, operation, input.params);
115
114
  } catch (cause) {
116
115
  throw requestValidationError(operation.id, "params", cause);
117
116
  }
@@ -251,14 +250,24 @@ function operationLookup(protocol) {
251
250
  return operations;
252
251
  }
253
252
  function createGscdumpV1Client(options) {
254
- const protocol = createGscdumpV1Protocol();
255
- const operations = operationLookup(protocol);
256
253
  const retryOptions = resolveRetryOptions(options.retry);
257
254
  const apiRoot = options.apiRoot ?? DEFAULT_API_ROOT;
258
255
  const fetchImpl = options.fetch ?? globalThis.fetch;
256
+ let runtimePromise;
259
257
  if (typeof fetchImpl !== "function") throw new TypeError("createGscdumpV1Client requires a fetch implementation in this runtime.");
258
+ function getRuntime() {
259
+ return runtimePromise ??= import("@gscdump/contracts/v1/http").then(({ buildHttpOperationPath: buildOperationPath, createGscdumpV1Protocol }) => {
260
+ const protocol = createGscdumpV1Protocol();
261
+ return {
262
+ buildOperationPath,
263
+ operations: operationLookup(protocol),
264
+ protocol
265
+ };
266
+ });
267
+ }
260
268
  const execute = executeUntyped;
261
269
  async function executeUntyped(operationId, input, executeOptions = {}) {
270
+ const { buildOperationPath, operations, protocol } = await getRuntime();
262
271
  const entry = operations.get(operationId);
263
272
  if (!entry) throw new GscdumpV1Error({
264
273
  code: "request_validation",
@@ -268,7 +277,7 @@ function createGscdumpV1Client(options) {
268
277
  });
269
278
  const { operation, surface } = entry;
270
279
  if (typeof input !== "object" || input === null || Array.isArray(input)) throw requestValidationError(operation.id, "input", /* @__PURE__ */ new TypeError("input must be an object."));
271
- const prepared = prepareRequest(surface, operation, input, executeOptions);
280
+ const prepared = prepareRequest(buildOperationPath, surface, operation, input, executeOptions);
272
281
  let url;
273
282
  try {
274
283
  url = appendQuery(resolveApiUrl(apiRoot, prepared.path), prepared.query);
@@ -1,6 +1,6 @@
1
- import { RealtimeV1Cursor, RealtimeV1Event, RealtimeV1StreamHead, RealtimeV1StreamId } from "@gscdump/contracts/v1";
1
+ import { RealtimeV1Cursor, RealtimeV1Event, RealtimeV1StreamHead, RealtimeV1StreamId } from "@gscdump/contracts/v1/realtime";
2
2
  type MaybePromise<T> = T | Promise<T>;
3
- declare const GSCDUMP_REALTIME_V1_SDK_VERSION: '1.4.1';
3
+ declare const GSCDUMP_REALTIME_V1_SDK_VERSION: '1.4.2';
4
4
  type GscdumpRealtimeV1TransportState = 'idle' | 'ticketing' | 'connecting' | 'handshaking' | 'replaying' | 'live' | 'waiting' | 'stopped' | 'terminal';
5
5
  type GscdumpRealtimeV1Freshness = 'unknown' | 'stale' | 'applying' | 'fresh' | 'resyncing' | 'degraded';
6
6
  type GscdumpRealtimeV1ErrorCode = 'cursor_store_failed' | 'effect_failed' | 'heartbeat_stale' | 'integration_failed' | 'protocol_error' | 'resync_failed' | 'runtime_unavailable' | 'socket_error' | 'ticket_invalid' | 'ticket_provider_failed' | 'upgrade_rejected';
@@ -1,6 +1,6 @@
1
1
  import { utf8Size } from "../utf8.mjs";
2
- import { GSCDUMP_REALTIME_ACK_POLICY, GSCDUMP_REALTIME_CLOSE_CODES, GSCDUMP_REALTIME_CONNECTION_POLICY, GSCDUMP_REALTIME_LIMITS, GSCDUMP_REALTIME_PING, GSCDUMP_REALTIME_PONG, GSCDUMP_REALTIME_SUBPROTOCOL, REALTIME_V1_EVENT_NAMES, REALTIME_V1_RESOURCE_TYPES, createGscdumpV1Protocol } from "@gscdump/contracts/v1";
3
- const GSCDUMP_REALTIME_V1_SDK_VERSION = "1.4.1";
2
+ import { GSCDUMP_REALTIME_ACK_POLICY, GSCDUMP_REALTIME_CLOSE_CODES, GSCDUMP_REALTIME_CONNECTION_POLICY, GSCDUMP_REALTIME_LIMITS, GSCDUMP_REALTIME_PING, GSCDUMP_REALTIME_PONG, GSCDUMP_REALTIME_PROTOCOL_VERSION, GSCDUMP_REALTIME_SUBPROTOCOL, REALTIME_V1_EVENT_NAMES, REALTIME_V1_RESOURCE_TYPES, createRealtimeV1Schemas } from "@gscdump/contracts/v1/realtime";
3
+ const GSCDUMP_REALTIME_V1_SDK_VERSION = "1.4.2";
4
4
  var GscdumpRealtimeV1Error = class extends Error {
5
5
  tag = "GscdumpRealtimeV1Error";
6
6
  code;
@@ -84,10 +84,10 @@ function safeRandom(random) {
84
84
  return Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : .5;
85
85
  }
86
86
  function createGscdumpRealtimeV1Client(options) {
87
- const protocol = createGscdumpV1Protocol();
87
+ const schemas = createRealtimeV1Schemas();
88
88
  const runtime = options.runtime ?? defaultRuntime();
89
89
  const cursorStore = options.cursorStore ?? createMemoryCursorStore();
90
- const sdkVersion = options.sdkVersion ?? "1.4.1";
90
+ const sdkVersion = options.sdkVersion ?? "1.4.2";
91
91
  if (!sdkVersion) throw new TypeError("sdkVersion cannot be empty.");
92
92
  let running = false;
93
93
  let epoch = 0;
@@ -228,7 +228,7 @@ function createGscdumpRealtimeV1Client(options) {
228
228
  }
229
229
  }
230
230
  function sendAck(context, appliedCursor) {
231
- sendJson(context, protocol.schemas.ackFrame.parse({
231
+ sendJson(context, schemas.ackFrame.parse({
232
232
  type: "ack",
233
233
  cursor: appliedCursor
234
234
  }));
@@ -714,7 +714,7 @@ function createGscdumpRealtimeV1Client(options) {
714
714
  cause
715
715
  });
716
716
  }
717
- const parsed = protocol.schemas.serverFrame.safeParse(rawFrame);
717
+ const parsed = schemas.serverFrame.safeParse(rawFrame);
718
718
  if (!parsed.success) throw new GscdumpRealtimeV1Error({
719
719
  code: "protocol_error",
720
720
  message: "The server frame did not match the v1 protocol.",
@@ -771,7 +771,7 @@ function createGscdumpRealtimeV1Client(options) {
771
771
  });
772
772
  }
773
773
  if (stored === null) return null;
774
- const parsed = protocol.schemas.cursor.safeParse(stored);
774
+ const parsed = schemas.cursor.safeParse(stored);
775
775
  if (!parsed.success) {
776
776
  reportError(new GscdumpRealtimeV1Error({
777
777
  code: "cursor_store_failed",
@@ -799,7 +799,7 @@ function createGscdumpRealtimeV1Client(options) {
799
799
  cause
800
800
  });
801
801
  }
802
- const parsed = protocol.schemas.ticketResponse.client.safeParse(raw);
802
+ const parsed = schemas.ticketResponseClient.safeParse(raw);
803
803
  if (!parsed.success) throw new GscdumpRealtimeV1Error({
804
804
  code: "ticket_invalid",
805
805
  message: "The realtime ticket response did not match the v1 contract.",
@@ -900,9 +900,9 @@ function createGscdumpRealtimeV1Client(options) {
900
900
  }
901
901
  setState("handshaking", cursor ? "stale" : "unknown");
902
902
  try {
903
- const hello = protocol.schemas.helloFrame.parse({
903
+ const hello = schemas.helloFrame.parse({
904
904
  type: "hello",
905
- protocolVersion: protocol.constants.realtimeProtocolVersion,
905
+ protocolVersion: GSCDUMP_REALTIME_PROTOCOL_VERSION,
906
906
  sdkVersion,
907
907
  resume: cursor
908
908
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/sdk",
3
3
  "type": "module",
4
- "version": "1.4.1",
4
+ "version": "1.4.2",
5
5
  "description": "Consumer SDK for hosted gscdump.com integrations.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -135,6 +135,16 @@
135
135
  "types": "./dist/v1/index.d.mts",
136
136
  "import": "./dist/v1/index.mjs",
137
137
  "default": "./dist/v1/index.mjs"
138
+ },
139
+ "./v1/http": {
140
+ "types": "./dist/v1/http.d.mts",
141
+ "import": "./dist/v1/http.mjs",
142
+ "default": "./dist/v1/http.mjs"
143
+ },
144
+ "./v1/realtime": {
145
+ "types": "./dist/v1/realtime.d.mts",
146
+ "import": "./dist/v1/realtime.mjs",
147
+ "default": "./dist/v1/realtime.mjs"
138
148
  }
139
149
  },
140
150
  "main": "./dist/index.mjs",
@@ -148,10 +158,10 @@
148
158
  "dependencies": {
149
159
  "ofetch": "^1.5.1",
150
160
  "zod": "^4.4.3",
151
- "@gscdump/analysis": "^1.4.1",
152
- "@gscdump/contracts": "^1.4.1",
153
- "@gscdump/engine": "^1.4.1",
154
- "gscdump": "^1.4.1"
161
+ "@gscdump/contracts": "^1.4.2",
162
+ "@gscdump/engine": "^1.4.2",
163
+ "gscdump": "^1.4.2",
164
+ "@gscdump/analysis": "^1.4.2"
155
165
  },
156
166
  "devDependencies": {
157
167
  "typescript": "^7.0.2",