@itwin/core-frontend 4.0.0-dev.22 → 4.0.0-dev.24
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/lib/cjs/GeoServices.d.ts +57 -5
- package/lib/cjs/GeoServices.d.ts.map +1 -1
- package/lib/cjs/GeoServices.js +182 -155
- package/lib/cjs/GeoServices.js.map +1 -1
- package/lib/cjs/request/Request.d.ts.map +1 -1
- package/lib/cjs/request/Request.js.map +1 -1
- package/lib/cjs/tile/GltfReader.js +1 -1
- package/lib/cjs/tile/GltfReader.js.map +1 -1
- package/lib/cjs/tile/map/ArcGisUtilities.d.ts.map +1 -1
- package/lib/cjs/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -2
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/esm/GeoServices.d.ts +57 -5
- package/lib/esm/GeoServices.d.ts.map +1 -1
- package/lib/esm/GeoServices.js +180 -154
- package/lib/esm/GeoServices.js.map +1 -1
- package/lib/esm/request/Request.d.ts.map +1 -1
- package/lib/esm/request/Request.js.map +1 -1
- package/lib/esm/tile/GltfReader.js +1 -1
- package/lib/esm/tile/GltfReader.js.map +1 -1
- package/lib/esm/tile/map/ArcGisUtilities.d.ts.map +1 -1
- package/lib/esm/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -2
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/package.json +18 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../src/request/Request.ts"],"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BACf,IAAI,EAAE,SAAS;iBAChB,CAAC;gBACF,OAAO,CAAC,WAAW,CAAC,CAAC;YACvB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;KACJ;IAED,0DAA0D;IAE1D;;;;;;MAME;IACF,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC;QAC7B,MAAM,WAAW,GAAa;YAC5B,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,MAAM,EAAE,QAAQ,CAAC,MAAM;SACxB,CAAC;QACF,OAAO,WAAW,CAAC;KACpB;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,WAAW,CAAC;KACnB;AACH,CAAC;AAzJD,0BAyJC;AAED;;;;GAIG;AACI,KAAK,UAAU,OAAO,CAAC,GAAW;IACvC,MAAM,OAAO,GAAmB;QAC9B,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,MAAM;KACrB,CAAC;IACF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAPD,0BAOC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module iTwinServiceClients\r\n */\r\nimport * as deepAssign from \"deep-assign\";\r\nimport * as _ from \"lodash\";\r\nimport * as https from \"https\";\r\nimport { IStringifyOptions, stringify } from \"qs\";\r\nimport * as sarequest from \"superagent\";\r\nimport { BentleyError, GetMetaDataFunction, HttpStatus, Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { FrontendLoggerCategory } from \"../FrontendLoggerCategory\";\r\n\r\nconst loggerCategory: string = FrontendLoggerCategory.Request;\r\n\r\n// CMS TODO: Move this entire wrapper to the frontend for use in the map/tile requests. Replace it with\r\n// just using fetch directly as it is only ever used browser side.\r\n\r\n/** @internal */\r\nexport const requestIdHeaderName = \"X-Correlation-Id\";\r\n\r\n/** @internal */\r\nexport interface RequestBasicCredentials { // axios: AxiosBasicCredentials\r\n user: string; // axios: username\r\n password: string; // axios: password\r\n}\r\n\r\n/** Typical option to query REST API. Note that services may not quite support these fields,\r\n * and the interface is only provided as a hint.\r\n * @internal\r\n */\r\nexport interface RequestQueryOptions {\r\n /**\r\n * Select string used by the query (use the mapped EC property names, and not TypeScript property names)\r\n * Example: \"Name,Size,Description\"\r\n */\r\n $select?: string;\r\n\r\n /**\r\n * Filter string used by the query (use the mapped EC property names, and not TypeScript property names)\r\n * Example: \"Name like '*.pdf' and Size lt 1000\"\r\n */\r\n $filter?: string;\r\n\r\n /** Sets the limit on the number of entries to be returned by the query */\r\n $top?: number;\r\n\r\n /** Sets the number of entries to be skipped */\r\n $skip?: number;\r\n\r\n /**\r\n * Orders the return values (use the mapped EC property names, and not TypeScript property names)\r\n * Example: \"Size desc\"\r\n */\r\n $orderby?: string;\r\n\r\n /**\r\n * Sets the limit on the number of entries to be returned by a single response.\r\n * Can be used with a Top option. For example if Top is set to 1000 and PageSize\r\n * is set to 100 then 10 requests will be performed to get result.\r\n */\r\n $pageSize?: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface RequestQueryStringifyOptions {\r\n delimiter?: string;\r\n encode?: boolean;\r\n}\r\n\r\n/** Option to control the time outs\r\n * Use a short response timeout to detect unresponsive networks quickly, and a long deadline to give time for downloads on slow,\r\n * but reliable, networks. Note that both of these timers limit how long uploads of attached files are allowed to take. Use long\r\n * timeouts if you're uploading files.\r\n * @internal\r\n */\r\nexport interface RequestTimeoutOptions {\r\n /** Sets a deadline (in milliseconds) for the entire request (including all uploads, redirects, server processing time) to complete.\r\n * If the response isn't fully downloaded within that time, the request will be aborted\r\n */\r\n deadline?: number;\r\n\r\n /** Sets maximum time (in milliseconds) to wait for the first byte to arrive from the server, but it does not limit how long the entire\r\n * download can take. Response timeout should be at least few seconds longer than just the time it takes the server to respond, because\r\n * it also includes time to make DNS lookup, TCP/IP and TLS connections, and time to upload request data.\r\n */\r\n response?: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface RequestOptions {\r\n method: string;\r\n headers?: any; // {Mas-App-Guid, Mas-UUid, User-Agent}\r\n auth?: RequestBasicCredentials;\r\n body?: any;\r\n qs?: any | RequestQueryOptions;\r\n responseType?: string;\r\n timeout?: RequestTimeoutOptions; // Optional timeouts. If unspecified, an arbitrary default is setup.\r\n stream?: any; // Optional stream to read the response to/from (only for NodeJs applications)\r\n readStream?: any; // Optional stream to read input from (only for NodeJs applications)\r\n buffer?: any;\r\n parser?: any;\r\n accept?: string;\r\n redirects?: number;\r\n errorCallback?: (response: any) => ResponseError;\r\n retryCallback?: (error: any, response: any) => boolean;\r\n progressCallback?: ProgressCallback;\r\n agent?: https.Agent;\r\n retries?: number;\r\n useCorsProxy?: boolean;\r\n}\r\n\r\n/** Response object if the request was successful. Note that the status within the range of 200-299 are considered as a success.\r\n * @internal\r\n */\r\nexport interface Response {\r\n body: any; // Parsed body of response\r\n text: string | undefined; // Returned for responseType:text\r\n header: any; // Parsed headers of response\r\n status: number; // Status code of response\r\n}\r\n\r\n/** @internal */\r\nexport interface ProgressInfo {\r\n percent?: number;\r\n total?: number;\r\n loaded: number;\r\n}\r\n\r\n/** @internal */\r\nexport type ProgressCallback = (progress: ProgressInfo) => void;\r\n\r\n/** @internal */\r\nexport class RequestGlobalOptions {\r\n public static httpsProxy?: https.Agent = undefined;\r\n /** Creates an agent for any user defined proxy using the supplied additional options. Returns undefined if user hasn't defined a proxy.\r\n * @internal\r\n */\r\n public static createHttpsProxy: (additionalOptions?: https.AgentOptions) => https.Agent | undefined = (_additionalOptions?: https.AgentOptions) => undefined;\r\n public static maxRetries: number = 4;\r\n public static timeout: RequestTimeoutOptions = {\r\n deadline: 25000,\r\n response: 10000,\r\n };\r\n // Assume application is online or offline. This hint skip retry/timeout\r\n public static online: boolean = true;\r\n}\r\n\r\n/** Error object that's thrown/rejected if the Request fails due to a network error, or if the status is *not* in the range of 200-299 (inclusive)\r\n * @internal\r\n */\r\nexport class ResponseError extends BentleyError {\r\n protected _data?: any;\r\n public status?: number;\r\n public description?: string;\r\n public constructor(errorNumber: number | HttpStatus, message?: string, getMetaData?: GetMetaDataFunction) {\r\n super(errorNumber, message, getMetaData);\r\n }\r\n\r\n /**\r\n * Parses error from server's response\r\n * @param response Http response from the server.\r\n * @returns Parsed error.\r\n * @internal\r\n */\r\n public static parse(response: any, log = true): ResponseError {\r\n const error = new ResponseError(ResponseError.parseHttpStatus(response.statusType));\r\n if (!response) {\r\n error.message = \"Couldn't get response object.\";\r\n return error;\r\n }\r\n\r\n if (response.response) {\r\n if (response.response.error) {\r\n error.name = response.response.error.name || error.name;\r\n error.description = response.response.error.message;\r\n }\r\n if (response.response.res) {\r\n error.message = response.response.res.statusMessage;\r\n }\r\n if (response.response.body && Object.keys(response.response.body).length > 0) {\r\n error._data = {};\r\n deepAssign.default(error._data, response.response.body);\r\n } else {\r\n error._data = response.response.text;\r\n }\r\n }\r\n\r\n error.status = response.status || response.statusCode;\r\n error.name = response.code || response.name || error.name;\r\n error.message = error.message || response.message || response.statusMessage;\r\n\r\n if (log)\r\n error.log();\r\n\r\n return error;\r\n }\r\n\r\n /**\r\n * Decides whether request should be retried or not\r\n * @param error Error returned by request\r\n * @param response Response returned by request\r\n * @internal\r\n */\r\n public static shouldRetry(error: any, response: any): boolean {\r\n if (error !== undefined && error !== null) {\r\n if ((error.status === undefined || error.status === null) && (error.res === undefined || error.res === null)) {\r\n return true;\r\n }\r\n }\r\n return (response !== undefined && response.statusType === HttpStatus.ServerError);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static parseHttpStatus(statusType: number): HttpStatus {\r\n switch (statusType) {\r\n case 1:\r\n return HttpStatus.Info;\r\n case 2:\r\n return HttpStatus.Success;\r\n case 3:\r\n return HttpStatus.Redirection;\r\n case 4:\r\n return HttpStatus.ClientError;\r\n case 5:\r\n return HttpStatus.ServerError;\r\n default:\r\n return HttpStatus.Success;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public logMessage(): string {\r\n return `${this.status} ${this.name}: ${this.message}`;\r\n }\r\n\r\n /**\r\n * Logs this error\r\n * @internal\r\n */\r\n public log(): void {\r\n Logger.logError(loggerCategory, this.logMessage(), () => this.getMetaData());\r\n }\r\n}\r\n\r\nconst logResponse = (req: sarequest.SuperAgentRequest, startTime: number) => (res: sarequest.Response) => {\r\n const elapsed = new Date().getTime() - startTime;\r\n const elapsedTime = `${elapsed}ms`;\r\n Logger.logTrace(loggerCategory, `${req.method.toUpperCase()} ${res.status} ${req.url} (${elapsedTime})`);\r\n};\r\n\r\n// eslint-disable-next-line @typescript-eslint/promise-function-async\r\nconst logRequest = (req: sarequest.SuperAgentRequest): sarequest.SuperAgentRequest => {\r\n const startTime = new Date().getTime();\r\n return req.on(\"response\", logResponse(req, startTime));\r\n};\r\n\r\n/** Wrapper around making HTTP requests with the specific options.\r\n *\r\n * Usable in both a browser and node based environment.\r\n *\r\n * @param url Server URL to address the request\r\n * @param options Options to pass to the request\r\n * @returns Resolves to the response from the server\r\n * @throws ResponseError if the request fails due to network issues, or if the returned status is *outside* the range of 200-299 (inclusive)\r\n * @internal\r\n */\r\nexport async function request(url: string, options: RequestOptions): Promise<Response> {\r\n if (!RequestGlobalOptions.online) {\r\n throw new ResponseError(503, \"Service unavailable\");\r\n }\r\n\r\n let sareq: sarequest.SuperAgentRequest = sarequest.default(options.method, url);\r\n const retries = typeof options.retries === \"undefined\" ? RequestGlobalOptions.maxRetries : options.retries;\r\n sareq = sareq.retry(retries, options.retryCallback);\r\n\r\n if (Logger.isEnabled(loggerCategory, LogLevel.Trace))\r\n sareq = sareq.use(logRequest);\r\n\r\n if (options.headers)\r\n sareq = sareq.set(options.headers);\r\n\r\n let queryStr: string = \"\";\r\n let fullUrl: string = \"\";\r\n if (options.qs && Object.keys(options.qs).length > 0) {\r\n const stringifyOptions: IStringifyOptions = { delimiter: \"&\", encode: false };\r\n queryStr = stringify(options.qs, stringifyOptions);\r\n sareq = sareq.query(queryStr);\r\n fullUrl = `${url}?${queryStr}`;\r\n } else {\r\n fullUrl = url;\r\n }\r\n\r\n Logger.logInfo(loggerCategory, fullUrl);\r\n\r\n if (options.auth)\r\n sareq = sareq.auth(options.auth.user, options.auth.password);\r\n\r\n if (options.accept)\r\n sareq = sareq.accept(options.accept);\r\n\r\n if (options.body)\r\n sareq = sareq.send(options.body);\r\n\r\n if (options.timeout)\r\n sareq = sareq.timeout(options.timeout);\r\n else\r\n sareq = sareq.timeout(RequestGlobalOptions.timeout);\r\n\r\n if (options.responseType)\r\n sareq = sareq.responseType(options.responseType);\r\n\r\n if (options.redirects)\r\n sareq = sareq.redirects(options.redirects);\r\n else\r\n sareq = sareq.redirects(0);\r\n\r\n if (options.buffer)\r\n sareq = sareq.buffer(options.buffer);\r\n\r\n if (options.parser)\r\n sareq = sareq.parse(options.parser);\r\n\r\n /** Default to any globally supplied proxy, unless an agent is specified in this call */\r\n if (options.agent)\r\n sareq = sareq.agent(options.agent);\r\n else if (RequestGlobalOptions.httpsProxy)\r\n sareq = sareq.agent(RequestGlobalOptions.httpsProxy);\r\n\r\n if (options.progressCallback) {\r\n sareq = sareq.on(\"progress\", (event: sarequest.ProgressEvent) => {\r\n if (event) {\r\n options.progressCallback!({\r\n loaded: event.loaded,\r\n total: event.total,\r\n percent: event.percent,\r\n });\r\n }\r\n });\r\n }\r\n\r\n const errorCallback = options.errorCallback ? options.errorCallback : ResponseError.parse;\r\n\r\n if (options.readStream) {\r\n if (typeof window !== \"undefined\")\r\n throw new Error(\"This option is not supported on browsers\");\r\n\r\n return new Promise<Response>((resolve, reject) => {\r\n sareq = sareq.type(\"blob\");\r\n options\r\n .readStream\r\n .pipe(sareq)\r\n .on(\"error\", (error: any) => {\r\n const parsedError = errorCallback(error);\r\n reject(parsedError);\r\n })\r\n .on(\"end\", () => {\r\n const retResponse: Response = {\r\n status: 201,\r\n header: undefined,\r\n body: undefined,\r\n text: undefined,\r\n };\r\n resolve(retResponse);\r\n });\r\n });\r\n }\r\n\r\n if (options.stream) {\r\n if (typeof window !== \"undefined\")\r\n throw new Error(\"This option is not supported on browsers\");\r\n\r\n return new Promise<Response>((resolve, reject) => {\r\n sareq\r\n .on(\"response\", (res: any) => {\r\n if (res.statusCode !== 200) {\r\n const parsedError = errorCallback(res);\r\n reject(parsedError);\r\n return;\r\n }\r\n })\r\n .pipe(options.stream)\r\n .on(\"error\", (error: any) => {\r\n const parsedError = errorCallback(error);\r\n reject(parsedError);\r\n })\r\n .on(\"finish\", () => {\r\n const retResponse: Response = {\r\n status: 200,\r\n header: undefined,\r\n body: undefined,\r\n text: undefined,\r\n };\r\n resolve(retResponse);\r\n });\r\n });\r\n }\r\n\r\n // console.log(\"%s %s %s\", url, options.method, queryStr);\r\n\r\n /**\r\n * Note:\r\n * Javascript's fetch returns status.OK if error is between 200-299 inclusive, and doesn't reject in this case.\r\n * Fetch only rejects if there's some network issue (permissions issue or similar)\r\n * Superagent rejects network issues, and errors outside the range of 200-299. We are currently using\r\n * superagent, but may eventually switch to JavaScript's fetch library.\r\n */\r\n try {\r\n const response = await sareq;\r\n const retResponse: Response = {\r\n body: response.body,\r\n text: response.text,\r\n header: response.header,\r\n status: response.status,\r\n };\r\n return retResponse;\r\n } catch (error) {\r\n const parsedError = errorCallback(error);\r\n throw parsedError;\r\n }\r\n}\r\n\r\n/**\r\n * fetch json from HTTP request\r\n * @param url server URL to address the request\r\n * @internal\r\n */\r\nexport async function getJson(url: string): Promise<any> {\r\n const options: RequestOptions = {\r\n method: \"GET\",\r\n responseType: \"json\",\r\n };\r\n const data = await request(url, options);\r\n return data.body;\r\n}\r\n"]}
|
|
1
|
+
{"version":3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,MAAM,EAAE,SAAS;oBACjB,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,SAAS;iBAChB,CAAC;gBACF,OAAO,CAAC,WAAW,CAAC,CAAC;YACvB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;KACJ;IAED,0DAA0D;IAE1D;;;;;;MAME;IACF,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC;QAC7B,MAAM,WAAW,GAAa;YAC5B,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,MAAM,EAAE,QAAQ,CAAC,MAAM;SACxB,CAAC;QACF,OAAO,WAAW,CAAC;KACpB;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QACzC,MAAM,WAAW,CAAC;KACnB;AACH,CAAC;AAzJD,0BAyJC;AAED;;;;GAIG;AACI,KAAK,UAAU,OAAO,CAAC,GAAW;IACvC,MAAM,OAAO,GAAmB;QAC9B,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,MAAM;KACrB,CAAC;IACF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAPD,0BAOC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module iTwinServiceClients\r\n */\r\nimport * as deepAssign from \"deep-assign\";\r\nimport * as https from \"https\";\r\nimport { IStringifyOptions, stringify } from \"qs\";\r\nimport * as sarequest from \"superagent\";\r\nimport { BentleyError, GetMetaDataFunction, HttpStatus, Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { FrontendLoggerCategory } from \"../FrontendLoggerCategory\";\r\n\r\nconst loggerCategory: string = FrontendLoggerCategory.Request;\r\n\r\n// CMS TODO: Move this entire wrapper to the frontend for use in the map/tile requests. Replace it with\r\n// just using fetch directly as it is only ever used browser side.\r\n\r\n/** @internal */\r\nexport const requestIdHeaderName = \"X-Correlation-Id\";\r\n\r\n/** @internal */\r\nexport interface RequestBasicCredentials { // axios: AxiosBasicCredentials\r\n user: string; // axios: username\r\n password: string; // axios: password\r\n}\r\n\r\n/** Typical option to query REST API. Note that services may not quite support these fields,\r\n * and the interface is only provided as a hint.\r\n * @internal\r\n */\r\nexport interface RequestQueryOptions {\r\n /**\r\n * Select string used by the query (use the mapped EC property names, and not TypeScript property names)\r\n * Example: \"Name,Size,Description\"\r\n */\r\n $select?: string;\r\n\r\n /**\r\n * Filter string used by the query (use the mapped EC property names, and not TypeScript property names)\r\n * Example: \"Name like '*.pdf' and Size lt 1000\"\r\n */\r\n $filter?: string;\r\n\r\n /** Sets the limit on the number of entries to be returned by the query */\r\n $top?: number;\r\n\r\n /** Sets the number of entries to be skipped */\r\n $skip?: number;\r\n\r\n /**\r\n * Orders the return values (use the mapped EC property names, and not TypeScript property names)\r\n * Example: \"Size desc\"\r\n */\r\n $orderby?: string;\r\n\r\n /**\r\n * Sets the limit on the number of entries to be returned by a single response.\r\n * Can be used with a Top option. For example if Top is set to 1000 and PageSize\r\n * is set to 100 then 10 requests will be performed to get result.\r\n */\r\n $pageSize?: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface RequestQueryStringifyOptions {\r\n delimiter?: string;\r\n encode?: boolean;\r\n}\r\n\r\n/** Option to control the time outs\r\n * Use a short response timeout to detect unresponsive networks quickly, and a long deadline to give time for downloads on slow,\r\n * but reliable, networks. Note that both of these timers limit how long uploads of attached files are allowed to take. Use long\r\n * timeouts if you're uploading files.\r\n * @internal\r\n */\r\nexport interface RequestTimeoutOptions {\r\n /** Sets a deadline (in milliseconds) for the entire request (including all uploads, redirects, server processing time) to complete.\r\n * If the response isn't fully downloaded within that time, the request will be aborted\r\n */\r\n deadline?: number;\r\n\r\n /** Sets maximum time (in milliseconds) to wait for the first byte to arrive from the server, but it does not limit how long the entire\r\n * download can take. Response timeout should be at least few seconds longer than just the time it takes the server to respond, because\r\n * it also includes time to make DNS lookup, TCP/IP and TLS connections, and time to upload request data.\r\n */\r\n response?: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface RequestOptions {\r\n method: string;\r\n headers?: any; // {Mas-App-Guid, Mas-UUid, User-Agent}\r\n auth?: RequestBasicCredentials;\r\n body?: any;\r\n qs?: any | RequestQueryOptions;\r\n responseType?: string;\r\n timeout?: RequestTimeoutOptions; // Optional timeouts. If unspecified, an arbitrary default is setup.\r\n stream?: any; // Optional stream to read the response to/from (only for NodeJs applications)\r\n readStream?: any; // Optional stream to read input from (only for NodeJs applications)\r\n buffer?: any;\r\n parser?: any;\r\n accept?: string;\r\n redirects?: number;\r\n errorCallback?: (response: any) => ResponseError;\r\n retryCallback?: (error: any, response: any) => boolean;\r\n progressCallback?: ProgressCallback;\r\n agent?: https.Agent;\r\n retries?: number;\r\n useCorsProxy?: boolean;\r\n}\r\n\r\n/** Response object if the request was successful. Note that the status within the range of 200-299 are considered as a success.\r\n * @internal\r\n */\r\nexport interface Response {\r\n body: any; // Parsed body of response\r\n text: string | undefined; // Returned for responseType:text\r\n header: any; // Parsed headers of response\r\n status: number; // Status code of response\r\n}\r\n\r\n/** @internal */\r\nexport interface ProgressInfo {\r\n percent?: number;\r\n total?: number;\r\n loaded: number;\r\n}\r\n\r\n/** @internal */\r\nexport type ProgressCallback = (progress: ProgressInfo) => void;\r\n\r\n/** @internal */\r\nexport class RequestGlobalOptions {\r\n public static httpsProxy?: https.Agent = undefined;\r\n /** Creates an agent for any user defined proxy using the supplied additional options. Returns undefined if user hasn't defined a proxy.\r\n * @internal\r\n */\r\n public static createHttpsProxy: (additionalOptions?: https.AgentOptions) => https.Agent | undefined = (_additionalOptions?: https.AgentOptions) => undefined;\r\n public static maxRetries: number = 4;\r\n public static timeout: RequestTimeoutOptions = {\r\n deadline: 25000,\r\n response: 10000,\r\n };\r\n // Assume application is online or offline. This hint skip retry/timeout\r\n public static online: boolean = true;\r\n}\r\n\r\n/** Error object that's thrown/rejected if the Request fails due to a network error, or if the status is *not* in the range of 200-299 (inclusive)\r\n * @internal\r\n */\r\nexport class ResponseError extends BentleyError {\r\n protected _data?: any;\r\n public status?: number;\r\n public description?: string;\r\n public constructor(errorNumber: number | HttpStatus, message?: string, getMetaData?: GetMetaDataFunction) {\r\n super(errorNumber, message, getMetaData);\r\n }\r\n\r\n /**\r\n * Parses error from server's response\r\n * @param response Http response from the server.\r\n * @returns Parsed error.\r\n * @internal\r\n */\r\n public static parse(response: any, log = true): ResponseError {\r\n const error = new ResponseError(ResponseError.parseHttpStatus(response.statusType));\r\n if (!response) {\r\n error.message = \"Couldn't get response object.\";\r\n return error;\r\n }\r\n\r\n if (response.response) {\r\n if (response.response.error) {\r\n error.name = response.response.error.name || error.name;\r\n error.description = response.response.error.message;\r\n }\r\n if (response.response.res) {\r\n error.message = response.response.res.statusMessage;\r\n }\r\n if (response.response.body && Object.keys(response.response.body).length > 0) {\r\n error._data = {};\r\n deepAssign.default(error._data, response.response.body);\r\n } else {\r\n error._data = response.response.text;\r\n }\r\n }\r\n\r\n error.status = response.status || response.statusCode;\r\n error.name = response.code || response.name || error.name;\r\n error.message = error.message || response.message || response.statusMessage;\r\n\r\n if (log)\r\n error.log();\r\n\r\n return error;\r\n }\r\n\r\n /**\r\n * Decides whether request should be retried or not\r\n * @param error Error returned by request\r\n * @param response Response returned by request\r\n * @internal\r\n */\r\n public static shouldRetry(error: any, response: any): boolean {\r\n if (error !== undefined && error !== null) {\r\n if ((error.status === undefined || error.status === null) && (error.res === undefined || error.res === null)) {\r\n return true;\r\n }\r\n }\r\n return (response !== undefined && response.statusType === HttpStatus.ServerError);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static parseHttpStatus(statusType: number): HttpStatus {\r\n switch (statusType) {\r\n case 1:\r\n return HttpStatus.Info;\r\n case 2:\r\n return HttpStatus.Success;\r\n case 3:\r\n return HttpStatus.Redirection;\r\n case 4:\r\n return HttpStatus.ClientError;\r\n case 5:\r\n return HttpStatus.ServerError;\r\n default:\r\n return HttpStatus.Success;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public logMessage(): string {\r\n return `${this.status} ${this.name}: ${this.message}`;\r\n }\r\n\r\n /**\r\n * Logs this error\r\n * @internal\r\n */\r\n public log(): void {\r\n Logger.logError(loggerCategory, this.logMessage(), () => this.getMetaData());\r\n }\r\n}\r\n\r\nconst logResponse = (req: sarequest.SuperAgentRequest, startTime: number) => (res: sarequest.Response) => {\r\n const elapsed = new Date().getTime() - startTime;\r\n const elapsedTime = `${elapsed}ms`;\r\n Logger.logTrace(loggerCategory, `${req.method.toUpperCase()} ${res.status} ${req.url} (${elapsedTime})`);\r\n};\r\n\r\n// eslint-disable-next-line @typescript-eslint/promise-function-async\r\nconst logRequest = (req: sarequest.SuperAgentRequest): sarequest.SuperAgentRequest => {\r\n const startTime = new Date().getTime();\r\n return req.on(\"response\", logResponse(req, startTime));\r\n};\r\n\r\n/** Wrapper around making HTTP requests with the specific options.\r\n *\r\n * Usable in both a browser and node based environment.\r\n *\r\n * @param url Server URL to address the request\r\n * @param options Options to pass to the request\r\n * @returns Resolves to the response from the server\r\n * @throws ResponseError if the request fails due to network issues, or if the returned status is *outside* the range of 200-299 (inclusive)\r\n * @internal\r\n */\r\nexport async function request(url: string, options: RequestOptions): Promise<Response> {\r\n if (!RequestGlobalOptions.online) {\r\n throw new ResponseError(503, \"Service unavailable\");\r\n }\r\n\r\n let sareq: sarequest.SuperAgentRequest = sarequest.default(options.method, url);\r\n const retries = typeof options.retries === \"undefined\" ? RequestGlobalOptions.maxRetries : options.retries;\r\n sareq = sareq.retry(retries, options.retryCallback);\r\n\r\n if (Logger.isEnabled(loggerCategory, LogLevel.Trace))\r\n sareq = sareq.use(logRequest);\r\n\r\n if (options.headers)\r\n sareq = sareq.set(options.headers);\r\n\r\n let queryStr: string = \"\";\r\n let fullUrl: string = \"\";\r\n if (options.qs && Object.keys(options.qs).length > 0) {\r\n const stringifyOptions: IStringifyOptions = { delimiter: \"&\", encode: false };\r\n queryStr = stringify(options.qs, stringifyOptions);\r\n sareq = sareq.query(queryStr);\r\n fullUrl = `${url}?${queryStr}`;\r\n } else {\r\n fullUrl = url;\r\n }\r\n\r\n Logger.logInfo(loggerCategory, fullUrl);\r\n\r\n if (options.auth)\r\n sareq = sareq.auth(options.auth.user, options.auth.password);\r\n\r\n if (options.accept)\r\n sareq = sareq.accept(options.accept);\r\n\r\n if (options.body)\r\n sareq = sareq.send(options.body);\r\n\r\n if (options.timeout)\r\n sareq = sareq.timeout(options.timeout);\r\n else\r\n sareq = sareq.timeout(RequestGlobalOptions.timeout);\r\n\r\n if (options.responseType)\r\n sareq = sareq.responseType(options.responseType);\r\n\r\n if (options.redirects)\r\n sareq = sareq.redirects(options.redirects);\r\n else\r\n sareq = sareq.redirects(0);\r\n\r\n if (options.buffer)\r\n sareq = sareq.buffer(options.buffer);\r\n\r\n if (options.parser)\r\n sareq = sareq.parse(options.parser);\r\n\r\n /** Default to any globally supplied proxy, unless an agent is specified in this call */\r\n if (options.agent)\r\n sareq = sareq.agent(options.agent);\r\n else if (RequestGlobalOptions.httpsProxy)\r\n sareq = sareq.agent(RequestGlobalOptions.httpsProxy);\r\n\r\n if (options.progressCallback) {\r\n sareq = sareq.on(\"progress\", (event: sarequest.ProgressEvent) => {\r\n if (event) {\r\n options.progressCallback!({\r\n loaded: event.loaded,\r\n total: event.total,\r\n percent: event.percent,\r\n });\r\n }\r\n });\r\n }\r\n\r\n const errorCallback = options.errorCallback ? options.errorCallback : ResponseError.parse;\r\n\r\n if (options.readStream) {\r\n if (typeof window !== \"undefined\")\r\n throw new Error(\"This option is not supported on browsers\");\r\n\r\n return new Promise<Response>((resolve, reject) => {\r\n sareq = sareq.type(\"blob\");\r\n options\r\n .readStream\r\n .pipe(sareq)\r\n .on(\"error\", (error: any) => {\r\n const parsedError = errorCallback(error);\r\n reject(parsedError);\r\n })\r\n .on(\"end\", () => {\r\n const retResponse: Response = {\r\n status: 201,\r\n header: undefined,\r\n body: undefined,\r\n text: undefined,\r\n };\r\n resolve(retResponse);\r\n });\r\n });\r\n }\r\n\r\n if (options.stream) {\r\n if (typeof window !== \"undefined\")\r\n throw new Error(\"This option is not supported on browsers\");\r\n\r\n return new Promise<Response>((resolve, reject) => {\r\n sareq\r\n .on(\"response\", (res: any) => {\r\n if (res.statusCode !== 200) {\r\n const parsedError = errorCallback(res);\r\n reject(parsedError);\r\n return;\r\n }\r\n })\r\n .pipe(options.stream)\r\n .on(\"error\", (error: any) => {\r\n const parsedError = errorCallback(error);\r\n reject(parsedError);\r\n })\r\n .on(\"finish\", () => {\r\n const retResponse: Response = {\r\n status: 200,\r\n header: undefined,\r\n body: undefined,\r\n text: undefined,\r\n };\r\n resolve(retResponse);\r\n });\r\n });\r\n }\r\n\r\n // console.log(\"%s %s %s\", url, options.method, queryStr);\r\n\r\n /**\r\n * Note:\r\n * Javascript's fetch returns status.OK if error is between 200-299 inclusive, and doesn't reject in this case.\r\n * Fetch only rejects if there's some network issue (permissions issue or similar)\r\n * Superagent rejects network issues, and errors outside the range of 200-299. We are currently using\r\n * superagent, but may eventually switch to JavaScript's fetch library.\r\n */\r\n try {\r\n const response = await sareq;\r\n const retResponse: Response = {\r\n body: response.body,\r\n text: response.text,\r\n header: response.header,\r\n status: response.status,\r\n };\r\n return retResponse;\r\n } catch (error) {\r\n const parsedError = errorCallback(error);\r\n throw parsedError;\r\n }\r\n}\r\n\r\n/**\r\n * fetch json from HTTP request\r\n * @param url server URL to address the request\r\n * @internal\r\n */\r\nexport async function getJson(url: string): Promise<any> {\r\n const options: RequestOptions = {\r\n method: \"GET\",\r\n responseType: \"json\",\r\n };\r\n const data = await request(url, options);\r\n return data.body;\r\n}\r\n"]}
|
|
@@ -828,7 +828,7 @@ class GltfReader {
|
|
|
828
828
|
readMeshPrimitive(primitive, featureTable, pseudoRtcBias) {
|
|
829
829
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
830
830
|
const materialName = core_bentley_1.JsonUtils.asString(primitive.material);
|
|
831
|
-
const material = 0 < materialName.length ? this._materials[materialName] :
|
|
831
|
+
const material = 0 < materialName.length ? this._materials[materialName] : {};
|
|
832
832
|
if (!material)
|
|
833
833
|
return undefined;
|
|
834
834
|
const hasBakedLighting = undefined === primitive.attributes.NORMAL || undefined !== ((_a = material.extensions) === null || _a === void 0 ? void 0 : _a.KHR_materials_unlit);
|