@itwin/core-backend 3.5.0-dev.8 → 3.6.0-dev.1

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 (140) hide show
  1. package/CHANGELOG.md +92 -1
  2. package/lib/cjs/BriefcaseManager.d.ts +7 -2
  3. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  4. package/lib/cjs/BriefcaseManager.js +11 -3
  5. package/lib/cjs/BriefcaseManager.js.map +1 -1
  6. package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
  7. package/lib/cjs/ChangeSummaryManager.js +2 -0
  8. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  9. package/lib/cjs/ClassRegistry.d.ts +8 -0
  10. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  11. package/lib/cjs/ClassRegistry.js +47 -13
  12. package/lib/cjs/ClassRegistry.js.map +1 -1
  13. package/lib/cjs/CloudSqlite.d.ts +1 -0
  14. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  15. package/lib/cjs/CloudSqlite.js +1 -0
  16. package/lib/cjs/CloudSqlite.js.map +1 -1
  17. package/lib/cjs/ConcurrentQuery.d.ts +3 -1
  18. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
  19. package/lib/cjs/ConcurrentQuery.js +6 -0
  20. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  21. package/lib/cjs/CustomViewState3dCreator.d.ts +3 -14
  22. package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
  23. package/lib/cjs/CustomViewState3dCreator.js +11 -43
  24. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  25. package/lib/cjs/DisplayStyle.d.ts +9 -9
  26. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  27. package/lib/cjs/DisplayStyle.js +12 -12
  28. package/lib/cjs/DisplayStyle.js.map +1 -1
  29. package/lib/cjs/Element.d.ts +23 -30
  30. package/lib/cjs/Element.d.ts.map +1 -1
  31. package/lib/cjs/Element.js +42 -46
  32. package/lib/cjs/Element.js.map +1 -1
  33. package/lib/cjs/ElementAspect.d.ts +24 -4
  34. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  35. package/lib/cjs/ElementAspect.js +35 -2
  36. package/lib/cjs/ElementAspect.js.map +1 -1
  37. package/lib/cjs/Entity.d.ts +31 -1
  38. package/lib/cjs/Entity.d.ts.map +1 -1
  39. package/lib/cjs/Entity.js +52 -0
  40. package/lib/cjs/Entity.js.map +1 -1
  41. package/lib/cjs/EntityReferences.d.ts +50 -0
  42. package/lib/cjs/EntityReferences.d.ts.map +1 -0
  43. package/lib/cjs/EntityReferences.js +96 -0
  44. package/lib/cjs/EntityReferences.js.map +1 -0
  45. package/lib/cjs/ExternalSource.d.ts +3 -1
  46. package/lib/cjs/ExternalSource.d.ts.map +1 -1
  47. package/lib/cjs/ExternalSource.js +6 -0
  48. package/lib/cjs/ExternalSource.js.map +1 -1
  49. package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
  50. package/lib/cjs/GeoCoordConfig.js +10 -7
  51. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  52. package/lib/cjs/HubMock.d.ts +1 -0
  53. package/lib/cjs/HubMock.d.ts.map +1 -1
  54. package/lib/cjs/HubMock.js +34 -2
  55. package/lib/cjs/HubMock.js.map +1 -1
  56. package/lib/cjs/IModelCloneContext.d.ts +5 -82
  57. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  58. package/lib/cjs/IModelCloneContext.js +7 -142
  59. package/lib/cjs/IModelCloneContext.js.map +1 -1
  60. package/lib/cjs/IModelDb.d.ts +21 -2
  61. package/lib/cjs/IModelDb.d.ts.map +1 -1
  62. package/lib/cjs/IModelDb.js +64 -14
  63. package/lib/cjs/IModelDb.js.map +1 -1
  64. package/lib/cjs/IModelElementCloneContext.d.ts +90 -0
  65. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -0
  66. package/lib/cjs/IModelElementCloneContext.js +160 -0
  67. package/lib/cjs/IModelElementCloneContext.js.map +1 -0
  68. package/lib/cjs/IModelHost.d.ts +9 -0
  69. package/lib/cjs/IModelHost.d.ts.map +1 -1
  70. package/lib/cjs/IModelHost.js +9 -2
  71. package/lib/cjs/IModelHost.js.map +1 -1
  72. package/lib/cjs/IpcHost.d.ts +6 -0
  73. package/lib/cjs/IpcHost.d.ts.map +1 -1
  74. package/lib/cjs/IpcHost.js +47 -3
  75. package/lib/cjs/IpcHost.js.map +1 -1
  76. package/lib/cjs/Model.d.ts +8 -2
  77. package/lib/cjs/Model.d.ts.map +1 -1
  78. package/lib/cjs/Model.js +15 -1
  79. package/lib/cjs/Model.js.map +1 -1
  80. package/lib/cjs/NativeHost.d.ts.map +1 -1
  81. package/lib/cjs/NativeHost.js +10 -15
  82. package/lib/cjs/NativeHost.js.map +1 -1
  83. package/lib/cjs/PromiseMemoizer.d.ts +4 -4
  84. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
  85. package/lib/cjs/PromiseMemoizer.js +44 -44
  86. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  87. package/lib/cjs/Relationship.d.ts +18 -2
  88. package/lib/cjs/Relationship.d.ts.map +1 -1
  89. package/lib/cjs/Relationship.js +30 -1
  90. package/lib/cjs/Relationship.js.map +1 -1
  91. package/lib/cjs/RpcBackend.d.ts +0 -23
  92. package/lib/cjs/RpcBackend.d.ts.map +1 -1
  93. package/lib/cjs/RpcBackend.js +13 -108
  94. package/lib/cjs/RpcBackend.js.map +1 -1
  95. package/lib/cjs/SqliteStatement.d.ts +81 -4
  96. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  97. package/lib/cjs/SqliteStatement.js +163 -25
  98. package/lib/cjs/SqliteStatement.js.map +1 -1
  99. package/lib/cjs/ViewDefinition.d.ts +14 -10
  100. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  101. package/lib/cjs/ViewDefinition.js +31 -20
  102. package/lib/cjs/ViewDefinition.js.map +1 -1
  103. package/lib/cjs/ViewStateHydrator.js +2 -2
  104. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  105. package/lib/cjs/core-backend.d.ts +4 -2
  106. package/lib/cjs/core-backend.d.ts.map +1 -1
  107. package/lib/cjs/core-backend.js +4 -2
  108. package/lib/cjs/core-backend.js.map +1 -1
  109. package/lib/cjs/rpc/multipart.d.ts +12 -0
  110. package/lib/cjs/rpc/multipart.d.ts.map +1 -0
  111. package/lib/cjs/rpc/multipart.js +71 -0
  112. package/lib/cjs/rpc/multipart.js.map +1 -0
  113. package/lib/cjs/rpc/tracing.d.ts +29 -0
  114. package/lib/cjs/rpc/tracing.d.ts.map +1 -0
  115. package/lib/cjs/rpc/tracing.js +74 -0
  116. package/lib/cjs/rpc/tracing.js.map +1 -0
  117. package/lib/cjs/rpc/web/logging.d.ts +10 -0
  118. package/lib/cjs/rpc/web/logging.d.ts.map +1 -0
  119. package/lib/cjs/rpc/web/logging.js +43 -0
  120. package/lib/cjs/rpc/web/logging.js.map +1 -0
  121. package/lib/cjs/rpc/web/request.d.ts +7 -0
  122. package/lib/cjs/rpc/web/request.d.ts.map +1 -0
  123. package/lib/cjs/rpc/web/request.js +74 -0
  124. package/lib/cjs/rpc/web/request.js.map +1 -0
  125. package/lib/cjs/rpc/web/response.d.ts +7 -0
  126. package/lib/cjs/rpc/web/response.d.ts.map +1 -0
  127. package/lib/cjs/rpc/web/response.js +106 -0
  128. package/lib/cjs/rpc/web/response.js.map +1 -0
  129. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +4 -2
  130. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  131. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +80 -51
  132. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  133. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
  134. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +13 -15
  135. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  136. package/lib/cjs/workspace/Workspace.d.ts +1 -1
  137. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  138. package/lib/cjs/workspace/Workspace.js +2 -2
  139. package/lib/cjs/workspace/Workspace.js.map +1 -1
  140. 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,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,SAAS,mCAAI,oBAAoB,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE;YAC1G,UAAU,EAAE,EAAE,GAAG,2BAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;YACzD,IAAI,EAAE,uBAAQ,CAAC,M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K,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"]}
@@ -88,22 +88,58 @@ export declare class SqliteStatement implements IterableIterator<any>, IDisposab
88
88
  * case of other binding errors.
89
89
  */
90
90
  bindValue(parameter: BindParameter, value: any): void;
91
- private checkBind;
92
91
  /** Bind an integer parameter
93
- * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
94
- * @param val integer to bind.
92
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
93
+ * @param val integer to bind.
95
94
  */
96
95
  bindInteger(parameter: BindParameter, val: number): void;
96
+ /** Bind an integer parameter if it is defined. Otherwise do nothing.
97
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
98
+ * @param val integer to bind.
99
+ */
100
+ maybeBindInteger(parameter: BindParameter, val?: number): void;
101
+ /** Bind a boolean parameter.
102
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
103
+ * @param val boolean to bind.
104
+ */
105
+ bindBoolean(parameter: BindParameter, val: boolean): void;
106
+ /** Bind a boolean parameter if it is defined. Otherwise do nothing.
107
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
108
+ * @param val boolean to bind.
109
+ */
110
+ maybeBindBoolean(parameter: BindParameter, val?: boolean): void;
111
+ /** JSON.stringify a property value and bind the JSON string.
112
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
113
+ * @param val object to bind.
114
+ * @internal
115
+ */
116
+ bindProps<T>(colIndex: number, val: T): void;
117
+ /** JSON.stringify a property value if it is defined, and bind the JSON string. Otherwise do nothing.
118
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
119
+ * @param val object to bind.
120
+ * @internal
121
+ */
122
+ maybeBindProps<T>(colIndex: number, val?: T): void;
97
123
  /** Bind a double parameter
98
124
  * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
99
125
  * @param val double to bind.
100
126
  */
101
127
  bindDouble(parameter: BindParameter, val: number): void;
128
+ /** Bind a double parameter if it is defined. Otherwise do nothing.
129
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
130
+ * @param val double to bind.
131
+ */
132
+ maybeBindDouble(parameter: BindParameter, val?: number): void;
102
133
  /** Bind a string parameter
103
134
  * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
104
135
  * @param val string to bind.
105
136
  */
106
137
  bindString(parameter: BindParameter, val: string): void;
138
+ /** Bind a string parameter if it is defined. Otherwise do nothing.
139
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
140
+ * @param val string to bind.
141
+ */
142
+ maybeBindString(parameter: BindParameter, val?: string): void;
107
143
  /** Bind an Id64String parameter as a 64-bit integer
108
144
  * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
109
145
  * @param val Id to bind.
@@ -119,6 +155,11 @@ export declare class SqliteStatement implements IterableIterator<any>, IDisposab
119
155
  * @param val blob to bind.
120
156
  */
121
157
  bindBlob(parameter: BindParameter, blob: Uint8Array): void;
158
+ /** Bind a blob parameter if it is defined. Otherwise do nothing.
159
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
160
+ * @param val blob to bind.
161
+ */
162
+ maybeBindBlob(parameter: BindParameter, val?: Uint8Array): void;
122
163
  /** Bind null to a parameter
123
164
  * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
124
165
  */
@@ -165,18 +206,34 @@ export declare class SqliteStatement implements IterableIterator<any>, IDisposab
165
206
  * @param colIndex Index of SQL column in query result (0-based)
166
207
  */
167
208
  getValueBlob(colIndex: number): Uint8Array;
209
+ /** Get the value as a blob, or undefined if it is null.
210
+ * @param colIndex Index of SQL column in query result (0-based)
211
+ */
212
+ getValueBlobMaybe(colIndex: number): Uint8Array | undefined;
168
213
  /** Get a value as a double
169
214
  * @param colIndex Index of SQL column in query result (0-based)
170
215
  */
171
216
  getValueDouble(colIndex: number): number;
217
+ /** Get the value as an double, or undefined if it is null.
218
+ * @param colIndex Index of SQL column in query result (0-based)
219
+ */
220
+ getValueDoubleMaybe(colIndex: number): number | undefined;
172
221
  /** Get a value as a integer
173
222
  * @param colIndex Index of SQL column in query result (0-based)
174
223
  */
175
224
  getValueInteger(colIndex: number): number;
225
+ /** Get the value as an integer, or undefined if it is null.
226
+ * @param colIndex Index of SQL column in query result (0-based)
227
+ */
228
+ getValueIntegerMaybe(colIndex: number): number | undefined;
176
229
  /** Get a value as a string
177
230
  * @param colIndex Index of SQL column in query result (0-based)
178
231
  */
179
232
  getValueString(colIndex: number): string;
233
+ /** Get the value as a string, or undefined if it is null.
234
+ * @param colIndex Index of SQL column in query result (0-based)
235
+ */
236
+ getValueStringMaybe(colIndex: number): string | undefined;
180
237
  /** Get a value as an Id
181
238
  * @param colIndex Index of SQL column in query result (0-based)
182
239
  */
@@ -185,6 +242,26 @@ export declare class SqliteStatement implements IterableIterator<any>, IDisposab
185
242
  * @param colIndex Index of SQL column in query result (0-based)
186
243
  */
187
244
  getValueGuid(colIndex: number): GuidString;
245
+ /** Get the value as a boolean. Returns `false` if the column is null.
246
+ * @param colIndex Index of SQL column in query result (0-based)
247
+ */
248
+ getValueBoolean(colIndex: number): boolean;
249
+ /** Get the value of a [julianday](https://www.sqlite.org/lang_datefunc.html) column as a JavaScript `Date`.
250
+ * @param colIndex Index of SQL column in query result (0-based)
251
+ * @beta
252
+ */
253
+ getValueDate(colIndex: number): Date;
254
+ /** Get the value as a "props" JSON string, then parse it and return the object
255
+ * @param colIndex Index of SQL column in query result (0-based)
256
+ * @internal
257
+ */
258
+ getProps<T>(colIndex: number): T;
259
+ /** Get the value as a "props" JSON string, then parse it and return the object.
260
+ * If the column is null, return undefined.
261
+ * @param colIndex Index of SQL column in query result (0-based)
262
+ * @internal
263
+ */
264
+ getPropsMaybe<T>(colIndex: number): T | undefined;
188
265
  /** Get the current row.
189
266
  * The returned row is formatted as JavaScript object where every SELECT clause item becomes a property in the JavaScript object.
190
267
  *
@@ -247,7 +324,7 @@ export declare class SqliteValue {
247
324
  * [SqliteValueType.Blob]($backend) | Uint8Array
248
325
  */
249
326
  get value(): any;
250
- /** Get the value as BLOB */
327
+ /** Get the value as Blob */
251
328
  getBlob(): Uint8Array;
252
329
  /** Get the value as a double value */
253
330
  getDouble(): number;
@@ -1 +1 @@
1
- {"version":3,"file":"SqliteStatement.d.ts","sourceRoot":"","sources":["../../src/SqliteStatement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAwB,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAU,MAAM,qBAAqB,CAAC;AAElH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED;;GAEG;AACH,oBAAY,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,eAAgB,YAAW,gBAAgB,CAAC,GAAG,CAAC,EAAE,WAAW;IAIrD,OAAO,CAAC,IAAI;IAH/B,OAAO,CAAC,KAAK,CAA6C;IAC1D,OAAO,CAAC,GAAG,CAAmC;gBAEnB,IAAI,EAAE,MAAM;IACvC,IAAW,IAAI,IAAI,cAAc,CAAC,eAAe,CAAwB;IACzE,IAAW,GAAG,WAAwB;IAEtC,oEAAoE;IACpE,IAAW,UAAU,IAAI,OAAO,CAA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AAI,eAAe,CAAqD;IAEvF,gDAAgD;IAChD,IAAW,UAAU,IAAI,MAAM,CAAqD;IAEpF;;;;;;;;;OASG;IACH,IAAW,KAAK,IAAI,GAAG,CAetB;IAED,4BAA4B;IACrB,OAAO,IAAI,UAAU;IAC5B,sCAAsC;IAC/B,SAAS,IAAI,MAAM;IAC1B,uCAAuC;IAChC,UAAU,IAAI,MAAM;IAC3B,sCAAsC;IAC/B,SAAS,IAAI,MAAM;IAC1B,mCAAmC;IAC5B,KAAK,IAAI,UAAU;IAC1B,oCAAoC;IAC7B,OAAO,IAAI,UAAU;CAC7B;AAED,UAAU,SAAS;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,IAAI,IAAI,CAAC;IACd,aAAa,IAAI,IAAI,CAAC;CACvB;AAED;;;;GAIG;AACH,qBAAa,cAAc,CAAC,IAAI,SAAS,SAAS;IAChD,OAAO,CAAC,MAAM,CAAuB;gBAElB,QAAQ,SAAK;IAIhC,IAAW,IAAI,WAA+B;IACvC,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAiB9B,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAI5C,KAAK;CAIb"}
@@ -11,6 +11,10 @@ exports.StatementCache = exports.SqliteValue = exports.SqliteValueType = exports
11
11
  const core_bentley_1 = require("@itwin/core-bentley");
12
12
  const core_common_1 = require("@itwin/core-common");
13
13
  const IModelHost_1 = require("./IModelHost");
14
+ function checkBind(stat) {
15
+ if (stat !== core_bentley_1.DbResult.BE_SQLITE_OK)
16
+ throw new core_common_1.IModelError(stat, "SQLite Bind error");
17
+ }
14
18
  /** Executes SQLite SQL statements.
15
19
  *
16
20
  * A statement must be prepared before it can be executed, and it must be released when no longer needed.
@@ -137,57 +141,117 @@ class SqliteStatement {
137
141
  if (stat !== core_bentley_1.DbResult.BE_SQLITE_OK)
138
142
  throw new core_common_1.IModelError(stat, "Error in bindValue");
139
143
  }
140
- checkBind(stat) {
141
- if (stat !== core_bentley_1.DbResult.BE_SQLITE_OK)
142
- throw new core_common_1.IModelError(stat, "SQLite Bind error");
143
- }
144
144
  /** Bind an integer parameter
145
- * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
146
- * @param val integer to bind.
145
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
146
+ * @param val integer to bind.
147
147
  */
148
148
  bindInteger(parameter, val) {
149
- this.checkBind(this.stmt.bindInteger(parameter, val));
149
+ checkBind(this.stmt.bindInteger(parameter, val));
150
+ }
151
+ /** Bind an integer parameter if it is defined. Otherwise do nothing.
152
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
153
+ * @param val integer to bind.
154
+ */
155
+ maybeBindInteger(parameter, val) {
156
+ if (val !== undefined)
157
+ this.bindInteger(parameter, val);
158
+ }
159
+ /** Bind a boolean parameter.
160
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
161
+ * @param val boolean to bind.
162
+ */
163
+ bindBoolean(parameter, val) {
164
+ this.bindInteger(parameter, val ? 1 : 0);
165
+ }
166
+ /** Bind a boolean parameter if it is defined. Otherwise do nothing.
167
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
168
+ * @param val boolean to bind.
169
+ */
170
+ maybeBindBoolean(parameter, val) {
171
+ if (val !== undefined)
172
+ this.bindBoolean(parameter, val);
173
+ }
174
+ /** JSON.stringify a property value and bind the JSON string.
175
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
176
+ * @param val object to bind.
177
+ * @internal
178
+ */
179
+ bindProps(colIndex, val) {
180
+ this.bindString(colIndex, JSON.stringify(val));
181
+ }
182
+ /** JSON.stringify a property value if it is defined, and bind the JSON string. Otherwise do nothing.
183
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
184
+ * @param val object to bind.
185
+ * @internal
186
+ */
187
+ maybeBindProps(colIndex, val) {
188
+ if (val !== undefined)
189
+ this.bindProps(colIndex, val);
150
190
  }
151
191
  /** Bind a double parameter
152
192
  * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
153
193
  * @param val double to bind.
154
194
  */
155
195
  bindDouble(parameter, val) {
156
- this.checkBind(this.stmt.bindDouble(parameter, val));
196
+ checkBind(this.stmt.bindDouble(parameter, val));
197
+ }
198
+ /** Bind a double parameter if it is defined. Otherwise do nothing.
199
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
200
+ * @param val double to bind.
201
+ */
202
+ maybeBindDouble(parameter, val) {
203
+ if (val !== undefined)
204
+ this.bindDouble(parameter, val);
157
205
  }
158
206
  /** Bind a string parameter
159
207
  * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
160
208
  * @param val string to bind.
161
209
  */
162
210
  bindString(parameter, val) {
163
- this.checkBind(this.stmt.bindString(parameter, val));
211
+ checkBind(this.stmt.bindString(parameter, val));
212
+ }
213
+ /** Bind a string parameter if it is defined. Otherwise do nothing.
214
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
215
+ * @param val string to bind.
216
+ */
217
+ maybeBindString(parameter, val) {
218
+ if (val !== undefined)
219
+ this.bindString(parameter, val);
164
220
  }
165
221
  /** Bind an Id64String parameter as a 64-bit integer
166
222
  * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
167
223
  * @param val Id to bind.
168
224
  */
169
225
  bindId(parameter, id) {
170
- this.checkBind(this.stmt.bindId(parameter, id));
226
+ checkBind(this.stmt.bindId(parameter, id));
171
227
  }
172
228
  /** Bind a Guid parameter
173
229
  * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
174
230
  * @param val Guid to bind.
175
231
  */
176
232
  bindGuid(parameter, guid) {
177
- this.checkBind(this.stmt.bindGuid(parameter, guid));
233
+ checkBind(this.stmt.bindGuid(parameter, guid));
178
234
  }
179
235
  /** Bind a blob parameter
180
236
  * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
181
237
  * @param val blob to bind.
182
238
  */
183
239
  bindBlob(parameter, blob) {
184
- this.checkBind(this.stmt.bindBlob(parameter, blob));
240
+ checkBind(this.stmt.bindBlob(parameter, blob));
241
+ }
242
+ /** Bind a blob parameter if it is defined. Otherwise do nothing.
243
+ * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
244
+ * @param val blob to bind.
245
+ */
246
+ maybeBindBlob(parameter, val) {
247
+ if (val !== undefined)
248
+ this.bindBlob(parameter, val);
185
249
  }
186
250
  /** Bind null to a parameter
187
251
  * @param parameter Index (1-based) or name of the parameter (including the initial ':', '@' or '$')
188
252
  */
189
253
  bindNull(parameter) {
190
- this.checkBind(this.stmt.bindNull(parameter));
254
+ checkBind(this.stmt.bindNull(parameter));
191
255
  }
192
256
  /** Bind values to all parameters in the statement.
193
257
  * @param values The values to bind to the parameters.
@@ -234,45 +298,119 @@ class SqliteStatement {
234
298
  * - [DbResult.BE_SQLITE_DONE]($core-bentley) if the statement has been executed successfully.
235
299
  * - Error status in case of errors.
236
300
  */
237
- step() { return this.stmt.step(); }
301
+ step() {
302
+ return this.stmt.step();
303
+ }
238
304
  /** Get the query result's column count (only for SQL SELECT statements). */
239
- getColumnCount() { return this.stmt.getColumnCount(); }
305
+ getColumnCount() {
306
+ return this.stmt.getColumnCount();
307
+ }
240
308
  /** Get the value for the column at the given index in the query result.
241
309
  * @param columnIx Index of SQL column in query result (0-based)
242
310
  */
243
- getValue(columnIx) { return new SqliteValue(this.stmt, columnIx); }
311
+ getValue(columnIx) {
312
+ return new SqliteValue(this.stmt, columnIx);
313
+ }
244
314
  /** Determine whether the value of the specified column is null
245
315
  * @param colIndex Index of SQL column in query result (0-based)
246
316
  */
247
- isValueNull(colIndex) { return this.stmt.isValueNull(colIndex); }
317
+ isValueNull(colIndex) {
318
+ return this.stmt.isValueNull(colIndex);
319
+ }
248
320
  /** Get a size in bytes of a blob or text column
249
321
  * @param colIndex Index of SQL column in query result (0-based)
250
322
  */
251
- getColumnBytes(colIndex) { return this.stmt.getColumnBytes(colIndex); }
323
+ getColumnBytes(colIndex) {
324
+ return this.stmt.getColumnBytes(colIndex);
325
+ }
252
326
  /** Get a value as a blob
253
327
  * @param colIndex Index of SQL column in query result (0-based)
254
328
  */
255
- getValueBlob(colIndex) { return this.stmt.getValueBlob(colIndex); }
329
+ getValueBlob(colIndex) {
330
+ return this.stmt.getValueBlob(colIndex);
331
+ }
332
+ /** Get the value as a blob, or undefined if it is null.
333
+ * @param colIndex Index of SQL column in query result (0-based)
334
+ */
335
+ getValueBlobMaybe(colIndex) {
336
+ return this.isValueNull(colIndex) ? undefined : this.getValueBlob(colIndex);
337
+ }
256
338
  /** Get a value as a double
257
339
  * @param colIndex Index of SQL column in query result (0-based)
258
340
  */
259
- getValueDouble(colIndex) { return this.stmt.getValueDouble(colIndex); }
341
+ getValueDouble(colIndex) {
342
+ return this.stmt.getValueDouble(colIndex);
343
+ }
344
+ /** Get the value as an double, or undefined if it is null.
345
+ * @param colIndex Index of SQL column in query result (0-based)
346
+ */
347
+ getValueDoubleMaybe(colIndex) {
348
+ return this.isValueNull(colIndex) ? undefined : this.getValueDouble(colIndex);
349
+ }
260
350
  /** Get a value as a integer
261
351
  * @param colIndex Index of SQL column in query result (0-based)
262
352
  */
263
- getValueInteger(colIndex) { return this.stmt.getValueInteger(colIndex); }
353
+ getValueInteger(colIndex) {
354
+ return this.stmt.getValueInteger(colIndex);
355
+ }
356
+ /** Get the value as an integer, or undefined if it is null.
357
+ * @param colIndex Index of SQL column in query result (0-based)
358
+ */
359
+ getValueIntegerMaybe(colIndex) {
360
+ return this.isValueNull(colIndex) ? undefined : this.getValueInteger(colIndex);
361
+ }
264
362
  /** Get a value as a string
265
363
  * @param colIndex Index of SQL column in query result (0-based)
266
364
  */
267
- getValueString(colIndex) { return this.stmt.getValueString(colIndex); }
365
+ getValueString(colIndex) {
366
+ return this.stmt.getValueString(colIndex);
367
+ }
368
+ /** Get the value as a string, or undefined if it is null.
369
+ * @param colIndex Index of SQL column in query result (0-based)
370
+ */
371
+ getValueStringMaybe(colIndex) {
372
+ return this.isValueNull(colIndex) ? undefined : this.getValueString(colIndex);
373
+ }
268
374
  /** Get a value as an Id
269
375
  * @param colIndex Index of SQL column in query result (0-based)
270
376
  */
271
- getValueId(colIndex) { return this.stmt.getValueId(colIndex); }
377
+ getValueId(colIndex) {
378
+ return this.stmt.getValueId(colIndex);
379
+ }
272
380
  /** Get a value as a Guid
273
381
  * @param colIndex Index of SQL column in query result (0-based)
274
382
  */
275
- getValueGuid(colIndex) { return this.stmt.getValueGuid(colIndex); }
383
+ getValueGuid(colIndex) {
384
+ return this.stmt.getValueGuid(colIndex);
385
+ }
386
+ /** Get the value as a boolean. Returns `false` if the column is null.
387
+ * @param colIndex Index of SQL column in query result (0-based)
388
+ */
389
+ getValueBoolean(colIndex) {
390
+ return this.isValueNull(colIndex) ? false : 0 !== this.getValueInteger(colIndex);
391
+ }
392
+ /** Get the value of a [julianday](https://www.sqlite.org/lang_datefunc.html) column as a JavaScript `Date`.
393
+ * @param colIndex Index of SQL column in query result (0-based)
394
+ * @beta
395
+ */
396
+ getValueDate(colIndex) {
397
+ return new Date((this.stmt.getValueDouble(colIndex) - 2440587.5) * 86400000); // conversion from julian day ms to unix epoch ms
398
+ }
399
+ /** Get the value as a "props" JSON string, then parse it and return the object
400
+ * @param colIndex Index of SQL column in query result (0-based)
401
+ * @internal
402
+ */
403
+ getProps(colIndex) {
404
+ return JSON.parse(this.getValueString(colIndex));
405
+ }
406
+ /** Get the value as a "props" JSON string, then parse it and return the object.
407
+ * If the column is null, return undefined.
408
+ * @param colIndex Index of SQL column in query result (0-based)
409
+ * @internal
410
+ */
411
+ getPropsMaybe(colIndex) {
412
+ return this.isValueNull(colIndex) ? undefined : this.getProps(colIndex);
413
+ }
276
414
  /** Get the current row.
277
415
  * The returned row is formatted as JavaScript object where every SELECT clause item becomes a property in the JavaScript object.
278
416
  *
@@ -398,7 +536,7 @@ class SqliteValue {
398
536
  throw new Error("Unhandled SqliteValueType");
399
537
  }
400
538
  }
401
- /** Get the value as BLOB */
539
+ /** Get the value as Blob */
402
540
  getBlob() { return this._stmt.getValueBlob(this._colIndex); }
403
541
  /** Get the value as a double value */
404
542
  getDouble() { return this._stmt.getValueDouble(this._colIndex); }