@esri/arcgis-rest-places 1.0.2 → 1.1.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/dist/bundled/places.esm.js +7 -7
- package/dist/bundled/places.esm.js.map +1 -1
- package/dist/bundled/places.esm.min.js +3 -3
- package/dist/bundled/places.esm.min.js.map +1 -1
- package/dist/bundled/places.umd.js +7 -7
- package/dist/bundled/places.umd.js.map +1 -1
- package/dist/bundled/places.umd.min.js +3 -3
- package/dist/bundled/places.umd.min.js.map +1 -1
- package/dist/cjs/findPlacesNearPoint.js +1 -1
- package/dist/cjs/findPlacesNearPoint.js.map +1 -1
- package/dist/cjs/findPlacesWithinExtent.js +1 -1
- package/dist/cjs/findPlacesWithinExtent.js.map +1 -1
- package/dist/cjs/getCategories.js +1 -1
- package/dist/cjs/getCategories.js.map +1 -1
- package/dist/cjs/getCategory.js +1 -1
- package/dist/cjs/getCategory.js.map +1 -1
- package/dist/cjs/getPlaceDetails.js +1 -1
- package/dist/cjs/getPlaceDetails.js.map +1 -1
- package/dist/esm/findPlacesNearPoint.d.ts +5 -0
- package/dist/esm/findPlacesNearPoint.js +1 -1
- package/dist/esm/findPlacesNearPoint.js.map +1 -1
- package/dist/esm/findPlacesWithinExtent.d.ts +5 -0
- package/dist/esm/findPlacesWithinExtent.js +1 -1
- package/dist/esm/findPlacesWithinExtent.js.map +1 -1
- package/dist/esm/getCategories.d.ts +5 -0
- package/dist/esm/getCategories.js +1 -1
- package/dist/esm/getCategories.js.map +1 -1
- package/dist/esm/getCategory.d.ts +5 -0
- package/dist/esm/getCategory.js +1 -1
- package/dist/esm/getCategory.js.map +1 -1
- package/dist/esm/getPlaceDetails.d.ts +5 -0
- package/dist/esm/getPlaceDetails.js +1 -1
- package/dist/esm/getPlaceDetails.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-places - v1.0.
|
|
2
|
+
* @esri/arcgis-rest-places - v1.0.2 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2024 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Tue Jun 18 2024 23:49:53 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
6
|
import { appendCustomParams, request } from '@esri/arcgis-rest-request';
|
|
7
7
|
|
|
@@ -55,7 +55,7 @@ function getNextPageParams(currentOffset = 0, currentPageSize = 10) {
|
|
|
55
55
|
*/
|
|
56
56
|
function findPlacesNearPoint(requestOptions) {
|
|
57
57
|
const options = appendCustomParams(requestOptions, ["x", "y", "radius", "categoryIds", "pageSize", "offset", "searchText"], Object.assign({}, requestOptions));
|
|
58
|
-
return request(`${baseUrl}/places/near-point`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
58
|
+
return request(requestOptions.endpoint || `${baseUrl}/places/near-point`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
59
59
|
const r = Object.assign({}, response);
|
|
60
60
|
if (hasNextPage(response)) {
|
|
61
61
|
r.nextPage = () => {
|
|
@@ -115,7 +115,7 @@ function findPlacesWithinExtent(requestOptions) {
|
|
|
115
115
|
"offset",
|
|
116
116
|
"searchText"
|
|
117
117
|
], Object.assign({}, requestOptions));
|
|
118
|
-
return request(`${baseUrl}/places/within-extent`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
118
|
+
return request(requestOptions.endpoint || `${baseUrl}/places/within-extent`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
119
119
|
const r = Object.assign({}, response);
|
|
120
120
|
if (hasNextPage(response)) {
|
|
121
121
|
r.nextPage = () => {
|
|
@@ -158,7 +158,7 @@ function findPlacesWithinExtent(requestOptions) {
|
|
|
158
158
|
function getPlaceDetails(requestOptions) {
|
|
159
159
|
const { placeId } = requestOptions;
|
|
160
160
|
const options = appendCustomParams(requestOptions, ["requestedFields"], Object.assign({}, requestOptions));
|
|
161
|
-
return request(`${baseUrl}/places/${placeId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
161
|
+
return request(requestOptions.endpoint || `${baseUrl}/places/${placeId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
/**
|
|
@@ -185,7 +185,7 @@ function getPlaceDetails(requestOptions) {
|
|
|
185
185
|
*/
|
|
186
186
|
function getCategories(requestOptions) {
|
|
187
187
|
const options = appendCustomParams(requestOptions, ["filter"], Object.assign({}, requestOptions));
|
|
188
|
-
return request(`${baseUrl}/categories`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
188
|
+
return request(requestOptions.endpoint || `${baseUrl}/categories`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
@@ -206,7 +206,7 @@ function getCategories(requestOptions) {
|
|
|
206
206
|
function getCategory(requestOptions) {
|
|
207
207
|
const { categoryId } = requestOptions;
|
|
208
208
|
const options = appendCustomParams(requestOptions, [], Object.assign({}, requestOptions));
|
|
209
|
-
return request(`${baseUrl}/categories/${categoryId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
209
|
+
return request(requestOptions.endpoint || `${baseUrl}/categories/${categoryId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
export { findPlacesNearPoint, findPlacesWithinExtent, getCategories, getCategory, getPlaceDetails };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"places.esm.js","sources":["../../src/utils.ts","../../src/findPlacesNearPoint.ts","../../src/findPlacesWithinExtent.ts","../../src/getPlaceDetails.ts","../../src/getCategories.ts","../../src/getCategory.ts"],"sourcesContent":["export const baseUrl =\n \"https://places-api.arcgis.com/arcgis/rest/services/places-service/v1\";\n\nexport function hasNextPage(response: any) {\n return !!response?.links?.next || !!response?.pagination?.nextUrl;\n}\n\nexport function getNextPageParams(currentOffset = 0, currentPageSize = 10) {\n return {\n offset: currentOffset + currentPageSize,\n pageSize: currentPageSize\n };\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"nearPointGet\"][\"parameters\"][\"query\"],\n \"x\" | \"y\" | \"radius\" | \"categoryIds\" | \"pageSize\" | \"offset\" | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"nearPointGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesNearPoint};\n */\nexport interface IFindPlacesNearPointResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesNearPointResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlacesNearPointOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * Searches places that are within a given radius of a geographic point.\n * You must supply the `x` and `y` coordinates of the point that you wish\n * to search from. You can either specify a search radius, or use the\n * default (500 meters). You could use this method to search for places\n * around a user's GPS position, or a location clicked on a map.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```js\n * import { findPlacesNearPoint } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await findPlacesNearPoint({\n * x: -3.1883,\n * y: 55.9533,\n * radius: 100,\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\");\n * });\n *\n * console.log(response);\n * ```\n */\nexport function findPlacesNearPoint(\n requestOptions: IFindPlacesNearPointOptions\n): Promise<IFindPlacesNearPointResponse> {\n const options = appendCustomParams<IFindPlacesNearPointOptions>(\n requestOptions,\n [\"x\", \"y\", \"radius\", \"categoryIds\", \"pageSize\", \"offset\", \"searchText\"],\n {\n ...requestOptions\n }\n );\n\n return (\n request(`${baseUrl}/places/near-point`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesNearPointResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesNearPoint(nextOptions);\n };\n }\n\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"withinExtentGet\"][\"parameters\"][\"query\"],\n | \"xmin\"\n | \"ymin\"\n | \"xmax\"\n | \"ymax\"\n | \"categoryIds\"\n | \"pageSize\"\n | \"offset\"\n | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"withinExtentGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesWithinExtent};\n */\nexport interface IFindPlacesWithinExtentResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesWithinExtentResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlaceWithinExtentOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * Searches the world-wide set of places for those that are within an\n * extent, or bounding box. You must supply the `xmin`, `ymin`, `xmax` and\n * `ymax` coordinates of the extent. You could use this endpoint to search\n * for places in the visible extent of a user's screen.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can also refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```\n * import { findPlacesWithinExtent } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const results = await findPlacesWithinExtent({\n * xmin: -118.013334,\n * ymin: 33.78193,\n * xmax: -117.795753,\n * ymax: 33.873337,\n * categoryIds: [\"13002\"],\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(results)\n * ```\n */\nexport function findPlacesWithinExtent(\n requestOptions: IFindPlaceWithinExtentOptions\n): Promise<IFindPlacesWithinExtentResponse> {\n const options = appendCustomParams<IFindPlaceWithinExtentOptions>(\n requestOptions,\n [\n \"xmin\",\n \"ymin\",\n \"xmax\",\n \"ymax\",\n \"categoryIds\",\n \"pageSize\",\n \"offset\",\n \"searchText\"\n ],\n {\n ...requestOptions\n }\n );\n\n return (\n request(`${baseUrl}/places/within-extent`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesWithinExtentResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesWithinExtent(nextOptions);\n };\n }\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"placeIdGet\"][\"parameters\"][\"query\"],\n \"requestedFields\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"placeIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getPlace};\n */\nexport interface IGetPlaceResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getPlace}.\n */\nexport interface IGetPlaceOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n placeId: string;\n}\n\n/**\n * Returns a single place, including additional details, such as:\n *\n * - contact details\n * - address\n * - price information\n * - user rating\n * - opening hours\n *\n * This endpoint can be used to fetch additional details for a specific\n * place, returned from a places search request.\n *\n * Note that some fields, such as opening hours, are not available for\n * every place. Where a field is not available it will be omitted from the\n * response and you will not be charged for this data.\n *\n * ```js\n * import { getPlaceDetails } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const place = getPlaceDetails({\n * placeId: \"e78051acc722c55ab11ba930d8dd7772\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(place);\n * ```\n */\nexport function getPlaceDetails(\n requestOptions: IGetPlaceOptions\n): Promise<IGetPlaceResponse> {\n const { placeId } = requestOptions;\n\n const options = appendCustomParams<IGetPlaceOptions>(\n requestOptions,\n [\"requestedFields\"],\n {\n ...requestOptions\n }\n );\n\n return request(`${baseUrl}/places/${placeId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"categoriesGet\"][\"parameters\"][\"query\"],\n \"filter\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategories};\n */\nexport interface IGetCategoriesResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategories}.\n */\nexport interface IGetCategoriesOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * The ArcGIS Places service has many categories (or types) of place, from\n * art museums to zoos. This endpoint returns all the categories including\n * their label and `categoryId`. The category Id can be used to search for\n * types of places with a `places/near-point` or `places/within-extent`\n * request.\n *\n * Categories also have information on their `parent`. This allows you to\n * search for specific categories such as \"French Restaurant\" - or to\n * look for more generic types such as \"Restaurant\".\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await getCategories({\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response.categories);\n * ```\n */\nexport function getCategories(\n requestOptions: IGetCategoriesOptions\n): Promise<IGetCategoriesResponse> {\n const options = appendCustomParams<IGetCategoriesOptions>(\n requestOptions,\n [\"filter\"],\n {\n ...requestOptions\n }\n );\n\n return request(`${baseUrl}/categories`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = operations[\"categoriesCategoryIdGet\"][\"parameters\"][\"query\"];\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesCategoryIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategory};\n */\nexport interface IGetCategoryResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategory}.\n */\nexport interface IGetCategoryOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n categoryId: string;\n}\n\n/**\n * Returns details about a single category by Id.\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = getCategory({\n * categoryId: \"10000\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response);\n * ```\n **/\nexport function getCategory(\n requestOptions: IGetCategoryOptions\n): Promise<IGetCategoryResponse> {\n const { categoryId } = requestOptions;\n\n const options = appendCustomParams<IGetCategoryOptions>(requestOptions, [], {\n ...requestOptions\n });\n\n return request(`${baseUrl}/categories/${categoryId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n"],"names":[],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"places.esm.js","sources":["../../src/utils.ts","../../src/findPlacesNearPoint.ts","../../src/findPlacesWithinExtent.ts","../../src/getPlaceDetails.ts","../../src/getCategories.ts","../../src/getCategory.ts"],"sourcesContent":["export const baseUrl =\n \"https://places-api.arcgis.com/arcgis/rest/services/places-service/v1\";\n\nexport function hasNextPage(response: any) {\n return !!response?.links?.next || !!response?.pagination?.nextUrl;\n}\n\nexport function getNextPageParams(currentOffset = 0, currentPageSize = 10) {\n return {\n offset: currentOffset + currentPageSize,\n pageSize: currentPageSize\n };\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"nearPointGet\"][\"parameters\"][\"query\"],\n \"x\" | \"y\" | \"radius\" | \"categoryIds\" | \"pageSize\" | \"offset\" | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"nearPointGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesNearPoint};\n */\nexport interface IFindPlacesNearPointResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesNearPointResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlacesNearPointOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches places that are within a given radius of a geographic point.\n * You must supply the `x` and `y` coordinates of the point that you wish\n * to search from. You can either specify a search radius, or use the\n * default (500 meters). You could use this method to search for places\n * around a user's GPS position, or a location clicked on a map.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```js\n * import { findPlacesNearPoint } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await findPlacesNearPoint({\n * x: -3.1883,\n * y: 55.9533,\n * radius: 100,\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\");\n * });\n *\n * console.log(response);\n * ```\n */\nexport function findPlacesNearPoint(\n requestOptions: IFindPlacesNearPointOptions\n): Promise<IFindPlacesNearPointResponse> {\n const options = appendCustomParams<IFindPlacesNearPointOptions>(\n requestOptions,\n [\"x\", \"y\", \"radius\", \"categoryIds\", \"pageSize\", \"offset\", \"searchText\"],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/near-point`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesNearPointResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesNearPoint(nextOptions);\n };\n }\n\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"withinExtentGet\"][\"parameters\"][\"query\"],\n | \"xmin\"\n | \"ymin\"\n | \"xmax\"\n | \"ymax\"\n | \"categoryIds\"\n | \"pageSize\"\n | \"offset\"\n | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"withinExtentGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesWithinExtent};\n */\nexport interface IFindPlacesWithinExtentResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesWithinExtentResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlaceWithinExtentOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches the world-wide set of places for those that are within an\n * extent, or bounding box. You must supply the `xmin`, `ymin`, `xmax` and\n * `ymax` coordinates of the extent. You could use this endpoint to search\n * for places in the visible extent of a user's screen.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can also refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```\n * import { findPlacesWithinExtent } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const results = await findPlacesWithinExtent({\n * xmin: -118.013334,\n * ymin: 33.78193,\n * xmax: -117.795753,\n * ymax: 33.873337,\n * categoryIds: [\"13002\"],\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(results)\n * ```\n */\nexport function findPlacesWithinExtent(\n requestOptions: IFindPlaceWithinExtentOptions\n): Promise<IFindPlacesWithinExtentResponse> {\n const options = appendCustomParams<IFindPlaceWithinExtentOptions>(\n requestOptions,\n [\n \"xmin\",\n \"ymin\",\n \"xmax\",\n \"ymax\",\n \"categoryIds\",\n \"pageSize\",\n \"offset\",\n \"searchText\"\n ],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/within-extent`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesWithinExtentResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesWithinExtent(nextOptions);\n };\n }\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"placeIdGet\"][\"parameters\"][\"query\"],\n \"requestedFields\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"placeIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getPlace};\n */\nexport interface IGetPlaceResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getPlace}.\n */\nexport interface IGetPlaceOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n placeId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns a single place, including additional details, such as:\n *\n * - contact details\n * - address\n * - price information\n * - user rating\n * - opening hours\n *\n * This endpoint can be used to fetch additional details for a specific\n * place, returned from a places search request.\n *\n * Note that some fields, such as opening hours, are not available for\n * every place. Where a field is not available it will be omitted from the\n * response and you will not be charged for this data.\n *\n * ```js\n * import { getPlaceDetails } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const place = getPlaceDetails({\n * placeId: \"e78051acc722c55ab11ba930d8dd7772\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(place);\n * ```\n */\nexport function getPlaceDetails(\n requestOptions: IGetPlaceOptions\n): Promise<IGetPlaceResponse> {\n const { placeId } = requestOptions;\n\n const options = appendCustomParams<IGetPlaceOptions>(\n requestOptions,\n [\"requestedFields\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/places/${placeId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"categoriesGet\"][\"parameters\"][\"query\"],\n \"filter\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategories};\n */\nexport interface IGetCategoriesResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategories}.\n */\nexport interface IGetCategoriesOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * The ArcGIS Places service has many categories (or types) of place, from\n * art museums to zoos. This endpoint returns all the categories including\n * their label and `categoryId`. The category Id can be used to search for\n * types of places with a `places/near-point` or `places/within-extent`\n * request.\n *\n * Categories also have information on their `parent`. This allows you to\n * search for specific categories such as \"French Restaurant\" - or to\n * look for more generic types such as \"Restaurant\".\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await getCategories({\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response.categories);\n * ```\n */\nexport function getCategories(\n requestOptions: IGetCategoriesOptions\n): Promise<IGetCategoriesResponse> {\n const options = appendCustomParams<IGetCategoriesOptions>(\n requestOptions,\n [\"filter\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/categories`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = operations[\"categoriesCategoryIdGet\"][\"parameters\"][\"query\"];\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesCategoryIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategory};\n */\nexport interface IGetCategoryResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategory}.\n */\nexport interface IGetCategoryOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n categoryId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns details about a single category by Id.\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = getCategory({\n * categoryId: \"10000\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response);\n * ```\n **/\nexport function getCategory(\n requestOptions: IGetCategoryOptions\n): Promise<IGetCategoryResponse> {\n const { categoryId } = requestOptions;\n\n const options = appendCustomParams<IGetCategoryOptions>(requestOptions, [], {\n ...requestOptions\n });\n\n return request(\n requestOptions.endpoint || `${baseUrl}/categories/${categoryId}`,\n {\n ...options,\n httpMethod: \"GET\"\n }\n );\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-places - v1.0.
|
|
2
|
+
* @esri/arcgis-rest-places - v1.0.2 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2024 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Tue Jun 18 2024 23:49:53 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
|
-
import{appendCustomParams as e,request as t}from"@esri/arcgis-rest-request";const
|
|
6
|
+
import{appendCustomParams as e,request as t}from"@esri/arcgis-rest-request";const n="https://places-api.arcgis.com/arcgis/rest/services/places-service/v1";function s(e){var t,n;return!!(null===(t=null==e?void 0:e.links)||void 0===t?void 0:t.next)||!!(null===(n=null==e?void 0:e.pagination)||void 0===n?void 0:n.nextUrl)}function i(e=0,t=10){return{offset:e+t,pageSize:t}}function c(a){const o=e(a,["x","y","radius","categoryIds","pageSize","offset","searchText"],Object.assign({},a));return t(a.endpoint||`${n}/places/near-point`,Object.assign(Object.assign({},o),{httpMethod:"GET"})).then((e=>{const t=Object.assign({},e);return s(e)&&(t.nextPage=()=>c(Object.assign(Object.assign({},a),i(a.offset,a.pageSize)))),t}))}function a(c){const o=e(c,["xmin","ymin","xmax","ymax","categoryIds","pageSize","offset","searchText"],Object.assign({},c));return t(c.endpoint||`${n}/places/within-extent`,Object.assign(Object.assign({},o),{httpMethod:"GET"})).then((e=>{const t=Object.assign({},e);return s(e)&&(t.nextPage=()=>a(Object.assign(Object.assign({},c),i(c.offset,c.pageSize)))),t}))}function o(s){const{placeId:i}=s,c=e(s,["requestedFields"],Object.assign({},s));return t(s.endpoint||`${n}/places/${i}`,Object.assign(Object.assign({},c),{httpMethod:"GET"}))}function r(s){const i=e(s,["filter"],Object.assign({},s));return t(s.endpoint||`${n}/categories`,Object.assign(Object.assign({},i),{httpMethod:"GET"}))}function g(s){const{categoryId:i}=s,c=e(s,[],Object.assign({},s));return t(s.endpoint||`${n}/categories/${i}`,Object.assign(Object.assign({},c),{httpMethod:"GET"}))}export{c as findPlacesNearPoint,a as findPlacesWithinExtent,r as getCategories,g as getCategory,o as getPlaceDetails};
|
|
7
7
|
//# sourceMappingURL=places.esm.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"places.esm.min.js","sources":["../../src/utils.ts","../../src/findPlacesNearPoint.ts","../../src/findPlacesWithinExtent.ts","../../src/getPlaceDetails.ts","../../src/getCategories.ts","../../src/getCategory.ts"],"sourcesContent":["export const baseUrl =\n \"https://places-api.arcgis.com/arcgis/rest/services/places-service/v1\";\n\nexport function hasNextPage(response: any) {\n return !!response?.links?.next || !!response?.pagination?.nextUrl;\n}\n\nexport function getNextPageParams(currentOffset = 0, currentPageSize = 10) {\n return {\n offset: currentOffset + currentPageSize,\n pageSize: currentPageSize\n };\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"nearPointGet\"][\"parameters\"][\"query\"],\n \"x\" | \"y\" | \"radius\" | \"categoryIds\" | \"pageSize\" | \"offset\" | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"nearPointGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesNearPoint};\n */\nexport interface IFindPlacesNearPointResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesNearPointResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlacesNearPointOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * Searches places that are within a given radius of a geographic point.\n * You must supply the `x` and `y` coordinates of the point that you wish\n * to search from. You can either specify a search radius, or use the\n * default (500 meters). You could use this method to search for places\n * around a user's GPS position, or a location clicked on a map.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```js\n * import { findPlacesNearPoint } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await findPlacesNearPoint({\n * x: -3.1883,\n * y: 55.9533,\n * radius: 100,\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\");\n * });\n *\n * console.log(response);\n * ```\n */\nexport function findPlacesNearPoint(\n requestOptions: IFindPlacesNearPointOptions\n): Promise<IFindPlacesNearPointResponse> {\n const options = appendCustomParams<IFindPlacesNearPointOptions>(\n requestOptions,\n [\"x\", \"y\", \"radius\", \"categoryIds\", \"pageSize\", \"offset\", \"searchText\"],\n {\n ...requestOptions\n }\n );\n\n return (\n request(`${baseUrl}/places/near-point`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesNearPointResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesNearPoint(nextOptions);\n };\n }\n\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"withinExtentGet\"][\"parameters\"][\"query\"],\n | \"xmin\"\n | \"ymin\"\n | \"xmax\"\n | \"ymax\"\n | \"categoryIds\"\n | \"pageSize\"\n | \"offset\"\n | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"withinExtentGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesWithinExtent};\n */\nexport interface IFindPlacesWithinExtentResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesWithinExtentResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlaceWithinExtentOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * Searches the world-wide set of places for those that are within an\n * extent, or bounding box. You must supply the `xmin`, `ymin`, `xmax` and\n * `ymax` coordinates of the extent. You could use this endpoint to search\n * for places in the visible extent of a user's screen.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can also refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```\n * import { findPlacesWithinExtent } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const results = await findPlacesWithinExtent({\n * xmin: -118.013334,\n * ymin: 33.78193,\n * xmax: -117.795753,\n * ymax: 33.873337,\n * categoryIds: [\"13002\"],\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(results)\n * ```\n */\nexport function findPlacesWithinExtent(\n requestOptions: IFindPlaceWithinExtentOptions\n): Promise<IFindPlacesWithinExtentResponse> {\n const options = appendCustomParams<IFindPlaceWithinExtentOptions>(\n requestOptions,\n [\n \"xmin\",\n \"ymin\",\n \"xmax\",\n \"ymax\",\n \"categoryIds\",\n \"pageSize\",\n \"offset\",\n \"searchText\"\n ],\n {\n ...requestOptions\n }\n );\n\n return (\n request(`${baseUrl}/places/within-extent`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesWithinExtentResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesWithinExtent(nextOptions);\n };\n }\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"placeIdGet\"][\"parameters\"][\"query\"],\n \"requestedFields\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"placeIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getPlace};\n */\nexport interface IGetPlaceResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getPlace}.\n */\nexport interface IGetPlaceOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n placeId: string;\n}\n\n/**\n * Returns a single place, including additional details, such as:\n *\n * - contact details\n * - address\n * - price information\n * - user rating\n * - opening hours\n *\n * This endpoint can be used to fetch additional details for a specific\n * place, returned from a places search request.\n *\n * Note that some fields, such as opening hours, are not available for\n * every place. Where a field is not available it will be omitted from the\n * response and you will not be charged for this data.\n *\n * ```js\n * import { getPlaceDetails } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const place = getPlaceDetails({\n * placeId: \"e78051acc722c55ab11ba930d8dd7772\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(place);\n * ```\n */\nexport function getPlaceDetails(\n requestOptions: IGetPlaceOptions\n): Promise<IGetPlaceResponse> {\n const { placeId } = requestOptions;\n\n const options = appendCustomParams<IGetPlaceOptions>(\n requestOptions,\n [\"requestedFields\"],\n {\n ...requestOptions\n }\n );\n\n return request(`${baseUrl}/places/${placeId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"categoriesGet\"][\"parameters\"][\"query\"],\n \"filter\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategories};\n */\nexport interface IGetCategoriesResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategories}.\n */\nexport interface IGetCategoriesOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * The ArcGIS Places service has many categories (or types) of place, from\n * art museums to zoos. This endpoint returns all the categories including\n * their label and `categoryId`. The category Id can be used to search for\n * types of places with a `places/near-point` or `places/within-extent`\n * request.\n *\n * Categories also have information on their `parent`. This allows you to\n * search for specific categories such as \"French Restaurant\" - or to\n * look for more generic types such as \"Restaurant\".\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await getCategories({\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response.categories);\n * ```\n */\nexport function getCategories(\n requestOptions: IGetCategoriesOptions\n): Promise<IGetCategoriesResponse> {\n const options = appendCustomParams<IGetCategoriesOptions>(\n requestOptions,\n [\"filter\"],\n {\n ...requestOptions\n }\n );\n\n return request(`${baseUrl}/categories`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = operations[\"categoriesCategoryIdGet\"][\"parameters\"][\"query\"];\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesCategoryIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategory};\n */\nexport interface IGetCategoryResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategory}.\n */\nexport interface IGetCategoryOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n categoryId: string;\n}\n\n/**\n * Returns details about a single category by Id.\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = getCategory({\n * categoryId: \"10000\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response);\n * ```\n **/\nexport function getCategory(\n requestOptions: IGetCategoryOptions\n): Promise<IGetCategoryResponse> {\n const { categoryId } = requestOptions;\n\n const options = appendCustomParams<IGetCategoryOptions>(requestOptions, [], {\n ...requestOptions\n });\n\n return request(`${baseUrl}/categories/${categoryId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n"],"names":["baseUrl","hasNextPage","response","links","next","pagination","nextUrl","getNextPageParams","currentOffset","currentPageSize","offset","pageSize","findPlacesNearPoint","requestOptions","options","appendCustomParams","request","httpMethod","then","r","nextPage","findPlacesWithinExtent","getPlaceDetails","placeId","getCategories","getCategory","categoryId"],"mappings":";;;;;4EAAO,MAAMA,EACX,gFAEcC,EAAYC,WAC1B,mBAASA,eAAAA,EAAUC,4BAAOC,oBAAUF,eAAAA,EAAUG,iCAAYC,QAC5D,UAEgBC,EAAkBC,EAAgB,EAAGC,EAAkB,IACrE,MAAO,CACLC,OAAQF,EAAgBC,EACxBE,SAAUF,EAEd,UC0DgBG,EACdC,GAEA,MAAMC,EAAUC,EACdF,EACA,CAAC,IAAK,IAAK,SAAU,cAAe,WAAY,SAAU,+BAErDA,IAIP,OACEG,EAAQ,GAAGhB,qDACNc,IACHG,WAAY,SAEdC,MAAMhB,IACN,MAAMiB,mBACDjB,GAaL,OAVID,EAAYC,KACdiB,EAAEC,SAAW,IAKJR,iCAHFC,GACAN,EAAkBM,EAAeH,OAAQG,EAAeF,aAM1DQ,CAAC,GAEZ,UCzBgBE,EACdR,GAEA,MAAMC,EAAUC,EACdF,EACA,CACE,OACA,OACA,OACA,OACA,cACA,WACA,SACA,+BAGGA,IAIP,OACEG,EAAQ,GAAGhB,wDACNc,IACHG,WAAY,SAEdC,MAAMhB,IACN,MAAMiB,mBACDjB,GAYL,OATID,EAAYC,KACdiB,EAAEC,SAAW,IAKJC,iCAHFR,GACAN,EAAkBM,EAAeH,OAAQG,EAAeF,aAK1DQ,CAAC,GAEZ,UCzDgBG,EACdT,GAEA,MAAMU,QAAEA,GAAYV,EAEdC,EAAUC,EACdF,EACA,CAAC,oCAEIA,IAIP,OAAOG,EAAQ,GAAGhB,YAAkBuB,mCAC/BT,IACHG,WAAY,QAEhB,UCzBgBO,EACdX,GAEA,MAAMC,EAAUC,EACdF,EACA,CAAC,2BAEIA,IAIP,OAAOG,EAAQ,GAAGhB,8CACbc,IACHG,WAAY,QAEhB,UCvBgBQ,EACdZ,GAEA,MAAMa,WAAEA,GAAeb,EAEjBC,EAAUC,EAAwCF,EAAgB,oBACnEA,IAGL,OAAOG,EAAQ,GAAGhB,gBAAsB0B,mCACnCZ,IACHG,WAAY,QAEhB"}
|
|
1
|
+
{"version":3,"file":"places.esm.min.js","sources":["../../src/utils.ts","../../src/findPlacesNearPoint.ts","../../src/findPlacesWithinExtent.ts","../../src/getPlaceDetails.ts","../../src/getCategories.ts","../../src/getCategory.ts"],"sourcesContent":["export const baseUrl =\n \"https://places-api.arcgis.com/arcgis/rest/services/places-service/v1\";\n\nexport function hasNextPage(response: any) {\n return !!response?.links?.next || !!response?.pagination?.nextUrl;\n}\n\nexport function getNextPageParams(currentOffset = 0, currentPageSize = 10) {\n return {\n offset: currentOffset + currentPageSize,\n pageSize: currentPageSize\n };\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"nearPointGet\"][\"parameters\"][\"query\"],\n \"x\" | \"y\" | \"radius\" | \"categoryIds\" | \"pageSize\" | \"offset\" | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"nearPointGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesNearPoint};\n */\nexport interface IFindPlacesNearPointResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesNearPointResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlacesNearPointOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches places that are within a given radius of a geographic point.\n * You must supply the `x` and `y` coordinates of the point that you wish\n * to search from. You can either specify a search radius, or use the\n * default (500 meters). You could use this method to search for places\n * around a user's GPS position, or a location clicked on a map.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```js\n * import { findPlacesNearPoint } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await findPlacesNearPoint({\n * x: -3.1883,\n * y: 55.9533,\n * radius: 100,\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\");\n * });\n *\n * console.log(response);\n * ```\n */\nexport function findPlacesNearPoint(\n requestOptions: IFindPlacesNearPointOptions\n): Promise<IFindPlacesNearPointResponse> {\n const options = appendCustomParams<IFindPlacesNearPointOptions>(\n requestOptions,\n [\"x\", \"y\", \"radius\", \"categoryIds\", \"pageSize\", \"offset\", \"searchText\"],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/near-point`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesNearPointResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesNearPoint(nextOptions);\n };\n }\n\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"withinExtentGet\"][\"parameters\"][\"query\"],\n | \"xmin\"\n | \"ymin\"\n | \"xmax\"\n | \"ymax\"\n | \"categoryIds\"\n | \"pageSize\"\n | \"offset\"\n | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"withinExtentGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesWithinExtent};\n */\nexport interface IFindPlacesWithinExtentResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesWithinExtentResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlaceWithinExtentOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches the world-wide set of places for those that are within an\n * extent, or bounding box. You must supply the `xmin`, `ymin`, `xmax` and\n * `ymax` coordinates of the extent. You could use this endpoint to search\n * for places in the visible extent of a user's screen.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can also refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```\n * import { findPlacesWithinExtent } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const results = await findPlacesWithinExtent({\n * xmin: -118.013334,\n * ymin: 33.78193,\n * xmax: -117.795753,\n * ymax: 33.873337,\n * categoryIds: [\"13002\"],\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(results)\n * ```\n */\nexport function findPlacesWithinExtent(\n requestOptions: IFindPlaceWithinExtentOptions\n): Promise<IFindPlacesWithinExtentResponse> {\n const options = appendCustomParams<IFindPlaceWithinExtentOptions>(\n requestOptions,\n [\n \"xmin\",\n \"ymin\",\n \"xmax\",\n \"ymax\",\n \"categoryIds\",\n \"pageSize\",\n \"offset\",\n \"searchText\"\n ],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/within-extent`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesWithinExtentResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesWithinExtent(nextOptions);\n };\n }\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"placeIdGet\"][\"parameters\"][\"query\"],\n \"requestedFields\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"placeIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getPlace};\n */\nexport interface IGetPlaceResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getPlace}.\n */\nexport interface IGetPlaceOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n placeId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns a single place, including additional details, such as:\n *\n * - contact details\n * - address\n * - price information\n * - user rating\n * - opening hours\n *\n * This endpoint can be used to fetch additional details for a specific\n * place, returned from a places search request.\n *\n * Note that some fields, such as opening hours, are not available for\n * every place. Where a field is not available it will be omitted from the\n * response and you will not be charged for this data.\n *\n * ```js\n * import { getPlaceDetails } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const place = getPlaceDetails({\n * placeId: \"e78051acc722c55ab11ba930d8dd7772\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(place);\n * ```\n */\nexport function getPlaceDetails(\n requestOptions: IGetPlaceOptions\n): Promise<IGetPlaceResponse> {\n const { placeId } = requestOptions;\n\n const options = appendCustomParams<IGetPlaceOptions>(\n requestOptions,\n [\"requestedFields\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/places/${placeId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"categoriesGet\"][\"parameters\"][\"query\"],\n \"filter\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategories};\n */\nexport interface IGetCategoriesResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategories}.\n */\nexport interface IGetCategoriesOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * The ArcGIS Places service has many categories (or types) of place, from\n * art museums to zoos. This endpoint returns all the categories including\n * their label and `categoryId`. The category Id can be used to search for\n * types of places with a `places/near-point` or `places/within-extent`\n * request.\n *\n * Categories also have information on their `parent`. This allows you to\n * search for specific categories such as \"French Restaurant\" - or to\n * look for more generic types such as \"Restaurant\".\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await getCategories({\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response.categories);\n * ```\n */\nexport function getCategories(\n requestOptions: IGetCategoriesOptions\n): Promise<IGetCategoriesResponse> {\n const options = appendCustomParams<IGetCategoriesOptions>(\n requestOptions,\n [\"filter\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/categories`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = operations[\"categoriesCategoryIdGet\"][\"parameters\"][\"query\"];\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesCategoryIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategory};\n */\nexport interface IGetCategoryResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategory}.\n */\nexport interface IGetCategoryOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n categoryId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns details about a single category by Id.\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = getCategory({\n * categoryId: \"10000\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response);\n * ```\n **/\nexport function getCategory(\n requestOptions: IGetCategoryOptions\n): Promise<IGetCategoryResponse> {\n const { categoryId } = requestOptions;\n\n const options = appendCustomParams<IGetCategoryOptions>(requestOptions, [], {\n ...requestOptions\n });\n\n return request(\n requestOptions.endpoint || `${baseUrl}/categories/${categoryId}`,\n {\n ...options,\n httpMethod: \"GET\"\n }\n );\n}\n"],"names":["baseUrl","hasNextPage","response","links","next","pagination","nextUrl","getNextPageParams","currentOffset","currentPageSize","offset","pageSize","findPlacesNearPoint","requestOptions","options","appendCustomParams","request","endpoint","httpMethod","then","r","nextPage","findPlacesWithinExtent","getPlaceDetails","placeId","getCategories","getCategory","categoryId"],"mappings":";;;;;4EAAO,MAAMA,EACX,gFAEcC,EAAYC,WAC1B,mBAASA,eAAAA,EAAUC,4BAAOC,oBAAUF,eAAAA,EAAUG,iCAAYC,QAC5D,UAEgBC,EAAkBC,EAAgB,EAAGC,EAAkB,IACrE,MAAO,CACLC,OAAQF,EAAgBC,EACxBE,SAAUF,EAEd,UCgEgBG,EACdC,GAEA,MAAMC,EAAUC,EACdF,EACA,CAAC,IAAK,IAAK,SAAU,cAAe,WAAY,SAAU,+BAErDA,IAIP,OACEG,EAAQH,EAAeI,UAAY,GAAGjB,qDACjCc,IACHI,WAAY,SAEdC,MAAMjB,IACN,MAAMkB,mBACDlB,GAaL,OAVID,EAAYC,KACdkB,EAAEC,SAAW,IAKJT,iCAHFC,GACAN,EAAkBM,EAAeH,OAAQG,EAAeF,aAM1DS,CAAC,GAEZ,UCzBgBE,EACdT,GAEA,MAAMC,EAAUC,EACdF,EACA,CACE,OACA,OACA,OACA,OACA,cACA,WACA,SACA,+BAGGA,IAIP,OACEG,EAAQH,EAAeI,UAAY,GAAGjB,wDACjCc,IACHI,WAAY,SAEdC,MAAMjB,IACN,MAAMkB,mBACDlB,GAYL,OATID,EAAYC,KACdkB,EAAEC,SAAW,IAKJC,iCAHFT,GACAN,EAAkBM,EAAeH,OAAQG,EAAeF,aAK1DS,CAAC,GAEZ,UC1DgBG,EACdV,GAEA,MAAMW,QAAEA,GAAYX,EAEdC,EAAUC,EACdF,EACA,CAAC,oCAEIA,IAIP,OAAOG,EAAQH,EAAeI,UAAY,GAAGjB,YAAkBwB,mCAC1DV,IACHI,WAAY,QAEhB,UCxBgBO,EACdZ,GAEA,MAAMC,EAAUC,EACdF,EACA,CAAC,2BAEIA,IAIP,OAAOG,EAAQH,EAAeI,UAAY,GAAGjB,8CACxCc,IACHI,WAAY,QAEhB,UCxBgBQ,EACdb,GAEA,MAAMc,WAAEA,GAAed,EAEjBC,EAAUC,EAAwCF,EAAgB,oBACnEA,IAGL,OAAOG,EACLH,EAAeI,UAAY,GAAGjB,gBAAsB2B,mCAE/Cb,IACHI,WAAY,QAGlB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-places - v1.0.
|
|
2
|
+
* @esri/arcgis-rest-places - v1.0.2 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2024 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Tue Jun 18 2024 23:49:53 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
6
|
(function (global, factory) {
|
|
7
7
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/arcgis-rest-request')) :
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
*/
|
|
60
60
|
function findPlacesNearPoint(requestOptions) {
|
|
61
61
|
const options = arcgisRestRequest.appendCustomParams(requestOptions, ["x", "y", "radius", "categoryIds", "pageSize", "offset", "searchText"], Object.assign({}, requestOptions));
|
|
62
|
-
return arcgisRestRequest.request(`${baseUrl}/places/near-point`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
62
|
+
return arcgisRestRequest.request(requestOptions.endpoint || `${baseUrl}/places/near-point`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
63
63
|
const r = Object.assign({}, response);
|
|
64
64
|
if (hasNextPage(response)) {
|
|
65
65
|
r.nextPage = () => {
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"offset",
|
|
120
120
|
"searchText"
|
|
121
121
|
], Object.assign({}, requestOptions));
|
|
122
|
-
return arcgisRestRequest.request(`${baseUrl}/places/within-extent`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
122
|
+
return arcgisRestRequest.request(requestOptions.endpoint || `${baseUrl}/places/within-extent`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
123
123
|
const r = Object.assign({}, response);
|
|
124
124
|
if (hasNextPage(response)) {
|
|
125
125
|
r.nextPage = () => {
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
function getPlaceDetails(requestOptions) {
|
|
163
163
|
const { placeId } = requestOptions;
|
|
164
164
|
const options = arcgisRestRequest.appendCustomParams(requestOptions, ["requestedFields"], Object.assign({}, requestOptions));
|
|
165
|
-
return arcgisRestRequest.request(`${baseUrl}/places/${placeId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
165
|
+
return arcgisRestRequest.request(requestOptions.endpoint || `${baseUrl}/places/${placeId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
/**
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
*/
|
|
190
190
|
function getCategories(requestOptions) {
|
|
191
191
|
const options = arcgisRestRequest.appendCustomParams(requestOptions, ["filter"], Object.assign({}, requestOptions));
|
|
192
|
-
return arcgisRestRequest.request(`${baseUrl}/categories`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
192
|
+
return arcgisRestRequest.request(requestOptions.endpoint || `${baseUrl}/categories`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
/**
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
function getCategory(requestOptions) {
|
|
211
211
|
const { categoryId } = requestOptions;
|
|
212
212
|
const options = arcgisRestRequest.appendCustomParams(requestOptions, [], Object.assign({}, requestOptions));
|
|
213
|
-
return arcgisRestRequest.request(`${baseUrl}/categories/${categoryId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
213
|
+
return arcgisRestRequest.request(requestOptions.endpoint || `${baseUrl}/categories/${categoryId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
exports.findPlacesNearPoint = findPlacesNearPoint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"places.umd.js","sources":["../../src/utils.ts","../../src/findPlacesNearPoint.ts","../../src/findPlacesWithinExtent.ts","../../src/getPlaceDetails.ts","../../src/getCategories.ts","../../src/getCategory.ts"],"sourcesContent":["export const baseUrl =\n \"https://places-api.arcgis.com/arcgis/rest/services/places-service/v1\";\n\nexport function hasNextPage(response: any) {\n return !!response?.links?.next || !!response?.pagination?.nextUrl;\n}\n\nexport function getNextPageParams(currentOffset = 0, currentPageSize = 10) {\n return {\n offset: currentOffset + currentPageSize,\n pageSize: currentPageSize\n };\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"nearPointGet\"][\"parameters\"][\"query\"],\n \"x\" | \"y\" | \"radius\" | \"categoryIds\" | \"pageSize\" | \"offset\" | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"nearPointGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesNearPoint};\n */\nexport interface IFindPlacesNearPointResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesNearPointResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlacesNearPointOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * Searches places that are within a given radius of a geographic point.\n * You must supply the `x` and `y` coordinates of the point that you wish\n * to search from. You can either specify a search radius, or use the\n * default (500 meters). You could use this method to search for places\n * around a user's GPS position, or a location clicked on a map.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```js\n * import { findPlacesNearPoint } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await findPlacesNearPoint({\n * x: -3.1883,\n * y: 55.9533,\n * radius: 100,\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\");\n * });\n *\n * console.log(response);\n * ```\n */\nexport function findPlacesNearPoint(\n requestOptions: IFindPlacesNearPointOptions\n): Promise<IFindPlacesNearPointResponse> {\n const options = appendCustomParams<IFindPlacesNearPointOptions>(\n requestOptions,\n [\"x\", \"y\", \"radius\", \"categoryIds\", \"pageSize\", \"offset\", \"searchText\"],\n {\n ...requestOptions\n }\n );\n\n return (\n request(`${baseUrl}/places/near-point`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesNearPointResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesNearPoint(nextOptions);\n };\n }\n\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"withinExtentGet\"][\"parameters\"][\"query\"],\n | \"xmin\"\n | \"ymin\"\n | \"xmax\"\n | \"ymax\"\n | \"categoryIds\"\n | \"pageSize\"\n | \"offset\"\n | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"withinExtentGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesWithinExtent};\n */\nexport interface IFindPlacesWithinExtentResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesWithinExtentResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlaceWithinExtentOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * Searches the world-wide set of places for those that are within an\n * extent, or bounding box. You must supply the `xmin`, `ymin`, `xmax` and\n * `ymax` coordinates of the extent. You could use this endpoint to search\n * for places in the visible extent of a user's screen.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can also refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```\n * import { findPlacesWithinExtent } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const results = await findPlacesWithinExtent({\n * xmin: -118.013334,\n * ymin: 33.78193,\n * xmax: -117.795753,\n * ymax: 33.873337,\n * categoryIds: [\"13002\"],\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(results)\n * ```\n */\nexport function findPlacesWithinExtent(\n requestOptions: IFindPlaceWithinExtentOptions\n): Promise<IFindPlacesWithinExtentResponse> {\n const options = appendCustomParams<IFindPlaceWithinExtentOptions>(\n requestOptions,\n [\n \"xmin\",\n \"ymin\",\n \"xmax\",\n \"ymax\",\n \"categoryIds\",\n \"pageSize\",\n \"offset\",\n \"searchText\"\n ],\n {\n ...requestOptions\n }\n );\n\n return (\n request(`${baseUrl}/places/within-extent`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesWithinExtentResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesWithinExtent(nextOptions);\n };\n }\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"placeIdGet\"][\"parameters\"][\"query\"],\n \"requestedFields\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"placeIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getPlace};\n */\nexport interface IGetPlaceResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getPlace}.\n */\nexport interface IGetPlaceOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n placeId: string;\n}\n\n/**\n * Returns a single place, including additional details, such as:\n *\n * - contact details\n * - address\n * - price information\n * - user rating\n * - opening hours\n *\n * This endpoint can be used to fetch additional details for a specific\n * place, returned from a places search request.\n *\n * Note that some fields, such as opening hours, are not available for\n * every place. Where a field is not available it will be omitted from the\n * response and you will not be charged for this data.\n *\n * ```js\n * import { getPlaceDetails } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const place = getPlaceDetails({\n * placeId: \"e78051acc722c55ab11ba930d8dd7772\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(place);\n * ```\n */\nexport function getPlaceDetails(\n requestOptions: IGetPlaceOptions\n): Promise<IGetPlaceResponse> {\n const { placeId } = requestOptions;\n\n const options = appendCustomParams<IGetPlaceOptions>(\n requestOptions,\n [\"requestedFields\"],\n {\n ...requestOptions\n }\n );\n\n return request(`${baseUrl}/places/${placeId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"categoriesGet\"][\"parameters\"][\"query\"],\n \"filter\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategories};\n */\nexport interface IGetCategoriesResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategories}.\n */\nexport interface IGetCategoriesOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * The ArcGIS Places service has many categories (or types) of place, from\n * art museums to zoos. This endpoint returns all the categories including\n * their label and `categoryId`. The category Id can be used to search for\n * types of places with a `places/near-point` or `places/within-extent`\n * request.\n *\n * Categories also have information on their `parent`. This allows you to\n * search for specific categories such as \"French Restaurant\" - or to\n * look for more generic types such as \"Restaurant\".\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await getCategories({\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response.categories);\n * ```\n */\nexport function getCategories(\n requestOptions: IGetCategoriesOptions\n): Promise<IGetCategoriesResponse> {\n const options = appendCustomParams<IGetCategoriesOptions>(\n requestOptions,\n [\"filter\"],\n {\n ...requestOptions\n }\n );\n\n return request(`${baseUrl}/categories`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = operations[\"categoriesCategoryIdGet\"][\"parameters\"][\"query\"];\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesCategoryIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategory};\n */\nexport interface IGetCategoryResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategory}.\n */\nexport interface IGetCategoryOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n categoryId: string;\n}\n\n/**\n * Returns details about a single category by Id.\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = getCategory({\n * categoryId: \"10000\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response);\n * ```\n **/\nexport function getCategory(\n requestOptions: IGetCategoryOptions\n): Promise<IGetCategoryResponse> {\n const { categoryId } = requestOptions;\n\n const options = appendCustomParams<IGetCategoryOptions>(requestOptions, [], {\n ...requestOptions\n });\n\n return request(`${baseUrl}/categories/${categoryId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n"],"names":["appendCustomParams","request"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"places.umd.js","sources":["../../src/utils.ts","../../src/findPlacesNearPoint.ts","../../src/findPlacesWithinExtent.ts","../../src/getPlaceDetails.ts","../../src/getCategories.ts","../../src/getCategory.ts"],"sourcesContent":["export const baseUrl =\n \"https://places-api.arcgis.com/arcgis/rest/services/places-service/v1\";\n\nexport function hasNextPage(response: any) {\n return !!response?.links?.next || !!response?.pagination?.nextUrl;\n}\n\nexport function getNextPageParams(currentOffset = 0, currentPageSize = 10) {\n return {\n offset: currentOffset + currentPageSize,\n pageSize: currentPageSize\n };\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"nearPointGet\"][\"parameters\"][\"query\"],\n \"x\" | \"y\" | \"radius\" | \"categoryIds\" | \"pageSize\" | \"offset\" | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"nearPointGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesNearPoint};\n */\nexport interface IFindPlacesNearPointResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesNearPointResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlacesNearPointOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches places that are within a given radius of a geographic point.\n * You must supply the `x` and `y` coordinates of the point that you wish\n * to search from. You can either specify a search radius, or use the\n * default (500 meters). You could use this method to search for places\n * around a user's GPS position, or a location clicked on a map.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```js\n * import { findPlacesNearPoint } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await findPlacesNearPoint({\n * x: -3.1883,\n * y: 55.9533,\n * radius: 100,\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\");\n * });\n *\n * console.log(response);\n * ```\n */\nexport function findPlacesNearPoint(\n requestOptions: IFindPlacesNearPointOptions\n): Promise<IFindPlacesNearPointResponse> {\n const options = appendCustomParams<IFindPlacesNearPointOptions>(\n requestOptions,\n [\"x\", \"y\", \"radius\", \"categoryIds\", \"pageSize\", \"offset\", \"searchText\"],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/near-point`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesNearPointResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesNearPoint(nextOptions);\n };\n }\n\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"withinExtentGet\"][\"parameters\"][\"query\"],\n | \"xmin\"\n | \"ymin\"\n | \"xmax\"\n | \"ymax\"\n | \"categoryIds\"\n | \"pageSize\"\n | \"offset\"\n | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"withinExtentGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesWithinExtent};\n */\nexport interface IFindPlacesWithinExtentResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesWithinExtentResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlaceWithinExtentOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches the world-wide set of places for those that are within an\n * extent, or bounding box. You must supply the `xmin`, `ymin`, `xmax` and\n * `ymax` coordinates of the extent. You could use this endpoint to search\n * for places in the visible extent of a user's screen.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can also refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```\n * import { findPlacesWithinExtent } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const results = await findPlacesWithinExtent({\n * xmin: -118.013334,\n * ymin: 33.78193,\n * xmax: -117.795753,\n * ymax: 33.873337,\n * categoryIds: [\"13002\"],\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(results)\n * ```\n */\nexport function findPlacesWithinExtent(\n requestOptions: IFindPlaceWithinExtentOptions\n): Promise<IFindPlacesWithinExtentResponse> {\n const options = appendCustomParams<IFindPlaceWithinExtentOptions>(\n requestOptions,\n [\n \"xmin\",\n \"ymin\",\n \"xmax\",\n \"ymax\",\n \"categoryIds\",\n \"pageSize\",\n \"offset\",\n \"searchText\"\n ],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/within-extent`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesWithinExtentResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesWithinExtent(nextOptions);\n };\n }\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"placeIdGet\"][\"parameters\"][\"query\"],\n \"requestedFields\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"placeIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getPlace};\n */\nexport interface IGetPlaceResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getPlace}.\n */\nexport interface IGetPlaceOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n placeId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns a single place, including additional details, such as:\n *\n * - contact details\n * - address\n * - price information\n * - user rating\n * - opening hours\n *\n * This endpoint can be used to fetch additional details for a specific\n * place, returned from a places search request.\n *\n * Note that some fields, such as opening hours, are not available for\n * every place. Where a field is not available it will be omitted from the\n * response and you will not be charged for this data.\n *\n * ```js\n * import { getPlaceDetails } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const place = getPlaceDetails({\n * placeId: \"e78051acc722c55ab11ba930d8dd7772\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(place);\n * ```\n */\nexport function getPlaceDetails(\n requestOptions: IGetPlaceOptions\n): Promise<IGetPlaceResponse> {\n const { placeId } = requestOptions;\n\n const options = appendCustomParams<IGetPlaceOptions>(\n requestOptions,\n [\"requestedFields\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/places/${placeId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"categoriesGet\"][\"parameters\"][\"query\"],\n \"filter\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategories};\n */\nexport interface IGetCategoriesResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategories}.\n */\nexport interface IGetCategoriesOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * The ArcGIS Places service has many categories (or types) of place, from\n * art museums to zoos. This endpoint returns all the categories including\n * their label and `categoryId`. The category Id can be used to search for\n * types of places with a `places/near-point` or `places/within-extent`\n * request.\n *\n * Categories also have information on their `parent`. This allows you to\n * search for specific categories such as \"French Restaurant\" - or to\n * look for more generic types such as \"Restaurant\".\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await getCategories({\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response.categories);\n * ```\n */\nexport function getCategories(\n requestOptions: IGetCategoriesOptions\n): Promise<IGetCategoriesResponse> {\n const options = appendCustomParams<IGetCategoriesOptions>(\n requestOptions,\n [\"filter\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/categories`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = operations[\"categoriesCategoryIdGet\"][\"parameters\"][\"query\"];\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesCategoryIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategory};\n */\nexport interface IGetCategoryResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategory}.\n */\nexport interface IGetCategoryOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n categoryId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns details about a single category by Id.\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = getCategory({\n * categoryId: \"10000\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response);\n * ```\n **/\nexport function getCategory(\n requestOptions: IGetCategoryOptions\n): Promise<IGetCategoryResponse> {\n const { categoryId } = requestOptions;\n\n const options = appendCustomParams<IGetCategoryOptions>(requestOptions, [], {\n ...requestOptions\n });\n\n return request(\n requestOptions.endpoint || `${baseUrl}/categories/${categoryId}`,\n {\n ...options,\n httpMethod: \"GET\"\n }\n );\n}\n"],"names":["appendCustomParams","request"],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/arcgis-rest-places - v1.0.
|
|
2
|
+
* @esri/arcgis-rest-places - v1.0.2 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2017-2024 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Tue Jun 18 2024 23:49:53 GMT+0000 (Coordinated Universal Time)
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/arcgis-rest-request")):"function"==typeof define&&define.amd?define(["exports","@esri/arcgis-rest-request"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisRest=e.arcgisRest||{},e.arcgisRest)}(this,(function(e,t){"use strict";const s="https://places-api.arcgis.com/arcgis/rest/services/places-service/v1";function n(e){var t,s;return!!(null===(t=null==e?void 0:e.links)||void 0===t?void 0:t.next)||!!(null===(s=null==e?void 0:e.pagination)||void 0===s?void 0:s.nextUrl)}function i(e=0,t=10){return{offset:e+t,pageSize:t}}e.findPlacesNearPoint=function e(a){const c=t.appendCustomParams(a,["x","y","radius","categoryIds","pageSize","offset","searchText"],Object.assign({},a));return t.request(
|
|
6
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/arcgis-rest-request")):"function"==typeof define&&define.amd?define(["exports","@esri/arcgis-rest-request"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisRest=e.arcgisRest||{},e.arcgisRest)}(this,(function(e,t){"use strict";const s="https://places-api.arcgis.com/arcgis/rest/services/places-service/v1";function n(e){var t,s;return!!(null===(t=null==e?void 0:e.links)||void 0===t?void 0:t.next)||!!(null===(s=null==e?void 0:e.pagination)||void 0===s?void 0:s.nextUrl)}function i(e=0,t=10){return{offset:e+t,pageSize:t}}e.findPlacesNearPoint=function e(a){const c=t.appendCustomParams(a,["x","y","radius","categoryIds","pageSize","offset","searchText"],Object.assign({},a));return t.request(a.endpoint||`${s}/places/near-point`,Object.assign(Object.assign({},c),{httpMethod:"GET"})).then((t=>{const s=Object.assign({},t);return n(t)&&(s.nextPage=()=>e(Object.assign(Object.assign({},a),i(a.offset,a.pageSize)))),s}))},e.findPlacesWithinExtent=function e(a){const c=t.appendCustomParams(a,["xmin","ymin","xmax","ymax","categoryIds","pageSize","offset","searchText"],Object.assign({},a));return t.request(a.endpoint||`${s}/places/within-extent`,Object.assign(Object.assign({},c),{httpMethod:"GET"})).then((t=>{const s=Object.assign({},t);return n(t)&&(s.nextPage=()=>e(Object.assign(Object.assign({},a),i(a.offset,a.pageSize)))),s}))},e.getCategories=function(e){const n=t.appendCustomParams(e,["filter"],Object.assign({},e));return t.request(e.endpoint||`${s}/categories`,Object.assign(Object.assign({},n),{httpMethod:"GET"}))},e.getCategory=function(e){const{categoryId:n}=e,i=t.appendCustomParams(e,[],Object.assign({},e));return t.request(e.endpoint||`${s}/categories/${n}`,Object.assign(Object.assign({},i),{httpMethod:"GET"}))},e.getPlaceDetails=function(e){const{placeId:n}=e,i=t.appendCustomParams(e,["requestedFields"],Object.assign({},e));return t.request(e.endpoint||`${s}/places/${n}`,Object.assign(Object.assign({},i),{httpMethod:"GET"}))},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
7
7
|
//# sourceMappingURL=places.umd.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"places.umd.min.js","sources":["../../src/utils.ts","../../src/findPlacesNearPoint.ts","../../src/findPlacesWithinExtent.ts","../../src/getCategories.ts","../../src/getCategory.ts","../../src/getPlaceDetails.ts"],"sourcesContent":["export const baseUrl =\n \"https://places-api.arcgis.com/arcgis/rest/services/places-service/v1\";\n\nexport function hasNextPage(response: any) {\n return !!response?.links?.next || !!response?.pagination?.nextUrl;\n}\n\nexport function getNextPageParams(currentOffset = 0, currentPageSize = 10) {\n return {\n offset: currentOffset + currentPageSize,\n pageSize: currentPageSize\n };\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"nearPointGet\"][\"parameters\"][\"query\"],\n \"x\" | \"y\" | \"radius\" | \"categoryIds\" | \"pageSize\" | \"offset\" | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"nearPointGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesNearPoint};\n */\nexport interface IFindPlacesNearPointResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesNearPointResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlacesNearPointOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * Searches places that are within a given radius of a geographic point.\n * You must supply the `x` and `y` coordinates of the point that you wish\n * to search from. You can either specify a search radius, or use the\n * default (500 meters). You could use this method to search for places\n * around a user's GPS position, or a location clicked on a map.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```js\n * import { findPlacesNearPoint } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await findPlacesNearPoint({\n * x: -3.1883,\n * y: 55.9533,\n * radius: 100,\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\");\n * });\n *\n * console.log(response);\n * ```\n */\nexport function findPlacesNearPoint(\n requestOptions: IFindPlacesNearPointOptions\n): Promise<IFindPlacesNearPointResponse> {\n const options = appendCustomParams<IFindPlacesNearPointOptions>(\n requestOptions,\n [\"x\", \"y\", \"radius\", \"categoryIds\", \"pageSize\", \"offset\", \"searchText\"],\n {\n ...requestOptions\n }\n );\n\n return (\n request(`${baseUrl}/places/near-point`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesNearPointResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesNearPoint(nextOptions);\n };\n }\n\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"withinExtentGet\"][\"parameters\"][\"query\"],\n | \"xmin\"\n | \"ymin\"\n | \"xmax\"\n | \"ymax\"\n | \"categoryIds\"\n | \"pageSize\"\n | \"offset\"\n | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"withinExtentGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesWithinExtent};\n */\nexport interface IFindPlacesWithinExtentResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesWithinExtentResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlaceWithinExtentOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * Searches the world-wide set of places for those that are within an\n * extent, or bounding box. You must supply the `xmin`, `ymin`, `xmax` and\n * `ymax` coordinates of the extent. You could use this endpoint to search\n * for places in the visible extent of a user's screen.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can also refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```\n * import { findPlacesWithinExtent } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const results = await findPlacesWithinExtent({\n * xmin: -118.013334,\n * ymin: 33.78193,\n * xmax: -117.795753,\n * ymax: 33.873337,\n * categoryIds: [\"13002\"],\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(results)\n * ```\n */\nexport function findPlacesWithinExtent(\n requestOptions: IFindPlaceWithinExtentOptions\n): Promise<IFindPlacesWithinExtentResponse> {\n const options = appendCustomParams<IFindPlaceWithinExtentOptions>(\n requestOptions,\n [\n \"xmin\",\n \"ymin\",\n \"xmax\",\n \"ymax\",\n \"categoryIds\",\n \"pageSize\",\n \"offset\",\n \"searchText\"\n ],\n {\n ...requestOptions\n }\n );\n\n return (\n request(`${baseUrl}/places/within-extent`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesWithinExtentResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesWithinExtent(nextOptions);\n };\n }\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"categoriesGet\"][\"parameters\"][\"query\"],\n \"filter\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategories};\n */\nexport interface IGetCategoriesResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategories}.\n */\nexport interface IGetCategoriesOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {}\n\n/**\n * The ArcGIS Places service has many categories (or types) of place, from\n * art museums to zoos. This endpoint returns all the categories including\n * their label and `categoryId`. The category Id can be used to search for\n * types of places with a `places/near-point` or `places/within-extent`\n * request.\n *\n * Categories also have information on their `parent`. This allows you to\n * search for specific categories such as \"French Restaurant\" - or to\n * look for more generic types such as \"Restaurant\".\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await getCategories({\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response.categories);\n * ```\n */\nexport function getCategories(\n requestOptions: IGetCategoriesOptions\n): Promise<IGetCategoriesResponse> {\n const options = appendCustomParams<IGetCategoriesOptions>(\n requestOptions,\n [\"filter\"],\n {\n ...requestOptions\n }\n );\n\n return request(`${baseUrl}/categories`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = operations[\"categoriesCategoryIdGet\"][\"parameters\"][\"query\"];\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesCategoryIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategory};\n */\nexport interface IGetCategoryResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategory}.\n */\nexport interface IGetCategoryOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n categoryId: string;\n}\n\n/**\n * Returns details about a single category by Id.\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = getCategory({\n * categoryId: \"10000\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response);\n * ```\n **/\nexport function getCategory(\n requestOptions: IGetCategoryOptions\n): Promise<IGetCategoryResponse> {\n const { categoryId } = requestOptions;\n\n const options = appendCustomParams<IGetCategoryOptions>(requestOptions, [], {\n ...requestOptions\n });\n\n return request(`${baseUrl}/categories/${categoryId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"placeIdGet\"][\"parameters\"][\"query\"],\n \"requestedFields\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"placeIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getPlace};\n */\nexport interface IGetPlaceResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getPlace}.\n */\nexport interface IGetPlaceOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n placeId: string;\n}\n\n/**\n * Returns a single place, including additional details, such as:\n *\n * - contact details\n * - address\n * - price information\n * - user rating\n * - opening hours\n *\n * This endpoint can be used to fetch additional details for a specific\n * place, returned from a places search request.\n *\n * Note that some fields, such as opening hours, are not available for\n * every place. Where a field is not available it will be omitted from the\n * response and you will not be charged for this data.\n *\n * ```js\n * import { getPlaceDetails } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const place = getPlaceDetails({\n * placeId: \"e78051acc722c55ab11ba930d8dd7772\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(place);\n * ```\n */\nexport function getPlaceDetails(\n requestOptions: IGetPlaceOptions\n): Promise<IGetPlaceResponse> {\n const { placeId } = requestOptions;\n\n const options = appendCustomParams<IGetPlaceOptions>(\n requestOptions,\n [\"requestedFields\"],\n {\n ...requestOptions\n }\n );\n\n return request(`${baseUrl}/places/${placeId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n"],"names":["baseUrl","hasNextPage","response","links","next","pagination","nextUrl","getNextPageParams","currentOffset","currentPageSize","offset","pageSize","findPlacesNearPoint","requestOptions","options","appendCustomParams","request","httpMethod","then","r","nextPage","findPlacesWithinExtent","categoryId","placeId"],"mappings":";;;;;gVAAO,MAAMA,EACX,gFAEcC,EAAYC,WAC1B,mBAASA,eAAAA,EAAUC,4BAAOC,oBAAUF,eAAAA,EAAUG,iCAAYC,QAC5D,UAEgBC,EAAkBC,EAAgB,EAAGC,EAAkB,IACrE,MAAO,CACLC,OAAQF,EAAgBC,EACxBE,SAAUF,EAEd,gCC0DgBG,EACdC,GAEA,MAAMC,EAAUC,qBACdF,EACA,CAAC,IAAK,IAAK,SAAU,cAAe,WAAY,SAAU,+BAErDA,IAIP,OACEG,UAAQ,GAAGhB,qDACNc,IACHG,WAAY,SAEdC,MAAMhB,IACN,MAAMiB,mBACDjB,GAaL,OAVID,EAAYC,KACdiB,EAAEC,SAAW,IAKJR,iCAHFC,GACAN,EAAkBM,EAAeH,OAAQG,EAAeF,aAM1DQ,CAAC,GAEZ,oCCzBgBE,EACdR,GAEA,MAAMC,EAAUC,qBACdF,EACA,CACE,OACA,OACA,OACA,OACA,cACA,WACA,SACA,+BAGGA,IAIP,OACEG,UAAQ,GAAGhB,wDACNc,IACHG,WAAY,SAEdC,MAAMhB,IACN,MAAMiB,mBACDjB,GAYL,OATID,EAAYC,KACdiB,EAAEC,SAAW,IAKJC,iCAHFR,GACAN,EAAkBM,EAAeH,OAAQG,EAAeF,aAK1DQ,CAAC,GAEZ,2BChEEN,GAEA,MAAMC,EAAUC,qBACdF,EACA,CAAC,2BAEIA,IAIP,OAAOG,UAAQ,GAAGhB,8CACbc,IACHG,WAAY,QAEhB,yBCtBEJ,GAEA,MAAMS,WAAEA,GAAeT,EAEjBC,EAAUC,qBAAwCF,EAAgB,oBACnEA,IAGL,OAAOG,UAAQ,GAAGhB,gBAAsBsB,mCACnCR,IACHG,WAAY,QAEhB,6BCIEJ,GAEA,MAAMU,QAAEA,GAAYV,EAEdC,EAAUC,qBACdF,EACA,CAAC,oCAEIA,IAIP,OAAOG,UAAQ,GAAGhB,YAAkBuB,mCAC/BT,IACHG,WAAY,QAEhB"}
|
|
1
|
+
{"version":3,"file":"places.umd.min.js","sources":["../../src/utils.ts","../../src/findPlacesNearPoint.ts","../../src/findPlacesWithinExtent.ts","../../src/getCategories.ts","../../src/getCategory.ts","../../src/getPlaceDetails.ts"],"sourcesContent":["export const baseUrl =\n \"https://places-api.arcgis.com/arcgis/rest/services/places-service/v1\";\n\nexport function hasNextPage(response: any) {\n return !!response?.links?.next || !!response?.pagination?.nextUrl;\n}\n\nexport function getNextPageParams(currentOffset = 0, currentPageSize = 10) {\n return {\n offset: currentOffset + currentPageSize,\n pageSize: currentPageSize\n };\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"nearPointGet\"][\"parameters\"][\"query\"],\n \"x\" | \"y\" | \"radius\" | \"categoryIds\" | \"pageSize\" | \"offset\" | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"nearPointGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesNearPoint};\n */\nexport interface IFindPlacesNearPointResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesNearPointResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlacesNearPointOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches places that are within a given radius of a geographic point.\n * You must supply the `x` and `y` coordinates of the point that you wish\n * to search from. You can either specify a search radius, or use the\n * default (500 meters). You could use this method to search for places\n * around a user's GPS position, or a location clicked on a map.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```js\n * import { findPlacesNearPoint } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await findPlacesNearPoint({\n * x: -3.1883,\n * y: 55.9533,\n * radius: 100,\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\");\n * });\n *\n * console.log(response);\n * ```\n */\nexport function findPlacesNearPoint(\n requestOptions: IFindPlacesNearPointOptions\n): Promise<IFindPlacesNearPointResponse> {\n const options = appendCustomParams<IFindPlacesNearPointOptions>(\n requestOptions,\n [\"x\", \"y\", \"radius\", \"categoryIds\", \"pageSize\", \"offset\", \"searchText\"],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/near-point`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesNearPointResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesNearPoint(nextOptions);\n };\n }\n\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"withinExtentGet\"][\"parameters\"][\"query\"],\n | \"xmin\"\n | \"ymin\"\n | \"xmax\"\n | \"ymax\"\n | \"categoryIds\"\n | \"pageSize\"\n | \"offset\"\n | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"withinExtentGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesWithinExtent};\n */\nexport interface IFindPlacesWithinExtentResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesWithinExtentResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlaceWithinExtentOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches the world-wide set of places for those that are within an\n * extent, or bounding box. You must supply the `xmin`, `ymin`, `xmax` and\n * `ymax` coordinates of the extent. You could use this endpoint to search\n * for places in the visible extent of a user's screen.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can also refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```\n * import { findPlacesWithinExtent } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const results = await findPlacesWithinExtent({\n * xmin: -118.013334,\n * ymin: 33.78193,\n * xmax: -117.795753,\n * ymax: 33.873337,\n * categoryIds: [\"13002\"],\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(results)\n * ```\n */\nexport function findPlacesWithinExtent(\n requestOptions: IFindPlaceWithinExtentOptions\n): Promise<IFindPlacesWithinExtentResponse> {\n const options = appendCustomParams<IFindPlaceWithinExtentOptions>(\n requestOptions,\n [\n \"xmin\",\n \"ymin\",\n \"xmax\",\n \"ymax\",\n \"categoryIds\",\n \"pageSize\",\n \"offset\",\n \"searchText\"\n ],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/within-extent`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesWithinExtentResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesWithinExtent(nextOptions);\n };\n }\n return r;\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"categoriesGet\"][\"parameters\"][\"query\"],\n \"filter\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategories};\n */\nexport interface IGetCategoriesResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategories}.\n */\nexport interface IGetCategoriesOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * The ArcGIS Places service has many categories (or types) of place, from\n * art museums to zoos. This endpoint returns all the categories including\n * their label and `categoryId`. The category Id can be used to search for\n * types of places with a `places/near-point` or `places/within-extent`\n * request.\n *\n * Categories also have information on their `parent`. This allows you to\n * search for specific categories such as \"French Restaurant\" - or to\n * look for more generic types such as \"Restaurant\".\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await getCategories({\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response.categories);\n * ```\n */\nexport function getCategories(\n requestOptions: IGetCategoriesOptions\n): Promise<IGetCategoriesResponse> {\n const options = appendCustomParams<IGetCategoriesOptions>(\n requestOptions,\n [\"filter\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/categories`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = operations[\"categoriesCategoryIdGet\"][\"parameters\"][\"query\"];\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesCategoryIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategory};\n */\nexport interface IGetCategoryResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategory}.\n */\nexport interface IGetCategoryOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n categoryId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns details about a single category by Id.\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = getCategory({\n * categoryId: \"10000\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response);\n * ```\n **/\nexport function getCategory(\n requestOptions: IGetCategoryOptions\n): Promise<IGetCategoryResponse> {\n const { categoryId } = requestOptions;\n\n const options = appendCustomParams<IGetCategoryOptions>(requestOptions, [], {\n ...requestOptions\n });\n\n return request(\n requestOptions.endpoint || `${baseUrl}/categories/${categoryId}`,\n {\n ...options,\n httpMethod: \"GET\"\n }\n );\n}\n","import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"placeIdGet\"][\"parameters\"][\"query\"],\n \"requestedFields\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"placeIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getPlace};\n */\nexport interface IGetPlaceResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getPlace}.\n */\nexport interface IGetPlaceOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n placeId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns a single place, including additional details, such as:\n *\n * - contact details\n * - address\n * - price information\n * - user rating\n * - opening hours\n *\n * This endpoint can be used to fetch additional details for a specific\n * place, returned from a places search request.\n *\n * Note that some fields, such as opening hours, are not available for\n * every place. Where a field is not available it will be omitted from the\n * response and you will not be charged for this data.\n *\n * ```js\n * import { getPlaceDetails } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const place = getPlaceDetails({\n * placeId: \"e78051acc722c55ab11ba930d8dd7772\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(place);\n * ```\n */\nexport function getPlaceDetails(\n requestOptions: IGetPlaceOptions\n): Promise<IGetPlaceResponse> {\n const { placeId } = requestOptions;\n\n const options = appendCustomParams<IGetPlaceOptions>(\n requestOptions,\n [\"requestedFields\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/places/${placeId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n"],"names":["baseUrl","hasNextPage","response","links","next","pagination","nextUrl","getNextPageParams","currentOffset","currentPageSize","offset","pageSize","findPlacesNearPoint","requestOptions","options","appendCustomParams","request","endpoint","httpMethod","then","r","nextPage","findPlacesWithinExtent","categoryId","placeId"],"mappings":";;;;;gVAAO,MAAMA,EACX,gFAEcC,EAAYC,WAC1B,mBAASA,eAAAA,EAAUC,4BAAOC,oBAAUF,eAAAA,EAAUG,iCAAYC,QAC5D,UAEgBC,EAAkBC,EAAgB,EAAGC,EAAkB,IACrE,MAAO,CACLC,OAAQF,EAAgBC,EACxBE,SAAUF,EAEd,gCCgEgBG,EACdC,GAEA,MAAMC,EAAUC,qBACdF,EACA,CAAC,IAAK,IAAK,SAAU,cAAe,WAAY,SAAU,+BAErDA,IAIP,OACEG,UAAQH,EAAeI,UAAY,GAAGjB,qDACjCc,IACHI,WAAY,SAEdC,MAAMjB,IACN,MAAMkB,mBACDlB,GAaL,OAVID,EAAYC,KACdkB,EAAEC,SAAW,IAKJT,iCAHFC,GACAN,EAAkBM,EAAeH,OAAQG,EAAeF,aAM1DS,CAAC,GAEZ,oCCzBgBE,EACdT,GAEA,MAAMC,EAAUC,qBACdF,EACA,CACE,OACA,OACA,OACA,OACA,cACA,WACA,SACA,+BAGGA,IAIP,OACEG,UAAQH,EAAeI,UAAY,GAAGjB,wDACjCc,IACHI,WAAY,SAEdC,MAAMjB,IACN,MAAMkB,mBACDlB,GAYL,OATID,EAAYC,KACdkB,EAAEC,SAAW,IAKJC,iCAHFT,GACAN,EAAkBM,EAAeH,OAAQG,EAAeF,aAK1DS,CAAC,GAEZ,2BChEEP,GAEA,MAAMC,EAAUC,qBACdF,EACA,CAAC,2BAEIA,IAIP,OAAOG,UAAQH,EAAeI,UAAY,GAAGjB,8CACxCc,IACHI,WAAY,QAEhB,yBCvBEL,GAEA,MAAMU,WAAEA,GAAeV,EAEjBC,EAAUC,qBAAwCF,EAAgB,oBACnEA,IAGL,OAAOG,UACLH,EAAeI,UAAY,GAAGjB,gBAAsBuB,mCAE/CT,IACHI,WAAY,QAGlB,6BCCEL,GAEA,MAAMW,QAAEA,GAAYX,EAEdC,EAAUC,qBACdF,EACA,CAAC,oCAEIA,IAIP,OAAOG,UAAQH,EAAeI,UAAY,GAAGjB,YAAkBwB,mCAC1DV,IACHI,WAAY,QAEhB"}
|
|
@@ -41,7 +41,7 @@ const utils_js_1 = require("./utils.js");
|
|
|
41
41
|
*/
|
|
42
42
|
function findPlacesNearPoint(requestOptions) {
|
|
43
43
|
const options = (0, arcgis_rest_request_1.appendCustomParams)(requestOptions, ["x", "y", "radius", "categoryIds", "pageSize", "offset", "searchText"], Object.assign({}, requestOptions));
|
|
44
|
-
return (0, arcgis_rest_request_1.request)(`${utils_js_1.baseUrl}/places/near-point`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
44
|
+
return (0, arcgis_rest_request_1.request)(requestOptions.endpoint || `${utils_js_1.baseUrl}/places/near-point`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
45
45
|
const r = Object.assign({}, response);
|
|
46
46
|
if ((0, utils_js_1.hasNextPage)(response)) {
|
|
47
47
|
r.nextPage = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findPlacesNearPoint.js","sourceRoot":"","sources":["../../src/findPlacesNearPoint.ts"],"names":[],"mappings":";;;AAAA,mEAImC;AAGnC,yCAAqE;
|
|
1
|
+
{"version":3,"file":"findPlacesNearPoint.js","sourceRoot":"","sources":["../../src/findPlacesNearPoint.ts"],"names":[],"mappings":";;;AAAA,mEAImC;AAGnC,yCAAqE;AAiCrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,SAAgB,mBAAmB,CACjC,cAA2C;IAE3C,MAAM,OAAO,GAAG,IAAA,wCAAkB,EAChC,cAAc,EACd,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,oBAElE,cAAc,EAEpB,CAAC;IAEF,OACE,IAAA,6BAAO,EAAC,cAAc,CAAC,QAAQ,IAAI,GAAG,kBAAO,oBAAoB,kCAC5D,OAAO,KACV,UAAU,EAAE,KAAK,IAEpB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QAClB,MAAM,CAAC,qBACF,QAAQ,CACZ,CAAC;QAEF,IAAI,IAAA,sBAAW,EAAC,QAAQ,CAAC,EAAE;YACzB,CAAC,CAAC,QAAQ,GAAG,GAAG,EAAE;gBAChB,MAAM,WAAW,mCACZ,cAAc,GACd,IAAA,4BAAiB,EAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CACrE,CAAC;gBACF,OAAO,mBAAmB,CAAC,WAAW,CAAC,CAAC;YAC1C,CAAC,CAAC;SACH;QAED,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC;AAjCD,kDAiCC","sourcesContent":["import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"nearPointGet\"][\"parameters\"][\"query\"],\n \"x\" | \"y\" | \"radius\" | \"categoryIds\" | \"pageSize\" | \"offset\" | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"nearPointGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesNearPoint};\n */\nexport interface IFindPlacesNearPointResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesNearPointResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlacesNearPointOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches places that are within a given radius of a geographic point.\n * You must supply the `x` and `y` coordinates of the point that you wish\n * to search from. You can either specify a search radius, or use the\n * default (500 meters). You could use this method to search for places\n * around a user's GPS position, or a location clicked on a map.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```js\n * import { findPlacesNearPoint } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await findPlacesNearPoint({\n * x: -3.1883,\n * y: 55.9533,\n * radius: 100,\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\");\n * });\n *\n * console.log(response);\n * ```\n */\nexport function findPlacesNearPoint(\n requestOptions: IFindPlacesNearPointOptions\n): Promise<IFindPlacesNearPointResponse> {\n const options = appendCustomParams<IFindPlacesNearPointOptions>(\n requestOptions,\n [\"x\", \"y\", \"radius\", \"categoryIds\", \"pageSize\", \"offset\", \"searchText\"],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/near-point`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesNearPointResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesNearPoint(nextOptions);\n };\n }\n\n return r;\n });\n}\n"]}
|
|
@@ -51,7 +51,7 @@ function findPlacesWithinExtent(requestOptions) {
|
|
|
51
51
|
"offset",
|
|
52
52
|
"searchText"
|
|
53
53
|
], Object.assign({}, requestOptions));
|
|
54
|
-
return (0, arcgis_rest_request_1.request)(`${utils_js_1.baseUrl}/places/within-extent`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
54
|
+
return (0, arcgis_rest_request_1.request)(requestOptions.endpoint || `${utils_js_1.baseUrl}/places/within-extent`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
55
55
|
const r = Object.assign({}, response);
|
|
56
56
|
if ((0, utils_js_1.hasNextPage)(response)) {
|
|
57
57
|
r.nextPage = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findPlacesWithinExtent.js","sourceRoot":"","sources":["../../src/findPlacesWithinExtent.ts"],"names":[],"mappings":";;;AAAA,mEAImC;AAGnC,yCAAqE;
|
|
1
|
+
{"version":3,"file":"findPlacesWithinExtent.js","sourceRoot":"","sources":["../../src/findPlacesWithinExtent.ts"],"names":[],"mappings":";;;AAAA,mEAImC;AAGnC,yCAAqE;AAwCrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,SAAgB,sBAAsB,CACpC,cAA6C;IAE7C,MAAM,OAAO,GAAG,IAAA,wCAAkB,EAChC,cAAc,EACd;QACE,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,aAAa;QACb,UAAU;QACV,QAAQ;QACR,YAAY;KACb,oBAEI,cAAc,EAEpB,CAAC;IAEF,OACE,IAAA,6BAAO,EAAC,cAAc,CAAC,QAAQ,IAAI,GAAG,kBAAO,uBAAuB,kCAC/D,OAAO,KACV,UAAU,EAAE,KAAK,IAEpB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QAClB,MAAM,CAAC,qBACF,QAAQ,CACZ,CAAC;QAEF,IAAI,IAAA,sBAAW,EAAC,QAAQ,CAAC,EAAE;YACzB,CAAC,CAAC,QAAQ,GAAG,GAAG,EAAE;gBAChB,MAAM,WAAW,mCACZ,cAAc,GACd,IAAA,4BAAiB,EAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CACrE,CAAC;gBACF,OAAO,sBAAsB,CAAC,WAAW,CAAC,CAAC;YAC7C,CAAC,CAAC;SACH;QACD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC;AAzCD,wDAyCC","sourcesContent":["import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"withinExtentGet\"][\"parameters\"][\"query\"],\n | \"xmin\"\n | \"ymin\"\n | \"xmax\"\n | \"ymax\"\n | \"categoryIds\"\n | \"pageSize\"\n | \"offset\"\n | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"withinExtentGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesWithinExtent};\n */\nexport interface IFindPlacesWithinExtentResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesWithinExtentResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlaceWithinExtentOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches the world-wide set of places for those that are within an\n * extent, or bounding box. You must supply the `xmin`, `ymin`, `xmax` and\n * `ymax` coordinates of the extent. You could use this endpoint to search\n * for places in the visible extent of a user's screen.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can also refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```\n * import { findPlacesWithinExtent } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const results = await findPlacesWithinExtent({\n * xmin: -118.013334,\n * ymin: 33.78193,\n * xmax: -117.795753,\n * ymax: 33.873337,\n * categoryIds: [\"13002\"],\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(results)\n * ```\n */\nexport function findPlacesWithinExtent(\n requestOptions: IFindPlaceWithinExtentOptions\n): Promise<IFindPlacesWithinExtentResponse> {\n const options = appendCustomParams<IFindPlaceWithinExtentOptions>(\n requestOptions,\n [\n \"xmin\",\n \"ymin\",\n \"xmax\",\n \"ymax\",\n \"categoryIds\",\n \"pageSize\",\n \"offset\",\n \"searchText\"\n ],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/within-extent`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesWithinExtentResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesWithinExtent(nextOptions);\n };\n }\n return r;\n });\n}\n"]}
|
|
@@ -27,7 +27,7 @@ const utils_js_1 = require("./utils.js");
|
|
|
27
27
|
*/
|
|
28
28
|
function getCategories(requestOptions) {
|
|
29
29
|
const options = (0, arcgis_rest_request_1.appendCustomParams)(requestOptions, ["filter"], Object.assign({}, requestOptions));
|
|
30
|
-
return (0, arcgis_rest_request_1.request)(`${utils_js_1.baseUrl}/categories`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
30
|
+
return (0, arcgis_rest_request_1.request)(requestOptions.endpoint || `${utils_js_1.baseUrl}/categories`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
31
31
|
}
|
|
32
32
|
exports.getCategories = getCategories;
|
|
33
33
|
//# sourceMappingURL=getCategories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCategories.js","sourceRoot":"","sources":["../../src/getCategories.ts"],"names":[],"mappings":";;;AAAA,mEAImC;AAGnC,yCAAqC;
|
|
1
|
+
{"version":3,"file":"getCategories.js","sourceRoot":"","sources":["../../src/getCategories.ts"],"names":[],"mappings":";;;AAAA,mEAImC;AAGnC,yCAAqC;AA+BrC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,aAAa,CAC3B,cAAqC;IAErC,MAAM,OAAO,GAAG,IAAA,wCAAkB,EAChC,cAAc,EACd,CAAC,QAAQ,CAAC,oBAEL,cAAc,EAEpB,CAAC;IAEF,OAAO,IAAA,6BAAO,EAAC,cAAc,CAAC,QAAQ,IAAI,GAAG,kBAAO,aAAa,kCAC5D,OAAO,KACV,UAAU,EAAE,KAAK,IACjB,CAAC;AACL,CAAC;AAfD,sCAeC","sourcesContent":["import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"categoriesGet\"][\"parameters\"][\"query\"],\n \"filter\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategories};\n */\nexport interface IGetCategoriesResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategories}.\n */\nexport interface IGetCategoriesOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * The ArcGIS Places service has many categories (or types) of place, from\n * art museums to zoos. This endpoint returns all the categories including\n * their label and `categoryId`. The category Id can be used to search for\n * types of places with a `places/near-point` or `places/within-extent`\n * request.\n *\n * Categories also have information on their `parent`. This allows you to\n * search for specific categories such as \"French Restaurant\" - or to\n * look for more generic types such as \"Restaurant\".\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await getCategories({\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response.categories);\n * ```\n */\nexport function getCategories(\n requestOptions: IGetCategoriesOptions\n): Promise<IGetCategoriesResponse> {\n const options = appendCustomParams<IGetCategoriesOptions>(\n requestOptions,\n [\"filter\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/categories`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n"]}
|
package/dist/cjs/getCategory.js
CHANGED
|
@@ -21,7 +21,7 @@ const utils_js_1 = require("./utils.js");
|
|
|
21
21
|
function getCategory(requestOptions) {
|
|
22
22
|
const { categoryId } = requestOptions;
|
|
23
23
|
const options = (0, arcgis_rest_request_1.appendCustomParams)(requestOptions, [], Object.assign({}, requestOptions));
|
|
24
|
-
return (0, arcgis_rest_request_1.request)(`${utils_js_1.baseUrl}/categories/${categoryId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
24
|
+
return (0, arcgis_rest_request_1.request)(requestOptions.endpoint || `${utils_js_1.baseUrl}/categories/${categoryId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
25
25
|
}
|
|
26
26
|
exports.getCategory = getCategory;
|
|
27
27
|
//# sourceMappingURL=getCategory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCategory.js","sourceRoot":"","sources":["../../src/getCategory.ts"],"names":[],"mappings":";;;AAAA,mEAImC;AAGnC,yCAAqC;
|
|
1
|
+
{"version":3,"file":"getCategory.js","sourceRoot":"","sources":["../../src/getCategory.ts"],"names":[],"mappings":";;;AAAA,mEAImC;AAGnC,yCAAqC;AA6BrC;;;;;;;;;;;;;;IAcI;AACJ,SAAgB,WAAW,CACzB,cAAmC;IAEnC,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC;IAEtC,MAAM,OAAO,GAAG,IAAA,wCAAkB,EAAsB,cAAc,EAAE,EAAE,oBACrE,cAAc,EACjB,CAAC;IAEH,OAAO,IAAA,6BAAO,EACZ,cAAc,CAAC,QAAQ,IAAI,GAAG,kBAAO,eAAe,UAAU,EAAE,kCAE3D,OAAO,KACV,UAAU,EAAE,KAAK,IAEpB,CAAC;AACJ,CAAC;AAhBD,kCAgBC","sourcesContent":["import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = operations[\"categoriesCategoryIdGet\"][\"parameters\"][\"query\"];\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesCategoryIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategory};\n */\nexport interface IGetCategoryResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategory}.\n */\nexport interface IGetCategoryOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n categoryId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns details about a single category by Id.\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = getCategory({\n * categoryId: \"10000\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response);\n * ```\n **/\nexport function getCategory(\n requestOptions: IGetCategoryOptions\n): Promise<IGetCategoryResponse> {\n const { categoryId } = requestOptions;\n\n const options = appendCustomParams<IGetCategoryOptions>(requestOptions, [], {\n ...requestOptions\n });\n\n return request(\n requestOptions.endpoint || `${baseUrl}/categories/${categoryId}`,\n {\n ...options,\n httpMethod: \"GET\"\n }\n );\n}\n"]}
|
|
@@ -34,7 +34,7 @@ const utils_js_1 = require("./utils.js");
|
|
|
34
34
|
function getPlaceDetails(requestOptions) {
|
|
35
35
|
const { placeId } = requestOptions;
|
|
36
36
|
const options = (0, arcgis_rest_request_1.appendCustomParams)(requestOptions, ["requestedFields"], Object.assign({}, requestOptions));
|
|
37
|
-
return (0, arcgis_rest_request_1.request)(`${utils_js_1.baseUrl}/places/${placeId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
37
|
+
return (0, arcgis_rest_request_1.request)(requestOptions.endpoint || `${utils_js_1.baseUrl}/places/${placeId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
38
38
|
}
|
|
39
39
|
exports.getPlaceDetails = getPlaceDetails;
|
|
40
40
|
//# sourceMappingURL=getPlaceDetails.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPlaceDetails.js","sourceRoot":"","sources":["../../src/getPlaceDetails.ts"],"names":[],"mappings":";;;AAAA,mEAImC;AAGnC,yCAAqC;
|
|
1
|
+
{"version":3,"file":"getPlaceDetails.js","sourceRoot":"","sources":["../../src/getPlaceDetails.ts"],"names":[],"mappings":";;;AAAA,mEAImC;AAGnC,yCAAqC;AAgCrC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,eAAe,CAC7B,cAAgC;IAEhC,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC;IAEnC,MAAM,OAAO,GAAG,IAAA,wCAAkB,EAChC,cAAc,EACd,CAAC,iBAAiB,CAAC,oBAEd,cAAc,EAEpB,CAAC;IAEF,OAAO,IAAA,6BAAO,EAAC,cAAc,CAAC,QAAQ,IAAI,GAAG,kBAAO,WAAW,OAAO,EAAE,kCACnE,OAAO,KACV,UAAU,EAAE,KAAK,IACjB,CAAC;AACL,CAAC;AAjBD,0CAiBC","sourcesContent":["import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"placeIdGet\"][\"parameters\"][\"query\"],\n \"requestedFields\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"placeIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getPlace};\n */\nexport interface IGetPlaceResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getPlace}.\n */\nexport interface IGetPlaceOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n placeId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns a single place, including additional details, such as:\n *\n * - contact details\n * - address\n * - price information\n * - user rating\n * - opening hours\n *\n * This endpoint can be used to fetch additional details for a specific\n * place, returned from a places search request.\n *\n * Note that some fields, such as opening hours, are not available for\n * every place. Where a field is not available it will be omitted from the\n * response and you will not be charged for this data.\n *\n * ```js\n * import { getPlaceDetails } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const place = getPlaceDetails({\n * placeId: \"e78051acc722c55ab11ba930d8dd7772\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(place);\n * ```\n */\nexport function getPlaceDetails(\n requestOptions: IGetPlaceOptions\n): Promise<IGetPlaceResponse> {\n const { placeId } = requestOptions;\n\n const options = appendCustomParams<IGetPlaceOptions>(\n requestOptions,\n [\"requestedFields\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/places/${placeId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n"]}
|
|
@@ -12,6 +12,11 @@ export interface IFindPlacesNearPointResponse extends successResponse {
|
|
|
12
12
|
* Options for {@linkcode findPlacesNearPoint}.
|
|
13
13
|
*/
|
|
14
14
|
export interface IFindPlacesNearPointOptions extends Omit<IRequestOptions, "httpMethod" | "f">, queryParams {
|
|
15
|
+
/**
|
|
16
|
+
* Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
endpoint?: string;
|
|
15
20
|
}
|
|
16
21
|
/**
|
|
17
22
|
* Searches places that are within a given radius of a geographic point.
|
|
@@ -38,7 +38,7 @@ import { baseUrl, hasNextPage, getNextPageParams } from "./utils.js";
|
|
|
38
38
|
*/
|
|
39
39
|
export function findPlacesNearPoint(requestOptions) {
|
|
40
40
|
const options = appendCustomParams(requestOptions, ["x", "y", "radius", "categoryIds", "pageSize", "offset", "searchText"], Object.assign({}, requestOptions));
|
|
41
|
-
return request(`${baseUrl}/places/near-point`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
41
|
+
return request(requestOptions.endpoint || `${baseUrl}/places/near-point`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
42
42
|
const r = Object.assign({}, response);
|
|
43
43
|
if (hasNextPage(response)) {
|
|
44
44
|
r.nextPage = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findPlacesNearPoint.js","sourceRoot":"","sources":["../../src/findPlacesNearPoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"findPlacesNearPoint.js","sourceRoot":"","sources":["../../src/findPlacesNearPoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAiCrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,mBAAmB,CACjC,cAA2C;IAE3C,MAAM,OAAO,GAAG,kBAAkB,CAChC,cAAc,EACd,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,oBAElE,cAAc,EAEpB,CAAC;IAEF,OACE,OAAO,CAAC,cAAc,CAAC,QAAQ,IAAI,GAAG,OAAO,oBAAoB,kCAC5D,OAAO,KACV,UAAU,EAAE,KAAK,IAEpB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QAClB,MAAM,CAAC,qBACF,QAAQ,CACZ,CAAC;QAEF,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE;YACzB,CAAC,CAAC,QAAQ,GAAG,GAAG,EAAE;gBAChB,MAAM,WAAW,mCACZ,cAAc,GACd,iBAAiB,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CACrE,CAAC;gBACF,OAAO,mBAAmB,CAAC,WAAW,CAAC,CAAC;YAC1C,CAAC,CAAC;SACH;QAED,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"nearPointGet\"][\"parameters\"][\"query\"],\n \"x\" | \"y\" | \"radius\" | \"categoryIds\" | \"pageSize\" | \"offset\" | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"nearPointGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesNearPoint};\n */\nexport interface IFindPlacesNearPointResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesNearPointResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlacesNearPointOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches places that are within a given radius of a geographic point.\n * You must supply the `x` and `y` coordinates of the point that you wish\n * to search from. You can either specify a search radius, or use the\n * default (500 meters). You could use this method to search for places\n * around a user's GPS position, or a location clicked on a map.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```js\n * import { findPlacesNearPoint } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await findPlacesNearPoint({\n * x: -3.1883,\n * y: 55.9533,\n * radius: 100,\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\");\n * });\n *\n * console.log(response);\n * ```\n */\nexport function findPlacesNearPoint(\n requestOptions: IFindPlacesNearPointOptions\n): Promise<IFindPlacesNearPointResponse> {\n const options = appendCustomParams<IFindPlacesNearPointOptions>(\n requestOptions,\n [\"x\", \"y\", \"radius\", \"categoryIds\", \"pageSize\", \"offset\", \"searchText\"],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/near-point`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesNearPointResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesNearPoint(nextOptions);\n };\n }\n\n return r;\n });\n}\n"]}
|
|
@@ -12,6 +12,11 @@ export interface IFindPlacesWithinExtentResponse extends successResponse {
|
|
|
12
12
|
* Options for {@linkcode findPlacesNearPoint}.
|
|
13
13
|
*/
|
|
14
14
|
export interface IFindPlaceWithinExtentOptions extends Omit<IRequestOptions, "httpMethod" | "f">, queryParams {
|
|
15
|
+
/**
|
|
16
|
+
* Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
endpoint?: string;
|
|
15
20
|
}
|
|
16
21
|
/**
|
|
17
22
|
* Searches the world-wide set of places for those that are within an
|
|
@@ -48,7 +48,7 @@ export function findPlacesWithinExtent(requestOptions) {
|
|
|
48
48
|
"offset",
|
|
49
49
|
"searchText"
|
|
50
50
|
], Object.assign({}, requestOptions));
|
|
51
|
-
return request(`${baseUrl}/places/within-extent`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
51
|
+
return request(requestOptions.endpoint || `${baseUrl}/places/within-extent`, Object.assign(Object.assign({}, options), { httpMethod: "GET" })).then((response) => {
|
|
52
52
|
const r = Object.assign({}, response);
|
|
53
53
|
if (hasNextPage(response)) {
|
|
54
54
|
r.nextPage = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findPlacesWithinExtent.js","sourceRoot":"","sources":["../../src/findPlacesWithinExtent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"findPlacesWithinExtent.js","sourceRoot":"","sources":["../../src/findPlacesWithinExtent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAwCrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,sBAAsB,CACpC,cAA6C;IAE7C,MAAM,OAAO,GAAG,kBAAkB,CAChC,cAAc,EACd;QACE,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;QACN,aAAa;QACb,UAAU;QACV,QAAQ;QACR,YAAY;KACb,oBAEI,cAAc,EAEpB,CAAC;IAEF,OACE,OAAO,CAAC,cAAc,CAAC,QAAQ,IAAI,GAAG,OAAO,uBAAuB,kCAC/D,OAAO,KACV,UAAU,EAAE,KAAK,IAEpB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;QAClB,MAAM,CAAC,qBACF,QAAQ,CACZ,CAAC;QAEF,IAAI,WAAW,CAAC,QAAQ,CAAC,EAAE;YACzB,CAAC,CAAC,QAAQ,GAAG,GAAG,EAAE;gBAChB,MAAM,WAAW,mCACZ,cAAc,GACd,iBAAiB,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CACrE,CAAC;gBACF,OAAO,sBAAsB,CAAC,WAAW,CAAC,CAAC;YAC7C,CAAC,CAAC;SACH;QACD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl, hasNextPage, getNextPageParams } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"withinExtentGet\"][\"parameters\"][\"query\"],\n | \"xmin\"\n | \"ymin\"\n | \"xmax\"\n | \"ymax\"\n | \"categoryIds\"\n | \"pageSize\"\n | \"offset\"\n | \"searchText\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"withinExtentGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode findPlacesWithinExtent};\n */\nexport interface IFindPlacesWithinExtentResponse extends successResponse {\n nextPage?: () => Promise<IFindPlacesWithinExtentResponse>;\n}\n\n/**\n * Options for {@linkcode findPlacesNearPoint}.\n */\nexport interface IFindPlaceWithinExtentOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Searches the world-wide set of places for those that are within an\n * extent, or bounding box. You must supply the `xmin`, `ymin`, `xmax` and\n * `ymax` coordinates of the extent. You could use this endpoint to search\n * for places in the visible extent of a user's screen.\n *\n * The returned places contain basic data such as name, category and\n * location. You can use the {@linkcode getPlace} method to get additional\n * details for a given place.\n *\n * You can also refine the results by supplying additional search parameters,\n * including:\n *\n * - A list of category Ids, see {@linkcode searchCategories} or {@linkcode getCategories}.\n * - A partial name filter with `name` option\n *\n * As this request can return many results, pagination is supported.\n * When a query results in more than [pageSize] places, the response will contain the property\n * `pagination` in addition to place results. If `pagination` exists, an additional method\n * `response.nextPage()` can be used to get the next page of results.\n *\n * ```\n * import { findPlacesWithinExtent } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const results = await findPlacesWithinExtent({\n * xmin: -118.013334,\n * ymin: 33.78193,\n * xmax: -117.795753,\n * ymax: 33.873337,\n * categoryIds: [\"13002\"],\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(results)\n * ```\n */\nexport function findPlacesWithinExtent(\n requestOptions: IFindPlaceWithinExtentOptions\n): Promise<IFindPlacesWithinExtentResponse> {\n const options = appendCustomParams<IFindPlaceWithinExtentOptions>(\n requestOptions,\n [\n \"xmin\",\n \"ymin\",\n \"xmax\",\n \"ymax\",\n \"categoryIds\",\n \"pageSize\",\n \"offset\",\n \"searchText\"\n ],\n {\n ...requestOptions\n }\n );\n\n return (\n request(requestOptions.endpoint || `${baseUrl}/places/within-extent`, {\n ...options,\n httpMethod: \"GET\"\n }) as Promise<successResponse>\n ).then((response) => {\n const r: IFindPlacesWithinExtentResponse = {\n ...response\n };\n\n if (hasNextPage(response)) {\n r.nextPage = () => {\n const nextOptions = {\n ...requestOptions,\n ...getNextPageParams(requestOptions.offset, requestOptions.pageSize)\n };\n return findPlacesWithinExtent(nextOptions);\n };\n }\n return r;\n });\n}\n"]}
|
|
@@ -11,6 +11,11 @@ export interface IGetCategoriesResponse extends successResponse {
|
|
|
11
11
|
* Options for {@linkcode getCategories}.
|
|
12
12
|
*/
|
|
13
13
|
export interface IGetCategoriesOptions extends Omit<IRequestOptions, "httpMethod" | "f">, queryParams {
|
|
14
|
+
/**
|
|
15
|
+
* Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
endpoint?: string;
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
21
|
* The ArcGIS Places service has many categories (or types) of place, from
|
|
@@ -24,6 +24,6 @@ import { baseUrl } from "./utils.js";
|
|
|
24
24
|
*/
|
|
25
25
|
export function getCategories(requestOptions) {
|
|
26
26
|
const options = appendCustomParams(requestOptions, ["filter"], Object.assign({}, requestOptions));
|
|
27
|
-
return request(`${baseUrl}/categories`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
27
|
+
return request(requestOptions.endpoint || `${baseUrl}/categories`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=getCategories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCategories.js","sourceRoot":"","sources":["../../src/getCategories.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"getCategories.js","sourceRoot":"","sources":["../../src/getCategories.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA+BrC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,aAAa,CAC3B,cAAqC;IAErC,MAAM,OAAO,GAAG,kBAAkB,CAChC,cAAc,EACd,CAAC,QAAQ,CAAC,oBAEL,cAAc,EAEpB,CAAC;IAEF,OAAO,OAAO,CAAC,cAAc,CAAC,QAAQ,IAAI,GAAG,OAAO,aAAa,kCAC5D,OAAO,KACV,UAAU,EAAE,KAAK,IACjB,CAAC;AACL,CAAC","sourcesContent":["import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"categoriesGet\"][\"parameters\"][\"query\"],\n \"filter\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategories};\n */\nexport interface IGetCategoriesResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategories}.\n */\nexport interface IGetCategoriesOptions\n extends Omit<IRequestOptions, \"httpMethod\" | \"f\">,\n queryParams {\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * The ArcGIS Places service has many categories (or types) of place, from\n * art museums to zoos. This endpoint returns all the categories including\n * their label and `categoryId`. The category Id can be used to search for\n * types of places with a `places/near-point` or `places/within-extent`\n * request.\n *\n * Categories also have information on their `parent`. This allows you to\n * search for specific categories such as \"French Restaurant\" - or to\n * look for more generic types such as \"Restaurant\".\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = await getCategories({\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response.categories);\n * ```\n */\nexport function getCategories(\n requestOptions: IGetCategoriesOptions\n): Promise<IGetCategoriesResponse> {\n const options = appendCustomParams<IGetCategoriesOptions>(\n requestOptions,\n [\"filter\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/categories`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n"]}
|
|
@@ -12,6 +12,11 @@ export interface IGetCategoryResponse extends successResponse {
|
|
|
12
12
|
*/
|
|
13
13
|
export interface IGetCategoryOptions extends Omit<IRequestOptions, "httpMethod">, queryParams {
|
|
14
14
|
categoryId: string;
|
|
15
|
+
/**
|
|
16
|
+
* Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
endpoint?: string;
|
|
15
20
|
}
|
|
16
21
|
/**
|
|
17
22
|
* Returns details about a single category by Id.
|
package/dist/esm/getCategory.js
CHANGED
|
@@ -18,6 +18,6 @@ import { baseUrl } from "./utils.js";
|
|
|
18
18
|
export function getCategory(requestOptions) {
|
|
19
19
|
const { categoryId } = requestOptions;
|
|
20
20
|
const options = appendCustomParams(requestOptions, [], Object.assign({}, requestOptions));
|
|
21
|
-
return request(`${baseUrl}/categories/${categoryId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
21
|
+
return request(requestOptions.endpoint || `${baseUrl}/categories/${categoryId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
22
22
|
}
|
|
23
23
|
//# sourceMappingURL=getCategory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCategory.js","sourceRoot":"","sources":["../../src/getCategory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"getCategory.js","sourceRoot":"","sources":["../../src/getCategory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA6BrC;;;;;;;;;;;;;;IAcI;AACJ,MAAM,UAAU,WAAW,CACzB,cAAmC;IAEnC,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,CAAC;IAEtC,MAAM,OAAO,GAAG,kBAAkB,CAAsB,cAAc,EAAE,EAAE,oBACrE,cAAc,EACjB,CAAC;IAEH,OAAO,OAAO,CACZ,cAAc,CAAC,QAAQ,IAAI,GAAG,OAAO,eAAe,UAAU,EAAE,kCAE3D,OAAO,KACV,UAAU,EAAE,KAAK,IAEpB,CAAC;AACJ,CAAC","sourcesContent":["import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = operations[\"categoriesCategoryIdGet\"][\"parameters\"][\"query\"];\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"categoriesCategoryIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getCategory};\n */\nexport interface IGetCategoryResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getCategory}.\n */\nexport interface IGetCategoryOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n categoryId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns details about a single category by Id.\n *\n * ```js\n * import { getCategories } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const response = getCategory({\n * categoryId: \"10000\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(response);\n * ```\n **/\nexport function getCategory(\n requestOptions: IGetCategoryOptions\n): Promise<IGetCategoryResponse> {\n const { categoryId } = requestOptions;\n\n const options = appendCustomParams<IGetCategoryOptions>(requestOptions, [], {\n ...requestOptions\n });\n\n return request(\n requestOptions.endpoint || `${baseUrl}/categories/${categoryId}`,\n {\n ...options,\n httpMethod: \"GET\"\n }\n );\n}\n"]}
|
|
@@ -12,6 +12,11 @@ export interface IGetPlaceResponse extends successResponse {
|
|
|
12
12
|
*/
|
|
13
13
|
export interface IGetPlaceOptions extends Omit<IRequestOptions, "httpMethod">, queryParams {
|
|
14
14
|
placeId: string;
|
|
15
|
+
/**
|
|
16
|
+
* Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
endpoint?: string;
|
|
15
20
|
}
|
|
16
21
|
/**
|
|
17
22
|
* Returns a single place, including additional details, such as:
|
|
@@ -31,6 +31,6 @@ import { baseUrl } from "./utils.js";
|
|
|
31
31
|
export function getPlaceDetails(requestOptions) {
|
|
32
32
|
const { placeId } = requestOptions;
|
|
33
33
|
const options = appendCustomParams(requestOptions, ["requestedFields"], Object.assign({}, requestOptions));
|
|
34
|
-
return request(`${baseUrl}/places/${placeId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
34
|
+
return request(requestOptions.endpoint || `${baseUrl}/places/${placeId}`, Object.assign(Object.assign({}, options), { httpMethod: "GET" }));
|
|
35
35
|
}
|
|
36
36
|
//# sourceMappingURL=getPlaceDetails.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPlaceDetails.js","sourceRoot":"","sources":["../../src/getPlaceDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"getPlaceDetails.js","sourceRoot":"","sources":["../../src/getPlaceDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAgCrC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,eAAe,CAC7B,cAAgC;IAEhC,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC;IAEnC,MAAM,OAAO,GAAG,kBAAkB,CAChC,cAAc,EACd,CAAC,iBAAiB,CAAC,oBAEd,cAAc,EAEpB,CAAC;IAEF,OAAO,OAAO,CAAC,cAAc,CAAC,QAAQ,IAAI,GAAG,OAAO,WAAW,OAAO,EAAE,kCACnE,OAAO,KACV,UAAU,EAAE,KAAK,IACjB,CAAC;AACL,CAAC","sourcesContent":["import {\n request,\n appendCustomParams,\n IRequestOptions\n} from \"@esri/arcgis-rest-request\";\n\nimport { operations } from \"./openapi-types.js\";\nimport { baseUrl } from \"./utils.js\";\n\n// determine the list of allowed params we want to allow as options\n// this should match the array given to appendCustomParams below\ntype queryParams = Pick<\n operations[\"placeIdGet\"][\"parameters\"][\"query\"],\n \"requestedFields\"\n>;\n\n// get the correct type of the response format\ntype successResponse =\n operations[\"placeIdGet\"][\"responses\"][\"200\"][\"content\"][\"application/json\"];\n\n/**\n * The response format for {@linkcode getPlace};\n */\nexport interface IGetPlaceResponse extends successResponse {}\n\n/**\n * Options for {@linkcode getPlace}.\n */\nexport interface IGetPlaceOptions\n extends Omit<IRequestOptions, \"httpMethod\">,\n queryParams {\n placeId: string;\n /**\n * Override the URL. This should be the full URL to the API endpoint you want to call. Used internally by Esri staff for testing.\n * @private\n */\n endpoint?: string;\n}\n\n/**\n * Returns a single place, including additional details, such as:\n *\n * - contact details\n * - address\n * - price information\n * - user rating\n * - opening hours\n *\n * This endpoint can be used to fetch additional details for a specific\n * place, returned from a places search request.\n *\n * Note that some fields, such as opening hours, are not available for\n * every place. Where a field is not available it will be omitted from the\n * response and you will not be charged for this data.\n *\n * ```js\n * import { getPlaceDetails } from \"@esri/arcgis-rest-places\";\n * import { ApiKeyManager } from \"@esri/arcgis-rest-request\";\n *\n * const place = getPlaceDetails({\n * placeId: \"e78051acc722c55ab11ba930d8dd7772\",\n * authentication: ApiKeyManager.fromKey(\"YOUR_API_KEY\")\n * });\n *\n * console.log(place);\n * ```\n */\nexport function getPlaceDetails(\n requestOptions: IGetPlaceOptions\n): Promise<IGetPlaceResponse> {\n const { placeId } = requestOptions;\n\n const options = appendCustomParams<IGetPlaceOptions>(\n requestOptions,\n [\"requestedFields\"],\n {\n ...requestOptions\n }\n );\n\n return request(requestOptions.endpoint || `${baseUrl}/places/${placeId}`, {\n ...options,\n httpMethod: \"GET\"\n });\n}\n"]}
|