@wishknish/knishio-client-ts 0.8.0 → 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
@@ -30942,6 +30942,7 @@ ${operationTypes.join("\n")}
30942
30942
  metaId
30943
30943
  jsonData
30944
30944
  createdAt
30945
+ updatedAt
30945
30946
  }
30946
30947
  }
30947
30948
  `;
@@ -33086,7 +33087,7 @@ ${operationTypes.join("\n")}
33086
33087
  /**
33087
33088
  * Executes a query or mutation
33088
33089
  */
33089
- async executeQuery(query, variables = null) {
33090
+ async executeQuery(query, variables = null, context = {}) {
33090
33091
  if (this.$__authToken && this.$__authToken.isExpired() && !this.$__authInProcess) {
33091
33092
  this.log("info", "KnishIOClient::executeQuery() - Access token is expired. Getting new one...");
33092
33093
  await this.requestAuthToken({
@@ -33102,7 +33103,7 @@ ${operationTypes.join("\n")}
33102
33103
  return response;
33103
33104
  });
33104
33105
  }
33105
- return await query.execute({ variables: variables || {} });
33106
+ return await query.execute({ variables: variables || {}, context });
33106
33107
  }
33107
33108
  /**
33108
33109
  * When a ProposeMolecule submission is rejected for a position-related
@@ -33435,7 +33436,8 @@ ${operationTypes.join("\n")}
33435
33436
  throughMolecule = false,
33436
33437
  values = null,
33437
33438
  keys = null,
33438
- atomValues = null
33439
+ atomValues = null,
33440
+ requestPolicy = null
33439
33441
  }) {
33440
33442
  this.log("info", `KnishIOClient::queryMeta() - Querying metaType: ${metaType}, metaId: ${metaId}...`);
33441
33443
  let query;
@@ -33487,7 +33489,8 @@ ${operationTypes.join("\n")}
33487
33489
  cellSlug: this.getCellSlug()
33488
33490
  });
33489
33491
  }
33490
- return this.executeQuery(query, variables);
33492
+ const context = requestPolicy ? { requestPolicy } : {};
33493
+ return this.executeQuery(query, variables, context);
33491
33494
  }
33492
33495
  /**
33493
33496
  * Queries meta assets and verifies cryptographic integrity of associated molecules.