@wishknish/knishio-client-ts 0.8.1 → 0.8.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.
package/dist/index.d.cts CHANGED
@@ -278,6 +278,7 @@ interface GraphQLRequest {
278
278
  query: string;
279
279
  variables?: Record<string, unknown>;
280
280
  operationName?: string | null;
281
+ context?: Record<string, unknown>;
281
282
  }
282
283
  interface GraphQLResponse<T = unknown> {
283
284
  data?: T | null;
@@ -1177,7 +1178,7 @@ declare class KnishIOClient {
1177
1178
  molecule?: Molecule | null;
1178
1179
  }): Promise<T>;
1179
1180
  private withMoleculeLock;
1180
- executeQuery(query: Query | Mutation, variables?: Record<string, any> | null): Promise<Response | null>;
1181
+ executeQuery(query: Query | Mutation, variables?: Record<string, any> | null, context?: Record<string, any>): Promise<Response | null>;
1181
1182
  private handlePositionDrift;
1182
1183
  setSecret(secret: string): void;
1183
1184
  setAuthToken(authToken: AuthToken): void;
@@ -1226,7 +1227,7 @@ declare class KnishIOClient {
1226
1227
  queryContinuId({ bundle }: {
1227
1228
  bundle: BundleHash | string;
1228
1229
  }): Promise<Response>;
1229
- queryMeta({ metaType, metaId, key, value, latest, fields: _fields, filter, queryArgs, count, countBy, throughAtom, throughMolecule, values, keys, atomValues }: {
1230
+ queryMeta({ metaType, metaId, key, value, latest, fields: _fields, filter, queryArgs, count, countBy, throughAtom, throughMolecule, values, keys, atomValues, requestPolicy }: {
1230
1231
  metaType: MetaType | string;
1231
1232
  metaId?: MetaId | string | null;
1232
1233
  key?: string | null;
@@ -1242,6 +1243,7 @@ declare class KnishIOClient {
1242
1243
  values?: any[] | null;
1243
1244
  keys?: string[] | null;
1244
1245
  atomValues?: any[] | null;
1246
+ requestPolicy?: 'cache-first' | 'cache-only' | 'network-only' | 'cache-and-network' | null;
1245
1247
  }): Promise<Response>;
1246
1248
  queryMetaVerified(params: {
1247
1249
  metaType: MetaType | string;
package/dist/index.d.ts CHANGED
@@ -278,6 +278,7 @@ interface GraphQLRequest {
278
278
  query: string;
279
279
  variables?: Record<string, unknown>;
280
280
  operationName?: string | null;
281
+ context?: Record<string, unknown>;
281
282
  }
282
283
  interface GraphQLResponse<T = unknown> {
283
284
  data?: T | null;
@@ -1177,7 +1178,7 @@ declare class KnishIOClient {
1177
1178
  molecule?: Molecule | null;
1178
1179
  }): Promise<T>;
1179
1180
  private withMoleculeLock;
1180
- executeQuery(query: Query | Mutation, variables?: Record<string, any> | null): Promise<Response | null>;
1181
+ executeQuery(query: Query | Mutation, variables?: Record<string, any> | null, context?: Record<string, any>): Promise<Response | null>;
1181
1182
  private handlePositionDrift;
1182
1183
  setSecret(secret: string): void;
1183
1184
  setAuthToken(authToken: AuthToken): void;
@@ -1226,7 +1227,7 @@ declare class KnishIOClient {
1226
1227
  queryContinuId({ bundle }: {
1227
1228
  bundle: BundleHash | string;
1228
1229
  }): Promise<Response>;
1229
- queryMeta({ metaType, metaId, key, value, latest, fields: _fields, filter, queryArgs, count, countBy, throughAtom, throughMolecule, values, keys, atomValues }: {
1230
+ queryMeta({ metaType, metaId, key, value, latest, fields: _fields, filter, queryArgs, count, countBy, throughAtom, throughMolecule, values, keys, atomValues, requestPolicy }: {
1230
1231
  metaType: MetaType | string;
1231
1232
  metaId?: MetaId | string | null;
1232
1233
  key?: string | null;
@@ -1242,6 +1243,7 @@ declare class KnishIOClient {
1242
1243
  values?: any[] | null;
1243
1244
  keys?: string[] | null;
1244
1245
  atomValues?: any[] | null;
1246
+ requestPolicy?: 'cache-first' | 'cache-only' | 'network-only' | 'cache-and-network' | null;
1245
1247
  }): Promise<Response>;
1246
1248
  queryMetaVerified(params: {
1247
1249
  metaType: MetaType | string;
@@ -28486,14 +28486,14 @@ ${operationTypes.join("\n")}
28486
28486
  });
28487
28487
  }
28488
28488
  async query(request) {
28489
- const { query, variables } = request;
28490
- const result = await this.$__client.query(query, variables || {}).toPromise();
28489
+ const { query, variables, context } = request;
28490
+ const result = await this.$__client.query(query, variables || {}, context).toPromise();
28491
28491
  return this.formatResponse(result);
28492
28492
  }
28493
28493
  async mutation(request) {
28494
- const { query, variables } = request;
28494
+ const { query, variables, context } = request;
28495
28495
  const mutationString = request.mutation || query;
28496
- const result = await this.$__client.mutation(mutationString, variables || {}).toPromise();
28496
+ const result = await this.$__client.mutation(mutationString, variables || {}, context).toPromise();
28497
28497
  return this.formatResponse(result);
28498
28498
  }
28499
28499
  // Alias for mutation() to match JS SDK interface
@@ -33087,7 +33087,7 @@ ${operationTypes.join("\n")}
33087
33087
  /**
33088
33088
  * Executes a query or mutation
33089
33089
  */
33090
- async executeQuery(query, variables = null) {
33090
+ async executeQuery(query, variables = null, context = {}) {
33091
33091
  if (this.$__authToken && this.$__authToken.isExpired() && !this.$__authInProcess) {
33092
33092
  this.log("info", "KnishIOClient::executeQuery() - Access token is expired. Getting new one...");
33093
33093
  await this.requestAuthToken({
@@ -33103,7 +33103,7 @@ ${operationTypes.join("\n")}
33103
33103
  return response;
33104
33104
  });
33105
33105
  }
33106
- return await query.execute({ variables: variables || {} });
33106
+ return await query.execute({ variables: variables || {}, context });
33107
33107
  }
33108
33108
  /**
33109
33109
  * When a ProposeMolecule submission is rejected for a position-related
@@ -33436,7 +33436,8 @@ ${operationTypes.join("\n")}
33436
33436
  throughMolecule = false,
33437
33437
  values = null,
33438
33438
  keys = null,
33439
- atomValues = null
33439
+ atomValues = null,
33440
+ requestPolicy = null
33440
33441
  }) {
33441
33442
  this.log("info", `KnishIOClient::queryMeta() - Querying metaType: ${metaType}, metaId: ${metaId}...`);
33442
33443
  let query;
@@ -33488,7 +33489,8 @@ ${operationTypes.join("\n")}
33488
33489
  cellSlug: this.getCellSlug()
33489
33490
  });
33490
33491
  }
33491
- return this.executeQuery(query, variables);
33492
+ const context = requestPolicy ? { requestPolicy } : {};
33493
+ return this.executeQuery(query, variables, context);
33492
33494
  }
33493
33495
  /**
33494
33496
  * Queries meta assets and verifies cryptographic integrity of associated molecules.