@itwin/core-backend 3.5.0-dev.41 → 3.5.0-dev.45

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
  3. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  4. package/lib/cjs/ClassRegistry.d.ts +8 -1
  5. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  6. package/lib/cjs/ClassRegistry.js +22 -16
  7. package/lib/cjs/ClassRegistry.js.map +1 -1
  8. package/lib/cjs/ElementAspect.d.ts +21 -3
  9. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  10. package/lib/cjs/ElementAspect.js +28 -3
  11. package/lib/cjs/ElementAspect.js.map +1 -1
  12. package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
  13. package/lib/cjs/GeoCoordConfig.js +10 -6
  14. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  15. package/lib/cjs/IModelHost.d.ts +1 -0
  16. package/lib/cjs/IModelHost.d.ts.map +1 -1
  17. package/lib/cjs/IModelHost.js +4 -0
  18. package/lib/cjs/IModelHost.js.map +1 -1
  19. package/lib/cjs/RpcBackend.d.ts +0 -23
  20. package/lib/cjs/RpcBackend.d.ts.map +1 -1
  21. package/lib/cjs/RpcBackend.js +13 -108
  22. package/lib/cjs/RpcBackend.js.map +1 -1
  23. package/lib/cjs/core-backend.d.ts +1 -1
  24. package/lib/cjs/core-backend.d.ts.map +1 -1
  25. package/lib/cjs/core-backend.js +1 -1
  26. package/lib/cjs/core-backend.js.map +1 -1
  27. package/lib/cjs/rpc/multipart.d.ts +12 -0
  28. package/lib/cjs/rpc/multipart.d.ts.map +1 -0
  29. package/lib/cjs/rpc/multipart.js +71 -0
  30. package/lib/cjs/rpc/multipart.js.map +1 -0
  31. package/lib/cjs/rpc/tracing.d.ts +29 -0
  32. package/lib/cjs/rpc/tracing.d.ts.map +1 -0
  33. package/lib/cjs/rpc/tracing.js +74 -0
  34. package/lib/cjs/rpc/tracing.js.map +1 -0
  35. package/lib/cjs/rpc/web/logging.d.ts +10 -0
  36. package/lib/cjs/rpc/web/logging.d.ts.map +1 -0
  37. package/lib/cjs/rpc/web/logging.js +43 -0
  38. package/lib/cjs/rpc/web/logging.js.map +1 -0
  39. package/lib/cjs/rpc/web/request.d.ts +7 -0
  40. package/lib/cjs/rpc/web/request.d.ts.map +1 -0
  41. package/lib/cjs/rpc/web/request.js +74 -0
  42. package/lib/cjs/rpc/web/request.js.map +1 -0
  43. package/lib/cjs/rpc/web/response.d.ts +7 -0
  44. package/lib/cjs/rpc/web/response.d.ts.map +1 -0
  45. package/lib/cjs/rpc/web/response.js +106 -0
  46. package/lib/cjs/rpc/web/response.js.map +1 -0
  47. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +29 -29
  48. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  49. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +7 -7
  50. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  51. package/package.json +14 -14
@@ -1 +1 @@
1
- {"version":3,"file":"RpcBackend.js","sourceRoot":"","sources":["../../src/RpcBackend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0BAA0B;AAE1B,sDAAwE;AACxE,oDAAiJ;AACjJ,6CAAgD;AAChD,sCAAsC;AACtC,yCAAyC;AACzC,mEAAgE;AAChE,6CAA0C;AAE1C;;;;;;GAMG;AACH,MAAa,QAAQ;IAGnB;;SAEK;IACE,MAAM,KAAK,eAAe;QAC/B,OAAO,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAA6B,CAAC;IACjE,CAAC;IAED;;SAEK;IACE,MAAM,KAAK,qBAAqB;QACrC,IAAA,qBAAM,EAAC,SAAS,KAAK,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC/C,OAAO,QAAQ,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AS,EAAE;wBAC3B,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;qBACnC;yBAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;wBACjC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;4BACpB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;yBAC3C;wBAED,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC;wBACzC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;qBACpC;yBAAM;wBACL,MAAM,IAAI,yBAAW,CAAC,2BAAa,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;qBAC9D;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;gBACpB,IAAI,CAAC,GAAG,CAAC,CAAC;gBACV,SAAU;oBACR,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;oBAC/B,IAAI,CAAC,IAAI,EAAE;wBACT,MAAM;qBACP;oBAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;oBACvD,EAAE,CAAC,CAAC;iBACL;gBAED,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AA9ED,oDA8EC","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 RpcInterface\r\n */\r\n\r\n// cspell:ignore calltrace\r\n\r\nimport { assert, Logger, SpanKind, Tracing } from \"@itwin/core-bentley\";\r\nimport { BentleyStatus, HttpServerRequest, IModelError, RpcActivity, RpcInvocation, RpcMultipart, RpcSerializedValue } from \"@itwin/core-common\";\r\nimport { AsyncLocalStorage } from \"async_hooks\";\r\nimport * as FormData from \"form-data\";\r\nimport * as multiparty from \"multiparty\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/**\r\n * Utility for tracing Rpc activity processing. When multiple Rpc requests are being processed asynchronously, this\r\n * class can be used to correlate the current calltrace with the originating RpcActivity. This is used for automatic appending\r\n * of RpcActivity to log messages emitted during Rpc processing. It may also be used to retrieve the user accessToken\r\n * from the RpcActivity.\r\n * @public\r\n */\r\nexport class RpcTrace {\r\n private static _storage = new AsyncLocalStorage();\r\n\r\n /** Get the [RpcActivity]($common) for the currently executing async, or `undefined` if there is no\r\n * RpcActivity in the current call stack.\r\n * */\r\n public static get currentActivity(): RpcActivity | undefined {\r\n return RpcTrace._storage.getStore() as RpcActivity | undefined;\r\n }\r\n\r\n /** Get the [RpcActivity]($common) for the currently executing async. Asserts that the RpcActivity\r\n * exists in the current call stack.\r\n * */\r\n public static get expectCurrentActivity(): RpcActivity {\r\n assert(undefined !== RpcTrace.currentActivity);\r\n return RpcTrace.currentActivity;\r\n }\r\n\r\n /** Start the processing of an RpcActivity. */\r\n public static async run<T>(activity: RpcActivity, fn: () => Promise<T>): Promise<T> {\r\n return RpcTrace._storage.run(activity, fn);\r\n }\r\n\r\n /** Start the processing of an RpcActivity inside an OpenTelemetry span */\r\n public static async runWithSpan<T>(activity: RpcActivity, fn: () => Promise<T>): Promise<T> {\r\n return Tracing.withSpan(activity.rpcMethod ?? \"unknown RPC method\", async () => RpcTrace.run(activity, fn), {\r\n attributes: { ...RpcInvocation.sanitizeForLog(activity) },\r\n kind: SpanKind.SERVER,\r\n });\r\n }\r\n}\r\n\r\nlet initialized = false;\r\n/** @internal */\r\nexport function initializeRpcBackend(enableOpenTelemetry: boolean = false) {\r\n if (initialized)\r\n return;\r\n\r\n initialized = true;\r\n\r\n RpcInvocation.runActivity = RpcTrace.run; // redirect the invocation processing to the tracer\r\n\r\n if (enableOpenTelemetry) {\r\n try {\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n const api = require(\"@opentelemetry/api\");\r\n const tracer = api.trace.getTracer(\"@itwin/core-backend\", IModelHost.backendVersion);\r\n Tracing.enableOpenTelemetry(tracer, api);\r\n RpcInvocation.runActivity = RpcTrace.runWithSpan; // wrap invocation in an OpenTelemetry span in addition to RpcTrace\r\n } catch (e) {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n Logger.logError(BackendLoggerCategory.IModelHost, \"Failed to initialize OpenTelemetry\");\r\n Logger.logException(BackendLoggerCategory.IModelHost, e);\r\n }\r\n }\r\n\r\n // set up static logger metadata to include current RpcActivity information for logs during rpc processing\r\n Logger.staticMetaData.set(\"rpc\", () => RpcInvocation.sanitizeForLog(RpcTrace.currentActivity));\r\n\r\n RpcMultipart.createStream = (value: RpcSerializedValue) => {\r\n const form = new FormData();\r\n RpcMultipart.writeValueToForm(form, value);\r\n // Type information for FormData is lying. It actually extends Stream but not Readable, although it appears to work\r\n // fine for now.\r\n return form;\r\n };\r\n\r\n RpcMultipart.parseRequest = async (req: HttpServerRequest) => {\r\n return new Promise<RpcSerializedValue>((resolve, reject) => {\r\n const form = new multiparty.Form({ maxFieldsSize: Infinity });\r\n form.on(\"error\", (err) => {\r\n reject(err);\r\n });\r\n\r\n const value = RpcSerializedValue.create();\r\n const data: { [index: string]: { size: number, chunks: Buffer[] } } = {};\r\n\r\n form.on(\"part\", (part: multiparty.Part) => {\r\n part.on(\"data\", (chunk: string | Buffer) => {\r\n if (part.name === \"objects\") {\r\n value.objects += chunk.toString();\r\n } else if (Buffer.isBuffer(chunk)) {\r\n if (!data[part.name]) {\r\n data[part.name] = { size: 0, chunks: [] };\r\n }\r\n\r\n data[part.name].size += chunk.byteLength;\r\n data[part.name].chunks.push(chunk);\r\n } else {\r\n throw new IModelError(BentleyStatus.ERROR, \"Unknown input.\");\r\n }\r\n });\r\n });\r\n\r\n form.on(\"close\", () => {\r\n let i = 0;\r\n for (; ;) {\r\n const part = data[`data-${i}`];\r\n if (!part) {\r\n break;\r\n }\r\n\r\n value.data.push(Buffer.concat(part.chunks, part.size));\r\n ++i;\r\n }\r\n\r\n resolve(value);\r\n });\r\n\r\n form.parse(req);\r\n });\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"RpcBackend.js","sourceRoot":"","sources":["../../src/RpcBackend.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAsF;AACtF,+CAAsG;AACtG,2CAAkD;AAClD,+CAA4D;AAC5D,+CAAiD;AACjD,iDAAkD;AAElD,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,gBAAgB;AAChB,SAAgB,oBAAoB,CAAC,sBAA+B,KAAK;IACvE,IAAI,WAAW;QACb,OAAO;IAET,IAAA,2BAAiB,EAAC,mBAAmB,CAAC,CAAC;IAEvC,0BAAY,CAAC,QAAQ,CAAC,YAAY,GAAG,iCAAqB,CAAC;IAC3D,0BAAY,CAAC,QAAQ,CAAC,YAAY,GAAG,iCAAqB,CAAC;IAC3D,0BAAY,CAAC,QAAQ,CAAC,YAAY,GAAG,iCAAqB,CAAC;IAE3D,8BAAgB,CAAC,OAAO,CAAC,YAAY,GAAG,uBAAY,CAAC;IACrD,8BAAgB,CAAC,OAAO,CAAC,YAAY,GAAG,sBAAY,CAAC;IAErD,8BAAgB,CAAC,iBAAiB,CAAC,IAAI,iCAAuB,EAAE,CAAC,CAAC;IAElE,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAhBD,oDAgBC","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 RpcInterface\r\n */\r\n\r\nimport { RpcMultipart, WebAppRpcLogging, WebAppRpcRequest } from \"@itwin/core-common\";\r\nimport { appendToMultipartForm, createMultipartStream, parseMultipartRequest } from \"./rpc/multipart\";\r\nimport { initializeTracing } from \"./rpc/tracing\";\r\nimport { WebAppRpcLoggingBackend } from \"./rpc/web/logging\";\r\nimport { parseRequest } from \"./rpc/web/request\";\r\nimport { sendResponse } from \"./rpc/web/response\";\r\n\r\nlet initialized = false;\r\n/** @internal */\r\nexport function initializeRpcBackend(enableOpenTelemetry: boolean = false) {\r\n if (initialized)\r\n return;\r\n\r\n initializeTracing(enableOpenTelemetry);\r\n\r\n RpcMultipart.platform.createStream = createMultipartStream;\r\n RpcMultipart.platform.parseRequest = parseMultipartRequest;\r\n RpcMultipart.platform.appendToForm = appendToMultipartForm;\r\n\r\n WebAppRpcRequest.backend.sendResponse = sendResponse;\r\n WebAppRpcRequest.backend.parseRequest = parseRequest;\r\n\r\n WebAppRpcLogging.initializeBackend(new WebAppRpcLoggingBackend());\r\n\r\n initialized = true;\r\n}\r\n"]}
@@ -30,7 +30,7 @@ export * from "./BackendLoggerCategory";
30
30
  export * from "./Material";
31
31
  export * from "./Model";
32
32
  export * from "./NavigationRelationship";
33
- export * from "./RpcBackend";
33
+ export * from "./rpc/tracing";
34
34
  export * from "./Schema";
35
35
  export * from "./SqliteStatement";
36
36
  export * from "./SQLiteDb";
@@ -1 +1 @@
1
- {"version":3,"file":"core-backend.d.ts","sourceRoot":"","sources":["../../src/core-backend.ts"],"names":[],"mappings":"AAIA,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAA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;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAE3B;;;;GAIG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
1
+ {"version":3,"file":"core-backend.d.ts","sourceRoot":"","sources":["../../src/core-backend.ts"],"names":[],"mappings":"AAIA,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AAC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AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
@@ -47,7 +47,7 @@ __exportStar(require("./BackendLoggerCategory"), exports);
47
47
  __exportStar(require("./Material"), exports);
48
48
  __exportStar(require("./Model"), exports);
49
49
  __exportStar(require("./NavigationRelationship"), exports);
50
- __exportStar(require("./RpcBackend"), exports);
50
+ __exportStar(require("./rpc/tracing"), exports);
51
51
  __exportStar(require("./Schema"), exports);
52
52
  __exportStar(require("./SqliteStatement"), exports);
53
53
  __exportStar(require("./SQLiteDb"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"core-backend.js","sourceRoot":"","sources":["../../src/core-backend.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,qDAAmC;AACnC,6CAA2B;AAC3B,yDAAuC;AACvC,sDAAoC;AACpC,kDAAgC;AAChC,gDAA8B;AAC9B,gDAA8B;AAC9B,8CAA4B;AAC5B,qDAAmC;AACnC,iDAA+B;AAC/B,yCAAuB;AACvB,uDAAqC;AACrC,mDAAiC;AACjC,4CAA0B;AAC1B,kDAAgC;AAChC,sDAAoC;AACpC,2CAAyB;AACzB,mDAAiC;AACjC,mDAAiC;AACjC,mDAAiC;AACjC,6CAA2B;AAC3B,4CAA0B;AAC1B,+CAA6B;AAC7B,qDAAmC;AACnC,iDAA+B;AAC/B,4CAA0B;AAC1B,+CAA6B;AAC7B,8CAA4B;AAC5B,0DAAwC;AACxC,6CAA2B;AAC3B,0CAAwB;AACxB,2DAAyC;AACzC,+CAA6B;AAC7B,2CAAyB;AACzB,oDAAkC;AAClC,6CAA2B;AAC3B,mDAAiC;AACjC,kDAAgC;AAChC,sDAAoC;AACpC,6DAA2C;AAC3C,+DAA6C;AAC7C,0DAAwC;AACxC,4DAA0C;AAC1C,4DAAmG;AAA1F,iHAAA,cAAc,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAAE,uHAAA,oBAAoB,OAAA;AAChE,8DAA4C;AAC5C,uDAAqC;AACrC,+CAA6B;AAC7B,4CAA0B;AAC1B,qDAAmC;AACnC,+CAA6B;AAC7B,kDAAgC;AAChC,wDAAsC;AACtC,2DAAyC;AACzC,6CAA2B;AAC3B,qDAAmC;AACnC,oDAAkC;AAClC,uDAAqC;AACrC,8DAA4C;AAC5C,wDAAsC;AACtC,6CAA2B,CAAC,eAAe;AAE3C;;;;GAIG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;;GAIG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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\nexport * from \"./BriefcaseManager\";\r\nexport * from \"./Category\";\r\nexport * from \"./ChangeSummaryManager\";\r\nexport * from \"./CheckpointManager\";\r\nexport * from \"./ClassRegistry\";\r\nexport * from \"./CloudSqlite\";\r\nexport * from \"./CodeService\";\r\nexport * from \"./CodeSpecs\";\r\nexport * from \"./EntityReferences\";\r\nexport * from \"./DisplayStyle\";\r\nexport * from \"./ECDb\";\r\nexport * from \"./ECSchemaXmlContext\";\r\nexport * from \"./ECSqlStatement\";\r\nexport * from \"./Element\";\r\nexport * from \"./ElementAspect\";\r\nexport * from \"./ElementTreeWalker\";\r\nexport * from \"./Entity\";\r\nexport * from \"./ExportGraphics\";\r\nexport * from \"./ExternalSource\";\r\nexport * from \"./GeoCoordConfig\";\r\nexport * from \"./LocalHub\";\r\nexport * from \"./HubMock\";\r\nexport * from \"./IModelJsFs\";\r\nexport * from \"./BackendHubAccess\";\r\nexport * from \"./Relationship\";\r\nexport * from \"./Texture\";\r\nexport * from \"./TxnManager\";\r\nexport * from \"./LineStyle\";\r\nexport * from \"./BackendLoggerCategory\";\r\nexport * from \"./Material\";\r\nexport * from \"./Model\";\r\nexport * from \"./NavigationRelationship\";\r\nexport * from \"./RpcBackend\";\r\nexport * from \"./Schema\";\r\nexport * from \"./SqliteStatement\";\r\nexport * from \"./SQLiteDb\";\r\nexport * from \"./ViewDefinition\";\r\nexport * from \"./BisCoreSchema\";\r\nexport * from \"./ChangedElementsDb\";\r\nexport * from \"./domains/FunctionalSchema\";\r\nexport * from \"./domains/FunctionalElements\";\r\nexport * from \"./domains/GenericSchema\";\r\nexport * from \"./domains/GenericElements\";\r\nexport { IModelJsNative, NativeCloudSqlite, NativeLoggerCategory } from \"@bentley/imodeljs-native\";\r\nexport * from \"./IModelElementCloneContext\";\r\nexport * from \"./IModelCloneContext\";\r\nexport * from \"./IModelHost\";\r\nexport * from \"./IpcHost\";\r\nexport * from \"./NativeAppStorage\";\r\nexport * from \"./NativeHost\";\r\nexport * from \"./PropertyStore\";\r\nexport * from \"./CloudStorageBackend\";\r\nexport * from \"./AliCloudStorageService\";\r\nexport * from \"./DevTools\";\r\nexport * from \"./LocalhostIpcHost\";\r\nexport * from \"./ElementGraphics\";\r\nexport * from \"./workspace/Settings\";\r\nexport * from \"./workspace/SettingsSchemas\";\r\nexport * from \"./workspace/Workspace\";\r\nexport * from \"./IModelDb\"; // must be last\r\n\r\n/** @docs-package-description\r\n * The core-backend package always runs on the computer with a local Briefcase.\r\n *\r\n * It contains classes that [backend code]($docs/learning/backend/index.md) can use to work with directly with iModels.\r\n */\r\n/**\r\n * @docs-group-description IModelHost\r\n * Classes for configuring and administering the backend [host]($docs/learning/backend/IModelHost.md).\r\n * See [the learning article]($docs/learning/backend/IModelHost.md).\r\n */\r\n/**\r\n * @docs-group-description iModels\r\n * Classes for working with [iModels]($docs/learning/iModels.md).\r\n * See [the learning article]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Schema\r\n * Classes for working with [ECSchemas]($docs/learning/backend/SchemasAndElementsInTypeScript.md)\r\n */\r\n/**\r\n * @docs-group-description Models\r\n * Subclasses of [Models]($docs/BIS/guide/fundamentals/model-fundamentals.md).\r\n * See [the learning articles]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Elements\r\n * Subclasses of [Elements]($docs/BIS/guide/fundamentals/element-fundamentals.md).\r\n * See [the learning articles]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Codes\r\n * Classes for working with [Codes]($docs/BIS/guide/fundamentals/codes.md).\r\n * See [the learning articles]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description ViewDefinitions\r\n * Classes for working with Elements that define what appears in [Views]($docs/learning/frontend/views.md).\r\n * See [the learning articles]($docs/learning/backend/createelements/#orthographicviewdefinition).\r\n */\r\n/**\r\n * @docs-group-description Relationships\r\n * Classes that describe the [relationships]($docs/bis/guide/fundamentals/relationship-fundamentals.md) between elements.\r\n */\r\n/**\r\n * @docs-group-description ElementAspects\r\n * Subclasses of [ElementAspects]($docs/bis/guide/fundamentals/elementaspect-fundamentals.md).\r\n * See [the learning articles]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Categories\r\n * Classes for [Categories]($docs/bis/guide/fundamentals/categories.md).\r\n */\r\n/**\r\n * @docs-group-description Symbology\r\n * Classes for defining the appearance of element geometry\r\n */\r\n/**\r\n * @docs-group-description ECDb\r\n * Classes for working with ECDb.\r\n */\r\n/**\r\n * @docs-group-description SQLiteDb\r\n * Classes for working with SQLiteDb.\r\n */\r\n/**\r\n * @docs-group-description NativeApp\r\n * Classes for working with Mobile/Desktop Application.\r\n */\r\n/**\r\n * @docs-group-description ECSQL\r\n * Classes for working with [ECSQL]($docs/learning/ECSQL.md)\r\n */\r\n/**\r\n * @docs-group-description SQLite\r\n * Classes for working directly with SQLite\r\n */\r\n/**\r\n * @docs-group-description Portability\r\n * Classes to help write [portable apps]($docs/learning/Portability.md) and libraries that will run on any platform, including web apps, node services, Electron desktops apps, and mobile apps.\r\n */\r\n/**\r\n * @docs-group-description Utils\r\n * Miscellaneous utility classes.\r\n */\r\n/**\r\n * @docs-group-description Logging\r\n * Logger categories used by this package.\r\n */\r\n/**\r\n * @docs-group-description RpcInterface\r\n * Classes for working with [RpcInterfaces]($docs/learning/RpcInterface.md).\r\n */\r\n/**\r\n * @docs-group-description CloudStorageBackend\r\n * Classes for working with cloud storage.\r\n */\r\n/**\r\n * @docs-group-description AliCloudStorageService\r\n * Classes for working with cloud storage using AliCloud.\r\n */\r\n/**\r\n * @docs-group-description TileStorage\r\n * Class for working with cloud storage using iTwin/object-storage cloud providers\r\n */\r\n/**\r\n * @docs-group-description Authentication\r\n * Classes for working with Authentication.\r\n */\r\n/**\r\n * @docs-group-description Tiles\r\n * APIs for working with tile graphics.\r\n */\r\n/**\r\n * @docs-group-description HubAccess\r\n * APIs for working with IModelHub\r\n */\r\n/**\r\n * @docs-group-description Workspace\r\n * APIs for loading and using Settings and Workspace resources\r\n */\r\n/**\r\n * @docs-group-description ViewStateHydrator\r\n * Class responsible for loading ViewStates.\r\n */\r\n"]}
1
+ {"version":3,"file":"core-backend.js","sourceRoot":"","sources":["../../src/core-backend.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,qDAAmC;AAC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AGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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\nexport * from \"./BriefcaseManager\";\r\nexport * from \"./Category\";\r\nexport * from \"./ChangeSummaryManager\";\r\nexport * from \"./CheckpointManager\";\r\nexport * from \"./ClassRegistry\";\r\nexport * from \"./CloudSqlite\";\r\nexport * from \"./CodeService\";\r\nexport * from \"./CodeSpecs\";\r\nexport * from \"./EntityReferences\";\r\nexport * from \"./DisplayStyle\";\r\nexport * from \"./ECDb\";\r\nexport * from \"./ECSchemaXmlContext\";\r\nexport * from \"./ECSqlStatement\";\r\nexport * from \"./Element\";\r\nexport * from \"./ElementAspect\";\r\nexport * from \"./ElementTreeWalker\";\r\nexport * from \"./Entity\";\r\nexport * from \"./ExportGraphics\";\r\nexport * from \"./ExternalSource\";\r\nexport * from \"./GeoCoordConfig\";\r\nexport * from \"./LocalHub\";\r\nexport * from \"./HubMock\";\r\nexport * from \"./IModelJsFs\";\r\nexport * from \"./BackendHubAccess\";\r\nexport * from \"./Relationship\";\r\nexport * from \"./Texture\";\r\nexport * from \"./TxnManager\";\r\nexport * from \"./LineStyle\";\r\nexport * from \"./BackendLoggerCategory\";\r\nexport * from \"./Material\";\r\nexport * from \"./Model\";\r\nexport * from \"./NavigationRelationship\";\r\nexport * from \"./rpc/tracing\";\r\nexport * from \"./Schema\";\r\nexport * from \"./SqliteStatement\";\r\nexport * from \"./SQLiteDb\";\r\nexport * from \"./ViewDefinition\";\r\nexport * from \"./BisCoreSchema\";\r\nexport * from \"./ChangedElementsDb\";\r\nexport * from \"./domains/FunctionalSchema\";\r\nexport * from \"./domains/FunctionalElements\";\r\nexport * from \"./domains/GenericSchema\";\r\nexport * from \"./domains/GenericElements\";\r\nexport { IModelJsNative, NativeCloudSqlite, NativeLoggerCategory } from \"@bentley/imodeljs-native\";\r\nexport * from \"./IModelElementCloneContext\";\r\nexport * from \"./IModelCloneContext\";\r\nexport * from \"./IModelHost\";\r\nexport * from \"./IpcHost\";\r\nexport * from \"./NativeAppStorage\";\r\nexport * from \"./NativeHost\";\r\nexport * from \"./PropertyStore\";\r\nexport * from \"./CloudStorageBackend\";\r\nexport * from \"./AliCloudStorageService\";\r\nexport * from \"./DevTools\";\r\nexport * from \"./LocalhostIpcHost\";\r\nexport * from \"./ElementGraphics\";\r\nexport * from \"./workspace/Settings\";\r\nexport * from \"./workspace/SettingsSchemas\";\r\nexport * from \"./workspace/Workspace\";\r\nexport * from \"./IModelDb\"; // must be last\r\n\r\n/** @docs-package-description\r\n * The core-backend package always runs on the computer with a local Briefcase.\r\n *\r\n * It contains classes that [backend code]($docs/learning/backend/index.md) can use to work with directly with iModels.\r\n */\r\n/**\r\n * @docs-group-description IModelHost\r\n * Classes for configuring and administering the backend [host]($docs/learning/backend/IModelHost.md).\r\n * See [the learning article]($docs/learning/backend/IModelHost.md).\r\n */\r\n/**\r\n * @docs-group-description iModels\r\n * Classes for working with [iModels]($docs/learning/iModels.md).\r\n * See [the learning article]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Schema\r\n * Classes for working with [ECSchemas]($docs/learning/backend/SchemasAndElementsInTypeScript.md)\r\n */\r\n/**\r\n * @docs-group-description Models\r\n * Subclasses of [Models]($docs/BIS/guide/fundamentals/model-fundamentals.md).\r\n * See [the learning articles]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Elements\r\n * Subclasses of [Elements]($docs/BIS/guide/fundamentals/element-fundamentals.md).\r\n * See [the learning articles]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Codes\r\n * Classes for working with [Codes]($docs/BIS/guide/fundamentals/codes.md).\r\n * See [the learning articles]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description ViewDefinitions\r\n * Classes for working with Elements that define what appears in [Views]($docs/learning/frontend/views.md).\r\n * See [the learning articles]($docs/learning/backend/createelements/#orthographicviewdefinition).\r\n */\r\n/**\r\n * @docs-group-description Relationships\r\n * Classes that describe the [relationships]($docs/bis/guide/fundamentals/relationship-fundamentals.md) between elements.\r\n */\r\n/**\r\n * @docs-group-description ElementAspects\r\n * Subclasses of [ElementAspects]($docs/bis/guide/fundamentals/elementaspect-fundamentals.md).\r\n * See [the learning articles]($docs/learning/backend/index.md).\r\n */\r\n/**\r\n * @docs-group-description Categories\r\n * Classes for [Categories]($docs/bis/guide/fundamentals/categories.md).\r\n */\r\n/**\r\n * @docs-group-description Symbology\r\n * Classes for defining the appearance of element geometry\r\n */\r\n/**\r\n * @docs-group-description ECDb\r\n * Classes for working with ECDb.\r\n */\r\n/**\r\n * @docs-group-description SQLiteDb\r\n * Classes for working with SQLiteDb.\r\n */\r\n/**\r\n * @docs-group-description NativeApp\r\n * Classes for working with Mobile/Desktop Application.\r\n */\r\n/**\r\n * @docs-group-description ECSQL\r\n * Classes for working with [ECSQL]($docs/learning/ECSQL.md)\r\n */\r\n/**\r\n * @docs-group-description SQLite\r\n * Classes for working directly with SQLite\r\n */\r\n/**\r\n * @docs-group-description Portability\r\n * Classes to help write [portable apps]($docs/learning/Portability.md) and libraries that will run on any platform, including web apps, node services, Electron desktops apps, and mobile apps.\r\n */\r\n/**\r\n * @docs-group-description Utils\r\n * Miscellaneous utility classes.\r\n */\r\n/**\r\n * @docs-group-description Logging\r\n * Logger categories used by this package.\r\n */\r\n/**\r\n * @docs-group-description RpcInterface\r\n * Classes for working with [RpcInterfaces]($docs/learning/RpcInterface.md).\r\n */\r\n/**\r\n * @docs-group-description CloudStorageBackend\r\n * Classes for working with cloud storage.\r\n */\r\n/**\r\n * @docs-group-description AliCloudStorageService\r\n * Classes for working with cloud storage using AliCloud.\r\n */\r\n/**\r\n * @docs-group-description TileStorage\r\n * Class for working with cloud storage using iTwin/object-storage cloud providers\r\n */\r\n/**\r\n * @docs-group-description Authentication\r\n * Classes for working with Authentication.\r\n */\r\n/**\r\n * @docs-group-description Tiles\r\n * APIs for working with tile graphics.\r\n */\r\n/**\r\n * @docs-group-description HubAccess\r\n * APIs for working with IModelHub\r\n */\r\n/**\r\n * @docs-group-description Workspace\r\n * APIs for loading and using Settings and Workspace resources\r\n */\r\n/**\r\n * @docs-group-description ViewStateHydrator\r\n * Class responsible for loading ViewStates.\r\n */\r\n"]}
@@ -0,0 +1,12 @@
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import { FormDataCommon, HttpServerRequest, RpcSerializedValue } from "@itwin/core-common";
5
+ import * as FormData from "form-data";
6
+ /** @internal */
7
+ export declare function createMultipartStream(value: RpcSerializedValue): FormData;
8
+ /** @internal */
9
+ export declare function parseMultipartRequest(req: HttpServerRequest): Promise<RpcSerializedValue>;
10
+ /** @internal */
11
+ export declare function appendToMultipartForm(i: number, form: FormDataCommon, value: RpcSerializedValue): void;
12
+ //# sourceMappingURL=multipart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../../../src/rpc/multipart.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAiB,cAAc,EAAE,iBAAiB,EAA6B,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACrI,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AAGtC,gBAAgB;AAChB,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,YAM9D;AAED,gBAAgB;AAChB,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,iBAAiB,+BA4CjE;AAED,gBAAgB;AAChB,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,kBAAkB,QAG/F"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module RpcInterface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.appendToMultipartForm = exports.parseMultipartRequest = exports.createMultipartStream = void 0;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ const FormData = require("form-data");
13
+ const multiparty = require("multiparty");
14
+ /** @internal */
15
+ function createMultipartStream(value) {
16
+ const form = new FormData();
17
+ core_common_1.RpcMultipart.writeValueToForm(form, value);
18
+ // Type information for FormData is lying. It actually extends Stream but not Readable, although it appears to work
19
+ // fine for now.
20
+ return form;
21
+ }
22
+ exports.createMultipartStream = createMultipartStream;
23
+ /** @internal */
24
+ async function parseMultipartRequest(req) {
25
+ return new Promise((resolve, reject) => {
26
+ const form = new multiparty.Form({ maxFieldsSize: Infinity });
27
+ form.on("error", (err) => {
28
+ reject(err);
29
+ });
30
+ const value = core_common_1.RpcSerializedValue.create();
31
+ const data = {};
32
+ form.on("part", (part) => {
33
+ part.on("data", (chunk) => {
34
+ if (part.name === "objects") {
35
+ value.objects += chunk.toString();
36
+ }
37
+ else if (Buffer.isBuffer(chunk)) {
38
+ if (!data[part.name]) {
39
+ data[part.name] = { size: 0, chunks: [] };
40
+ }
41
+ data[part.name].size += chunk.byteLength;
42
+ data[part.name].chunks.push(chunk);
43
+ }
44
+ else {
45
+ throw new core_common_1.IModelError(core_common_1.BentleyStatus.ERROR, "Unknown input.");
46
+ }
47
+ });
48
+ });
49
+ form.on("close", () => {
50
+ let i = 0;
51
+ for (;;) {
52
+ const part = data[`data-${i}`];
53
+ if (!part) {
54
+ break;
55
+ }
56
+ value.data.push(Buffer.concat(part.chunks, part.size));
57
+ ++i;
58
+ }
59
+ resolve(value);
60
+ });
61
+ form.parse(req);
62
+ });
63
+ }
64
+ exports.parseMultipartRequest = parseMultipartRequest;
65
+ /** @internal */
66
+ function appendToMultipartForm(i, form, value) {
67
+ const buf = value.data[i];
68
+ form.append(`data-${i}`, Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength));
69
+ }
70
+ exports.appendToMultipartForm = appendToMultipartForm;
71
+ //# sourceMappingURL=multipart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multipart.js","sourceRoot":"","sources":["../../../src/rpc/multipart.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAqI;AACrI,sCAAsC;AACtC,yCAAyC;AAEzC,gBAAgB;AAChB,SAAgB,qBAAqB,CAAC,KAAyB;IAC7D,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;IAC5B,0BAAY,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3C,mHAAmH;IACnH,gBAAgB;IAChB,OAAO,IAAI,CAAC;AACd,CAAC;AAND,sDAMC;AAED,gBAAgB;AACT,KAAK,UAAU,qBAAqB,CAAC,GAAsB;IAChE,OAAO,IAAI,OAAO,CAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACzD,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACvB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,gCAAkB,CAAC,MAAM,EAAE,CAAC;QAC1C,MAAM,IAAI,GAA4D,EAAE,CAAC;QAEzE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAqB,EAAE,EAAE;YACxC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAsB,EAAE,EAAE;gBACzC,IAAI,IAAI,CAAC,IAAI,K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AAoB,EAAE,KAAyB;IAC9F,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AACpF,CAAC;AAHD,sDAGC","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 RpcInterface\r\n */\r\n\r\nimport { BentleyStatus, FormDataCommon, HttpServerRequest, IModelError, RpcMultipart, RpcSerializedValue } from \"@itwin/core-common\";\r\nimport * as FormData from \"form-data\";\r\nimport * as multiparty from \"multiparty\";\r\n\r\n/** @internal */\r\nexport function createMultipartStream(value: RpcSerializedValue) {\r\n const form = new FormData();\r\n RpcMultipart.writeValueToForm(form, value);\r\n // Type information for FormData is lying. It actually extends Stream but not Readable, although it appears to work\r\n // fine for now.\r\n return form;\r\n}\r\n\r\n/** @internal */\r\nexport async function parseMultipartRequest(req: HttpServerRequest) {\r\n return new Promise<RpcSerializedValue>((resolve, reject) => {\r\n const form = new multiparty.Form({ maxFieldsSize: Infinity });\r\n form.on(\"error\", (err) => {\r\n reject(err);\r\n });\r\n\r\n const value = RpcSerializedValue.create();\r\n const data: { [index: string]: { size: number, chunks: Buffer[] } } = {};\r\n\r\n form.on(\"part\", (part: multiparty.Part) => {\r\n part.on(\"data\", (chunk: string | Buffer) => {\r\n if (part.name === \"objects\") {\r\n value.objects += chunk.toString();\r\n } else if (Buffer.isBuffer(chunk)) {\r\n if (!data[part.name]) {\r\n data[part.name] = { size: 0, chunks: [] };\r\n }\r\n\r\n data[part.name].size += chunk.byteLength;\r\n data[part.name].chunks.push(chunk);\r\n } else {\r\n throw new IModelError(BentleyStatus.ERROR, \"Unknown input.\");\r\n }\r\n });\r\n });\r\n\r\n form.on(\"close\", () => {\r\n let i = 0;\r\n for (; ;) {\r\n const part = data[`data-${i}`];\r\n if (!part) {\r\n break;\r\n }\r\n\r\n value.data.push(Buffer.concat(part.chunks, part.size));\r\n ++i;\r\n }\r\n\r\n resolve(value);\r\n });\r\n\r\n form.parse(req);\r\n });\r\n}\r\n\r\n/** @internal */\r\nexport function appendToMultipartForm(i: number, form: FormDataCommon, value: RpcSerializedValue) {\r\n const buf = value.data[i];\r\n form.append(`data-${i}`, Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength));\r\n}\r\n"]}
@@ -0,0 +1,29 @@
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import { RpcActivity } from "@itwin/core-common";
5
+ /**
6
+ * Utility for tracing Rpc activity processing. When multiple Rpc requests are being processed asynchronously, this
7
+ * class can be used to correlate the current calltrace with the originating RpcActivity. This is used for automatic appending
8
+ * of RpcActivity to log messages emitted during Rpc processing. It may also be used to retrieve the user accessToken
9
+ * from the RpcActivity.
10
+ * @public
11
+ */
12
+ export declare class RpcTrace {
13
+ private static _storage;
14
+ /** Get the [RpcActivity]($common) for the currently executing async, or `undefined` if there is no
15
+ * RpcActivity in the current call stack.
16
+ * */
17
+ static get currentActivity(): RpcActivity | undefined;
18
+ /** Get the [RpcActivity]($common) for the currently executing async. Asserts that the RpcActivity
19
+ * exists in the current call stack.
20
+ * */
21
+ static get expectCurrentActivity(): RpcActivity;
22
+ /** Start the processing of an RpcActivity. */
23
+ static run<T>(activity: RpcActivity, fn: () => Promise<T>): Promise<T>;
24
+ /** Start the processing of an RpcActivity inside an OpenTelemetry span */
25
+ static runWithSpan<T>(activity: RpcActivity, fn: () => Promise<T>): Promise<T>;
26
+ }
27
+ /** @internal */
28
+ export declare function initializeTracing(enableOpenTelemetry?: boolean): void;
29
+ //# sourceMappingURL=tracing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../../src/rpc/tracing.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,WAAW,EAAiB,MAAM,oBAAoB,CAAC;AAKhE;;;;;;GAMG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA2B;IAElD;;SAEK;IACL,WAAkB,eAAe,IAAI,WAAW,GAAG,SAAS,CAE3D;IAED;;SAEK;IACL,WAAkB,qBAAqB,IAAI,WAAW,CAGrD;IAED,8CAA8C;WAC1B,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAInF,0EAA0E;WACtD,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAM5F;AAED,gBAAgB;AAChB,wBAAgB,iBAAiB,CAAC,mBAAmB,GAAE,OAAe,QAmBrE"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module RpcInterface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.initializeTracing = exports.RpcTrace = void 0;
11
+ // cspell:ignore calltrace
12
+ const core_bentley_1 = require("@itwin/core-bentley");
13
+ const core_common_1 = require("@itwin/core-common");
14
+ const async_hooks_1 = require("async_hooks");
15
+ const BackendLoggerCategory_1 = require("../BackendLoggerCategory");
16
+ const IModelHost_1 = require("../IModelHost");
17
+ /**
18
+ * Utility for tracing Rpc activity processing. When multiple Rpc requests are being processed asynchronously, this
19
+ * class can be used to correlate the current calltrace with the originating RpcActivity. This is used for automatic appending
20
+ * of RpcActivity to log messages emitted during Rpc processing. It may also be used to retrieve the user accessToken
21
+ * from the RpcActivity.
22
+ * @public
23
+ */
24
+ class RpcTrace {
25
+ /** Get the [RpcActivity]($common) for the currently executing async, or `undefined` if there is no
26
+ * RpcActivity in the current call stack.
27
+ * */
28
+ static get currentActivity() {
29
+ return RpcTrace._storage.getStore();
30
+ }
31
+ /** Get the [RpcActivity]($common) for the currently executing async. Asserts that the RpcActivity
32
+ * exists in the current call stack.
33
+ * */
34
+ static get expectCurrentActivity() {
35
+ (0, core_bentley_1.assert)(undefined !== RpcTrace.currentActivity);
36
+ return RpcTrace.currentActivity;
37
+ }
38
+ /** Start the processing of an RpcActivity. */
39
+ static async run(activity, fn) {
40
+ return RpcTrace._storage.run(activity, fn);
41
+ }
42
+ /** Start the processing of an RpcActivity inside an OpenTelemetry span */
43
+ static async runWithSpan(activity, fn) {
44
+ var _a;
45
+ return core_bentley_1.Tracing.withSpan((_a = activity.rpcMethod) !== null && _a !== void 0 ? _a : "unknown RPC method", async () => RpcTrace.run(activity, fn), {
46
+ attributes: { ...core_common_1.RpcInvocation.sanitizeForLog(activity) },
47
+ kind: core_bentley_1.SpanKind.SERVER,
48
+ });
49
+ }
50
+ }
51
+ exports.RpcTrace = RpcTrace;
52
+ RpcTrace._storage = new async_hooks_1.AsyncLocalStorage();
53
+ /** @internal */
54
+ function initializeTracing(enableOpenTelemetry = false) {
55
+ core_common_1.RpcInvocation.runActivity = RpcTrace.run; // redirect the invocation processing to the tracer
56
+ if (enableOpenTelemetry) {
57
+ try {
58
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
59
+ const api = require("@opentelemetry/api");
60
+ const tracer = api.trace.getTracer("@itwin/core-backend", IModelHost_1.IModelHost.backendVersion);
61
+ core_bentley_1.Tracing.enableOpenTelemetry(tracer, api);
62
+ core_common_1.RpcInvocation.runActivity = RpcTrace.runWithSpan; // wrap invocation in an OpenTelemetry span in addition to RpcTrace
63
+ }
64
+ catch (e) {
65
+ // eslint-disable-next-line @typescript-eslint/naming-convention
66
+ core_bentley_1.Logger.logError(BackendLoggerCategory_1.BackendLoggerCategory.IModelHost, "Failed to initialize OpenTelemetry");
67
+ core_bentley_1.Logger.logException(BackendLoggerCategory_1.BackendLoggerCategory.IModelHost, e);
68
+ }
69
+ }
70
+ // set up static logger metadata to include current RpcActivity information for logs during rpc processing
71
+ core_bentley_1.Logger.staticMetaData.set("rpc", () => core_common_1.RpcInvocation.sanitizeForLog(RpcTrace.currentActivity));
72
+ }
73
+ exports.initializeTracing = initializeTracing;
74
+ //# sourceMappingURL=tracing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../src/rpc/tracing.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0BAA0B;AAE1B,sDAAwE;AACxE,oDAAgE;AAChE,6CAAgD;AAChD,oEAAiE;AACjE,8CAA2C;AAE3C;;;;;;GAMG;AACH,MAAa,QAAQ;IAGnB;;SAEK;IACE,MAAM,KAAK,eAAe;QAC/B,OAAO,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAA6B,CAAC;IACjE,CAAC;IAED;;SAEK;IACE,MAAM,KAAK,qBAAqB;QACrC,IAAA,qBAAM,EAAC,SAAS,KAAK,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC/C,OAAO,QAAQ,CAAC,eAAe,CAAC;IAClC,CAAC;IAED,8CAA8C;IACvC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAI,QAAqB,EAAE,EAAoB;QACpE,OAAO,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,0EAA0E;IACnE,MAAM,CAAC,KAAK,CAAC,WAAW,CAAI,QAAqB,EAAE,EAAoB;;QAC5E,OAAO,sBAAO,CAAC,QAAQ,CAAC,MAAA,QAAQ,CAAC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(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 RpcInterface\r\n */\r\n\r\n// cspell:ignore calltrace\r\n\r\nimport { assert, Logger, SpanKind, Tracing } from \"@itwin/core-bentley\";\r\nimport { RpcActivity, RpcInvocation } from \"@itwin/core-common\";\r\nimport { AsyncLocalStorage } from \"async_hooks\";\r\nimport { BackendLoggerCategory } from \"../BackendLoggerCategory\";\r\nimport { IModelHost } from \"../IModelHost\";\r\n\r\n/**\r\n * Utility for tracing Rpc activity processing. When multiple Rpc requests are being processed asynchronously, this\r\n * class can be used to correlate the current calltrace with the originating RpcActivity. This is used for automatic appending\r\n * of RpcActivity to log messages emitted during Rpc processing. It may also be used to retrieve the user accessToken\r\n * from the RpcActivity.\r\n * @public\r\n */\r\nexport class RpcTrace {\r\n private static _storage = new AsyncLocalStorage();\r\n\r\n /** Get the [RpcActivity]($common) for the currently executing async, or `undefined` if there is no\r\n * RpcActivity in the current call stack.\r\n * */\r\n public static get currentActivity(): RpcActivity | undefined {\r\n return RpcTrace._storage.getStore() as RpcActivity | undefined;\r\n }\r\n\r\n /** Get the [RpcActivity]($common) for the currently executing async. Asserts that the RpcActivity\r\n * exists in the current call stack.\r\n * */\r\n public static get expectCurrentActivity(): RpcActivity {\r\n assert(undefined !== RpcTrace.currentActivity);\r\n return RpcTrace.currentActivity;\r\n }\r\n\r\n /** Start the processing of an RpcActivity. */\r\n public static async run<T>(activity: RpcActivity, fn: () => Promise<T>): Promise<T> {\r\n return RpcTrace._storage.run(activity, fn);\r\n }\r\n\r\n /** Start the processing of an RpcActivity inside an OpenTelemetry span */\r\n public static async runWithSpan<T>(activity: RpcActivity, fn: () => Promise<T>): Promise<T> {\r\n return Tracing.withSpan(activity.rpcMethod ?? \"unknown RPC method\", async () => RpcTrace.run(activity, fn), {\r\n attributes: { ...RpcInvocation.sanitizeForLog(activity) },\r\n kind: SpanKind.SERVER,\r\n });\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function initializeTracing(enableOpenTelemetry: boolean = false) {\r\n RpcInvocation.runActivity = RpcTrace.run; // redirect the invocation processing to the tracer\r\n\r\n if (enableOpenTelemetry) {\r\n try {\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires\r\n const api = require(\"@opentelemetry/api\");\r\n const tracer = api.trace.getTracer(\"@itwin/core-backend\", IModelHost.backendVersion);\r\n Tracing.enableOpenTelemetry(tracer, api);\r\n RpcInvocation.runActivity = RpcTrace.runWithSpan; // wrap invocation in an OpenTelemetry span in addition to RpcTrace\r\n } catch (e) {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n Logger.logError(BackendLoggerCategory.IModelHost, \"Failed to initialize OpenTelemetry\");\r\n Logger.logException(BackendLoggerCategory.IModelHost, e);\r\n }\r\n }\r\n\r\n // set up static logger metadata to include current RpcActivity information for logs during rpc processing\r\n Logger.staticMetaData.set(\"rpc\", () => RpcInvocation.sanitizeForLog(RpcTrace.currentActivity));\r\n}\r\n"]}
@@ -0,0 +1,10 @@
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import { RpcInvocation, RpcProtocolEvent, WebAppRpcLogging } from "@itwin/core-common";
5
+ export declare class WebAppRpcLoggingBackend extends WebAppRpcLogging {
6
+ protected logProtocolEvent(event: RpcProtocolEvent, object: RpcInvocation): Promise<void>;
7
+ protected getHostname(): string;
8
+ private logErrorBackend;
9
+ }
10
+ //# sourceMappingURL=logging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/logging.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAwB,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG7G,qBAAa,uBAAwB,SAAQ,gBAAgB;cAClC,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;cAQrF,WAAW,IAAI,MAAM;YAI1B,eAAe;CAiB9B"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module RpcInterface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.WebAppRpcLoggingBackend = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ const os = require("os");
14
+ class WebAppRpcLoggingBackend extends core_common_1.WebAppRpcLogging {
15
+ async logProtocolEvent(event, object) {
16
+ switch (event) {
17
+ case core_common_1.RpcProtocolEvent.RequestReceived: return this.logRequest(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, "RpcInterface.backend.request", object.request);
18
+ case core_common_1.RpcProtocolEvent.BackendErrorOccurred: return this.logErrorBackend("RpcInterface.backend.error", object);
19
+ case core_common_1.RpcProtocolEvent.BackendResponseCreated: return this.logResponse(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, "RpcInterface.backend.response", object.request, object.status, object.elapsed);
20
+ }
21
+ }
22
+ getHostname() {
23
+ return os.hostname();
24
+ }
25
+ async logErrorBackend(message, invocation) {
26
+ const operationDescriptor = this.buildOperationDescriptor(invocation.operation);
27
+ const pathIds = this.findPathIds(invocation.request.path);
28
+ const result = await invocation.result;
29
+ const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue
30
+ core_bentley_1.Logger.logInfo(core_common_1.CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, () => ({
31
+ method: invocation.request.method,
32
+ path: invocation.request.path,
33
+ status: invocation.status,
34
+ errorMessage,
35
+ // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!
36
+ ActivityId: invocation.request.id,
37
+ MachineName: this.getHostname(),
38
+ ...pathIds,
39
+ }));
40
+ }
41
+ }
42
+ exports.WebAppRpcLoggingBackend = WebAppRpcLoggingBackend;
43
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../../src/rpc/web/logging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,oDAA6G;AAC7G,yBAAyB;AAEzB,MAAa,uBAAwB,SAAQ,8BAAgB;IACxC,KAAK,CAAC,gBAAgB,CAAC,KAAuB,EAAE,MAAqB;QACtF,QAAQ,KAAK,EAAE;YACb,KAAK,8BAAgB,CAAC,eAAe,CAAC,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YACxJ,KAAK,8BAAgB,CAAC,oBAAoB,CAAC,CAAC,OAAO,IAAI,CAAC,eAAe,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;YAC9G,KAAK,8BAAgB,CAAC,sBAAsB,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,+BAA+B,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;SACjM;IACH,CAAC;IAEkB,WAAW;QAC5B,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,UAAyB;QACtE,MAAM,mBAAmB,GAAG,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAChF,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC;QACvC,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,2CAA2C;QAElH,qBAAM,CAAC,OAAO,CAAC,kCAAoB,CAAC,mBAAmB,EAAE,GAAG,OAAO,IAAI,mBAAmB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACnG,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,MAAM;YACjC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI;YAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,YAAY;YACZ,uGAAuG;YACvG,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE;YACjC,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YAC/B,GAAG,OAAO;SACX,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AA9BD,0DA8BC","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 RpcInterface\r\n */\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { CommonLoggerCategory, RpcInvocation, RpcProtocolEvent, WebAppRpcLogging } from \"@itwin/core-common\";\r\nimport * as os from \"os\";\r\n\r\nexport class WebAppRpcLoggingBackend extends WebAppRpcLogging {\r\n protected override async logProtocolEvent(event: RpcProtocolEvent, object: RpcInvocation): Promise<void> {\r\n switch (event) {\r\n case RpcProtocolEvent.RequestReceived: return this.logRequest(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.request\", object.request);\r\n case RpcProtocolEvent.BackendErrorOccurred: return this.logErrorBackend(\"RpcInterface.backend.error\", object);\r\n case RpcProtocolEvent.BackendResponseCreated: return this.logResponse(CommonLoggerCategory.RpcInterfaceBackend, \"RpcInterface.backend.response\", object.request, object.status, object.elapsed);\r\n }\r\n }\r\n\r\n protected override getHostname(): string {\r\n return os.hostname();\r\n }\r\n\r\n private async logErrorBackend(message: string, invocation: RpcInvocation): Promise<void> {\r\n const operationDescriptor = this.buildOperationDescriptor(invocation.operation);\r\n const pathIds = this.findPathIds(invocation.request.path);\r\n const result = await invocation.result;\r\n const errorMessage = result.message ? result.message : result.objects; // Can be an error or an RpcSerializedValue\r\n\r\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceBackend, `${message}.${operationDescriptor}`, () => ({\r\n method: invocation.request.method,\r\n path: invocation.request.path,\r\n status: invocation.status,\r\n errorMessage,\r\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\r\n ActivityId: invocation.request.id, // eslint-disable-line @typescript-eslint/naming-convention\r\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\r\n ...pathIds,\r\n }));\r\n }\r\n}\r\n"]}
@@ -0,0 +1,7 @@
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import { HttpServerRequest, SerializedRpcRequest, WebAppRpcProtocol } from "@itwin/core-common";
5
+ /** @internal */
6
+ export declare function parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest>;
7
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/request.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAEL,iBAAiB,EASjB,oBAAoB,EAEpB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAgC5B,gBAAgB;AAChB,wBAAsB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAoCrH"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module RpcInterface
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.parseRequest = void 0;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ function parseHeaders(protocol, req) {
13
+ var _a;
14
+ const headerNames = protocol.serializedClientRequestContextHeaderNames;
15
+ const parsedHeaders = {
16
+ id: req.header(headerNames.id) || "",
17
+ applicationId: req.header(headerNames.applicationId) || "",
18
+ applicationVersion: req.header(headerNames.applicationVersion) || "",
19
+ sessionId: req.header(headerNames.sessionId) || "",
20
+ authorization: (_a = (headerNames.authorization ? req.header(headerNames.authorization) : "")) !== null && _a !== void 0 ? _a : "",
21
+ };
22
+ return parsedHeaders;
23
+ }
24
+ function parseFromPath(operation) {
25
+ const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, "base64").toString("binary") : "";
26
+ return core_common_1.RpcSerializedValue.create(decoded);
27
+ }
28
+ async function parseFromBody(req) {
29
+ const contentType = core_common_1.WebAppRpcProtocol.computeContentType(req.header(core_common_1.WEB_RPC_CONSTANTS.CONTENT));
30
+ if (contentType === core_common_1.RpcContentType.Binary) {
31
+ const objects = JSON.stringify([core_common_1.MarshalingBinaryMarker.createDefault()]);
32
+ const data = [req.body];
33
+ return core_common_1.RpcSerializedValue.create(objects, data);
34
+ }
35
+ else if (contentType === core_common_1.RpcContentType.Multipart) {
36
+ return core_common_1.RpcMultipart.parseRequest(req);
37
+ }
38
+ else {
39
+ return core_common_1.RpcSerializedValue.create(req.body);
40
+ }
41
+ }
42
+ /** @internal */
43
+ async function parseRequest(protocol, req) {
44
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
45
+ const operation = protocol.getOperationFromPath(req.url);
46
+ const parsedHeaders = parseHeaders(protocol, req);
47
+ const request = {
48
+ ...parsedHeaders,
49
+ operation: {
50
+ interfaceDefinition: operation.interfaceDefinition,
51
+ operationName: operation.operationName,
52
+ interfaceVersion: operation.interfaceVersion,
53
+ },
54
+ method: req.method,
55
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
56
+ path: req.url,
57
+ parameters: operation.encodedRequest ? parseFromPath(operation) : await parseFromBody(req),
58
+ caching: operation.encodedRequest ? core_common_1.RpcResponseCacheControl.Immutable : core_common_1.RpcResponseCacheControl.None,
59
+ };
60
+ request.ip = req.ip;
61
+ request.protocolVersion = 0;
62
+ if (protocol.protocolVersionHeaderName) {
63
+ const version = req.header(protocol.protocolVersionHeaderName);
64
+ if (version) {
65
+ request.protocolVersion = parseInt(version, 10);
66
+ }
67
+ }
68
+ if (!request.id) {
69
+ throw new core_common_1.IModelError(core_common_1.BentleyStatus.ERROR, `Invalid request: Missing required activity ID.`);
70
+ }
71
+ return request;
72
+ }
73
+ exports.parseRequest = parseRequest;
74
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/rpc/web/request.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAc4B;AAE5B,SAAS,YAAY,CAAC,QAA2B,EAAE,GAAsB;;IACvE,MAAM,WAAW,GAA0B,QAAQ,CAAC,yCAAyC,CAAC;IAC9F,MAAM,aAAa,GAA0B;QAC3C,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE;QACpC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,EAAE;QAC1D,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,EAAE;QACpE,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE;QAClD,aAAa,EAAE,MAAA,CAAC,WAAW,CAAC,aAAa,CAAC,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E1D,MAAM,aAAa,GAAG,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAElD,MAAM,OAAO,GAAyB;QACpC,GAAG,aAAa;QAChB,SAAS,EAAE;YACT,mBAAmB,EAAE,SAAS,CAAC,mBAAmB;YAClD,aAAa,EAAE,SAAS,CAAC,aAAa;YACtC,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;SAC7C;QACD,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,oEAAoE;QACpE,IAAI,EAAE,GAAG,CAAC,GAAI;QACd,UAAU,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,GAAG,CAAC;QAC1F,OAAO,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,qCAAuB,CAAC,SAAS,CAAC,CAAC,CAAC,qCAAuB,CAAC,IAAI;KACrG,CAAC;IAEF,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;IAEpB,OAAO,CAAC,eAAe,GAAG,CAAC,CAAC;IAE5B,IAAI,QAAQ,CAAC,yBAAyB,EAAE;QACtC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;QAC/D,IAAI,OAAO,EAAE;YACX,OAAO,CAAC,eAAe,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;SACjD;KACF;IAED,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE;QACf,MAAM,IAAI,yBAAW,CAAC,2BAAa,CAAC,KAAK,EAAE,gDAAgD,CAAC,CAAC;KAC9F;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AApCD,oCAoCC","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 RpcInterface\r\n */\r\n\r\nimport {\r\n BentleyStatus,\r\n HttpServerRequest,\r\n IModelError,\r\n MarshalingBinaryMarker,\r\n RpcContentType,\r\n RpcMultipart,\r\n RpcResponseCacheControl,\r\n RpcSerializedValue,\r\n SerializedRpcActivity,\r\n SerializedRpcOperation,\r\n SerializedRpcRequest,\r\n WEB_RPC_CONSTANTS,\r\n WebAppRpcProtocol,\r\n} from \"@itwin/core-common\";\r\n\r\nfunction parseHeaders(protocol: WebAppRpcProtocol, req: HttpServerRequest): SerializedRpcActivity {\r\n const headerNames: SerializedRpcActivity = protocol.serializedClientRequestContextHeaderNames;\r\n const parsedHeaders: SerializedRpcActivity = {\r\n id: req.header(headerNames.id) || \"\",\r\n applicationId: req.header(headerNames.applicationId) || \"\",\r\n applicationVersion: req.header(headerNames.applicationVersion) || \"\",\r\n sessionId: req.header(headerNames.sessionId) || \"\",\r\n authorization: (headerNames.authorization ? req.header(headerNames.authorization) : \"\") ?? \"\",\r\n };\r\n return parsedHeaders;\r\n}\r\n\r\nfunction parseFromPath(operation: SerializedRpcOperation): RpcSerializedValue {\r\n const decoded = operation.encodedRequest ? Buffer.from(operation.encodedRequest, \"base64\").toString(\"binary\") : \"\";\r\n return RpcSerializedValue.create(decoded);\r\n}\r\n\r\nasync function parseFromBody(req: HttpServerRequest): Promise<RpcSerializedValue> {\r\n const contentType = WebAppRpcProtocol.computeContentType(req.header(WEB_RPC_CONSTANTS.CONTENT));\r\n if (contentType === RpcContentType.Binary) {\r\n const objects = JSON.stringify([MarshalingBinaryMarker.createDefault()]);\r\n const data = [req.body as Buffer];\r\n return RpcSerializedValue.create(objects, data);\r\n } else if (contentType === RpcContentType.Multipart) {\r\n return RpcMultipart.parseRequest(req);\r\n } else {\r\n return RpcSerializedValue.create(req.body as string);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport async function parseRequest(protocol: WebAppRpcProtocol, req: HttpServerRequest): Promise<SerializedRpcRequest> {\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n const operation = protocol.getOperationFromPath(req.url!);\r\n\r\n const parsedHeaders = parseHeaders(protocol, req);\r\n\r\n const request: SerializedRpcRequest = {\r\n ...parsedHeaders,\r\n operation: {\r\n interfaceDefinition: operation.interfaceDefinition,\r\n operationName: operation.operationName,\r\n interfaceVersion: operation.interfaceVersion,\r\n },\r\n method: req.method,\r\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\r\n path: req.url!,\r\n parameters: operation.encodedRequest ? parseFromPath(operation) : await parseFromBody(req),\r\n caching: operation.encodedRequest ? RpcResponseCacheControl.Immutable : RpcResponseCacheControl.None,\r\n };\r\n\r\n request.ip = req.ip;\r\n\r\n request.protocolVersion = 0;\r\n\r\n if (protocol.protocolVersionHeaderName) {\r\n const version = req.header(protocol.protocolVersionHeaderName);\r\n if (version) {\r\n request.protocolVersion = parseInt(version, 10);\r\n }\r\n }\r\n\r\n if (!request.id) {\r\n throw new IModelError(BentleyStatus.ERROR, `Invalid request: Missing required activity ID.`);\r\n }\r\n\r\n return request;\r\n}\r\n"]}
@@ -0,0 +1,7 @@
1
+ /** @packageDocumentation
2
+ * @module RpcInterface
3
+ */
4
+ import { HttpServerRequest, HttpServerResponse, RpcRequestFulfillment, SerializedRpcRequest, WebAppRpcProtocol } from "@itwin/core-common";
5
+ /** @internal */
6
+ export declare function sendResponse(protocol: WebAppRpcProtocol, request: SerializedRpcRequest, fulfillment: RpcRequestFulfillment, req: HttpServerRequest, res: HttpServerResponse): Promise<void>;
7
+ //# sourceMappingURL=response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../../src/rpc/web/response.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAKlB,qBAAqB,EAGrB,oBAAoB,EAEpB,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AA2D5B,gBAAgB;AAChB,wBAAsB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,qBAAqB,EAAE,GAAG,EAAE,iBAAiB,EAAE,GAAG,EAAE,kBAAkB,iBAqCjL"}