@itwin/core-common 5.0.0-dev.92 → 5.0.0-dev.94

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 (39) hide show
  1. package/lib/cjs/IModelError.d.ts +17 -7
  2. package/lib/cjs/IModelError.d.ts.map +1 -1
  3. package/lib/cjs/IModelError.js +5 -4
  4. package/lib/cjs/IModelError.js.map +1 -1
  5. package/lib/cjs/ITwinCoreErrors.d.ts +28 -0
  6. package/lib/cjs/ITwinCoreErrors.d.ts.map +1 -0
  7. package/lib/cjs/ITwinCoreErrors.js +28 -0
  8. package/lib/cjs/ITwinCoreErrors.js.map +1 -0
  9. package/lib/cjs/core-common.d.ts +2 -2
  10. package/lib/cjs/core-common.d.ts.map +1 -1
  11. package/lib/cjs/core-common.js +2 -2
  12. package/lib/cjs/core-common.js.map +1 -1
  13. package/lib/cjs/ipc/IpcSocket.d.ts +2 -23
  14. package/lib/cjs/ipc/IpcSocket.d.ts.map +1 -1
  15. package/lib/cjs/ipc/IpcSocket.js.map +1 -1
  16. package/lib/esm/IModelError.d.ts +17 -7
  17. package/lib/esm/IModelError.d.ts.map +1 -1
  18. package/lib/esm/IModelError.js +5 -4
  19. package/lib/esm/IModelError.js.map +1 -1
  20. package/lib/esm/ITwinCoreErrors.d.ts +28 -0
  21. package/lib/esm/ITwinCoreErrors.d.ts.map +1 -0
  22. package/lib/esm/ITwinCoreErrors.js +25 -0
  23. package/lib/esm/ITwinCoreErrors.js.map +1 -0
  24. package/lib/esm/core-common.d.ts +2 -2
  25. package/lib/esm/core-common.d.ts.map +1 -1
  26. package/lib/esm/core-common.js +2 -2
  27. package/lib/esm/core-common.js.map +1 -1
  28. package/lib/esm/ipc/IpcSocket.d.ts +2 -23
  29. package/lib/esm/ipc/IpcSocket.d.ts.map +1 -1
  30. package/lib/esm/ipc/IpcSocket.js.map +1 -1
  31. package/package.json +6 -6
  32. package/lib/cjs/ITwinError.d.ts +0 -108
  33. package/lib/cjs/ITwinError.d.ts.map +0 -1
  34. package/lib/cjs/ITwinError.js +0 -103
  35. package/lib/cjs/ITwinError.js.map +0 -1
  36. package/lib/esm/ITwinError.d.ts +0 -108
  37. package/lib/esm/ITwinError.d.ts.map +0 -1
  38. package/lib/esm/ITwinError.js +0 -95
  39. package/lib/esm/ITwinError.js.map +0 -1
@@ -1,95 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module iModels
7
- */
8
- /**
9
- * iTwinjs Core namespace namespace for a developer/application.
10
- * @beta
11
- */
12
- export const iTwinjsCoreNamespace = "itwinjs-core";
13
- /**
14
- * error keys object used to describe an error keys for a developer/application.
15
- * @beta
16
- */
17
- export const iTwinErrorKeys = {
18
- inUseLocks: "in-use-locks",
19
- channelNest: "channel-may-not-nest",
20
- channelNotAllowed: "channel-not-allowed",
21
- channelRootExists: "channel-root-exists"
22
- };
23
- /**
24
- * Record for all itwin error messages.
25
- * @beta
26
- */
27
- export const iTwinErrorMessages = {
28
- "inUseLocks": () => 'Objects are locked by another briefcase',
29
- "channelNest": (id) => `Channel ${id} may not nest`,
30
- "channelNotAllowed": (id) => `Channel ${id} is not allowed`,
31
- "channelRootExists": (id) => `Channel ${id} root already exist`,
32
- };
33
- /**
34
- * A function which will be used to construct an [[ITwinError]].
35
- * @param namespace The namespace associated with the error.
36
- * @param errorKey The errorKey associated with the error.
37
- * @param message The message associated with the error.
38
- * @param metadata Metadata associated with the error.
39
- * @beta
40
- */
41
- export function constructITwinError(namespace, errorKey, message, metadata) {
42
- const error = new Error();
43
- error.message = message ?? `${errorKey} occurred`;
44
- error.name = `${namespace}:${errorKey}`;
45
- error.namespace = namespace;
46
- error.errorKey = errorKey;
47
- error.metadata = metadata;
48
- Error.captureStackTrace(error, constructITwinError); // Optional, but this would hide constructITwinError from stack.
49
- return error;
50
- }
51
- /**
52
- * A function which constructs a detailed error for example [[ InUseLocksError ]] above.
53
- * @param namespace The namespace associated with the error.
54
- * @param errorKey The errorKey associated with the error.
55
- * @param details Other details associated with the error.
56
- * @param message The message associated with the error.
57
- * @param metadata Metadata associated with the error.
58
- * @beta
59
- */
60
- export function constructDetailedError(namespace, errorKey, details, message, metadata) {
61
- const baseError = constructITwinError(namespace, errorKey, message, metadata);
62
- Error.captureStackTrace(baseError, constructDetailedError); // Optional, but this would hide constructDetailedError from stack.
63
- return Object.assign(baseError, details);
64
- }
65
- /**
66
- * a high level function that returns a type asserter function which would return whether or not the passed in parameter is an [[ITwinError]]
67
- * @param namespace The namespace associated with the error.
68
- * @param errorKey The errorKey associated with the error.
69
- * @beta
70
- */
71
- export function createITwinErrorTypeAsserter(namespace, errorKey) {
72
- return (error) => isITwinError(error, namespace, errorKey);
73
- }
74
- /**
75
- * get the meta data associated with this ITwinError, if any.
76
- * @param error The error for which metadata is required.
77
- * @beta
78
- */
79
- export function getITwinErrorMetaData(error) {
80
- return (typeof error.metadata === "function") ? error.metadata() : error.metadata;
81
- }
82
- /**
83
- * type guard function that returns whether or not the passed in parameter is an [[ITwinError]]
84
- * @param error The error which is to ve verified.
85
- * @param namespace The namespace associated with the error.
86
- * @param errorKey The errorKey associated with the error.
87
- * @beta
88
- */
89
- export function isITwinError(error, namespace, errorKey) {
90
- return error !== undefined && error !== null && typeof error === "object"
91
- && "namespace" in error && "errorKey" in error && "message" in error
92
- && (namespace === undefined || error.namespace === namespace)
93
- && (errorKey === undefined || error.errorKey === errorKey);
94
- }
95
- //# sourceMappingURL=ITwinError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ITwinError.js","sourceRoot":"","sources":["../../src/ITwinError.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAuBH;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAEnD;;;GAGG;AACH,MAAM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iB,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC,CAAC,mEAAmE;IAC/H,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAM,CAAC;AAChD,CAAC;AAED;;;;;EAKE;AACF,MAAM,UAAU,4BAA4B,CAAuB,SAAiB,EAAE,QAAgB;IACpG,OAAO,CAAC,KAAc,EAAc,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAClF,CAAC;AAED;;;;EAIE;AACF,MAAM,UAAU,qBAAqB,CAAC,KAAiB;IACrD,OAAO,CAAC,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;AACpF,CAAC;AAED;;;;;;EAME;AACF,MAAM,UAAU,YAAY,CAAC,KAAc,EAAE,SAAkB,EAAE,QAAiB;IAChF,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;WACpE,WAAW,IAAI,KAAK,IAAI,UAAU,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK;WACjE,CAAC,SAAS,KAAK,SAAS,IAAK,KAAoB,CAAC,SAAS,KAAK,SAAS,CAAC;WAC1E,CAAC,QAAQ,KAAK,SAAS,IAAK,KAAoB,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { LoggingMetaData } from \"@itwin/core-bentley\";\nimport { LockState } from \"./IModelError\";\nimport { BriefcaseId } from \"./BriefcaseTypes\";\n\n/**\n * Detailed information about a particular object Lock that is causing the Lock update conflict.\n * An example of a lock update conflict would be attempting to use [LockControl.acquireLocks]($backend) on an object that is already locked by another Briefcase.\n * @beta\n */\nexport interface InUseLock {\n /** Id of the object that is causing conflict. */\n objectId: string;\n /**\n * The level of conflicting lock. Possible values are {@link LockState.Shared}, {@link LockState.Exclusive}.\n * See {@link LockState}.\n */\n state: LockState;\n /** An array of Briefcase ids that hold this lock. */\n briefcaseIds: BriefcaseId[];\n}\n\n/**\n * iTwinjs Core namespace namespace for a developer/application.\n * @beta\n */\nexport const iTwinjsCoreNamespace = \"itwinjs-core\";\n\n/**\n * error keys object used to describe an error keys for a developer/application.\n * @beta\n */\nexport const iTwinErrorKeys = {\n inUseLocks: \"in-use-locks\",\n channelNest: \"channel-may-not-nest\",\n channelNotAllowed: \"channel-not-allowed\",\n channelRootExists: \"channel-root-exists\"\n} as const;\n\n/**\n * Record for all itwin error messages.\n * @beta\n */\nexport const iTwinErrorMessages: Record<keyof typeof iTwinErrorKeys, (...args: any[]) => string> = {\n \"inUseLocks\": () => 'Objects are locked by another briefcase',\n \"channelNest\": (id) => `Channel ${id} may not nest`,\n \"channelNotAllowed\": (id) => `Channel ${id} is not allowed`,\n \"channelRootExists\": (id) => `Channel ${id} root already exist`,\n};\n\n\n/**\n * An interface used to describe an error for a developer/application. The message is not intended to be displayed to an end user.\n * This error interface should be extended when needing to throw errors with extra properties defined on them. See [[InUseLocksError]] for an example.\n * @beta\n */\nexport interface ITwinError extends Error {\n /** namespace for the error. This is a unique qualifier for the errorKey. */\n namespace: string;\n /** unique key for error, within namespace. All errorKeys within the same namespace must be unique. */\n errorKey: string;\n /** explanation of what went wrong. Intended to be read by a developer. */\n message: string;\n /** stack trace of the error. */\n stack?: string;\n /** metadata about the exception. */\n metadata?: LoggingMetaData;\n}\n\n/**\n * An error raised when there is a lock conflict detected.\n * Typically this error would be thrown by [LockControl.acquireLocks]($backend) when you are requesting a lock on an element that is already held by another briefcase.\n * @beta\n*/\nexport interface InUseLocksError extends ITwinError {\n inUseLocks: InUseLock[];\n}\n\n/**\n* A function which will be used to construct an [[ITwinError]].\n* @param namespace The namespace associated with the error.\n* @param errorKey The errorKey associated with the error.\n* @param message The message associated with the error.\n* @param metadata Metadata associated with the error.\n* @beta\n*/\nexport function constructITwinError(namespace: string, errorKey: string, message?: string, metadata?: LoggingMetaData): ITwinError {\n\n const error = new Error() as ITwinError;\n error.message = message ?? `${errorKey} occurred`;\n error.name = `${namespace}:${errorKey}`;\n error.namespace = namespace;\n error.errorKey = errorKey;\n error.metadata = metadata;\n\n Error.captureStackTrace(error, constructITwinError); // Optional, but this would hide constructITwinError from stack.\n return error;\n}\n\n/**\n* A function which constructs a detailed error for example [[ InUseLocksError ]] above.\n* @param namespace The namespace associated with the error.\n* @param errorKey The errorKey associated with the error.\n* @param details Other details associated with the error.\n* @param message The message associated with the error.\n* @param metadata Metadata associated with the error.\n* @beta\n*/\nexport function constructDetailedError<T extends ITwinError>(namespace: string, errorKey: string, details: Omit<T, keyof ITwinError>, message?: string, metadata?: LoggingMetaData): T {\n const baseError = constructITwinError(namespace, errorKey, message, metadata);\n\n Error.captureStackTrace(baseError, constructDetailedError); // Optional, but this would hide constructDetailedError from stack.\n return Object.assign(baseError, details) as T;\n}\n\n/**\n * a high level function that returns a type asserter function which would return whether or not the passed in parameter is an [[ITwinError]]\n * @param namespace The namespace associated with the error.\n * @param errorKey The errorKey associated with the error.\n * @beta\n*/\nexport function createITwinErrorTypeAsserter<T extends ITwinError>(namespace: string, errorKey: string) {\n return (error: unknown): error is T => isITwinError(error, namespace, errorKey);\n}\n\n/**\n * get the meta data associated with this ITwinError, if any.\n * @param error The error for which metadata is required.\n * @beta\n*/\nexport function getITwinErrorMetaData(error: ITwinError): object | undefined {\n return (typeof error.metadata === \"function\") ? error.metadata() : error.metadata;\n}\n\n/**\n * type guard function that returns whether or not the passed in parameter is an [[ITwinError]]\n * @param error The error which is to ve verified.\n * @param namespace The namespace associated with the error.\n * @param errorKey The errorKey associated with the error.\n * @beta\n*/\nexport function isITwinError(error: unknown, namespace?: string, errorKey?: string): error is ITwinError {\n return error !== undefined && error !== null && typeof error === \"object\"\n && \"namespace\" in error && \"errorKey\" in error && \"message\" in error\n && (namespace === undefined || (error as ITwinError).namespace === namespace)\n && (errorKey === undefined || (error as ITwinError).errorKey === errorKey);\n}\n"]}