@ethlete/query 5.33.1 → 5.33.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ethlete/query
2
2
 
3
+ ## 5.33.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c4f21f5`](https://github.com/ethlete-io/ethdk/commit/c4f21f5e69a6379d19989bc15ddfd86ca7eacdbd) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix gql query param parsing
8
+
9
+ ## 5.33.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`4fa6338`](https://github.com/ethlete-io/ethdk/commit/4fa63386c3af60d7843efb59592f7416b04330ac) Thanks [@TomTomB](https://github.com/TomTomB)! - Fix web socket throwing an injection error
14
+
3
15
  ## 5.33.1
4
16
 
5
17
  ### Patch Changes
@@ -122,7 +122,10 @@ const buildQueryString = (params, config) => {
122
122
  const ignoredValuesFns = config?.ignoredValuesFns ?? [isNaN$1, isEmptyString];
123
123
  const queryParams = [];
124
124
  function processValue(key, value) {
125
- if (config?.useJsonStringify) {
125
+ if (config?.objectNotation === 'json-stringify') {
126
+ if (value === undefined) {
127
+ return false;
128
+ }
126
129
  if (ignoredValues.includes(value)) {
127
130
  return false;
128
131
  }
@@ -130,7 +133,8 @@ const buildQueryString = (params, config) => {
130
133
  return false;
131
134
  }
132
135
  const encodedKey = encodeURIComponent(key);
133
- const encodedValue = encodeURIComponent(JSON.stringify(value));
136
+ const val = typeof value === 'object' ? JSON.stringify(value) : value;
137
+ const encodedValue = encodeURIComponent(val);
134
138
  queryParams.push(`${encodedKey}=${encodedValue}`);
135
139
  return true;
136
140
  }
@@ -716,19 +720,12 @@ class QueryCreator {
716
720
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
717
721
  // @ts-ignore
718
722
  this.prepare = (args) => {
719
- const shouldUseJsonStringifyForQs = isGqlQueryConfig(this._queryConfig) &&
720
- (this._queryConfig.transferVia === 'GET' ||
721
- (this._client.config.request?.gql?.transferVia === 'GET' && !this._queryConfig.transferVia));
722
- const originalQueryParams = this._client.config.request?.queryParams;
723
- const queryParamConfig = originalQueryParams
724
- ? { ...originalQueryParams, useJsonStringify: shouldUseJsonStringifyForQs }
725
- : undefined;
726
723
  const route = buildRoute({
727
724
  base: this._client.config.baseRoute,
728
725
  route: this._queryConfig.route,
729
726
  pathParams: args?.pathParams,
730
727
  queryParams: computeQueryQueryParams({ config: this._queryConfig, client: this._client, args }),
731
- queryParamConfig,
728
+ queryParamConfig: this._client.config.request?.queryParams,
732
729
  });
733
730
  const cacheKey = (args?.config?.queryStoreCacheKey ?? '') + buildQueryCacheKey$1(route, args);
734
731
  if (shouldCacheQuery$1(this._queryConfig.method) && !args?.config?.skipQueryStore) {
@@ -1007,17 +1004,19 @@ const getOpName = /(query|mutation) ?([\w\d-_]+)? ?\(.*?\)? \{/;
1007
1004
  const transformGql = (str) => {
1008
1005
  str = Array.isArray(str) ? str.join('') : str;
1009
1006
  const name = getOpName.exec(str);
1010
- return function (variables) {
1007
+ return (variables) => {
1011
1008
  const data = { query: str };
1012
1009
  if (variables)
1013
- data['variables'] = variables;
1010
+ data['variables'] = JSON.stringify(variables);
1014
1011
  if (name && name.length) {
1015
1012
  const operationName = name[2];
1016
1013
  if (operationName)
1017
1014
  data['operationName'] = name[2];
1018
1015
  }
1019
- // minify the query
1020
- data.query = data.query.replace(/\s+/g, ' ').trim();
1016
+ if (!isDevMode()) {
1017
+ // minify the query
1018
+ data.query = data.query.replace(/\s+/g, ' ').trim();
1019
+ }
1021
1020
  return data;
1022
1021
  };
1023
1022
  };
@@ -4338,9 +4337,7 @@ const createQueryRepository = (config) => {
4338
4337
  route: options.route,
4339
4338
  pathParams: args?.pathParams,
4340
4339
  queryParams: args?.queryParams,
4341
- queryParamConfig: options.internalRunQueryOptions?.forceJsonStringifyInQueryParams
4342
- ? { useJsonStringify: true }
4343
- : config.queryString,
4340
+ queryParamConfig: config.queryString,
4344
4341
  });
4345
4342
  const key = shouldCache &&
4346
4343
  buildQueryCacheKey(`${options.key ? options.key + '_' : ''}${route}`, {
@@ -4694,7 +4691,6 @@ const createGqlExecuteFn = (executeOptions) => {
4694
4691
  options,
4695
4692
  internalOptions: {
4696
4693
  useQueryRepositoryCache: executeOptions.creatorInternals.method === 'QUERY',
4697
- forceJsonStringifyInQueryParams: executeOptions.creatorInternals.method === 'QUERY',
4698
4694
  },
4699
4695
  transformResponse: (originalResponse) => {
4700
4696
  if (originalResponse && 'data' in originalResponse) {
@@ -5186,6 +5182,8 @@ const createWebSocketClient = (config) => {
5186
5182
  const isConnected = signal(false);
5187
5183
  const joinRoom = (room) => {
5188
5184
  const roomFn = typeof room === 'function' ? room : () => room;
5185
+ const pre = previousSignalValue(computed(() => roomFn()));
5186
+ const roomData = signal(null);
5189
5187
  const join = (name) => {
5190
5188
  socket.emit('join-room', name);
5191
5189
  const existingRoom = rooms.get(name);
@@ -5198,8 +5196,6 @@ const createWebSocketClient = (config) => {
5198
5196
  rooms.set(name, newRoom);
5199
5197
  return newRoom;
5200
5198
  };
5201
- const pre = previousSignalValue(computed(() => roomFn()));
5202
- const roomData = signal(null);
5203
5199
  effect(() => {
5204
5200
  const current = roomFn();
5205
5201
  untracked(() => {
@@ -5239,7 +5235,7 @@ const createWebSocketClient = (config) => {
5239
5235
  socket.on('connect', () => {
5240
5236
  isConnected.set(true);
5241
5237
  for (const room of rooms.keys()) {
5242
- joinRoom(room);
5238
+ socket.emit('join-room', room);
5243
5239
  }
5244
5240
  });
5245
5241
  socket.on('disconnect', () => isConnected.set(false));