@itwin/core-backend 4.0.0-dev.94 → 4.0.0-dev.96

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 (73) hide show
  1. package/lib/cjs/BlobContainerService.d.ts +120 -0
  2. package/lib/cjs/BlobContainerService.d.ts.map +1 -0
  3. package/lib/cjs/BlobContainerService.js +18 -0
  4. package/lib/cjs/BlobContainerService.js.map +1 -0
  5. package/lib/cjs/Category.d.ts +1 -1
  6. package/lib/cjs/Category.js +1 -1
  7. package/lib/cjs/Category.js.map +1 -1
  8. package/lib/cjs/ClassRegistry.js +3 -3
  9. package/lib/cjs/ClassRegistry.js.map +1 -1
  10. package/lib/cjs/CloudSqlite.d.ts +116 -14
  11. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  12. package/lib/cjs/CloudSqlite.js +189 -4
  13. package/lib/cjs/CloudSqlite.js.map +1 -1
  14. package/lib/cjs/CodeService.d.ts +110 -148
  15. package/lib/cjs/CodeService.d.ts.map +1 -1
  16. package/lib/cjs/CodeService.js.map +1 -1
  17. package/lib/cjs/CodeSpecs.js +1 -1
  18. package/lib/cjs/CodeSpecs.js.map +1 -1
  19. package/lib/cjs/DisplayStyle.d.ts +2 -4
  20. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  21. package/lib/cjs/DisplayStyle.js +4 -6
  22. package/lib/cjs/DisplayStyle.js.map +1 -1
  23. package/lib/cjs/Element.d.ts +9 -17
  24. package/lib/cjs/Element.d.ts.map +1 -1
  25. package/lib/cjs/Element.js +16 -24
  26. package/lib/cjs/Element.js.map +1 -1
  27. package/lib/cjs/ElementAspect.d.ts +1 -2
  28. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  29. package/lib/cjs/ElementAspect.js +2 -3
  30. package/lib/cjs/ElementAspect.js.map +1 -1
  31. package/lib/cjs/Entity.d.ts +12 -16
  32. package/lib/cjs/Entity.d.ts.map +1 -1
  33. package/lib/cjs/Entity.js +18 -35
  34. package/lib/cjs/Entity.js.map +1 -1
  35. package/lib/cjs/ExternalSource.d.ts +1 -2
  36. package/lib/cjs/ExternalSource.d.ts.map +1 -1
  37. package/lib/cjs/ExternalSource.js +2 -3
  38. package/lib/cjs/ExternalSource.js.map +1 -1
  39. package/lib/cjs/IModelHost.d.ts +2 -0
  40. package/lib/cjs/IModelHost.d.ts.map +1 -1
  41. package/lib/cjs/IModelHost.js +2 -0
  42. package/lib/cjs/IModelHost.js.map +1 -1
  43. package/lib/cjs/Model.d.ts +1 -2
  44. package/lib/cjs/Model.d.ts.map +1 -1
  45. package/lib/cjs/Model.js +2 -4
  46. package/lib/cjs/Model.js.map +1 -1
  47. package/lib/cjs/PropertyStore.d.ts +52 -61
  48. package/lib/cjs/PropertyStore.d.ts.map +1 -1
  49. package/lib/cjs/PropertyStore.js +169 -1
  50. package/lib/cjs/PropertyStore.js.map +1 -1
  51. package/lib/cjs/Relationship.d.ts +4 -7
  52. package/lib/cjs/Relationship.d.ts.map +1 -1
  53. package/lib/cjs/Relationship.js +7 -10
  54. package/lib/cjs/Relationship.js.map +1 -1
  55. package/lib/cjs/SQLiteDb.d.ts +106 -8
  56. package/lib/cjs/SQLiteDb.d.ts.map +1 -1
  57. package/lib/cjs/SQLiteDb.js +116 -10
  58. package/lib/cjs/SQLiteDb.js.map +1 -1
  59. package/lib/cjs/ViewDefinition.d.ts +6 -12
  60. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  61. package/lib/cjs/ViewDefinition.js +12 -18
  62. package/lib/cjs/ViewDefinition.js.map +1 -1
  63. package/lib/cjs/core-backend.d.ts +4 -6
  64. package/lib/cjs/core-backend.d.ts.map +1 -1
  65. package/lib/cjs/core-backend.js +4 -6
  66. package/lib/cjs/core-backend.js.map +1 -1
  67. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
  68. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +5 -2
  69. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  70. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  71. package/lib/cjs/workspace/Settings.js +2 -1
  72. package/lib/cjs/workspace/Settings.js.map +1 -1
  73. package/package.json +10 -10
@@ -1,152 +1,12 @@
1
- import { AccessToken, BentleyError, GuidString, MarkRequired, Mutable } from "@itwin/core-bentley";
1
+ import { BentleyError, GuidString, MarkRequired, Mutable } from "@itwin/core-bentley";
2
2
  import { CodeProps, FontId, FontType } from "@itwin/core-common";
3
3
  import { CloudSqlite } from "./CloudSqlite";
4
4
  import { IModelDb } from "./IModelDb";
5
5
  import { SettingObject } from "./workspace/Settings";
6
- /**
7
- * A readonly index of all known Codes for an iTwin. The CodeIndex may be slightly out-of-date
8
- * with the master copy in the cloud, but it should be periodically synchronized. Whenever codes are reserved/updated/deleted
9
- * locally, this copy is always up-to-date as of those changes.
10
- * @alpha
11
- */
12
- export interface CodeIndex {
13
- /**
14
- * Find the next available value for the supplied `SequenceScope`.
15
- * If the sequence is full (there are no available values), this will throw an exception with `errorId="SequenceFull"`
16
- * @param from the sequence and scope to search
17
- * @returns the next available CodeValue in the sequence.
18
- */
19
- findNextAvailable(from: CodeService.SequenceScope): CodeService.CodeValue;
20
- /**
21
- * Find the highest currently used value for the supplied `SequenceScope`
22
- * @param from the sequence and scope to search
23
- * @returns the highest used value, or undefined if no values have been used.
24
- */
25
- findHighestUsed(from: CodeService.SequenceScope): CodeService.CodeValue | undefined;
26
- /** Determine whether a code is present in this CodeIndex by its Guid. */
27
- isCodePresent(guid: CodeService.CodeGuid): boolean;
28
- /** Get the data for a code in this CodeIndex by its Guid.
29
- * @returns the data for the code or undefined if no code is present for the supplied Guid.
30
- */
31
- getCode(guid: CodeService.CodeGuid): CodeService.CodeEntry | undefined;
32
- /** Look up a code by its Scope, Spec, and Value.
33
- * @returns the Guid of the code, or undefined if not present.
34
- */
35
- findCode(code: CodeService.ScopeSpecAndValue): CodeService.CodeGuid | undefined;
36
- /** Look up a code spec by its name
37
- * @throws if the spec is not present.
38
- */
39
- getCodeSpec(props: CodeService.CodeSpecName): CodeService.NameAndJson;
40
- /** Call a `CodeIteration` function for all codes in this index, optionally filtered by a `CodeFilter ` */
41
- forAllCodes(iter: CodeService.CodeIteration, filter?: CodeService.CodeFilter): void;
42
- /** Call an iteration function for all code specs in this index, optionally filtered by a `ValueFilter ` */
43
- forAllCodeSpecs(iter: CodeService.NameAndJsonIteration, filter?: CodeService.ValueFilter): void;
44
- }
45
- /**
46
- * @alpha
47
- */
48
- export interface CodesDb {
49
- /**
50
- * Application-supplied parameters for obtaining the write lock on the container.
51
- * Applications should set these parameters by adding a listener for `BriefcaseDb.onCodeServiceCreated`
52
- * that is called every time a BriefcaseDb that uses code services is opened for write access.
53
- */
54
- readonly lockParams: CloudSqlite.ObtainLockParams;
55
- /** the code index for this CodeService */
56
- readonly codeIndex: CodeIndex;
57
- /**
58
- * The token that grants access to the cloud container for this CodeService.
59
- * It should be established in a listener for `BriefcaseDb.onCodeServiceCreated`, and should be refreshed (via a
60
- * timer) before it expires.
61
- */
62
- sasToken: AccessToken;
63
- /**
64
- * Synchronize the local index with any changes by made by others.
65
- * @note This is called automatically whenever any write operation is performed on the code index. It is only necessary to
66
- * call this directly if you have not changed the code index recently, but wish to perform a readonly operation and want to
67
- * ensure it is up-to-date as of now.
68
- * @note There is no guarantee that a readonly index is up-to-date even immediately after calling this method, since others
69
- * may be modifying it at any time.
70
- */
71
- synchronizeWithCloud(): void;
72
- /**
73
- * Verify that the Code of a to-be-inserted or to-be-updated Element:
74
- * 1. has already been reserved,
75
- * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,
76
- * the value from the code index is returned.
77
- *
78
- * If not, throw an exception. Elements with no CodeValue are ignored.
79
- * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.
80
- */
81
- verifyCode(specName: string, arg: CodeService.ElementCodeProps): void;
82
- /** Add a new code spec to this code service.
83
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
84
- */
85
- addCodeSpec(val: CodeService.NameAndJson): Promise<void>;
86
- /**
87
- * Add all of the codes and code specs from this CodeService's BriefcaseDb into the code index.
88
- * @returns the number of codes actually added.
89
- * @note It is not necessary to call this method unless the BriefcaseDb somehow becomes out of sync with its CodeService,
90
- * for example when migrating iModels to a new code service. It is safe (but relatively expensive) to call this method multiple times, since
91
- * any codes or code specs that are already in the index are ignored.
92
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
93
- */
94
- addAllCodes(iModel: IModelDb): Promise<number>;
95
- /**
96
- * Attempt to reserve a single proposed code.
97
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
98
- * @throws `CodeService.Error` if the proposed code cannot be reserved.
99
- */
100
- reserveCode(code: CodeService.ProposedCode): Promise<void>;
101
- /**
102
- * Attempt to reserve an array of proposed codes.
103
- * @returns number of codes actually reserved.
104
- * @see the `problems` member of the `CodeService.Error` exception
105
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
106
- * @note If you have a set of codes to reserve, it is considerably more efficient to do them as an array rather than one at a time.
107
- * @throws `CodeService.Error` if any of the proposed code cannot be reserved. The details for each failed code are in the `problems` member.
108
- */
109
- reserveCodes(arg: CodeService.ReserveCodesArgs): Promise<number>;
110
- /**
111
- * Attempt to reserve the next available code for a code sequence and scope.
112
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
113
- */
114
- reserveNextAvailableCode(arg: CodeService.ReserveNextArgs): Promise<void>;
115
- /**
116
- * Attempt to reserve an array of the next available codes for a code sequence and scope.
117
- * The length of the array determines the number of codes requested. The values for the new codes are returned
118
- * in the array, so they can be associated with the supplied GUIDs.
119
- * @returns number of codes actually reserved.
120
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
121
- */
122
- reserveNextAvailableCodes(arg: CodeService.ReserveNextArrayArgs): Promise<number>;
123
- /**
124
- * Update the properties of a single code.
125
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
126
- */
127
- updateCode(props: CodeService.UpdatedCode): Promise<void>;
128
- /**
129
- * Update the properties of an array codes.
130
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
131
- * @note If you have a set of codes to update, it is considerably more efficient to do them as an array rather than one at a time.
132
- * @returns number of codes actually updated.
133
- */
134
- updateCodes(arg: CodeService.UpdateCodesArgs): Promise<number>;
135
- /** Delete an array of codes by their guids.
136
- * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
137
- */
138
- deleteCodes(guid: CodeService.CodeGuid[]): Promise<void>;
139
- }
140
- /**
141
- * @internal
142
- */
143
- export interface InternalCodes extends CodesDb {
144
- reserveFontId(props: CodeService.FontIndexProps): Promise<FontId>;
145
- reserveBisCodeSpecs(specs: CodeService.BisCodeSpecIndexProps[]): Promise<void>;
146
- verifyBisCodeSpec(spec: CodeService.BisCodeSpecIndexProps): void;
147
- }
6
+ import { VersionedSqliteDb } from "./SQLiteDb";
148
7
  /**
149
8
  * The services for querying, reserving, updating, and deleting codes for a BriefcaseDb (available via `BriefcaseDb.codeService`) whenever it is opened for write access.
9
+ * See [CodeService]($docs/learning/backend/CodeService).
150
10
  * @alpha
151
11
  */
152
12
  export interface CodeService {
@@ -154,11 +14,9 @@ export interface CodeService {
154
14
  close: () => void;
155
15
  initialize(iModel: IModelDb): Promise<void>;
156
16
  /** the index for external Codes for this CodeService */
157
- readonly externalCodes?: CodesDb;
158
- /** the index for internal Codes for this CodeService
159
- * @internal
160
- */
161
- readonly internalCodes?: InternalCodes;
17
+ readonly externalCodes?: CloudSqlite.DbAccess<CodeService.CodesDb, CodeService.ReadMethods, CodeService.WriteMethods>;
18
+ /** the index for internal Codes for this CodeService */
19
+ readonly internalCodes?: CloudSqlite.DbAccess<CodeService.InternalCodes, CodeService.InternalReadMethods, CodeService.InternalWriteMethods>;
162
20
  /**
163
21
  * Application-supplied parameters for reserving new codes.
164
22
  */
@@ -176,6 +34,110 @@ export interface CodeService {
176
34
  }
177
35
  /** @alpha */
178
36
  export declare namespace CodeService {
37
+ interface WriteMethods {
38
+ /** Add a new code spec to this code service.
39
+ */
40
+ addCodeSpec(val: CodeService.NameAndJson): Promise<void>;
41
+ /**
42
+ * Add all of the codes and code specs from this CodeService's BriefcaseDb into the code index.
43
+ * @returns the number of codes actually added.
44
+ * @note It is not necessary to call this method unless the BriefcaseDb somehow becomes out of sync with its CodeService,
45
+ * for example when migrating iModels to a new code service. It is safe (but relatively expensive) to call this method multiple times, since
46
+ * any codes or code specs that are already in the index are ignored.
47
+ */
48
+ addAllCodes(iModel: IModelDb): Promise<number>;
49
+ /**
50
+ * Attempt to reserve a single proposed code.
51
+ * @throws `CodeService.Error` if the proposed code cannot be reserved.
52
+ */
53
+ reserveCode(code: CodeService.ProposedCode): Promise<void>;
54
+ /**
55
+ * Attempt to reserve an array of proposed codes.
56
+ * @returns number of codes actually reserved.
57
+ * @see the `problems` member of the `CodeService.Error` exception
58
+ * @note If you have a set of codes to reserve, it is considerably more efficient to do them as an array rather than one at a time.
59
+ * @throws `CodeService.Error` if any of the proposed code cannot be reserved. The details for each failed code are in the `problems` member.
60
+ */
61
+ reserveCodes(arg: CodeService.ReserveCodesArgs): Promise<number>;
62
+ /**
63
+ * Attempt to reserve the next available code for a code sequence and scope.
64
+ */
65
+ reserveNextAvailableCode(arg: CodeService.ReserveNextArgs): Promise<void>;
66
+ /**
67
+ * Attempt to reserve an array of the next available codes for a code sequence and scope.
68
+ * The length of the array determines the number of codes requested. The values for the new codes are returned
69
+ * in the array, so they can be associated with the supplied GUIDs.
70
+ * @returns number of codes actually reserved.
71
+ */
72
+ reserveNextAvailableCodes(arg: CodeService.ReserveNextArrayArgs): Promise<number>;
73
+ /**
74
+ * Update the properties of a single code.
75
+ */
76
+ updateCode(props: CodeService.UpdatedCode): Promise<void>;
77
+ /**
78
+ * Update the properties of an array codes.
79
+ * @note If you have a set of codes to update, it is considerably more efficient to do them as an array rather than one at a time.
80
+ * @returns number of codes actually updated.
81
+ */
82
+ updateCodes(arg: CodeService.UpdateCodesArgs): Promise<number>;
83
+ /** Delete an array of codes by their guids. */
84
+ deleteCodes(guid: CodeService.CodeGuid[]): Promise<void>;
85
+ }
86
+ interface ReadMethods {
87
+ /**
88
+ * Find the next available value for the supplied `SequenceScope`.
89
+ * If the sequence is full (there are no available values), this will throw an exception with `errorId="SequenceFull"`
90
+ * @param from the sequence and scope to search
91
+ * @returns the next available CodeValue in the sequence.
92
+ */
93
+ findNextAvailable(from: CodeService.SequenceScope): CodeService.CodeValue;
94
+ /**
95
+ * Find the highest currently used value for the supplied `SequenceScope`
96
+ * @param from the sequence and scope to search
97
+ * @returns the highest used value, or undefined if no values have been used.
98
+ */
99
+ findHighestUsed(from: CodeService.SequenceScope): CodeService.CodeValue | undefined;
100
+ /** Determine whether a code is present in this CodeIndex by its Guid. */
101
+ isCodePresent(guid: CodeService.CodeGuid): boolean;
102
+ /** Get the data for a code in this CodeIndex by its Guid.
103
+ * @returns the data for the code or undefined if no code is present for the supplied Guid.
104
+ */
105
+ getCode(guid: CodeService.CodeGuid): CodeService.CodeEntry | undefined;
106
+ /** Look up a code by its Scope, Spec, and Value.
107
+ * @returns the Guid of the code, or undefined if not present.
108
+ */
109
+ findCode(code: CodeService.ScopeSpecAndValue): CodeService.CodeGuid | undefined;
110
+ /** Look up a code spec by its name
111
+ * @throws if the spec is not present.
112
+ */
113
+ getCodeSpec(props: CodeService.CodeSpecName): CodeService.NameAndJson;
114
+ /** Call a `CodeIteration` function for all codes in this index, optionally filtered by a `CodeFilter ` */
115
+ forAllCodes(iter: CodeService.CodeIteration, filter?: CodeService.CodeFilter): void;
116
+ /** Call an iteration function for all code specs in this index, optionally filtered by a `ValueFilter ` */
117
+ forAllCodeSpecs(iter: CodeService.NameAndJsonIteration, filter?: CodeService.ValueFilter): void;
118
+ /**
119
+ * Verify that the Code of a to-be-inserted or to-be-updated Element:
120
+ * 1. has already been reserved,
121
+ * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,
122
+ * the value from the code index is returned.
123
+ *
124
+ * If not, throw an exception. Elements with no CodeValue are ignored.
125
+ * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.
126
+ */
127
+ verifyCode(specName: string, arg: CodeService.ElementCodeProps): void;
128
+ }
129
+ type CodesDb = VersionedSqliteDb & WriteMethods & ReadMethods;
130
+ interface InternalWriteMethods extends WriteMethods {
131
+ /** @internal */
132
+ reserveFontId(props: CodeService.FontIndexProps): Promise<FontId>;
133
+ /** @internal */
134
+ reserveBisCodeSpecs(specs: CodeService.BisCodeSpecIndexProps[]): Promise<void>;
135
+ }
136
+ interface InternalReadMethods extends ReadMethods {
137
+ /** @internal */
138
+ verifyBisCodeSpec(spec: CodeService.BisCodeSpecIndexProps): void;
139
+ }
140
+ type InternalCodes = CodesDb & InternalWriteMethods & InternalReadMethods;
179
141
  /** @internal */
180
142
  let createForIModel: ((db: IModelDb) => Promise<CodeService>) | undefined;
181
143
  /** Register an instance of a`CodeSequence` so it can be looked up by name. */
@@ -1 +1 @@
1
- {"version":3,"file":"CodeService.d.ts","sourceRoot":"","sources":["../../src/CodeService.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAgB,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;OAKG;IACH,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,aAAa,GAAG,WAAW,CAAC,SAAS,CAAC;IAE1E;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,aAAa,GAAG,WAAW,CAAC,SAAS,GAA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WAAW,GAAX,mBAAW,KAAX,mBAAW,QA6V3B","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\r\nimport { AccessToken, BentleyError, GuidString, IModelStatus, MarkRequired, Mutable } from \"@itwin/core-bentley\";\r\nimport { CodeProps, FontId, FontType } from \"@itwin/core-common\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { SettingObject } from \"./workspace/Settings\";\r\n\r\n/**\r\n * A readonly index of all known Codes for an iTwin. The CodeIndex may be slightly out-of-date\r\n * with the master copy in the cloud, but it should be periodically synchronized. Whenever codes are reserved/updated/deleted\r\n * locally, this copy is always up-to-date as of those changes.\r\n * @alpha\r\n */\r\nexport interface CodeIndex {\r\n /**\r\n * Find the next available value for the supplied `SequenceScope`.\r\n * If the sequence is full (there are no available values), this will throw an exception with `errorId=\"SequenceFull\"`\r\n * @param from the sequence and scope to search\r\n * @returns the next available CodeValue in the sequence.\r\n */\r\n findNextAvailable(from: CodeService.SequenceScope): CodeService.CodeValue;\r\n\r\n /**\r\n * Find the highest currently used value for the supplied `SequenceScope`\r\n * @param from the sequence and scope to search\r\n * @returns the highest used value, or undefined if no values have been used.\r\n */\r\n findHighestUsed(from: CodeService.SequenceScope): CodeService.CodeValue | undefined;\r\n\r\n /** Determine whether a code is present in this CodeIndex by its Guid. */\r\n isCodePresent(guid: CodeService.CodeGuid): boolean;\r\n\r\n /** Get the data for a code in this CodeIndex by its Guid.\r\n * @returns the data for the code or undefined if no code is present for the supplied Guid.\r\n */\r\n getCode(guid: CodeService.CodeGuid): CodeService.CodeEntry | undefined;\r\n\r\n /** Look up a code by its Scope, Spec, and Value.\r\n * @returns the Guid of the code, or undefined if not present.\r\n */\r\n findCode(code: CodeService.ScopeSpecAndValue): CodeService.CodeGuid | undefined;\r\n\r\n /** Look up a code spec by its name\r\n * @throws if the spec is not present.\r\n */\r\n getCodeSpec(props: CodeService.CodeSpecName): CodeService.NameAndJson;\r\n\r\n /** Call a `CodeIteration` function for all codes in this index, optionally filtered by a `CodeFilter ` */\r\n forAllCodes(iter: CodeService.CodeIteration, filter?: CodeService.CodeFilter): void;\r\n\r\n /** Call an iteration function for all code specs in this index, optionally filtered by a `ValueFilter ` */\r\n forAllCodeSpecs(iter: CodeService.NameAndJsonIteration, filter?: CodeService.ValueFilter): void;\r\n}\r\n\r\n/**\r\n * @alpha\r\n */\r\nexport interface CodesDb {\r\n /**\r\n * Application-supplied parameters for obtaining the write lock on the container.\r\n * Applications should set these parameters by adding a listener for `BriefcaseDb.onCodeServiceCreated`\r\n * that is called every time a BriefcaseDb that uses code services is opened for write access.\r\n */\r\n readonly lockParams: CloudSqlite.ObtainLockParams;\r\n\r\n /** the code index for this CodeService */\r\n readonly codeIndex: CodeIndex;\r\n\r\n /**\r\n * The token that grants access to the cloud container for this CodeService.\r\n * It should be established in a listener for `BriefcaseDb.onCodeServiceCreated`, and should be refreshed (via a\r\n * timer) before it expires.\r\n */\r\n sasToken: AccessToken;\r\n\r\n /**\r\n * Synchronize the local index with any changes by made by others.\r\n * @note This is called automatically whenever any write operation is performed on the code index. It is only necessary to\r\n * call this directly if you have not changed the code index recently, but wish to perform a readonly operation and want to\r\n * ensure it is up-to-date as of now.\r\n * @note There is no guarantee that a readonly index is up-to-date even immediately after calling this method, since others\r\n * may be modifying it at any time.\r\n */\r\n synchronizeWithCloud(): void;\r\n\r\n /**\r\n * Verify that the Code of a to-be-inserted or to-be-updated Element:\r\n * 1. has already been reserved,\r\n * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,\r\n * the value from the code index is returned.\r\n *\r\n * If not, throw an exception. Elements with no CodeValue are ignored.\r\n * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.\r\n */\r\n verifyCode(specName: string, arg: CodeService.ElementCodeProps): void;\r\n\r\n /** Add a new code spec to this code service.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n addCodeSpec(val: CodeService.NameAndJson): Promise<void>;\r\n\r\n /**\r\n * Add all of the codes and code specs from this CodeService's BriefcaseDb into the code index.\r\n * @returns the number of codes actually added.\r\n * @note It is not necessary to call this method unless the BriefcaseDb somehow becomes out of sync with its CodeService,\r\n * for example when migrating iModels to a new code service. It is safe (but relatively expensive) to call this method multiple times, since\r\n * any codes or code specs that are already in the index are ignored.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n addAllCodes(iModel: IModelDb): Promise<number>;\r\n\r\n /**\r\n * Attempt to reserve a single proposed code.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n * @throws `CodeService.Error` if the proposed code cannot be reserved.\r\n */\r\n reserveCode(code: CodeService.ProposedCode): Promise<void>;\r\n\r\n /**\r\n * Attempt to reserve an array of proposed codes.\r\n * @returns number of codes actually reserved.\r\n * @see the `problems` member of the `CodeService.Error` exception\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n * @note If you have a set of codes to reserve, it is considerably more efficient to do them as an array rather than one at a time.\r\n * @throws `CodeService.Error` if any of the proposed code cannot be reserved. The details for each failed code are in the `problems` member.\r\n */\r\n reserveCodes(arg: CodeService.ReserveCodesArgs): Promise<number>;\r\n\r\n /**\r\n * Attempt to reserve the next available code for a code sequence and scope.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n reserveNextAvailableCode(arg: CodeService.ReserveNextArgs): Promise<void>;\r\n\r\n /**\r\n * Attempt to reserve an array of the next available codes for a code sequence and scope.\r\n * The length of the array determines the number of codes requested. The values for the new codes are returned\r\n * in the array, so they can be associated with the supplied GUIDs.\r\n * @returns number of codes actually reserved.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n reserveNextAvailableCodes(arg: CodeService.ReserveNextArrayArgs): Promise<number>;\r\n\r\n /**\r\n * Update the properties of a single code.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n updateCode(props: CodeService.UpdatedCode): Promise<void>;\r\n\r\n /**\r\n * Update the properties of an array codes.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n * @note If you have a set of codes to update, it is considerably more efficient to do them as an array rather than one at a time.\r\n * @returns number of codes actually updated.\r\n */\r\n updateCodes(arg: CodeService.UpdateCodesArgs): Promise<number>;\r\n\r\n /** Delete an array of codes by their guids.\r\n * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.\r\n */\r\n deleteCodes(guid: CodeService.CodeGuid[]): Promise<void>;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface InternalCodes extends CodesDb {\r\n reserveFontId(props: CodeService.FontIndexProps): Promise<FontId>;\r\n reserveBisCodeSpecs(specs: CodeService.BisCodeSpecIndexProps[]): Promise<void>;\r\n verifyBisCodeSpec(spec: CodeService.BisCodeSpecIndexProps): void;\r\n}\r\n\r\n/**\r\n * The services for querying, reserving, updating, and deleting codes for a BriefcaseDb (available via `BriefcaseDb.codeService`) whenever it is opened for write access.\r\n * @alpha\r\n */\r\nexport interface CodeService {\r\n /** @internal */\r\n close: () => void;\r\n\r\n initialize(iModel: IModelDb): Promise<void>;\r\n\r\n /** the index for external Codes for this CodeService */\r\n readonly externalCodes?: CodesDb;\r\n\r\n /** the index for internal Codes for this CodeService\r\n * @internal\r\n */\r\n readonly internalCodes?: InternalCodes;\r\n\r\n /**\r\n * Application-supplied parameters for reserving new codes.\r\n */\r\n readonly appParams: CodeService.AuthorAndOrigin;\r\n\r\n /**\r\n * Verify that the Code of a to-be-inserted or to-be-updated Element:\r\n * 1. has already been reserved,\r\n * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,\r\n * the value from the code index is returned.\r\n *\r\n * If not, throw an exception. Elements with no CodeValue are ignored.\r\n * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.\r\n */\r\n verifyCode(props: CodeService.ElementCodeProps): void;\r\n}\r\n\r\n/** @alpha */\r\nexport namespace CodeService {\r\n /** @internal */\r\n const codeSequences = new Map<string, CodeSequence>();\r\n\r\n /** @internal */\r\n export let createForIModel: ((db: IModelDb) => Promise<CodeService>) | undefined;\r\n\r\n /** Register an instance of a`CodeSequence` so it can be looked up by name. */\r\n export function registerSequence(seq: CodeSequence) {\r\n codeSequences.set(seq.sequenceName, seq);\r\n }\r\n\r\n /** Get a previously registered `CodeSequence` by its name.\r\n * @throws if no sequence by that name was registered.\r\n */\r\n export function getSequence(name: string): CodeSequence {\r\n const seq = codeSequences.get(name);\r\n if (!seq)\r\n throw new Error(\"SequenceNotFound\", -1, `code sequence ${name} not found`);\r\n return seq;\r\n }\r\n\r\n /**\r\n * Turn a `CodePops` for the briefcase of this CodeService into a `ScopeAndSpec` object for use with a CodeService.\r\n * This is necessary because the `spec` member of `CodeProps` refers to the id of a code spec in the iModel, and\r\n * the `scope` member refers to the element Id of the scope element in the iModel. This helper function\r\n * converts the spec Id to the spec name and looks up the `FederationGuid` of the scope element.\r\n */\r\n export function makeScopeAndSpec(iModel: IModelDb, code: CodeProps): CodeService.ScopeAndSpec {\r\n const scopeGuid = iModel.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;\r\n if (undefined === scopeGuid)\r\n throw new CodeService.Error(\"MissingGuid\", IModelStatus.InvalidCode, \"code scope element has no federationGuid\");\r\n\r\n return { scopeGuid, specName: iModel.codeSpecs.getById(code.spec).name };\r\n }\r\n\r\n /** Turn a `CodeProps` and `ProposedCodeProps` into a `ProposedCode` for use with a CodeService.\r\n * @see [[makeScopeAndSpec]] for explanation of why this is necessary.\r\n */\r\n export function makeProposedCode(arg: CodeService.MakeProposedCodeArgs): CodeService.ProposedCode {\r\n return {\r\n ...arg.props,\r\n value: arg.code.value,\r\n ...makeScopeAndSpec(arg.iModel, arg.code),\r\n };\r\n }\r\n\r\n /** The name of a code spec */\r\n export type CodeSpecName = string;\r\n\r\n /**\r\n * The name that identifies the \"originator\" of a code. Usually this is the Guid of the iModel from which a code was added,\r\n * but can also be used to identify a system or type from an external code service.\r\n */\r\n export type CodeOriginName = string;\r\n\r\n /** The name that identifies the \"author\" of a code. Generally, this is intended to be the name of a person or group that helps identify the purpose of the code. */\r\n export type AuthorName = string;\r\n\r\n /** The value for a code. */\r\n export type CodeValue = string;\r\n\r\n /** The guid for a code. This identifies the real-world entity associated with the code. */\r\n export type CodeGuid = GuidString;\r\n\r\n /** The guid of the scope for a code. This identifies the real-world entity that provides the uniqueness scope for code values. */\r\n export type ScopeGuid = GuidString;\r\n\r\n /** An optional number associated with a code that may be used for \"status\" information. Values must be defined by applications. */\r\n export type CodeState = number;\r\n\r\n /** The return status of an iteration function. The value \"stop\" causes the iteration to terminate. */\r\n export type IterationReturn = void | \"stop\";\r\n\r\n /** An iteration function over codes in a code index. It is called with the Guid of a each code. */\r\n export type CodeIteration = (guid: GuidString) => IterationReturn;\r\n\r\n /** An iteration function over code specs in a code index. It is called with the name and json of a each code spec. */\r\n export type NameAndJsonIteration = (nameAndJson: NameAndJson) => IterationReturn;\r\n\r\n /** Argument for reserving an array of new codes. */\r\n export interface ReserveCodesArgs {\r\n /** an array of proposed codes to reserve.\r\n * @note the guid of each proposed code must be supplied by the caller.\r\n */\r\n readonly codes: CodeService.ProposedCode[];\r\n /** If true, unless all codes are available, don't reserve any codes. Otherwise reserve all available codes. */\r\n readonly allOrNothing?: true;\r\n }\r\n\r\n /** Argument for reserving a code from a code sequence. */\r\n export interface ReserveNextArgs {\r\n /** the properties of the new code */\r\n readonly code: CodeService.ProposedCodeProps;\r\n /** The code sequence and scope for the new code. */\r\n readonly from: SequenceScope;\r\n }\r\n\r\n /** Argument for reserving an array of codes from a code sequence. */\r\n export interface ReserveNextArrayArgs {\r\n /** an array of proposed codes to reserve. */\r\n readonly codes: CodeService.ProposedCodeProps[];\r\n /** The code sequence and scope for the new codes. */\r\n readonly from: CodeService.SequenceScope;\r\n /** If true, and in the event that the code sequence does not have enough available codes to fulfill all the entries in `codes`,\r\n * return as many as possible. Otherwise no codes are reserved. The `problems` member of the exception can be used to determine how many codes were available.\r\n * @note if `asManyAsPossible` is true, no error is thrown if the sequence becomes full. You must check the return value to see how many\r\n * were actually available. The `value` member will be undefined for any proposed codes that were not reserved.\r\n */\r\n readonly asManyAsPossible?: true;\r\n }\r\n\r\n /** Argument for updating an array of codes. */\r\n export interface UpdateCodesArgs {\r\n /** Properties of the codes to update */\r\n readonly props: CodeService.UpdatedCode[];\r\n /** If true, unless all codes are updated, don't update any codes. Otherwise update all possible codes. */\r\n readonly allOrNothing?: true;\r\n }\r\n\r\n /** Arguments for CodeService.makeProposedCode */\r\n export interface MakeProposedCodeArgs {\r\n readonly iModel: IModelDb;\r\n readonly code: Required<CodeProps>;\r\n readonly props: CodeService.CodeGuidStateJson;\r\n }\r\n\r\n /** The properties of an Element to be checked against the code index.\r\n * @see CodeService.verifyCode\r\n */\r\n export interface ElementCodeProps {\r\n /** iModel from which the code is being inserted/updated. */\r\n readonly iModel: IModelDb;\r\n /** Properties of the code */\r\n readonly props: {\r\n /** The imodel-specific code properties. */\r\n readonly code: CodeProps;\r\n /**\r\n * The federationGuid of the element being inserted or updated.\r\n * If federationGuid is defined, it is must match the value in the code index or an error is thrown.\r\n * If it is undefined, the value from the code index is returned here.\r\n */\r\n federationGuid?: GuidString;\r\n };\r\n }\r\n\r\n /** a name and a json object. Used for code specs, authors and origins. */\r\n export interface NameAndJson {\r\n readonly name: string;\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** A code Scope guid, and code spec name. */\r\n export interface ScopeAndSpec {\r\n readonly specName: CodeSpecName;\r\n readonly scopeGuid: ScopeGuid;\r\n }\r\n\r\n /** A code Scope guid, code spec, and code value. */\r\n export interface ScopeSpecAndValue extends ScopeAndSpec {\r\n readonly value: CodeValue;\r\n }\r\n\r\n /** The data held in a code index for a single code. */\r\n export interface CodeEntry {\r\n /** The name of the code spec for this code. */\r\n readonly specName: CodeSpecName;\r\n /** The guid of the entity that provides the scope for this code. */\r\n readonly scopeGuid: ScopeGuid;\r\n /** The value of this code. */\r\n readonly value: CodeValue;\r\n /** The guid of the entity this code identifies. */\r\n readonly guid: CodeGuid;\r\n /** the state of the code. May be undefined. */\r\n readonly state?: CodeState;\r\n /** The name of the originating source of this code (usually an iModel Guid). May be undefined. */\r\n readonly origin: CodeOriginName;\r\n /** The name of the author of this code. May be undefined. */\r\n readonly author?: AuthorName;\r\n /** Option json properties associated with this code. May be undefined. */\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** A filter used to limit and/or sort the values returned by an iteration. */\r\n export interface ValueFilter {\r\n /** A value filter. May include wild cards when used with `GLOB` or `LIKE` */\r\n readonly value?: string;\r\n /** The comparison operator for `value`. Default is `=` */\r\n readonly valueCompare?: \"GLOB\" | \"LIKE\" | \"NOT GLOB\" | \"NOT LIKE\" | \"=\" | \"<\" | \">\";\r\n /** Order results ascending or descending. If not supplied, the results are unordered (random). */\r\n readonly orderBy?: \"ASC\" | \"DESC\";\r\n /** An SQL expression to further filter results. This string is appended to the `WHERE` clause with an `AND` (that should not be part of the sqlExpression) */\r\n readonly sqlExpression?: string;\r\n }\r\n\r\n /** A filter to limit and/or sort the values for the [[CodeIndex.forAllCodes]] iteration. */\r\n export interface CodeFilter extends ValueFilter {\r\n /** If supplied, limit results to only those with this spec */\r\n readonly specName?: CodeSpecName;\r\n /** If supplied, limit results to only those with this scope Guid */\r\n readonly scopeGuid?: ScopeGuid;\r\n /** If supplied, limit results to only those with this origin */\r\n readonly origin?: CodeOriginName;\r\n }\r\n\r\n /** Author and origin information supplied when codes are reserved. */\r\n export interface AuthorAndOrigin {\r\n /** The name of the individual or group for whom the code was reserved. */\r\n readonly author: Mutable<NameAndJson>;\r\n /** The identity of the \"originator\" of the code. This is usually a guid of an iModel, but can be any unique string. */\r\n readonly origin: Mutable<NameAndJson>;\r\n }\r\n\r\n /** The Guid, state, and json properties of a code. */\r\n export interface CodeGuidStateJson {\r\n /** The Guid of the new code. This must be always be supplied by the application. */\r\n readonly guid: CodeGuid;\r\n /** An optional value for the state of the code. */\r\n readonly state?: CodeState;\r\n /** An optional json object to be stored with the code. */\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** Properties of a \"proposed\" new code to be reserved.\r\n * @note the Guid of the entity identified by this code *must* be supplied, but `value` is optional, since\r\n * this may be used to reserve codes from a sequence where the value is generated.\r\n */\r\n export interface ProposedCodeProps extends CodeGuidStateJson {\r\n /** The value for the proposed code.\r\n * @note For code sequence operations, this value is ignored on input and is set with a new value from the sequence on successful return.\r\n */\r\n value?: CodeValue;\r\n }\r\n\r\n /** Properties of a proposed new code that is not from a code sequence (its `value` is required). */\r\n export type ProposedCode = ProposedCodeProps & ScopeSpecAndValue;\r\n\r\n /** Properties that describe a code sequence and a scope and spec for a proposed code or array of codes from a sequence. */\r\n export interface SequenceScope extends ScopeAndSpec {\r\n /** The code sequence. */\r\n readonly seq: CodeSequence;\r\n /** A valid current value. If supplied, the returned value will always be later in the sequence than this. */\r\n readonly start?: CodeValue;\r\n }\r\n\r\n /** Properties of a code to be updated.\r\n * @note The `guid` member identifies the code to be updated and is required.\r\n * All other properties are optional - if `undefined`, its value is not changed.\r\n */\r\n export type UpdatedCode = MarkRequired<Partial<ProposedCode>, \"guid\">;\r\n\r\n /** A proposed code that could not be reserved due to some error. */\r\n export interface ReserveProblem {\r\n /** the proposed code that failed. */\r\n readonly code: ProposedCode;\r\n /** the reason for the failure */\r\n readonly errorId: ErrorId;\r\n /** the error message from the exception for this proposed code. */\r\n readonly message: string;\r\n }\r\n\r\n /** A update to a code that failed for some error. */\r\n export interface UpdateProblem {\r\n /** The properties of the code that was to be updated */\r\n readonly prop: UpdatedCode;\r\n /** the reason for the failure */\r\n readonly errorId: ErrorId;\r\n /** the error message from the exception for the update request. */\r\n readonly message: string;\r\n }\r\n\r\n /**\r\n * A sequence of code values following a increasing pattern. Valid code sequences must have a first value, a last value, and\r\n * a way to get the next valid value from an existing valid value.\r\n * Code sequences have a `sequenceName` so they can be registered using `CodeService.registerSequence`.\r\n */\r\n export interface CodeSequence {\r\n /** the name of this CodeSequence. */\r\n get sequenceName(): string;\r\n /** Get the first valid value for this CodeSequence */\r\n getFirstValue(): CodeValue;\r\n /** Get the last valid value for this CodeSequence */\r\n getLastValue(): CodeValue;\r\n /** Get the next valid value for this CodeSequence from the supplied value.\r\n * If the sequence is full (that is, the next value is greater than the last value, this method should throw with errorId=\"SequenceFull\".\r\n * @return the next valid value according to the rules of this CodeSequence.\r\n */\r\n getNextValue(code: CodeValue): CodeValue;\r\n /** Determine whether this supplied value is valid for this sequence. */\r\n isValidCode(code: CodeValue): boolean;\r\n }\r\n\r\n /** @internal */\r\n export interface FontIndexProps {\r\n id?: number;\r\n fontType: FontType;\r\n fontName: string;\r\n }\r\n /** @internal */\r\n export interface BisCodeSpecIndexProps {\r\n id?: number;\r\n name: string;\r\n props: string;\r\n }\r\n\r\n /** Exception class thrown by `CodeService` methods. */\r\n export class Error extends BentleyError {\r\n /** A string that indicates the type of problem that caused the exception. */\r\n public readonly errorId: ErrorId;\r\n /** For [[CodeService.reserveCodes]] and [[CodeService.updateCodes]], a list of the problem details. */\r\n public readonly problems?: ReserveProblem[] | UpdateProblem[];\r\n\r\n /** @internal */\r\n constructor(errorId: ErrorId, errNum: number, message: string, problems?: ReserveProblem[] | UpdateProblem[]) {\r\n super(errNum, message);\r\n this.errorId = errorId;\r\n this.problems = problems;\r\n }\r\n }\r\n\r\n /** Identifiers for exceptions thrown by `CodeService` methods.\r\n * @see [[CodeService.Error.errorId]]\r\n */\r\n export type ErrorId =\r\n \"BadIndexProps\" |\r\n \"CorruptIModel\" |\r\n \"CorruptIndex\" |\r\n \"DuplicateValue\" |\r\n \"GuidIsInUse\" |\r\n \"GuidMismatch\" |\r\n \"IllegalValue\" |\r\n \"InconsistentIModels\" |\r\n \"IndexReadonly\" |\r\n \"InvalidCodeScope\" |\r\n \"InvalidGuid\" |\r\n \"InvalidSequence\" |\r\n \"MissingCode\" |\r\n \"MissingGuid\" |\r\n \"MissingInput\" |\r\n \"MissingSpec\" |\r\n \"NoCodeIndex\" |\r\n \"SequenceFull\" |\r\n \"ReserveErrors\" |\r\n \"SequenceNotFound\" |\r\n \"SqlLogicError\" |\r\n \"UpdateErrors\" |\r\n \"ValueIsInUse\" |\r\n \"WrongVersion\";\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"CodeService.js","sourceRoot":"","sources":["../../src/CodeService.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAoG;AAyCpG,aAAa;AACb,IAAiB,WAAW,CA2d3B;AA3dD,WAAiB,WAAW;IA+H1B,gBAAgB;IAChB,MAAM,aAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;IAKtD,8EAA8E;IAC9E,SAAgB,gBAAgB,CAAC,GAAiB;QAChD,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IAFe,4BAAgB,mBAE/B,CAAA;IAED;;OAEG;IACH,SAAgB,WAAW,CAAC,IAAY;QACtC,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,GAAG;YACN,MAAM,IAAI,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,iBAAiB,IAAI,YAAY,CAAC,CAAC;QAC7E,OAAO,GAAG,CAAC;IACb,CAAC;IALe,uBAAW,cAK1B,CAAA;IAED;;;;;OAKG;IACH,SAAgB,gBAAgB,CAAC,MAAgB,EAAE,IAAe;QAChE,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC,cAAc,CAAC;QAC/G,IAAI,SAAS,KAAK,SAAS;YACzB,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,aAAa,EAAE,2BAAY,CAAC,WAAW,EAAE,0CAA0C,CAAC,CAAC;QAEnH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3E,CAAC;IANe,4BAAgB,mBAM/B,CAAA;IAED;;OAEG;IACH,SAAgB,gBAAgB,CAAC,GAAqC;QACpE,OAAO;YACL,GAAG,GAAG,CAAC,KAAK;YACZ,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK;YACrB,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC;SAC1C,CAAC;IACJ,CAAC;IANe,4BAAgB,mBAM/B,CAAA;IAoQD,uDAAuD;IACvD,MAAa,KAAM,SAAQ,2BAAY;QAMrC,gBAAgB;QAChB,YAAY,OAAgB,EAAE,MAAc,EAAE,OAAe,EAAE,QAA6C;YAC1G,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC3B,CAAC;KACF;IAZY,iBAAK,QAYjB,CAAA;AA+BH,CAAC,EA3dgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA2d3B","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\r\nimport { BentleyError, GuidString, IModelStatus, MarkRequired, Mutable } from \"@itwin/core-bentley\";\r\nimport { CodeProps, FontId, FontType } from \"@itwin/core-common\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { SettingObject } from \"./workspace/Settings\";\r\nimport { VersionedSqliteDb } from \"./SQLiteDb\";\r\n\r\n/**\r\n * The services for querying, reserving, updating, and deleting codes for a BriefcaseDb (available via `BriefcaseDb.codeService`) whenever it is opened for write access.\r\n * See [CodeService]($docs/learning/backend/CodeService).\r\n * @alpha\r\n */\r\nexport interface CodeService {\r\n /** @internal */\r\n close: () => void;\r\n\r\n initialize(iModel: IModelDb): Promise<void>;\r\n\r\n /** the index for external Codes for this CodeService */\r\n readonly externalCodes?: CloudSqlite.DbAccess<CodeService.CodesDb, CodeService.ReadMethods, CodeService.WriteMethods>;\r\n\r\n /** the index for internal Codes for this CodeService */\r\n readonly internalCodes?: CloudSqlite.DbAccess<CodeService.InternalCodes, CodeService.InternalReadMethods, CodeService.InternalWriteMethods>;\r\n\r\n /**\r\n * Application-supplied parameters for reserving new codes.\r\n */\r\n readonly appParams: CodeService.AuthorAndOrigin;\r\n\r\n /**\r\n * Verify that the Code of a to-be-inserted or to-be-updated Element:\r\n * 1. has already been reserved,\r\n * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,\r\n * the value from the code index is returned.\r\n *\r\n * If not, throw an exception. Elements with no CodeValue are ignored.\r\n * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.\r\n */\r\n verifyCode(props: CodeService.ElementCodeProps): void;\r\n}\r\n\r\n/** @alpha */\r\nexport namespace CodeService {\r\n\r\n export interface WriteMethods {\r\n /** Add a new code spec to this code service.\r\n */\r\n addCodeSpec(val: CodeService.NameAndJson): Promise<void>;\r\n\r\n /**\r\n * Add all of the codes and code specs from this CodeService's BriefcaseDb into the code index.\r\n * @returns the number of codes actually added.\r\n * @note It is not necessary to call this method unless the BriefcaseDb somehow becomes out of sync with its CodeService,\r\n * for example when migrating iModels to a new code service. It is safe (but relatively expensive) to call this method multiple times, since\r\n * any codes or code specs that are already in the index are ignored.\r\n */\r\n addAllCodes(iModel: IModelDb): Promise<number>;\r\n\r\n /**\r\n * Attempt to reserve a single proposed code.\r\n * @throws `CodeService.Error` if the proposed code cannot be reserved.\r\n */\r\n reserveCode(code: CodeService.ProposedCode): Promise<void>;\r\n\r\n /**\r\n * Attempt to reserve an array of proposed codes.\r\n * @returns number of codes actually reserved.\r\n * @see the `problems` member of the `CodeService.Error` exception\r\n * @note If you have a set of codes to reserve, it is considerably more efficient to do them as an array rather than one at a time.\r\n * @throws `CodeService.Error` if any of the proposed code cannot be reserved. The details for each failed code are in the `problems` member.\r\n */\r\n reserveCodes(arg: CodeService.ReserveCodesArgs): Promise<number>;\r\n\r\n /**\r\n * Attempt to reserve the next available code for a code sequence and scope.\r\n */\r\n reserveNextAvailableCode(arg: CodeService.ReserveNextArgs): Promise<void>;\r\n\r\n /**\r\n * Attempt to reserve an array of the next available codes for a code sequence and scope.\r\n * The length of the array determines the number of codes requested. The values for the new codes are returned\r\n * in the array, so they can be associated with the supplied GUIDs.\r\n * @returns number of codes actually reserved.\r\n */\r\n reserveNextAvailableCodes(arg: CodeService.ReserveNextArrayArgs): Promise<number>;\r\n\r\n /**\r\n * Update the properties of a single code.\r\n */\r\n updateCode(props: CodeService.UpdatedCode): Promise<void>;\r\n\r\n /**\r\n * Update the properties of an array codes.\r\n * @note If you have a set of codes to update, it is considerably more efficient to do them as an array rather than one at a time.\r\n * @returns number of codes actually updated.\r\n */\r\n updateCodes(arg: CodeService.UpdateCodesArgs): Promise<number>;\r\n\r\n /** Delete an array of codes by their guids. */\r\n deleteCodes(guid: CodeService.CodeGuid[]): Promise<void>;\r\n }\r\n\r\n export interface ReadMethods {\r\n /**\r\n * Find the next available value for the supplied `SequenceScope`.\r\n * If the sequence is full (there are no available values), this will throw an exception with `errorId=\"SequenceFull\"`\r\n * @param from the sequence and scope to search\r\n * @returns the next available CodeValue in the sequence.\r\n */\r\n findNextAvailable(from: CodeService.SequenceScope): CodeService.CodeValue;\r\n\r\n /**\r\n * Find the highest currently used value for the supplied `SequenceScope`\r\n * @param from the sequence and scope to search\r\n * @returns the highest used value, or undefined if no values have been used.\r\n */\r\n findHighestUsed(from: CodeService.SequenceScope): CodeService.CodeValue | undefined;\r\n\r\n /** Determine whether a code is present in this CodeIndex by its Guid. */\r\n isCodePresent(guid: CodeService.CodeGuid): boolean;\r\n\r\n /** Get the data for a code in this CodeIndex by its Guid.\r\n * @returns the data for the code or undefined if no code is present for the supplied Guid.\r\n */\r\n getCode(guid: CodeService.CodeGuid): CodeService.CodeEntry | undefined;\r\n\r\n /** Look up a code by its Scope, Spec, and Value.\r\n * @returns the Guid of the code, or undefined if not present.\r\n */\r\n findCode(code: CodeService.ScopeSpecAndValue): CodeService.CodeGuid | undefined;\r\n\r\n /** Look up a code spec by its name\r\n * @throws if the spec is not present.\r\n */\r\n getCodeSpec(props: CodeService.CodeSpecName): CodeService.NameAndJson;\r\n\r\n /** Call a `CodeIteration` function for all codes in this index, optionally filtered by a `CodeFilter ` */\r\n forAllCodes(iter: CodeService.CodeIteration, filter?: CodeService.CodeFilter): void;\r\n\r\n /** Call an iteration function for all code specs in this index, optionally filtered by a `ValueFilter ` */\r\n forAllCodeSpecs(iter: CodeService.NameAndJsonIteration, filter?: CodeService.ValueFilter): void;\r\n\r\n /**\r\n * Verify that the Code of a to-be-inserted or to-be-updated Element:\r\n * 1. has already been reserved,\r\n * 2. if the element has a `federationGuid`, it must match the reserved value. If the federationGuid is undefined,\r\n * the value from the code index is returned.\r\n *\r\n * If not, throw an exception. Elements with no CodeValue are ignored.\r\n * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.\r\n */\r\n verifyCode(specName: string, arg: CodeService.ElementCodeProps): void;\r\n }\r\n\r\n export type CodesDb = VersionedSqliteDb & WriteMethods & ReadMethods;\r\n\r\n export interface InternalWriteMethods extends WriteMethods {\r\n /** @internal */\r\n reserveFontId(props: CodeService.FontIndexProps): Promise<FontId>;\r\n /** @internal */\r\n reserveBisCodeSpecs(specs: CodeService.BisCodeSpecIndexProps[]): Promise<void>;\r\n }\r\n export interface InternalReadMethods extends ReadMethods {\r\n /** @internal */\r\n verifyBisCodeSpec(spec: CodeService.BisCodeSpecIndexProps): void;\r\n }\r\n\r\n export type InternalCodes = CodesDb & InternalWriteMethods & InternalReadMethods;\r\n\r\n /** @internal */\r\n const codeSequences = new Map<string, CodeSequence>();\r\n\r\n /** @internal */\r\n export let createForIModel: ((db: IModelDb) => Promise<CodeService>) | undefined;\r\n\r\n /** Register an instance of a`CodeSequence` so it can be looked up by name. */\r\n export function registerSequence(seq: CodeSequence) {\r\n codeSequences.set(seq.sequenceName, seq);\r\n }\r\n\r\n /** Get a previously registered `CodeSequence` by its name.\r\n * @throws if no sequence by that name was registered.\r\n */\r\n export function getSequence(name: string): CodeSequence {\r\n const seq = codeSequences.get(name);\r\n if (!seq)\r\n throw new Error(\"SequenceNotFound\", -1, `code sequence ${name} not found`);\r\n return seq;\r\n }\r\n\r\n /**\r\n * Turn a `CodePops` for the briefcase of this CodeService into a `ScopeAndSpec` object for use with a CodeService.\r\n * This is necessary because the `spec` member of `CodeProps` refers to the id of a code spec in the iModel, and\r\n * the `scope` member refers to the element Id of the scope element in the iModel. This helper function\r\n * converts the spec Id to the spec name and looks up the `FederationGuid` of the scope element.\r\n */\r\n export function makeScopeAndSpec(iModel: IModelDb, code: CodeProps): CodeService.ScopeAndSpec {\r\n const scopeGuid = iModel.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;\r\n if (undefined === scopeGuid)\r\n throw new CodeService.Error(\"MissingGuid\", IModelStatus.InvalidCode, \"code scope element has no federationGuid\");\r\n\r\n return { scopeGuid, specName: iModel.codeSpecs.getById(code.spec).name };\r\n }\r\n\r\n /** Turn a `CodeProps` and `ProposedCodeProps` into a `ProposedCode` for use with a CodeService.\r\n * @see [[makeScopeAndSpec]] for explanation of why this is necessary.\r\n */\r\n export function makeProposedCode(arg: CodeService.MakeProposedCodeArgs): CodeService.ProposedCode {\r\n return {\r\n ...arg.props,\r\n value: arg.code.value,\r\n ...makeScopeAndSpec(arg.iModel, arg.code),\r\n };\r\n }\r\n\r\n /** The name of a code spec */\r\n export type CodeSpecName = string;\r\n\r\n /**\r\n * The name that identifies the \"originator\" of a code. Usually this is the Guid of the iModel from which a code was added,\r\n * but can also be used to identify a system or type from an external code service.\r\n */\r\n export type CodeOriginName = string;\r\n\r\n /** The name that identifies the \"author\" of a code. Generally, this is intended to be the name of a person or group that helps identify the purpose of the code. */\r\n export type AuthorName = string;\r\n\r\n /** The value for a code. */\r\n export type CodeValue = string;\r\n\r\n /** The guid for a code. This identifies the real-world entity associated with the code. */\r\n export type CodeGuid = GuidString;\r\n\r\n /** The guid of the scope for a code. This identifies the real-world entity that provides the uniqueness scope for code values. */\r\n export type ScopeGuid = GuidString;\r\n\r\n /** An optional number associated with a code that may be used for \"status\" information. Values must be defined by applications. */\r\n export type CodeState = number;\r\n\r\n /** The return status of an iteration function. The value \"stop\" causes the iteration to terminate. */\r\n export type IterationReturn = void | \"stop\";\r\n\r\n /** An iteration function over codes in a code index. It is called with the Guid of a each code. */\r\n export type CodeIteration = (guid: GuidString) => IterationReturn;\r\n\r\n /** An iteration function over code specs in a code index. It is called with the name and json of a each code spec. */\r\n export type NameAndJsonIteration = (nameAndJson: NameAndJson) => IterationReturn;\r\n\r\n /** Argument for reserving an array of new codes. */\r\n export interface ReserveCodesArgs {\r\n /** an array of proposed codes to reserve.\r\n * @note the guid of each proposed code must be supplied by the caller.\r\n */\r\n readonly codes: CodeService.ProposedCode[];\r\n /** If true, unless all codes are available, don't reserve any codes. Otherwise reserve all available codes. */\r\n readonly allOrNothing?: true;\r\n }\r\n\r\n /** Argument for reserving a code from a code sequence. */\r\n export interface ReserveNextArgs {\r\n /** the properties of the new code */\r\n readonly code: CodeService.ProposedCodeProps;\r\n /** The code sequence and scope for the new code. */\r\n readonly from: SequenceScope;\r\n }\r\n\r\n /** Argument for reserving an array of codes from a code sequence. */\r\n export interface ReserveNextArrayArgs {\r\n /** an array of proposed codes to reserve. */\r\n readonly codes: CodeService.ProposedCodeProps[];\r\n /** The code sequence and scope for the new codes. */\r\n readonly from: CodeService.SequenceScope;\r\n /** If true, and in the event that the code sequence does not have enough available codes to fulfill all the entries in `codes`,\r\n * return as many as possible. Otherwise no codes are reserved. The `problems` member of the exception can be used to determine how many codes were available.\r\n * @note if `asManyAsPossible` is true, no error is thrown if the sequence becomes full. You must check the return value to see how many\r\n * were actually available. The `value` member will be undefined for any proposed codes that were not reserved.\r\n */\r\n readonly asManyAsPossible?: true;\r\n }\r\n\r\n /** Argument for updating an array of codes. */\r\n export interface UpdateCodesArgs {\r\n /** Properties of the codes to update */\r\n readonly props: CodeService.UpdatedCode[];\r\n /** If true, unless all codes are updated, don't update any codes. Otherwise update all possible codes. */\r\n readonly allOrNothing?: true;\r\n }\r\n\r\n /** Arguments for CodeService.makeProposedCode */\r\n export interface MakeProposedCodeArgs {\r\n readonly iModel: IModelDb;\r\n readonly code: Required<CodeProps>;\r\n readonly props: CodeService.CodeGuidStateJson;\r\n }\r\n\r\n /** The properties of an Element to be checked against the code index.\r\n * @see CodeService.verifyCode\r\n */\r\n export interface ElementCodeProps {\r\n /** iModel from which the code is being inserted/updated. */\r\n readonly iModel: IModelDb;\r\n /** Properties of the code */\r\n readonly props: {\r\n /** The imodel-specific code properties. */\r\n readonly code: CodeProps;\r\n /**\r\n * The federationGuid of the element being inserted or updated.\r\n * If federationGuid is defined, it is must match the value in the code index or an error is thrown.\r\n * If it is undefined, the value from the code index is returned here.\r\n */\r\n federationGuid?: GuidString;\r\n };\r\n }\r\n\r\n /** a name and a json object. Used for code specs, authors and origins. */\r\n export interface NameAndJson {\r\n readonly name: string;\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** A code Scope guid, and code spec name. */\r\n export interface ScopeAndSpec {\r\n readonly specName: CodeSpecName;\r\n readonly scopeGuid: ScopeGuid;\r\n }\r\n\r\n /** A code Scope guid, code spec, and code value. */\r\n export interface ScopeSpecAndValue extends ScopeAndSpec {\r\n readonly value: CodeValue;\r\n }\r\n\r\n /** The data held in a code index for a single code. */\r\n export interface CodeEntry {\r\n /** The name of the code spec for this code. */\r\n readonly specName: CodeSpecName;\r\n /** The guid of the entity that provides the scope for this code. */\r\n readonly scopeGuid: ScopeGuid;\r\n /** The value of this code. */\r\n readonly value: CodeValue;\r\n /** The guid of the entity this code identifies. */\r\n readonly guid: CodeGuid;\r\n /** the state of the code. May be undefined. */\r\n readonly state?: CodeState;\r\n /** The name of the originating source of this code (usually an iModel Guid). May be undefined. */\r\n readonly origin: CodeOriginName;\r\n /** The name of the author of this code. May be undefined. */\r\n readonly author?: AuthorName;\r\n /** Option json properties associated with this code. May be undefined. */\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** A filter used to limit and/or sort the values returned by an iteration. */\r\n export interface ValueFilter {\r\n /** A value filter. May include wild cards when used with `GLOB` or `LIKE` */\r\n readonly value?: string;\r\n /** The comparison operator for `value`. Default is `=` */\r\n readonly valueCompare?: \"GLOB\" | \"LIKE\" | \"NOT GLOB\" | \"NOT LIKE\" | \"=\" | \"<\" | \">\";\r\n /** Order results ascending or descending. If not supplied, the results are unordered (random). */\r\n readonly orderBy?: \"ASC\" | \"DESC\";\r\n /** An SQL expression to further filter results. This string is appended to the `WHERE` clause with an `AND` (that should not be part of the sqlExpression) */\r\n readonly sqlExpression?: string;\r\n }\r\n\r\n /** A filter to limit and/or sort the values for the [[CodeIndex.forAllCodes]] iteration. */\r\n export interface CodeFilter extends ValueFilter {\r\n /** If supplied, limit results to only those with this spec */\r\n readonly specName?: CodeSpecName;\r\n /** If supplied, limit results to only those with this scope Guid */\r\n readonly scopeGuid?: ScopeGuid;\r\n /** If supplied, limit results to only those with this origin */\r\n readonly origin?: CodeOriginName;\r\n }\r\n\r\n /** Author and origin information supplied when codes are reserved. */\r\n export interface AuthorAndOrigin {\r\n /** The name of the individual or group for whom the code was reserved. */\r\n readonly author: Mutable<NameAndJson>;\r\n /** The identity of the \"originator\" of the code. This is usually a guid of an iModel, but can be any unique string. */\r\n readonly origin: Mutable<NameAndJson>;\r\n }\r\n\r\n /** The Guid, state, and json properties of a code. */\r\n export interface CodeGuidStateJson {\r\n /** The Guid of the new code. This must be always be supplied by the application. */\r\n readonly guid: CodeGuid;\r\n /** An optional value for the state of the code. */\r\n readonly state?: CodeState;\r\n /** An optional json object to be stored with the code. */\r\n readonly json?: SettingObject;\r\n }\r\n\r\n /** Properties of a \"proposed\" new code to be reserved.\r\n * @note the Guid of the entity identified by this code *must* be supplied, but `value` is optional, since\r\n * this may be used to reserve codes from a sequence where the value is generated.\r\n */\r\n export interface ProposedCodeProps extends CodeGuidStateJson {\r\n /** The value for the proposed code.\r\n * @note For code sequence operations, this value is ignored on input and is set with a new value from the sequence on successful return.\r\n */\r\n value?: CodeValue;\r\n }\r\n\r\n /** Properties of a proposed new code that is not from a code sequence (its `value` is required). */\r\n export type ProposedCode = ProposedCodeProps & ScopeSpecAndValue;\r\n\r\n /** Properties that describe a code sequence and a scope and spec for a proposed code or array of codes from a sequence. */\r\n export interface SequenceScope extends ScopeAndSpec {\r\n /** The code sequence. */\r\n readonly seq: CodeSequence;\r\n /** A valid current value. If supplied, the returned value will always be later in the sequence than this. */\r\n readonly start?: CodeValue;\r\n }\r\n\r\n /** Properties of a code to be updated.\r\n * @note The `guid` member identifies the code to be updated and is required.\r\n * All other properties are optional - if `undefined`, its value is not changed.\r\n */\r\n export type UpdatedCode = MarkRequired<Partial<ProposedCode>, \"guid\">;\r\n\r\n /** A proposed code that could not be reserved due to some error. */\r\n export interface ReserveProblem {\r\n /** the proposed code that failed. */\r\n readonly code: ProposedCode;\r\n /** the reason for the failure */\r\n readonly errorId: ErrorId;\r\n /** the error message from the exception for this proposed code. */\r\n readonly message: string;\r\n }\r\n\r\n /** A update to a code that failed for some error. */\r\n export interface UpdateProblem {\r\n /** The properties of the code that was to be updated */\r\n readonly prop: UpdatedCode;\r\n /** the reason for the failure */\r\n readonly errorId: ErrorId;\r\n /** the error message from the exception for the update request. */\r\n readonly message: string;\r\n }\r\n\r\n /**\r\n * A sequence of code values following a increasing pattern. Valid code sequences must have a first value, a last value, and\r\n * a way to get the next valid value from an existing valid value.\r\n * Code sequences have a `sequenceName` so they can be registered using `CodeService.registerSequence`.\r\n */\r\n export interface CodeSequence {\r\n /** the name of this CodeSequence. */\r\n get sequenceName(): string;\r\n /** Get the first valid value for this CodeSequence */\r\n getFirstValue(): CodeValue;\r\n /** Get the last valid value for this CodeSequence */\r\n getLastValue(): CodeValue;\r\n /** Get the next valid value for this CodeSequence from the supplied value.\r\n * If the sequence is full (that is, the next value is greater than the last value, this method should throw with errorId=\"SequenceFull\".\r\n * @return the next valid value according to the rules of this CodeSequence.\r\n */\r\n getNextValue(code: CodeValue): CodeValue;\r\n /** Determine whether this supplied value is valid for this sequence. */\r\n isValidCode(code: CodeValue): boolean;\r\n }\r\n\r\n /** @internal */\r\n export interface FontIndexProps {\r\n id?: number;\r\n fontType: FontType;\r\n fontName: string;\r\n }\r\n /** @internal */\r\n export interface BisCodeSpecIndexProps {\r\n id?: number;\r\n name: string;\r\n props: string;\r\n }\r\n\r\n /** Exception class thrown by `CodeService` methods. */\r\n export class Error extends BentleyError {\r\n /** A string that indicates the type of problem that caused the exception. */\r\n public readonly errorId: ErrorId;\r\n /** For [[CodeService.reserveCodes]] and [[CodeService.updateCodes]], a list of the problem details. */\r\n public readonly problems?: ReserveProblem[] | UpdateProblem[];\r\n\r\n /** @internal */\r\n constructor(errorId: ErrorId, errNum: number, message: string, problems?: ReserveProblem[] | UpdateProblem[]) {\r\n super(errNum, message);\r\n this.errorId = errorId;\r\n this.problems = problems;\r\n }\r\n }\r\n\r\n /** Identifiers for exceptions thrown by `CodeService` methods.\r\n * @see [[CodeService.Error.errorId]]\r\n */\r\n export type ErrorId =\r\n \"BadIndexProps\" |\r\n \"CorruptIModel\" |\r\n \"CorruptIndex\" |\r\n \"DuplicateValue\" |\r\n \"GuidIsInUse\" |\r\n \"GuidMismatch\" |\r\n \"IllegalValue\" |\r\n \"InconsistentIModels\" |\r\n \"IndexReadonly\" |\r\n \"InvalidCodeScope\" |\r\n \"InvalidGuid\" |\r\n \"InvalidSequence\" |\r\n \"MissingCode\" |\r\n \"MissingGuid\" |\r\n \"MissingInput\" |\r\n \"MissingSpec\" |\r\n \"NoCodeIndex\" |\r\n \"SequenceFull\" |\r\n \"ReserveErrors\" |\r\n \"SequenceNotFound\" |\r\n \"SqlLogicError\" |\r\n \"UpdateErrors\" |\r\n \"ValueIsInUse\" |\r\n \"WrongVersion\";\r\n\r\n}\r\n"]}
@@ -93,7 +93,7 @@ class CodeSpecs {
93
93
  // internal code index via `internalCodes.reserveBisCodeSpecs` prior to calling this function.
94
94
  // This ensures that the Ids will be unique, and the property values consistent, even if more than one user
95
95
  // adds them without pushing their changes. The call to `verifyBisCodeSpec` will throw otherwise.
96
- internalCodes.verifyBisCodeSpec(spec);
96
+ internalCodes.reader.verifyBisCodeSpec(spec);
97
97
  }
98
98
  else {
99
99
  // If this iModel doesn't have an internal code index, we have no way of coordinating the Ids for CodeSpecs across multiple users.
@@ -1 +1 @@
1
- {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6F;AAC7F,oDAA8F;AAI9F;;GAEG;AACH,MAAa,SAAS;IAKpB,YAAY,MAAgB;QAFpB,qBAAgB,GAAe,EAAE,CAAC;QAGxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE;YAC1B,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SAC/E;IACH,CAAC;IAEO,UAAU,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,SAAS,CAAC,SAAS,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;YACrG,IAAI,CAAC,UAAU,CAAC,CAAC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CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/G,CAAC,CAAC,CAAC;IACL,CAAC;;AAvKc,mBAAS,GAAG,cAAc,AAAjB,CAAkB;AAD/B,8BAAS","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 Codes\r\n */\r\n\r\nimport { BentleyError, DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { CodeScopeSpec, CodeSpec, CodeSpecProperties, IModelError } from \"@itwin/core-common\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { CodeService } from \"./CodeService\";\r\n\r\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\r\n * @public\r\n */\r\nexport class CodeSpecs {\r\n private static tableName = \"bis_CodeSpec\";\r\n private _imodel: IModelDb;\r\n private _loadedCodeSpecs: CodeSpec[] = [];\r\n\r\n constructor(imodel: IModelDb) {\r\n this._imodel = imodel;\r\n if (imodel.isBriefcaseDb()) {\r\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\r\n }\r\n }\r\n\r\n private findByName(name: string): Id64String | undefined {\r\n return this._imodel.withSqliteStatement(`SELECT Id FROM ${CodeSpecs.tableName} WHERE Name=?`, (stmt) => {\r\n stmt.bindString(1, name);\r\n return stmt.nextRow() ? stmt.getValueId(0) : undefined;\r\n });\r\n }\r\n\r\n /** Look up the Id of the CodeSpec with the specified name. */\r\n public queryId(name: string): Id64String {\r\n const id = this.findByName(name);\r\n if (!id)\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\r\n return id;\r\n }\r\n\r\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\r\n * @param codeSpecId The Id of the CodeSpec to load\r\n * @returns The CodeSpec with the specified Id\r\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\r\n */\r\n public getById(codeSpecId: Id64String): CodeSpec {\r\n // good chance it is already loaded - check there before running a query\r\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\r\n if (found !== undefined)\r\n return found;\r\n\r\n // must load this codespec\r\n const loadedCodeSpec = this.load(codeSpecId);\r\n this._loadedCodeSpecs.push(loadedCodeSpec);\r\n return loadedCodeSpec;\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\r\n public hasId(codeSpecId: Id64String): boolean {\r\n try {\r\n return undefined !== this.getById(codeSpecId);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\r\n * @param name The name of the CodeSpec to load\r\n * @returns The CodeSpec with the specified name\r\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\r\n */\r\n public getByName(name: string): CodeSpec {\r\n // good chance it is already loaded - check there before running a query\r\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\r\n if (found !== undefined)\r\n return found;\r\n const codeSpecId = this.queryId(name);\r\n if (codeSpecId === undefined)\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\r\n return this.getById(codeSpecId);\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\r\n public hasName(name: string): boolean {\r\n try {\r\n return undefined !== this.getByName(name);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n private insertCodeSpec(specName: string, properties: CodeSpecProperties): Id64String {\r\n const iModel = this._imodel;\r\n const spec: CodeService.BisCodeSpecIndexProps = { name: specName.trim(), props: JSON.stringify(properties) };\r\n if (this.findByName(spec.name))\r\n throw new IModelError(IModelStatus.DuplicateName, \"CodeSpec already exists\");\r\n\r\n const internalCodes = iModel.codeService?.internalCodes;\r\n if (internalCodes) {\r\n // Since there is no lock on the codespec table, to add a codespec to an iModel it must first be reserved in the\r\n // internal code index via `internalCodes.reserveBisCodeSpecs` prior to calling this function.\r\n // This ensures that the Ids will be unique, and the property values consistent, even if more than one user\r\n // adds them without pushing their changes. The call to `verifyBisCodeSpec` will throw otherwise.\r\n internalCodes.verifyBisCodeSpec(spec);\r\n } else {\r\n // If this iModel doesn't have an internal code index, we have no way of coordinating the Ids for CodeSpecs across multiple users.\r\n // Just look in this briefcase to find the currently highest used Id and hope for the best.\r\n spec.id = iModel.withSqliteStatement(`SELECT MAX(Id) FROM ${CodeSpecs.tableName}`, (stmt) => stmt.nextRow() ? stmt.getValueInteger(0) + 1 : 1);\r\n }\r\n\r\n const id = spec.id!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n iModel.withSqliteStatement(`INSERT INTO ${CodeSpecs.tableName}(Id,Name,JsonProperties) VALUES(?,?,?)`, (stmt) => {\r\n stmt.bindInteger(1, id);\r\n stmt.bindString(2, spec.name);\r\n stmt.bindString(3, spec.props);\r\n const rc = stmt.step();\r\n if (rc !== DbResult.BE_SQLITE_DONE)\r\n throw new BentleyError(rc, \"Error inserting codeSpec\");\r\n });\r\n\r\n return Id64.fromLocalAndBriefcaseIds(id, 0);\r\n }\r\n\r\n /** Add a new CodeSpec to the iModel.\r\n * @param codeSpec The CodeSpec to insert\r\n * @returns The Id of the persistent CodeSpec.\r\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(codeSpec: CodeSpec): Id64String;\r\n\r\n /** Add a new CodeSpec to the IModelDb.\r\n * @param name The name for the new CodeSpec.\r\n * @param properties The properties or the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.\r\n * @returns The Id of the persistent CodeSpec.\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\r\n public insert(codeSpecOrName: CodeSpec | string, props?: CodeSpecProperties | CodeScopeSpec.Type): Id64String {\r\n if (codeSpecOrName instanceof CodeSpec) {\r\n const id = this.insertCodeSpec(codeSpecOrName.name, codeSpecOrName.properties);\r\n codeSpecOrName.id = id;\r\n return id;\r\n }\r\n if (props === undefined)\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\r\n\r\n if (typeof props === \"object\")\r\n return this.insertCodeSpec(codeSpecOrName, props);\r\n\r\n const spec = CodeSpec.create(this._imodel, codeSpecOrName, props);\r\n return this.insertCodeSpec(spec.name, spec.properties);\r\n }\r\n\r\n /** Update the Json properties of an existing CodeSpec.\r\n * @param codeSpec The codeSpec holding Json properties values to update\r\n * @throws if unable to update the codeSpec.\r\n */\r\n public updateProperties(codeSpec: CodeSpec): void {\r\n this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {\r\n stmt.bindString(1, JSON.stringify(codeSpec.properties));\r\n stmt.bindId(2, codeSpec.id);\r\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\r\n throw new IModelError(IModelStatus.BadArg, \"error updating CodeSpec properties\");\r\n });\r\n }\r\n\r\n /** Load a CodeSpec from the iModel\r\n * @param id The persistent Id of the CodeSpec to load\r\n */\r\n public load(id: Id64String): CodeSpec {\r\n if (Id64.isInvalid(id))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n return this._imodel.withSqliteStatement(`SELECT Name,JsonProperties FROM ${CodeSpecs.tableName} WHERE Id=?`, (stmt) => {\r\n stmt.bindId(1, id);\r\n if (!stmt.nextRow())\r\n throw new IModelError(IModelStatus.InvalidId, \"CodeSpec not found\");\r\n\r\n return CodeSpec.createFromJson(this._imodel, id, stmt.getValueString(0), JSON.parse(stmt.getValueString(1)));\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":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AAC;IAED;;OAEG;IACI,IAAI,CAAC,EAAc;QACxB,IAAI,mBAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAEtE,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,mCAAmC,SAAS,CAAC,SAAS,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE;YACpH,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/G,CAAC,CAAC,CAAC;IACL,CAAC;;AAvKc,mBAAS,GAAG,cAAc,AAAjB,CAAkB;AAD/B,8BAAS","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 Codes\r\n */\r\n\r\nimport { BentleyError, DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { CodeScopeSpec, CodeSpec, CodeSpecProperties, IModelError } from \"@itwin/core-common\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { CodeService } from \"./CodeService\";\r\n\r\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\r\n * @public\r\n */\r\nexport class CodeSpecs {\r\n private static tableName = \"bis_CodeSpec\";\r\n private _imodel: IModelDb;\r\n private _loadedCodeSpecs: CodeSpec[] = [];\r\n\r\n constructor(imodel: IModelDb) {\r\n this._imodel = imodel;\r\n if (imodel.isBriefcaseDb()) {\r\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\r\n }\r\n }\r\n\r\n private findByName(name: string): Id64String | undefined {\r\n return this._imodel.withSqliteStatement(`SELECT Id FROM ${CodeSpecs.tableName} WHERE Name=?`, (stmt) => {\r\n stmt.bindString(1, name);\r\n return stmt.nextRow() ? stmt.getValueId(0) : undefined;\r\n });\r\n }\r\n\r\n /** Look up the Id of the CodeSpec with the specified name. */\r\n public queryId(name: string): Id64String {\r\n const id = this.findByName(name);\r\n if (!id)\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\r\n return id;\r\n }\r\n\r\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\r\n * @param codeSpecId The Id of the CodeSpec to load\r\n * @returns The CodeSpec with the specified Id\r\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\r\n */\r\n public getById(codeSpecId: Id64String): CodeSpec {\r\n // good chance it is already loaded - check there before running a query\r\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\r\n if (found !== undefined)\r\n return found;\r\n\r\n // must load this codespec\r\n const loadedCodeSpec = this.load(codeSpecId);\r\n this._loadedCodeSpecs.push(loadedCodeSpec);\r\n return loadedCodeSpec;\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\r\n public hasId(codeSpecId: Id64String): boolean {\r\n try {\r\n return undefined !== this.getById(codeSpecId);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\r\n * @param name The name of the CodeSpec to load\r\n * @returns The CodeSpec with the specified name\r\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\r\n */\r\n public getByName(name: string): CodeSpec {\r\n // good chance it is already loaded - check there before running a query\r\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\r\n if (found !== undefined)\r\n return found;\r\n const codeSpecId = this.queryId(name);\r\n if (codeSpecId === undefined)\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\r\n return this.getById(codeSpecId);\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\r\n public hasName(name: string): boolean {\r\n try {\r\n return undefined !== this.getByName(name);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n private insertCodeSpec(specName: string, properties: CodeSpecProperties): Id64String {\r\n const iModel = this._imodel;\r\n const spec: CodeService.BisCodeSpecIndexProps = { name: specName.trim(), props: JSON.stringify(properties) };\r\n if (this.findByName(spec.name))\r\n throw new IModelError(IModelStatus.DuplicateName, \"CodeSpec already exists\");\r\n\r\n const internalCodes = iModel.codeService?.internalCodes;\r\n if (internalCodes) {\r\n // Since there is no lock on the codespec table, to add a codespec to an iModel it must first be reserved in the\r\n // internal code index via `internalCodes.reserveBisCodeSpecs` prior to calling this function.\r\n // This ensures that the Ids will be unique, and the property values consistent, even if more than one user\r\n // adds them without pushing their changes. The call to `verifyBisCodeSpec` will throw otherwise.\r\n internalCodes.reader.verifyBisCodeSpec(spec);\r\n } else {\r\n // If this iModel doesn't have an internal code index, we have no way of coordinating the Ids for CodeSpecs across multiple users.\r\n // Just look in this briefcase to find the currently highest used Id and hope for the best.\r\n spec.id = iModel.withSqliteStatement(`SELECT MAX(Id) FROM ${CodeSpecs.tableName}`, (stmt) => stmt.nextRow() ? stmt.getValueInteger(0) + 1 : 1);\r\n }\r\n\r\n const id = spec.id!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n iModel.withSqliteStatement(`INSERT INTO ${CodeSpecs.tableName}(Id,Name,JsonProperties) VALUES(?,?,?)`, (stmt) => {\r\n stmt.bindInteger(1, id);\r\n stmt.bindString(2, spec.name);\r\n stmt.bindString(3, spec.props);\r\n const rc = stmt.step();\r\n if (rc !== DbResult.BE_SQLITE_DONE)\r\n throw new BentleyError(rc, \"Error inserting codeSpec\");\r\n });\r\n\r\n return Id64.fromLocalAndBriefcaseIds(id, 0);\r\n }\r\n\r\n /** Add a new CodeSpec to the iModel.\r\n * @param codeSpec The CodeSpec to insert\r\n * @returns The Id of the persistent CodeSpec.\r\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(codeSpec: CodeSpec): Id64String;\r\n\r\n /** Add a new CodeSpec to the IModelDb.\r\n * @param name The name for the new CodeSpec.\r\n * @param properties The properties or the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.\r\n * @returns The Id of the persistent CodeSpec.\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\r\n public insert(codeSpecOrName: CodeSpec | string, props?: CodeSpecProperties | CodeScopeSpec.Type): Id64String {\r\n if (codeSpecOrName instanceof CodeSpec) {\r\n const id = this.insertCodeSpec(codeSpecOrName.name, codeSpecOrName.properties);\r\n codeSpecOrName.id = id;\r\n return id;\r\n }\r\n if (props === undefined)\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\r\n\r\n if (typeof props === \"object\")\r\n return this.insertCodeSpec(codeSpecOrName, props);\r\n\r\n const spec = CodeSpec.create(this._imodel, codeSpecOrName, props);\r\n return this.insertCodeSpec(spec.name, spec.properties);\r\n }\r\n\r\n /** Update the Json properties of an existing CodeSpec.\r\n * @param codeSpec The codeSpec holding Json properties values to update\r\n * @throws if unable to update the codeSpec.\r\n */\r\n public updateProperties(codeSpec: CodeSpec): void {\r\n this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {\r\n stmt.bindString(1, JSON.stringify(codeSpec.properties));\r\n stmt.bindId(2, codeSpec.id);\r\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\r\n throw new IModelError(IModelStatus.BadArg, \"error updating CodeSpec properties\");\r\n });\r\n }\r\n\r\n /** Load a CodeSpec from the iModel\r\n * @param id The persistent Id of the CodeSpec to load\r\n */\r\n public load(id: Id64String): CodeSpec {\r\n if (Id64.isInvalid(id))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n return this._imodel.withSqliteStatement(`SELECT Name,JsonProperties FROM ${CodeSpecs.tableName} WHERE Id=?`, (stmt) => {\r\n stmt.bindId(1, id);\r\n if (!stmt.nextRow())\r\n throw new IModelError(IModelStatus.InvalidId, \"CodeSpec not found\");\r\n\r\n return CodeSpec.createFromJson(this._imodel, id, stmt.getValueString(0), JSON.parse(stmt.getValueString(1)));\r\n });\r\n }\r\n}\r\n"]}
@@ -23,8 +23,7 @@ export declare abstract class DisplayStyle extends DefinitionElement {
23
23
  * @param codeValue The DisplayStyle name
24
24
  */
25
25
  static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code;
26
- /** @internal */
27
- protected collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void;
26
+ protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
28
27
  /** @alpha */
29
28
  protected static onCloned(context: IModelElementCloneContext, sourceElementProps: DisplayStyleProps, targetElementProps: DisplayStyleProps): void;
30
29
  loadScheduleScript(): RenderSchedule.ScriptReference | undefined;
@@ -82,8 +81,7 @@ export declare class DisplayStyle3d extends DisplayStyle {
82
81
  get settings(): DisplayStyle3dSettings;
83
82
  /** @internal */
84
83
  constructor(props: DisplayStyle3dProps, iModel: IModelDb);
85
- /** @internal */
86
- protected collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void;
84
+ protected collectReferenceIds(referenceIds: EntityReferenceSet): void;
87
85
  /** @alpha */
88
86
  protected static onCloned(context: IModelElementCloneContext, sourceElementProps: DisplayStyle3dProps, targetElementProps: DisplayStyle3dProps): void;
89
87
  /** Create a DisplayStyle3d for use by a ViewDefinition.
@@ -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AyB5I;;;;;;;OAOG;WACW,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,2BAA2B,GAAG,UAAU;CAIzI"}
@@ -32,9 +32,8 @@ class DisplayStyle extends Element_1.DefinitionElement {
32
32
  const codeSpec = iModel.codeSpecs.getByName(core_common_1.BisCodeSpec.displayStyle);
33
33
  return new core_common_1.Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
34
34
  }
35
- /** @internal */
36
- collectReferenceConcreteIds(referenceIds) {
37
- super.collectReferenceConcreteIds(referenceIds);
35
+ collectReferenceIds(referenceIds) {
36
+ super.collectReferenceIds(referenceIds);
38
37
  for (const [id] of this.settings.subCategoryOverrides) {
39
38
  referenceIds.addElement(id);
40
39
  }
@@ -173,9 +172,8 @@ class DisplayStyle3d extends DisplayStyle {
173
172
  super(props, iModel);
174
173
  this._settings = new core_common_1.DisplayStyle3dSettings(this.jsonProperties);
175
174
  }
176
- /** @internal */
177
- collectReferenceConcreteIds(referenceIds) {
178
- super.collectReferenceConcreteIds(referenceIds);
175
+ collectReferenceIds(referenceIds) {
176
+ super.collectReferenceIds(referenceIds);
179
177
  for (const textureId of this.settings.environment.sky.textureIds)
180
178
  referenceIds.addElement(textureId);
181
179
  if (this.settings.planProjectionSettings)