@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 +33 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.iife.js +33 -5
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +33 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/KnishIOClient.ts +46 -5
- package/src/schemas/index.ts +2 -1
- package/src/types/index.ts +6 -0
- package/src/validation/schemas.ts +5 -1
package/dist/index.d.cts
CHANGED
|
@@ -274,6 +274,7 @@ interface ValidationResult$1 {
|
|
|
274
274
|
expected?: string;
|
|
275
275
|
actual?: unknown;
|
|
276
276
|
}
|
|
277
|
+
type RequestPolicy = 'cache-first' | 'cache-only' | 'network-only' | 'cache-and-network';
|
|
277
278
|
interface GraphQLRequest {
|
|
278
279
|
query: string;
|
|
279
280
|
variables?: Record<string, unknown>;
|
|
@@ -1119,6 +1120,7 @@ declare class KnishIOClient {
|
|
|
1119
1120
|
private $__client;
|
|
1120
1121
|
private $__serverSdkVersion;
|
|
1121
1122
|
private $__logging;
|
|
1123
|
+
private $__defaultRequestPolicy;
|
|
1122
1124
|
private $__authTokenObjects;
|
|
1123
1125
|
private $__authToken;
|
|
1124
1126
|
private $__authInProcess;
|
|
@@ -1137,8 +1139,9 @@ declare class KnishIOClient {
|
|
|
1137
1139
|
} | null;
|
|
1138
1140
|
serverSdkVersion?: number;
|
|
1139
1141
|
logging?: boolean;
|
|
1142
|
+
defaultRequestPolicy?: RequestPolicy | null;
|
|
1140
1143
|
});
|
|
1141
|
-
initialize({ uri, cellSlug, socket, client, serverSdkVersion, logging }: {
|
|
1144
|
+
initialize({ uri, cellSlug, socket, client, serverSdkVersion, logging, defaultRequestPolicy }: {
|
|
1142
1145
|
uri: string | string[];
|
|
1143
1146
|
cellSlug?: string | null;
|
|
1144
1147
|
socket?: {
|
|
@@ -1148,12 +1151,15 @@ declare class KnishIOClient {
|
|
|
1148
1151
|
client?: GraphQLClient | null;
|
|
1149
1152
|
serverSdkVersion?: number;
|
|
1150
1153
|
logging?: boolean;
|
|
1154
|
+
defaultRequestPolicy?: RequestPolicy | null;
|
|
1151
1155
|
}): void;
|
|
1152
1156
|
getRandomUri(): string;
|
|
1153
1157
|
switchEncryption(encrypt: boolean): boolean;
|
|
1154
1158
|
deinitialize(): void;
|
|
1155
1159
|
subscribe(): GraphQLClient;
|
|
1156
1160
|
getServerSdkVersion(): number;
|
|
1161
|
+
getDefaultRequestPolicy(): RequestPolicy | null;
|
|
1162
|
+
setDefaultRequestPolicy(policy: RequestPolicy | null): void;
|
|
1157
1163
|
reset(): void;
|
|
1158
1164
|
client(): GraphQLClient;
|
|
1159
1165
|
setUri(uri: string | string[]): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -274,6 +274,7 @@ interface ValidationResult$1 {
|
|
|
274
274
|
expected?: string;
|
|
275
275
|
actual?: unknown;
|
|
276
276
|
}
|
|
277
|
+
type RequestPolicy = 'cache-first' | 'cache-only' | 'network-only' | 'cache-and-network';
|
|
277
278
|
interface GraphQLRequest {
|
|
278
279
|
query: string;
|
|
279
280
|
variables?: Record<string, unknown>;
|
|
@@ -1119,6 +1120,7 @@ declare class KnishIOClient {
|
|
|
1119
1120
|
private $__client;
|
|
1120
1121
|
private $__serverSdkVersion;
|
|
1121
1122
|
private $__logging;
|
|
1123
|
+
private $__defaultRequestPolicy;
|
|
1122
1124
|
private $__authTokenObjects;
|
|
1123
1125
|
private $__authToken;
|
|
1124
1126
|
private $__authInProcess;
|
|
@@ -1137,8 +1139,9 @@ declare class KnishIOClient {
|
|
|
1137
1139
|
} | null;
|
|
1138
1140
|
serverSdkVersion?: number;
|
|
1139
1141
|
logging?: boolean;
|
|
1142
|
+
defaultRequestPolicy?: RequestPolicy | null;
|
|
1140
1143
|
});
|
|
1141
|
-
initialize({ uri, cellSlug, socket, client, serverSdkVersion, logging }: {
|
|
1144
|
+
initialize({ uri, cellSlug, socket, client, serverSdkVersion, logging, defaultRequestPolicy }: {
|
|
1142
1145
|
uri: string | string[];
|
|
1143
1146
|
cellSlug?: string | null;
|
|
1144
1147
|
socket?: {
|
|
@@ -1148,12 +1151,15 @@ declare class KnishIOClient {
|
|
|
1148
1151
|
client?: GraphQLClient | null;
|
|
1149
1152
|
serverSdkVersion?: number;
|
|
1150
1153
|
logging?: boolean;
|
|
1154
|
+
defaultRequestPolicy?: RequestPolicy | null;
|
|
1151
1155
|
}): void;
|
|
1152
1156
|
getRandomUri(): string;
|
|
1153
1157
|
switchEncryption(encrypt: boolean): boolean;
|
|
1154
1158
|
deinitialize(): void;
|
|
1155
1159
|
subscribe(): GraphQLClient;
|
|
1156
1160
|
getServerSdkVersion(): number;
|
|
1161
|
+
getDefaultRequestPolicy(): RequestPolicy | null;
|
|
1162
|
+
setDefaultRequestPolicy(policy: RequestPolicy | null): void;
|
|
1157
1163
|
reset(): void;
|
|
1158
1164
|
client(): GraphQLClient;
|
|
1159
1165
|
setUri(uri: string | string[]): void;
|
package/dist/index.iife.js
CHANGED
|
@@ -24045,7 +24045,8 @@ ${operationTypes.join("\n")}
|
|
|
24045
24045
|
client: external_exports.unknown().optional(),
|
|
24046
24046
|
socket: external_exports.unknown().optional(),
|
|
24047
24047
|
serverSdkVersion: external_exports.number().int().min(1).optional(),
|
|
24048
|
-
logging: external_exports.boolean().optional()
|
|
24048
|
+
logging: external_exports.boolean().optional(),
|
|
24049
|
+
defaultRequestPolicy: external_exports.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
|
|
24049
24050
|
}).strict();
|
|
24050
24051
|
external_exports.object({
|
|
24051
24052
|
token: external_exports.string().min(1, "Auth token cannot be empty"),
|
|
@@ -29005,7 +29006,11 @@ ${operationTypes.join("\n")}
|
|
|
29005
29006
|
client: external_exports.unknown().optional(),
|
|
29006
29007
|
socket: external_exports.unknown().optional(),
|
|
29007
29008
|
serverSdkVersion: external_exports.number().int().min(1).max(10).default(4),
|
|
29008
|
-
logging: external_exports.boolean().default(false)
|
|
29009
|
+
logging: external_exports.boolean().default(false),
|
|
29010
|
+
// Optional default urql request policy for reads (server/sync clients pass
|
|
29011
|
+
// 'network-only'). Permitted by the strict schema so the constructor option
|
|
29012
|
+
// isn't rejected.
|
|
29013
|
+
defaultRequestPolicy: external_exports.enum(["cache-first", "cache-only", "network-only", "cache-and-network"]).nullable().optional()
|
|
29009
29014
|
}).strict();
|
|
29010
29015
|
var EnvironmentConfigSchema = external_exports.object({
|
|
29011
29016
|
NODE_ENV: external_exports.enum(["development", "production", "test"]).default("development"),
|
|
@@ -32773,6 +32778,10 @@ ${operationTypes.join("\n")}
|
|
|
32773
32778
|
$__client;
|
|
32774
32779
|
$__serverSdkVersion = 3;
|
|
32775
32780
|
$__logging = false;
|
|
32781
|
+
// Default urql request policy applied to reads when the caller doesn't pass
|
|
32782
|
+
// one. null = urql's default (cache-first). Server/sync clients set this to
|
|
32783
|
+
// 'network-only' so a long-lived client never serves a stale cached read.
|
|
32784
|
+
$__defaultRequestPolicy = null;
|
|
32776
32785
|
$__authTokenObjects = {};
|
|
32777
32786
|
$__authToken = null;
|
|
32778
32787
|
$__authInProcess = false;
|
|
@@ -32812,13 +32821,15 @@ ${operationTypes.join("\n")}
|
|
|
32812
32821
|
serverSdkVersion = 3,
|
|
32813
32822
|
logging = false
|
|
32814
32823
|
} = validatedConfig;
|
|
32824
|
+
const defaultRequestPolicy = config.defaultRequestPolicy ?? null;
|
|
32815
32825
|
this.initialize({
|
|
32816
32826
|
uri,
|
|
32817
32827
|
cellSlug,
|
|
32818
32828
|
socket,
|
|
32819
32829
|
client,
|
|
32820
32830
|
serverSdkVersion,
|
|
32821
|
-
logging
|
|
32831
|
+
logging,
|
|
32832
|
+
defaultRequestPolicy
|
|
32822
32833
|
});
|
|
32823
32834
|
}
|
|
32824
32835
|
/**
|
|
@@ -32830,7 +32841,8 @@ ${operationTypes.join("\n")}
|
|
|
32830
32841
|
socket = null,
|
|
32831
32842
|
client = null,
|
|
32832
32843
|
serverSdkVersion = 3,
|
|
32833
|
-
logging = false
|
|
32844
|
+
logging = false,
|
|
32845
|
+
defaultRequestPolicy = null
|
|
32834
32846
|
}) {
|
|
32835
32847
|
this.reset();
|
|
32836
32848
|
this.$__logging = logging;
|
|
@@ -32852,6 +32864,7 @@ ${operationTypes.join("\n")}
|
|
|
32852
32864
|
encrypt: this.$__encrypt
|
|
32853
32865
|
});
|
|
32854
32866
|
this.$__serverSdkVersion = serverSdkVersion;
|
|
32867
|
+
this.$__defaultRequestPolicy = defaultRequestPolicy;
|
|
32855
32868
|
}
|
|
32856
32869
|
/**
|
|
32857
32870
|
* Get random uri from specified this.$__uris
|
|
@@ -32899,6 +32912,20 @@ ${operationTypes.join("\n")}
|
|
|
32899
32912
|
getServerSdkVersion() {
|
|
32900
32913
|
return this.$__serverSdkVersion;
|
|
32901
32914
|
}
|
|
32915
|
+
/**
|
|
32916
|
+
* Gets the client's default urql request policy (null = urql default).
|
|
32917
|
+
*/
|
|
32918
|
+
getDefaultRequestPolicy() {
|
|
32919
|
+
return this.$__defaultRequestPolicy;
|
|
32920
|
+
}
|
|
32921
|
+
/**
|
|
32922
|
+
* Sets the default urql request policy applied to reads that don't specify
|
|
32923
|
+
* one. Pass 'network-only' on a long-lived server/sync client so it never
|
|
32924
|
+
* serves a stale cached read; null restores urql's default (cache-first).
|
|
32925
|
+
*/
|
|
32926
|
+
setDefaultRequestPolicy(policy) {
|
|
32927
|
+
this.$__defaultRequestPolicy = policy;
|
|
32928
|
+
}
|
|
32902
32929
|
/**
|
|
32903
32930
|
* Reset common properties
|
|
32904
32931
|
*/
|
|
@@ -33103,7 +33130,8 @@ ${operationTypes.join("\n")}
|
|
|
33103
33130
|
return response;
|
|
33104
33131
|
});
|
|
33105
33132
|
}
|
|
33106
|
-
|
|
33133
|
+
const effectiveContext = this.$__defaultRequestPolicy && !context.requestPolicy ? { requestPolicy: this.$__defaultRequestPolicy, ...context } : context;
|
|
33134
|
+
return await query.execute({ variables: variables || {}, context: effectiveContext });
|
|
33107
33135
|
}
|
|
33108
33136
|
/**
|
|
33109
33137
|
* When a ProposeMolecule submission is rejected for a position-related
|