How to use the @algolia/client-common.encode function in @algolia/client-common

To help you get started, we’ve selected a few @algolia/client-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algolia / algoliasearch-client-javascript / packages / transporter / src / __tests__ / fixtures.ts View on Github external
request(options: any = {}): Request {
      const headers: { readonly [key: string]: string } = {
        'X-Default-Header': 'Default value',
      };

      if (options.url !== undefined) {
        // eslint-disable-next-line no-param-reassign
        options.url +=
          (options.url.includes('?') ? '&' : '?') +
          encode('%s=%s', 'x-algolia-agent', `Algolia for JavaScript (${version}); Browser`);
      }

      return {
        data: '{}',
        headers,
        method: MethodEnum.Post,
        connectTimeout: 1,
        responseTimeout: 2,
        ...options,
      };
    },
  };
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / clearSynonyms.ts View on Github external
return (
    requestOptions?: ClearSynonymsOptions & RequestOptions
  ): Readonly> => {
    const { forwardToReplicas, ...options } = requestOptions || {};

    const mappedRequestOptions = createMappedRequestOptions(options);
    if (forwardToReplicas) {
      mappedRequestOptions.queryParameters.forwardToReplicas = 1; // eslint-disable-line functional/immutable-data
    }

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Post,
          path: encode('1/indexes/%s/synonyms/clear', base.indexName),
        },
        mappedRequestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / getSettings.ts View on Github external
return (requestOptions?: RequestOptions): Readonly> => {
    const mappedRequestOptions = createMappedRequestOptions(requestOptions);

    // eslint-disable-next-line functional/immutable-data
    mappedRequestOptions.queryParameters.getVersion = '2';

    return base.transporter.read(
      {
        method: MethodEnum.Get,
        path: encode('1/indexes/%s/settings', base.indexName),
      },
      mappedRequestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / transporter / src / serializer.ts View on Github external
.map(key =>
      encode(
        '%s=%s',
        key,
        isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key]
      )
    )
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / client / updateApiKey.ts View on Github external
);
        });
    };

    const wait: Wait = (_, waitRequestOptions) =>
      createRetryablePromise(retry => {
        return getApiKey(base)(apiKey, waitRequestOptions).then(getApiKeyResponse => {
          return hasChanged(getApiKeyResponse) ? Promise.resolve() : retry();
        });
      });

    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Put,
          path: encode('1/keys/%s', apiKey),
          data,
        },
        options
      ),
      wait
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / searchSynonyms.ts View on Github external
return (
    query: string,
    requestOptions?: SearchSynonymsOptions & RequestOptions
  ): Readonly> => {
    return base.transporter.read(
      {
        method: MethodEnum.Post,
        path: encode('1/indexes/%s/synonyms/search', base.indexName),
        data: {
          query,
        },
      },
      requestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / deleteIndex.ts View on Github external
return (requestOptions?: RequestOptions): Readonly> => {
    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Delete,
          path: encode('1/indexes/%s', base.indexName),
        },
        requestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / clearObjects.ts View on Github external
return (requestOptions?: RequestOptions): Readonly> => {
    return createWaitablePromise(
      base.transporter.write(
        {
          method: MethodEnum.Post,
          path: encode('1/indexes/%s/clear', base.indexName),
        },
        requestOptions
      ),
      (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / searchRules.ts View on Github external
return (
    query: string,
    requestOptions?: RequestOptions & SearchRulesOptions
  ): Readonly>> => {
    return base.transporter.read(
      {
        method: MethodEnum.Post,
        path: encode('1/indexes/%s/rules/search', base.indexName),
        data: {
          query,
        },
      },
      requestOptions
    );
  };
};
github algolia / algoliasearch-client-javascript / packages / client-search / src / methods / index / replaceAllObjects.ts View on Github external
const operation = (
      from: string,
      to: string,
      type: string,
      operatioRequestOptions?: RequestOptions
    ): Readonly> => {
      return createWaitablePromise(
        base.transporter.write(
          {
            method: MethodEnum.Post,
            path: encode('1/indexes/%s/operation', from),
            data: {
              operation: type,
              destination: to,
            },
          },
          operatioRequestOptions
        ),
        (response, waitRequestOptions) => waitTask(base)(response.taskID, waitRequestOptions)
      );
    };

@algolia/client-common

Common package for the Algolia JavaScript API client.

MIT
Latest version published 2 days ago

Package Health Score

85 / 100
Full package analysis

Similar packages