@wishknish/knishio-client-ts 0.8.1 → 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 +42 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.iife.js +42 -12
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +42 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/KnishIOClient.ts +65 -9
- package/src/libraries/GraphQLClient.ts +7 -4
- package/src/schemas/index.ts +2 -1
- package/src/types/index.ts +13 -0
- package/src/validation/schemas.ts +5 -1
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"),
|
|
@@ -5820,14 +5821,14 @@ var GraphQLClient = class {
|
|
|
5820
5821
|
});
|
|
5821
5822
|
}
|
|
5822
5823
|
async query(request) {
|
|
5823
|
-
const { query, variables } = request;
|
|
5824
|
-
const result = await this.$__client.query(query, variables || {}).toPromise();
|
|
5824
|
+
const { query, variables, context } = request;
|
|
5825
|
+
const result = await this.$__client.query(query, variables || {}, context).toPromise();
|
|
5825
5826
|
return this.formatResponse(result);
|
|
5826
5827
|
}
|
|
5827
5828
|
async mutation(request) {
|
|
5828
|
-
const { query, variables } = request;
|
|
5829
|
+
const { query, variables, context } = request;
|
|
5829
5830
|
const mutationString = request.mutation || query;
|
|
5830
|
-
const result = await this.$__client.mutation(mutationString, variables || {}).toPromise();
|
|
5831
|
+
const result = await this.$__client.mutation(mutationString, variables || {}, context).toPromise();
|
|
5831
5832
|
return this.formatResponse(result);
|
|
5832
5833
|
}
|
|
5833
5834
|
// Alias for mutation() to match JS SDK interface
|
|
@@ -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
|
*/
|
|
@@ -10378,7 +10405,7 @@ var KnishIOClient = class {
|
|
|
10378
10405
|
/**
|
|
10379
10406
|
* Executes a query or mutation
|
|
10380
10407
|
*/
|
|
10381
|
-
async executeQuery(query, variables = null) {
|
|
10408
|
+
async executeQuery(query, variables = null, context = {}) {
|
|
10382
10409
|
if (this.$__authToken && this.$__authToken.isExpired() && !this.$__authInProcess) {
|
|
10383
10410
|
this.log("info", "KnishIOClient::executeQuery() - Access token is expired. Getting new one...");
|
|
10384
10411
|
await this.requestAuthToken({
|
|
@@ -10394,7 +10421,8 @@ var KnishIOClient = class {
|
|
|
10394
10421
|
return response;
|
|
10395
10422
|
});
|
|
10396
10423
|
}
|
|
10397
|
-
|
|
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
|
|
@@ -10727,7 +10755,8 @@ var KnishIOClient = class {
|
|
|
10727
10755
|
throughMolecule = false,
|
|
10728
10756
|
values = null,
|
|
10729
10757
|
keys = null,
|
|
10730
|
-
atomValues = null
|
|
10758
|
+
atomValues = null,
|
|
10759
|
+
requestPolicy = null
|
|
10731
10760
|
}) {
|
|
10732
10761
|
this.log("info", `KnishIOClient::queryMeta() - Querying metaType: ${metaType}, metaId: ${metaId}...`);
|
|
10733
10762
|
let query;
|
|
@@ -10779,7 +10808,8 @@ var KnishIOClient = class {
|
|
|
10779
10808
|
cellSlug: this.getCellSlug()
|
|
10780
10809
|
});
|
|
10781
10810
|
}
|
|
10782
|
-
|
|
10811
|
+
const context = requestPolicy ? { requestPolicy } : {};
|
|
10812
|
+
return this.executeQuery(query, variables, context);
|
|
10783
10813
|
}
|
|
10784
10814
|
/**
|
|
10785
10815
|
* Queries meta assets and verifies cryptographic integrity of associated molecules.
|