@ethlete/query 5.25.1 → 5.26.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ethlete/query
2
2
 
3
+ ## 5.26.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`ee8928e`](https://github.com/ethlete-io/ethdk/commit/ee8928ecf262690698de4a19211d6a601f66fa27) Thanks [@TomTomB](https://github.com/TomTomB)! - Make route and query primary params instead of object properties
8
+
3
9
  ## 5.25.1
4
10
 
5
11
  ### Patch Changes
@@ -3339,13 +3339,14 @@ const shouldRetryRequest = (options) => {
3339
3339
  return { retry: false };
3340
3340
  };
3341
3341
  const getQueryFeatureUsage = (options) => {
3342
- const { creator, features, queryConfig } = options;
3342
+ const { creator, features, queryConfig, creatorInternals } = options;
3343
3343
  const hasWithArgsFeature = features.some((f) => f.type == "withArgs" /* QueryFeatureType.WithArgs */);
3344
3344
  const shouldAutoExecuteMethod = isCreateGqlQueryOptions(options)
3345
3345
  ? shouldAutoExecuteGqlQuery(options.creatorInternals.method)
3346
3346
  : shouldAutoExecuteQuery(options.creatorInternals.method);
3347
3347
  const shouldAutoExecute = shouldAutoExecuteMethod && !queryConfig.onlyManualExecution;
3348
- const hasRouteFunction = typeof creator.route === 'function';
3348
+ const hasRouteFunction = typeof creatorInternals.route === 'function' ||
3349
+ typeof creator.route === 'function';
3349
3350
  if (hasRouteFunction && !hasWithArgsFeature) {
3350
3351
  throw withArgsQueryFeatureMissingButRouteIsFunction();
3351
3352
  }
@@ -4093,15 +4094,10 @@ const queryExecute = (options) => {
4093
4094
  const { executeOptions, args, executeState, options: runQueryOptions, internalOptions: internalRunQueryOptions, transformResponse, } = options;
4094
4095
  const { deps, state, creator, creatorInternals, queryConfig } = executeOptions;
4095
4096
  const { key, request } = deps.client.repository.request({
4096
- route: creator.route,
4097
+ route: creatorInternals.route,
4097
4098
  method: creatorInternals.method,
4098
4099
  args,
4099
- clientOptions: {
4100
- reportProgress: creator.reportProgress,
4101
- withCredentials: creator.withCredentials,
4102
- transferCache: creator.transferCache,
4103
- responseType: creator.responseType,
4104
- },
4100
+ clientOptions: creator,
4105
4101
  destroyRef: deps.destroyRef,
4106
4102
  key: queryConfig.key,
4107
4103
  previousKey: executeState.previousKey(),
@@ -4421,43 +4417,43 @@ const createSecureQueryCreator = (options, internals) => {
4421
4417
 
4422
4418
  /** A query creator that creates a GET query */
4423
4419
  const createGetQuery = (client) => {
4424
- return (creatorOptions) => createQueryCreator(creatorOptions, { method: 'GET', client });
4420
+ return (route, creatorOptions) => createQueryCreator(creatorOptions, { method: 'GET', client, route });
4425
4421
  };
4426
4422
  /** A query creator that creates a secure GET query (requires authentication) */
4427
4423
  const createSecureGetQuery = (client, authProvider) => {
4428
- return (creatorOptions) => createSecureQueryCreator(creatorOptions, { method: 'GET', client, authProvider });
4424
+ return (route, creatorOptions) => createSecureQueryCreator(creatorOptions, { method: 'GET', client, authProvider, route });
4429
4425
  };
4430
4426
  /** A query creator that creates a POST query */
4431
4427
  const createPostQuery = (client) => {
4432
- return (creatorOptions) => createQueryCreator(creatorOptions, { method: 'POST', client });
4428
+ return (route, creatorOptions) => createQueryCreator(creatorOptions, { method: 'POST', client, route });
4433
4429
  };
4434
4430
  /** A query creator that creates a secure POST query (requires authentication) */
4435
4431
  const createSecurePostQuery = (client, authProvider) => {
4436
- return (creatorOptions) => createSecureQueryCreator(creatorOptions, { method: 'POST', client, authProvider });
4432
+ return (route, creatorOptions) => createSecureQueryCreator(creatorOptions, { method: 'POST', client, authProvider, route });
4437
4433
  };
4438
4434
  /** A query creator that creates a PUT query */
4439
4435
  const createPutQuery = (client) => {
4440
- return (creatorOptions) => createQueryCreator(creatorOptions, { method: 'PUT', client });
4436
+ return (route, creatorOptions) => createQueryCreator(creatorOptions, { method: 'PUT', client, route });
4441
4437
  };
4442
4438
  /** A query creator that creates a secure PUT query (requires authentication) */
4443
4439
  const createSecurePutQuery = (client, authProvider) => {
4444
- return (creatorOptions) => createSecureQueryCreator(creatorOptions, { method: 'PUT', client, authProvider });
4440
+ return (route, creatorOptions) => createSecureQueryCreator(creatorOptions, { method: 'PUT', client, authProvider, route });
4445
4441
  };
4446
4442
  /** A query creator that creates a DELETE query */
4447
4443
  const createDeleteQuery = (client) => {
4448
- return (creatorOptions) => createQueryCreator(creatorOptions, { method: 'DELETE', client });
4444
+ return (route, creatorOptions) => createQueryCreator(creatorOptions, { method: 'DELETE', client, route });
4449
4445
  };
4450
4446
  /** A query creator that creates a secure DELETE query (requires authentication) */
4451
4447
  const createSecureDeleteQuery = (client, authProvider) => {
4452
- return (creatorOptions) => createSecureQueryCreator(creatorOptions, { method: 'DELETE', client, authProvider });
4448
+ return (route, creatorOptions) => createSecureQueryCreator(creatorOptions, { method: 'DELETE', client, authProvider, route });
4453
4449
  };
4454
4450
  /** A query creator that creates a PATCH query */
4455
4451
  const createPatchQuery = (client) => {
4456
- return (creatorOptions) => createQueryCreator(creatorOptions, { method: 'PATCH', client });
4452
+ return (route, creatorOptions) => createQueryCreator(creatorOptions, { method: 'PATCH', client, route });
4457
4453
  };
4458
4454
  /** A query creator that creates a secure PATCH query (requires authentication) */
4459
4455
  const createSecurePatchQuery = (client, authProvider) => {
4460
- return (creatorOptions) => createSecureQueryCreator(creatorOptions, { method: 'PATCH', client, authProvider });
4456
+ return (route, creatorOptions) => createSecureQueryCreator(creatorOptions, { method: 'PATCH', client, authProvider, route });
4461
4457
  };
4462
4458
 
4463
4459
  const createGqlExecuteFn = (executeOptions) => {
@@ -4467,7 +4463,7 @@ const createGqlExecuteFn = (executeOptions) => {
4467
4463
  const { args = executeOptions.state.args(), options } = executeArgs ?? {};
4468
4464
  cleanupPreviousExecute({ executeOptions, executeState });
4469
4465
  // TODO: This should get cleaned up
4470
- const tpl = executeOptions.creator.query;
4466
+ const tpl = executeOptions.creatorInternals.query;
4471
4467
  const query = transformGql(tpl);
4472
4468
  let gqlParams = query(args?.variables);
4473
4469
  if (args?.queryParams && executeOptions.creatorInternals.transport === 'GET') {
@@ -4481,12 +4477,11 @@ const createGqlExecuteFn = (executeOptions) => {
4481
4477
  computedArgs.body = gqlParams;
4482
4478
  }
4483
4479
  const normalizedOpts = {
4484
- creator: {
4485
- route: (executeOptions.creator.route ?? ''),
4486
- },
4480
+ creator: executeOptions.creator ?? {},
4487
4481
  creatorInternals: {
4488
4482
  client: executeOptions.creatorInternals.client,
4489
4483
  method: executeOptions.creatorInternals.transport,
4484
+ route: (executeOptions.creator?.route ?? ''),
4490
4485
  },
4491
4486
  deps: executeOptions.deps,
4492
4487
  queryConfig: executeOptions.queryConfig,
@@ -4554,19 +4549,19 @@ const createGqlQueryCreator = (options, internals) => {
4554
4549
 
4555
4550
  /** A query creator that creates a GQL query where the payload is sent via GET (query params) */
4556
4551
  const createGqlQueryViaGet = (client) => {
4557
- return (creatorOptions) => createGqlQueryCreator(creatorOptions, { method: 'QUERY', client, transport: 'GET' });
4552
+ return (query, creatorOptions) => createGqlQueryCreator(creatorOptions, { method: 'QUERY', client, transport: 'GET', query });
4558
4553
  };
4559
4554
  /** A query creator that creates a GQL query where the payload is sent via POST (body) */
4560
4555
  const createGqlQueryViaPost = (client) => {
4561
- return (creatorOptions) => createGqlQueryCreator(creatorOptions, { method: 'QUERY', client, transport: 'POST' });
4556
+ return (query, creatorOptions) => createGqlQueryCreator(creatorOptions, { method: 'QUERY', client, transport: 'POST', query });
4562
4557
  };
4563
4558
  /** A query creator that creates a GQL mutation where the payload is sent via GET (query params) */
4564
4559
  const createGqlMutationViaGet = (client) => {
4565
- return (creatorOptions) => createGqlQueryCreator(creatorOptions, { method: 'MUTATE', client, transport: 'GET' });
4560
+ return (query, creatorOptions) => createGqlQueryCreator(creatorOptions, { method: 'MUTATE', client, transport: 'GET', query });
4566
4561
  };
4567
4562
  /** A query creator that creates a GQL mutation where the payload is sent via POST (body) */
4568
4563
  const createGqlMutationViaPost = (client) => {
4569
- return (creatorOptions) => createGqlQueryCreator(creatorOptions, { method: 'MUTATE', client, transport: 'POST' });
4564
+ return (query, creatorOptions) => createGqlQueryCreator(creatorOptions, { method: 'MUTATE', client, transport: 'POST', query });
4570
4565
  };
4571
4566
 
4572
4567
  const roomNotJoined = (room) => {