@itwin/core-backend 3.4.0-dev.20 → 3.4.0-dev.21

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.
@@ -1,7 +1,7 @@
1
- import { CloudSqlite } from "@bentley/imodeljs-native";
2
1
  import { AccessToken, BentleyError, GuidString, MarkRequired, Mutable } from "@itwin/core-bentley";
3
2
  import { CodeProps } from "@itwin/core-common";
4
- import { BriefcaseDb } from "./IModelDb";
3
+ import { IModelDb } from "./IModelDb";
4
+ import { SQLiteDb } from "./SQLiteDb";
5
5
  import { SettingObject } from "./workspace/Settings";
6
6
  /**
7
7
  * A readonly index of all known Codes for an iTwin. The CodeIndex may be slightly out-of-date
@@ -16,31 +16,31 @@ export interface CodeIndex {
16
16
  * @param from the sequence and scope to search
17
17
  * @returns the next available CodeValue in the sequence.
18
18
  */
19
- findNextAvailable: (from: CodeService.SequenceScope) => CodeService.CodeValue;
19
+ findNextAvailable(from: CodeService.SequenceScope): CodeService.CodeValue;
20
20
  /**
21
21
  * Find the highest currently used value for the supplied `SequenceScope`
22
22
  * @param from the sequence and scope to search
23
23
  * @returns the highest used value, or undefined if no values have been used.
24
24
  */
25
- findHighestUsed: (from: CodeService.SequenceScope) => CodeService.CodeValue | undefined;
25
+ findHighestUsed(from: CodeService.SequenceScope): CodeService.CodeValue | undefined;
26
26
  /** Determine whether a code is present in this CodeIndex by its Guid. */
27
- isCodePresent: (guid: CodeService.CodeGuid) => boolean;
27
+ isCodePresent(guid: CodeService.CodeGuid): boolean;
28
28
  /** Get the data for a code in this CodeIndex by its Guid.
29
29
  * @returns the data for the code or undefined if no code is present for the supplied Guid.
30
30
  */
31
- getCode: (guid: CodeService.CodeGuid) => CodeService.CodeEntry | undefined;
31
+ getCode(guid: CodeService.CodeGuid): CodeService.CodeEntry | undefined;
32
32
  /** Look up a code by its Scope, Spec, and Value.
33
33
  * @returns the Guid of the code, or undefined if not present.
34
34
  */
35
- findCode: (code: CodeService.ScopeSpecAndValue) => CodeService.CodeGuid | undefined;
35
+ findCode(code: CodeService.ScopeSpecAndValue): CodeService.CodeGuid | undefined;
36
36
  /** Look up a code spec by its name
37
37
  * @throws if the spec is not present.
38
38
  */
39
- getCodeSpec: (props: CodeService.CodeSpecName) => CodeService.NameAndJson;
39
+ getCodeSpec(props: CodeService.CodeSpecName): CodeService.NameAndJson;
40
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;
41
+ forAllCodes(iter: CodeService.CodeIteration, filter?: CodeService.CodeFilter): void;
42
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;
43
+ forAllCodeSpecs(iter: CodeService.NameAndJsonIteration, filter?: CodeService.ValueFilter): void;
44
44
  }
45
45
  /**
46
46
  * The services for querying, reserving, updating, and deleting codes for a BriefcaseDb (available via `BriefcaseDb.codeService`) whenever it is opened for write access.
@@ -50,9 +50,7 @@ export interface CodeService {
50
50
  /** @internal */
51
51
  close: () => void;
52
52
  /** @internal */
53
- addAllCodeSpecs: () => Promise<void>;
54
- /** the BriefcaseDb of this CodeService */
55
- readonly briefcase: BriefcaseDb;
53
+ addAllCodeSpecs(iModel: IModelDb): Promise<void>;
56
54
  /** the code index for this CodeService */
57
55
  readonly codeIndex: CodeIndex;
58
56
  /**
@@ -60,7 +58,7 @@ export interface CodeService {
60
58
  * Applications should set these parameters by adding a listener for `BriefcaseDb.onCodeServiceCreated`
61
59
  * that is called every time a BriefcaseDb that uses code services is opened for write access.
62
60
  */
63
- readonly appParams: CodeService.ObtainLockParams & CodeService.AuthorAndOrigin;
61
+ readonly appParams: SQLiteDb.ObtainLockParams & CodeService.AuthorAndOrigin;
64
62
  /**
65
63
  * The token that grants access to the cloud container for this CodeService.
66
64
  * It should be established in a listener for `BriefcaseDb.onCodeServiceCreated`, and should be refreshed (via a
@@ -75,7 +73,7 @@ export interface CodeService {
75
73
  * @note There is no guarantee that a readonly index is up-to-date even immediately after calling this method, since others
76
74
  * may be modifying it at any time.
77
75
  */
78
- synchronizeWithCloud: () => void;
76
+ synchronizeWithCloud(): void;
79
77
  /**
80
78
  * Verify that the Code of a to-be-inserted or to-be-updated Element:
81
79
  * 1. has already been reserved,
@@ -85,11 +83,11 @@ export interface CodeService {
85
83
  * If not, throw an exception. Elements with no CodeValue are ignored.
86
84
  * @note this method is automatically called whenever elements are added or updated by a BriefcaseDb with a CodeService.
87
85
  */
88
- verifyCode: (props: CodeService.ElementCodeProps) => void;
86
+ verifyCode(props: CodeService.ElementCodeProps): void;
89
87
  /** Add a new code spec to this code service.
90
88
  * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
91
89
  */
92
- addCodeSpec: (val: CodeService.NameAndJson) => Promise<void>;
90
+ addCodeSpec(val: CodeService.NameAndJson): Promise<void>;
93
91
  /**
94
92
  * Add all of the codes and code specs from this CodeService's BriefcaseDb into the code index.
95
93
  * @returns the number of codes actually added.
@@ -98,13 +96,13 @@ export interface CodeService {
98
96
  * any codes or code specs that are already in the index are ignored.
99
97
  * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
100
98
  */
101
- addAllCodes: () => Promise<number>;
99
+ addAllCodes(iModel: IModelDb): Promise<number>;
102
100
  /**
103
101
  * Attempt to reserve a single proposed code.
104
102
  * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
105
103
  * @throws `CodeService.Error` if the proposed code cannot be reserved.
106
104
  */
107
- reserveCode: (code: CodeService.ProposedCode) => Promise<void>;
105
+ reserveCode(code: CodeService.ProposedCode): Promise<void>;
108
106
  /**
109
107
  * Attempt to reserve an array of proposed codes.
110
108
  * @returns number of codes actually reserved.
@@ -113,12 +111,12 @@ export interface CodeService {
113
111
  * @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.
114
112
  * @throws `CodeService.Error` if any of the proposed code cannot be reserved. The details for each failed code are in the `problems` member.
115
113
  */
116
- reserveCodes: (arg: CodeService.ReserveCodesArgs) => Promise<number>;
114
+ reserveCodes(arg: CodeService.ReserveCodesArgs): Promise<number>;
117
115
  /**
118
116
  * Attempt to reserve the next available code for a code sequence and scope.
119
117
  * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
120
118
  */
121
- reserveNextAvailableCode: (arg: CodeService.ReserveNextArgs) => Promise<void>;
119
+ reserveNextAvailableCode(arg: CodeService.ReserveNextArgs): Promise<void>;
122
120
  /**
123
121
  * Attempt to reserve an array of the next available codes for a code sequence and scope.
124
122
  * The length of the array determines the number of codes requested. The values for the new codes are returned
@@ -126,28 +124,28 @@ export interface CodeService {
126
124
  * @returns number of codes actually reserved.
127
125
  * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
128
126
  */
129
- reserveNextAvailableCodes: (arg: CodeService.ReserveNextArrayArgs) => Promise<number>;
127
+ reserveNextAvailableCodes(arg: CodeService.ReserveNextArrayArgs): Promise<number>;
130
128
  /**
131
129
  * Update the properties of a single code.
132
130
  * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
133
131
  */
134
- updateCode: (props: CodeService.UpdatedCode) => Promise<void>;
132
+ updateCode(props: CodeService.UpdatedCode): Promise<void>;
135
133
  /**
136
134
  * Update the properties of an array codes.
137
135
  * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
138
136
  * @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.
139
137
  * @returns number of codes actually updated.
140
138
  */
141
- updateCodes: (arg: CodeService.UpdateCodesArgs) => Promise<number>;
139
+ updateCodes(arg: CodeService.UpdateCodesArgs): Promise<number>;
142
140
  /** Delete an array of codes by their guids.
143
141
  * @note This will automatically attempt to obtain, perform the operation, and then release the write lock.
144
142
  */
145
- deleteCodes: (guid: CodeService.CodeGuid[]) => Promise<void>;
143
+ deleteCodes(guid: CodeService.CodeGuid[]): Promise<void>;
146
144
  }
147
145
  /** @alpha */
148
146
  export declare namespace CodeService {
149
147
  /** @internal */
150
- let createForBriefcase: undefined | ((db: BriefcaseDb) => CodeService);
148
+ let createForIModel: ((db: IModelDb) => CodeService) | undefined;
151
149
  /** Register an instance of a`CodeSequence` so it can be looked up by name. */
152
150
  function registerSequence(seq: CodeSequence): void;
153
151
  /** Get a previously registered `CodeSequence` by its name.
@@ -160,7 +158,7 @@ export declare namespace CodeService {
160
158
  * the `scope` member refers to the element Id of the scope element in the iModel. This helper function
161
159
  * converts the spec Id to the spec name and looks up the `FederationGuid` of the scope element.
162
160
  */
163
- function makeScopeAndSpec(briefcase: BriefcaseDb, code: CodeProps): CodeService.ScopeAndSpec;
161
+ function makeScopeAndSpec(iModel: IModelDb, code: CodeProps): CodeService.ScopeAndSpec;
164
162
  /** Turn a `CodeProps` and `ProposedCodeProps` into a `ProposedCode` for use with a CodeService.
165
163
  * @see [[makeScopeAndSpec]] for explanation of why this is necessary.
166
164
  */
@@ -186,21 +184,6 @@ export declare namespace CodeService {
186
184
  type CodeIteration = (guid: GuidString) => IterationReturn;
187
185
  /** An iteration function over code specs in a code index. It is called with the name and json of a each code spec. */
188
186
  type NameAndJsonIteration = (nameAndJson: NameAndJson) => IterationReturn;
189
- /** Parameters used to obtain the write lock on a cloud container */
190
- interface ObtainLockParams {
191
- /** The name of the user attempting to acquire the write lock. This name will be shown to other users while the lock is held. */
192
- user?: string;
193
- /** number of times to retry in the event the lock currently held by someone else.
194
- * After this number of attempts, `onFailure` is called. Default is 20.
195
- */
196
- nRetries: number;
197
- /** Delay between retries, in milliseconds. Default is 100. */
198
- retryDelayMs: number;
199
- /** function called if lock cannot be obtained after all retries. It is called with the name of the user currently holding the lock and
200
- * generally is expected that the user will be consulted whether to wait further.
201
- * If this function returns "stop", an exception will be thrown. Otherwise the retry cycle is restarted. */
202
- onFailure?: CloudSqlite.WriteLockBusyHandler;
203
- }
204
187
  /** Argument for reserving an array of new codes. */
205
188
  interface ReserveCodesArgs {
206
189
  /** an array of proposed codes to reserve.
@@ -239,7 +222,7 @@ export declare namespace CodeService {
239
222
  }
240
223
  /** Arguments for CodeService.makeProposedCode */
241
224
  interface MakeProposedCodeArgs {
242
- readonly briefcase: BriefcaseDb;
225
+ readonly iModel: IModelDb;
243
226
  readonly code: Required<CodeProps>;
244
227
  readonly props: CodeService.CodeGuidStateJson;
245
228
  }
@@ -247,14 +230,19 @@ export declare namespace CodeService {
247
230
  * @see CodeService.verifyCode
248
231
  */
249
232
  interface ElementCodeProps {
250
- /** The imodel-specific code properties. */
251
- readonly code: CodeProps;
252
- /**
253
- * The federationGuid of the element being inserted or updated.
254
- * If federationGuid is defined, it is must match the value in the code index or an error is thrown.
255
- * If it is undefined, the value from the code index is returned here.
256
- */
257
- federationGuid?: GuidString;
233
+ /** iModel from which the code is being inserted/updated. */
234
+ readonly iModel: IModelDb;
235
+ /** Properties of the code */
236
+ readonly props: {
237
+ /** The imodel-specific code properties. */
238
+ readonly code: CodeProps;
239
+ /**
240
+ * The federationGuid of the element being inserted or updated.
241
+ * If federationGuid is defined, it is must match the value in the code index or an error is thrown.
242
+ * If it is undefined, the value from the code index is returned here.
243
+ */
244
+ federationGuid?: GuidString;
245
+ };
258
246
  }
259
247
  /** a name and a json object. Used for code specs, authors and origins. */
260
248
  interface NameAndJson {
@@ -1 +1 @@
1
- {"version":3,"file":"CodeService.d.ts","sourceRoot":"","sources":["../../src/CodeService.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAgB,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB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KAK7G;IAED;;OAEG;IACH,KAAY,OAAO,GACjB,eAAe,GACf,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,cAAc,GACd,eAAe,GACf,kBAAkB,GAClB,aAAa,GACb,iBAAiB,GACjB,aAAa,GACb,aAAa,GACb,cAAc,GACd,aAAa,GACb,aAAa,GACb,cAAc,GACd,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,cAAc,GACd,cAAc,GACd,cAAc,CAAC;CAElB"}
@@ -30,11 +30,11 @@ var CodeService;
30
30
  * the `scope` member refers to the element Id of the scope element in the iModel. This helper function
31
31
  * converts the spec Id to the spec name and looks up the `FederationGuid` of the scope element.
32
32
  */
33
- function makeScopeAndSpec(briefcase, code) {
34
- const scope = briefcase.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;
33
+ function makeScopeAndSpec(iModel, code) {
34
+ const scope = iModel.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;
35
35
  if (undefined === scope)
36
36
  throw new CodeService.Error("MissingGuid", core_bentley_1.IModelStatus.InvalidCode, "code scope element has no federationGuid");
37
- return { scope, spec: briefcase.codeSpecs.getById(code.spec).name };
37
+ return { scope, spec: iModel.codeSpecs.getById(code.spec).name };
38
38
  }
39
39
  CodeService.makeScopeAndSpec = makeScopeAndSpec;
40
40
  /** Turn a `CodeProps` and `ProposedCodeProps` into a `ProposedCode` for use with a CodeService.
@@ -44,7 +44,7 @@ var CodeService;
44
44
  return {
45
45
  ...arg.props,
46
46
  value: arg.code.value,
47
- ...makeScopeAndSpec(arg.briefcase, arg.code),
47
+ ...makeScopeAndSpec(arg.iModel, arg.code),
48
48
  };
49
49
  }
50
50
  CodeService.makeProposedCode = makeProposedCode;
@@ -1 +1 @@
1
- {"version":3,"file":"CodeService.js","sourceRoot":"","sources":["../../src/CodeService.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAG/F,sDAAiH;AA2KjH,aAAa;AACb,IAAiB,W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AG,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC;SAC7C,CAAC;IACJ,CAAC;IANe,4BAAgB,mBAM/B,CAAA;IAgQD,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;AA8BH,CAAC,EAtVgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAsV3B","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 { CloudSqlite } from \"@bentley/imodeljs-native\";\r\nimport { AccessToken, BentleyError, GuidString, IModelStatus, MarkRequired, Mutable } from \"@itwin/core-bentley\";\r\nimport { CodeProps } from \"@itwin/core-common\";\r\nimport { BriefcaseDb } 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 * 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 /** @internal */\r\n addAllCodeSpecs: () => Promise<void>;\r\n\r\n /** the BriefcaseDb of this CodeService */\r\n readonly briefcase: BriefcaseDb;\r\n\r\n /** the code index for this CodeService */\r\n readonly codeIndex: CodeIndex;\r\n\r\n /**\r\n * Application-supplied parameters for obtaining the write lock on the container and for reserving new codes.\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 appParams: CodeService.ObtainLockParams & CodeService.AuthorAndOrigin;\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: (props: 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: () => 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/** @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 createForBriefcase: undefined | ((db: BriefcaseDb) => CodeService);\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) { codeSequences.set(seq.sequenceName, seq); }\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(briefcase: BriefcaseDb, code: CodeProps): CodeService.ScopeAndSpec {\r\n const scope = briefcase.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;\r\n if (undefined === scope)\r\n throw new CodeService.Error(\"MissingGuid\", IModelStatus.InvalidCode, \"code scope element has no federationGuid\");\r\n\r\n return { scope, spec: briefcase.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.briefcase, 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 /** 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 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 /** Parameters used to obtain the write lock on a cloud container */\r\n export interface ObtainLockParams {\r\n /** The name of the user attempting to acquire the write lock. This name will be shown to other users while the lock is held. */\r\n user?: string;\r\n /** number of times to retry in the event the lock currently held by someone else.\r\n * After this number of attempts, `onFailure` is called. Default is 20.\r\n */\r\n nRetries: number;\r\n /** Delay between retries, in milliseconds. Default is 100. */\r\n retryDelayMs: number;\r\n /** function called if lock cannot be obtained after all retries. It is called with the name of the user currently holding the lock and\r\n * generally is expected that the user will be consulted whether to wait further.\r\n * If this function returns \"stop\", an exception will be thrown. Otherwise the retry cycle is restarted. */\r\n onFailure?: CloudSqlite.WriteLockBusyHandler;\r\n }\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 briefcase: BriefcaseDb;\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 /** 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 /** 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 spec: CodeSpecName;\r\n readonly scope: 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 spec: CodeSpecName;\r\n /** The guid of the entity that provides the scope for this code. */\r\n readonly scope: 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 spec?: CodeSpecName;\r\n /** If supplied, limit results to only those with this scope Guid */\r\n readonly scope?: 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 /** 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 \"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,sDAAiH;AAyKjH,aAAa;AACb,IAAiB,WAAW,CA2U3B;AA3UD,WAAiB,WAAW;IAC1B,gBAAgB;IAChB,MAAM,aAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;IAKtD,8EAA8E;IAC9E,SAAgB,gBAAgB,CAAC,GAAiB,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAAjF,4BAAgB,mBAAiE,CAAA;IAEjG;;MAEE;IACF,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,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC,cAAc,CAAC;QAC3G,IAAI,SAAS,KAAK,KAAK;YACrB,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,aAAa,EAAE,2BAAY,CAAC,WAAW,EAAE,0CAA0C,CAAC,CAAC;QAEnH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IACnE,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;IAqPD,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;AA8BH,CAAC,EA3UgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA2U3B","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 } from \"@itwin/core-common\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { SQLiteDb } from \"./SQLiteDb\";\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 * 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 /** @internal */\r\n addAllCodeSpecs(iModel: IModelDb): Promise<void>;\r\n\r\n /** the code index for this CodeService */\r\n readonly codeIndex: CodeIndex;\r\n\r\n /**\r\n * Application-supplied parameters for obtaining the write lock on the container and for reserving new codes.\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 appParams: SQLiteDb.ObtainLockParams & CodeService.AuthorAndOrigin;\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(props: 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/** @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) => 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) { codeSequences.set(seq.sequenceName, seq); }\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 scope = iModel.elements.getElementProps({ id: code.scope, onlyBaseProperties: true }).federationGuid;\r\n if (undefined === scope)\r\n throw new CodeService.Error(\"MissingGuid\", IModelStatus.InvalidCode, \"code scope element has no federationGuid\");\r\n\r\n return { scope, spec: 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 /** 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 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 spec: CodeSpecName;\r\n readonly scope: 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 spec: CodeSpecName;\r\n /** The guid of the entity that provides the scope for this code. */\r\n readonly scope: 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 spec?: CodeSpecName;\r\n /** If supplied, limit results to only those with this scope Guid */\r\n readonly scope?: 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 /** 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 \"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"]}
@@ -62,7 +62,7 @@ class Element extends Entity_1.Entity {
62
62
  iModel.locks.checkSharedLock(props.model, "model", "insert"); // inserting requires shared lock on model
63
63
  if (props.parent) // inserting requires shared lock on parent, if present
64
64
  iModel.locks.checkSharedLock(props.parent.id, "parent", "insert");
65
- (_c = iModel.codeService) === null || _c === void 0 ? void 0 : _c.verifyCode(props);
65
+ (_c = iModel.codeService) === null || _c === void 0 ? void 0 : _c.verifyCode(arg);
66
66
  }
67
67
  /** Called after a new Element was inserted.
68
68
  * @note If you override this method, you must call super.
@@ -81,7 +81,7 @@ class Element extends Entity_1.Entity {
81
81
  static onUpdate(arg) {
82
82
  var _c;
83
83
  arg.iModel.locks.checkExclusiveLock(arg.props.id, "element", "update"); // eslint-disable-line @typescript-eslint/no-non-null-assertion
84
- (_c = arg.iModel.codeService) === null || _c === void 0 ? void 0 : _c.verifyCode(arg.props);
84
+ (_c = arg.iModel.codeService) === null || _c === void 0 ? void 0 : _c.verifyCode(arg);
85
85
  }
86
86
  /** Called after an Element was updated.
87
87
  * @note If you override this method, you must call super.