@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.js CHANGED
@@ -3806,7 +3806,8 @@ z.object({
3806
3806
  client: z.unknown().optional(),
3807
3807
  socket: z.unknown().optional(),
3808
3808
  serverSdkVersion: z.number().int().min(1).optional(),
3809
- logging: z.boolean().optional()
3809
+ logging: z.boolean().optional(),
3810
+ defaultRequestPolicy: z.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
3810
3811
  }).strict();
3811
3812
  z.object({
3812
3813
  token: z.string().min(1, "Auth token cannot be empty"),
@@ -6336,7 +6337,11 @@ var KnishIOClientConfigSchema2 = z.object({
6336
6337
  client: z.unknown().optional(),
6337
6338
  socket: z.unknown().optional(),
6338
6339
  serverSdkVersion: z.number().int().min(1).max(10).default(4),
6339
- logging: z.boolean().default(false)
6340
+ logging: z.boolean().default(false),
6341
+ // Optional default urql request policy for reads (server/sync clients pass
6342
+ // 'network-only'). Permitted by the strict schema so the constructor option
6343
+ // isn't rejected.
6344
+ defaultRequestPolicy: z.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
6340
6345
  }).strict();
6341
6346
  var EnvironmentConfigSchema = z.object({
6342
6347
  NODE_ENV: z.enum(["development", "production", "test"]).default("development"),
@@ -10064,6 +10069,10 @@ var KnishIOClient = class {
10064
10069
  $__client;
10065
10070
  $__serverSdkVersion = 3;
10066
10071
  $__logging = false;
10072
+ // Default urql request policy applied to reads when the caller doesn't pass
10073
+ // one. null = urql's default (cache-first). Server/sync clients set this to
10074
+ // 'network-only' so a long-lived client never serves a stale cached read.
10075
+ $__defaultRequestPolicy = null;
10067
10076
  $__authTokenObjects = {};
10068
10077
  $__authToken = null;
10069
10078
  $__authInProcess = false;
@@ -10103,13 +10112,15 @@ var KnishIOClient = class {
10103
10112
  serverSdkVersion = 3,
10104
10113
  logging = false
10105
10114
  } = validatedConfig;
10115
+ const defaultRequestPolicy = config.defaultRequestPolicy ?? null;
10106
10116
  this.initialize({
10107
10117
  uri,
10108
10118
  cellSlug,
10109
10119
  socket,
10110
10120
  client,
10111
10121
  serverSdkVersion,
10112
- logging
10122
+ logging,
10123
+ defaultRequestPolicy
10113
10124
  });
10114
10125
  }
10115
10126
  /**
@@ -10121,7 +10132,8 @@ var KnishIOClient = class {
10121
10132
  socket = null,
10122
10133
  client = null,
10123
10134
  serverSdkVersion = 3,
10124
- logging = false
10135
+ logging = false,
10136
+ defaultRequestPolicy = null
10125
10137
  }) {
10126
10138
  this.reset();
10127
10139
  this.$__logging = logging;
@@ -10143,6 +10155,7 @@ var KnishIOClient = class {
10143
10155
  encrypt: this.$__encrypt
10144
10156
  });
10145
10157
  this.$__serverSdkVersion = serverSdkVersion;
10158
+ this.$__defaultRequestPolicy = defaultRequestPolicy;
10146
10159
  }
10147
10160
  /**
10148
10161
  * Get random uri from specified this.$__uris
@@ -10190,6 +10203,20 @@ var KnishIOClient = class {
10190
10203
  getServerSdkVersion() {
10191
10204
  return this.$__serverSdkVersion;
10192
10205
  }
10206
+ /**
10207
+ * Gets the client's default urql request policy (null = urql default).
10208
+ */
10209
+ getDefaultRequestPolicy() {
10210
+ return this.$__defaultRequestPolicy;
10211
+ }
10212
+ /**
10213
+ * Sets the default urql request policy applied to reads that don't specify
10214
+ * one. Pass 'network-only' on a long-lived server/sync client so it never
10215
+ * serves a stale cached read; null restores urql's default (cache-first).
10216
+ */
10217
+ setDefaultRequestPolicy(policy) {
10218
+ this.$__defaultRequestPolicy = policy;
10219
+ }
10193
10220
  /**
10194
10221
  * Reset common properties
10195
10222
  */
@@ -10394,7 +10421,8 @@ var KnishIOClient = class {
10394
10421
  return response;
10395
10422
  });
10396
10423
  }
10397
- return await query.execute({ variables: variables || {}, context });
10424
+ const effectiveContext = this.$__defaultRequestPolicy && !context.requestPolicy ? { requestPolicy: this.$__defaultRequestPolicy, ...context } : context;
10425
+ return await query.execute({ variables: variables || {}, context: effectiveContext });
10398
10426
  }
10399
10427
  /**
10400
10428
  * When a ProposeMolecule submission is rejected for a position-related