@wishknish/knishio-client-ts 0.8.2 → 0.8.3

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/index.cjs CHANGED
@@ -3812,7 +3812,8 @@ zod.z.object({
3812
3812
  client: zod.z.unknown().optional(),
3813
3813
  socket: zod.z.unknown().optional(),
3814
3814
  serverSdkVersion: zod.z.number().int().min(1).optional(),
3815
- logging: zod.z.boolean().optional()
3815
+ logging: zod.z.boolean().optional(),
3816
+ defaultRequestPolicy: zod.z.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
3816
3817
  }).strict();
3817
3818
  zod.z.object({
3818
3819
  token: zod.z.string().min(1, "Auth token cannot be empty"),
@@ -6342,7 +6343,11 @@ var KnishIOClientConfigSchema2 = zod.z.object({
6342
6343
  client: zod.z.unknown().optional(),
6343
6344
  socket: zod.z.unknown().optional(),
6344
6345
  serverSdkVersion: zod.z.number().int().min(1).max(10).default(4),
6345
- logging: zod.z.boolean().default(false)
6346
+ logging: zod.z.boolean().default(false),
6347
+ // Optional default urql request policy for reads (server/sync clients pass
6348
+ // 'network-only'). Permitted by the strict schema so the constructor option
6349
+ // isn't rejected.
6350
+ defaultRequestPolicy: zod.z.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
6346
6351
  }).strict();
6347
6352
  var EnvironmentConfigSchema = zod.z.object({
6348
6353
  NODE_ENV: zod.z.enum(["development", "production", "test"]).default("development"),
@@ -10070,6 +10075,10 @@ var KnishIOClient = class {
10070
10075
  $__client;
10071
10076
  $__serverSdkVersion = 3;
10072
10077
  $__logging = false;
10078
+ // Default urql request policy applied to reads when the caller doesn't pass
10079
+ // one. null = urql's default (cache-first). Server/sync clients set this to
10080
+ // 'network-only' so a long-lived client never serves a stale cached read.
10081
+ $__defaultRequestPolicy = null;
10073
10082
  $__authTokenObjects = {};
10074
10083
  $__authToken = null;
10075
10084
  $__authInProcess = false;
@@ -10109,13 +10118,15 @@ var KnishIOClient = class {
10109
10118
  serverSdkVersion = 3,
10110
10119
  logging = false
10111
10120
  } = validatedConfig;
10121
+ const defaultRequestPolicy = config.defaultRequestPolicy ?? null;
10112
10122
  this.initialize({
10113
10123
  uri,
10114
10124
  cellSlug,
10115
10125
  socket,
10116
10126
  client,
10117
10127
  serverSdkVersion,
10118
- logging
10128
+ logging,
10129
+ defaultRequestPolicy
10119
10130
  });
10120
10131
  }
10121
10132
  /**
@@ -10127,7 +10138,8 @@ var KnishIOClient = class {
10127
10138
  socket = null,
10128
10139
  client = null,
10129
10140
  serverSdkVersion = 3,
10130
- logging = false
10141
+ logging = false,
10142
+ defaultRequestPolicy = null
10131
10143
  }) {
10132
10144
  this.reset();
10133
10145
  this.$__logging = logging;
@@ -10149,6 +10161,7 @@ var KnishIOClient = class {
10149
10161
  encrypt: this.$__encrypt
10150
10162
  });
10151
10163
  this.$__serverSdkVersion = serverSdkVersion;
10164
+ this.$__defaultRequestPolicy = defaultRequestPolicy;
10152
10165
  }
10153
10166
  /**
10154
10167
  * Get random uri from specified this.$__uris
@@ -10196,6 +10209,20 @@ var KnishIOClient = class {
10196
10209
  getServerSdkVersion() {
10197
10210
  return this.$__serverSdkVersion;
10198
10211
  }
10212
+ /**
10213
+ * Gets the client's default urql request policy (null = urql default).
10214
+ */
10215
+ getDefaultRequestPolicy() {
10216
+ return this.$__defaultRequestPolicy;
10217
+ }
10218
+ /**
10219
+ * Sets the default urql request policy applied to reads that don't specify
10220
+ * one. Pass 'network-only' on a long-lived server/sync client so it never
10221
+ * serves a stale cached read; null restores urql's default (cache-first).
10222
+ */
10223
+ setDefaultRequestPolicy(policy) {
10224
+ this.$__defaultRequestPolicy = policy;
10225
+ }
10199
10226
  /**
10200
10227
  * Reset common properties
10201
10228
  */
@@ -10400,7 +10427,8 @@ var KnishIOClient = class {
10400
10427
  return response;
10401
10428
  });
10402
10429
  }
10403
- return await query.execute({ variables: variables || {}, context });
10430
+ const effectiveContext = this.$__defaultRequestPolicy && !context.requestPolicy ? { requestPolicy: this.$__defaultRequestPolicy, ...context } : context;
10431
+ return await query.execute({ variables: variables || {}, context: effectiveContext });
10404
10432
  }
10405
10433
  /**
10406
10434
  * When a ProposeMolecule submission is rejected for a position-related