@decaf-ts/for-fabric 0.1.119 → 0.2.0

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 (145) hide show
  1. package/dist/for-fabric.cjs +1 -1
  2. package/dist/for-fabric.cjs.map +1 -1
  3. package/dist/for-fabric.js +1 -1
  4. package/dist/for-fabric.js.map +1 -1
  5. package/lib/client/FabricClientAdapter.cjs +4 -7
  6. package/lib/client/FabricClientAdapter.js.map +1 -1
  7. package/lib/client/services/FabricIdentityService.cjs +3 -2
  8. package/lib/client/services/FabricIdentityService.js.map +1 -1
  9. package/lib/contract/OtherMarketContract.cjs +30 -0
  10. package/lib/contract/OtherMarketContract.d.ts +5 -0
  11. package/lib/contract/OtherMarketContract.js.map +1 -0
  12. package/lib/contract/OtherProductStrengthContract.cjs +30 -0
  13. package/lib/contract/OtherProductStrengthContract.d.ts +5 -0
  14. package/lib/contract/OtherProductStrengthContract.js.map +1 -0
  15. package/lib/contract/index.cjs +4 -0
  16. package/lib/contract/index.js.map +1 -1
  17. package/lib/contract/models/Audit.js.map +1 -1
  18. package/lib/contract/models/OtherAudit.cjs +105 -0
  19. package/lib/contract/models/OtherAudit.d.ts +13 -0
  20. package/lib/contract/models/OtherAudit.js.map +1 -0
  21. package/lib/contract/models/OtherMarket.cjs +78 -0
  22. package/lib/contract/models/OtherMarket.d.ts +12 -0
  23. package/lib/contract/models/OtherMarket.js.map +1 -0
  24. package/lib/contract/models/OtherProductShared.cjs +15 -4
  25. package/lib/contract/models/OtherProductShared.d.ts +4 -0
  26. package/lib/contract/models/OtherProductShared.js.map +1 -1
  27. package/lib/contract/models/OtherProductStrength.cjs +81 -0
  28. package/lib/contract/models/OtherProductStrength.d.ts +11 -0
  29. package/lib/contract/models/OtherProductStrength.js.map +1 -0
  30. package/lib/contract/models/Product.cjs +1 -1
  31. package/lib/contract/models/Product.js.map +1 -1
  32. package/lib/contract/models/ProductStrength.js.map +1 -1
  33. package/lib/contract/models/decorators-private.cjs +88 -0
  34. package/lib/contract/models/decorators-private.d.ts +16 -0
  35. package/lib/contract/models/decorators-private.js.map +1 -0
  36. package/lib/contract/models/decorators.cjs +31 -2
  37. package/lib/contract/models/decorators.d.ts +6 -1
  38. package/lib/contract/models/decorators.js.map +1 -1
  39. package/lib/contracts/ContractAdapter.cjs +259 -409
  40. package/lib/contracts/ContractAdapter.d.ts +5 -29
  41. package/lib/contracts/ContractAdapter.js.map +1 -1
  42. package/lib/contracts/ContractContext.cjs +41 -13
  43. package/lib/contracts/ContractContext.d.ts +13 -8
  44. package/lib/contracts/ContractContext.js.map +1 -1
  45. package/lib/contracts/FabricContractRepository.cjs +70 -0
  46. package/lib/contracts/FabricContractRepository.d.ts +6 -0
  47. package/lib/contracts/FabricContractRepository.js.map +1 -1
  48. package/lib/contracts/FabricContractSequence.cjs +7 -23
  49. package/lib/contracts/FabricContractSequence.js.map +1 -1
  50. package/lib/contracts/FabricContractStatement.cjs +136 -1
  51. package/lib/contracts/FabricContractStatement.d.ts +5 -2
  52. package/lib/contracts/FabricContractStatement.js.map +1 -1
  53. package/lib/contracts/crud/crud-contract.cjs +42 -17
  54. package/lib/contracts/crud/crud-contract.d.ts +6 -5
  55. package/lib/contracts/crud/crud-contract.js.map +1 -1
  56. package/lib/contracts/types.d.ts +9 -2
  57. package/lib/esm/client/FabricClientAdapter.js +4 -7
  58. package/lib/esm/client/FabricClientAdapter.js.map +1 -1
  59. package/lib/esm/client/services/FabricIdentityService.js +3 -2
  60. package/lib/esm/client/services/FabricIdentityService.js.map +1 -1
  61. package/lib/esm/contract/OtherMarketContract.d.ts +5 -0
  62. package/lib/esm/contract/OtherMarketContract.js +27 -0
  63. package/lib/esm/contract/OtherMarketContract.js.map +1 -0
  64. package/lib/esm/contract/OtherProductStrengthContract.d.ts +5 -0
  65. package/lib/esm/contract/OtherProductStrengthContract.js +27 -0
  66. package/lib/esm/contract/OtherProductStrengthContract.js.map +1 -0
  67. package/lib/esm/contract/index.js +4 -0
  68. package/lib/esm/contract/index.js.map +1 -1
  69. package/lib/esm/contract/models/Audit.js +1 -1
  70. package/lib/esm/contract/models/Audit.js.map +1 -1
  71. package/lib/esm/contract/models/OtherAudit.d.ts +13 -0
  72. package/lib/esm/contract/models/OtherAudit.js +102 -0
  73. package/lib/esm/contract/models/OtherAudit.js.map +1 -0
  74. package/lib/esm/contract/models/OtherMarket.d.ts +12 -0
  75. package/lib/esm/contract/models/OtherMarket.js +75 -0
  76. package/lib/esm/contract/models/OtherMarket.js.map +1 -0
  77. package/lib/esm/contract/models/OtherProductShared.d.ts +4 -0
  78. package/lib/esm/contract/models/OtherProductShared.js +16 -5
  79. package/lib/esm/contract/models/OtherProductShared.js.map +1 -1
  80. package/lib/esm/contract/models/OtherProductStrength.d.ts +11 -0
  81. package/lib/esm/contract/models/OtherProductStrength.js +78 -0
  82. package/lib/esm/contract/models/OtherProductStrength.js.map +1 -0
  83. package/lib/esm/contract/models/Product.js +1 -1
  84. package/lib/esm/contract/models/Product.js.map +1 -1
  85. package/lib/esm/contract/models/ProductStrength.js +1 -1
  86. package/lib/esm/contract/models/ProductStrength.js.map +1 -1
  87. package/lib/esm/contract/models/decorators-private.d.ts +16 -0
  88. package/lib/esm/contract/models/decorators-private.js +81 -0
  89. package/lib/esm/contract/models/decorators-private.js.map +1 -0
  90. package/lib/esm/contract/models/decorators.d.ts +6 -1
  91. package/lib/esm/contract/models/decorators.js +30 -2
  92. package/lib/esm/contract/models/decorators.js.map +1 -1
  93. package/lib/esm/contracts/ContractAdapter.d.ts +5 -29
  94. package/lib/esm/contracts/ContractAdapter.js +262 -412
  95. package/lib/esm/contracts/ContractAdapter.js.map +1 -1
  96. package/lib/esm/contracts/ContractContext.d.ts +13 -8
  97. package/lib/esm/contracts/ContractContext.js +41 -13
  98. package/lib/esm/contracts/ContractContext.js.map +1 -1
  99. package/lib/esm/contracts/FabricContractRepository.d.ts +6 -0
  100. package/lib/esm/contracts/FabricContractRepository.js +70 -0
  101. package/lib/esm/contracts/FabricContractRepository.js.map +1 -1
  102. package/lib/esm/contracts/FabricContractSequence.js +9 -25
  103. package/lib/esm/contracts/FabricContractSequence.js.map +1 -1
  104. package/lib/esm/contracts/FabricContractStatement.d.ts +5 -2
  105. package/lib/esm/contracts/FabricContractStatement.js +135 -0
  106. package/lib/esm/contracts/FabricContractStatement.js.map +1 -1
  107. package/lib/esm/contracts/crud/crud-contract.d.ts +6 -5
  108. package/lib/esm/contracts/crud/crud-contract.js +42 -17
  109. package/lib/esm/contracts/crud/crud-contract.js.map +1 -1
  110. package/lib/esm/contracts/types.d.ts +9 -2
  111. package/lib/esm/shared/decorators.d.ts +8 -0
  112. package/lib/esm/shared/decorators.js +90 -83
  113. package/lib/esm/shared/decorators.js.map +1 -1
  114. package/lib/esm/shared/overrides/overrides.js +7 -6
  115. package/lib/esm/shared/overrides/overrides.js.map +1 -1
  116. package/lib/esm/shared/types.d.ts +3 -2
  117. package/lib/esm/version.d.ts +1 -1
  118. package/lib/esm/version.js +1 -1
  119. package/lib/shared/decorators.cjs +91 -82
  120. package/lib/shared/decorators.d.ts +8 -0
  121. package/lib/shared/decorators.js.map +1 -1
  122. package/lib/shared/overrides/overrides.cjs +7 -6
  123. package/lib/shared/overrides/overrides.js.map +1 -1
  124. package/lib/shared/types.d.ts +3 -2
  125. package/lib/version.cjs +1 -1
  126. package/lib/version.d.ts +1 -1
  127. package/package.json +3 -3
  128. package/lib/contracts/ContractPrivateDataAdapter.cjs +0 -426
  129. package/lib/contracts/ContractPrivateDataAdapter.d.ts +0 -0
  130. package/lib/contracts/ContractPrivateDataAdapter.js.map +0 -1
  131. package/lib/contracts/FabricConstruction.cjs +0 -441
  132. package/lib/contracts/FabricConstruction.d.ts +0 -305
  133. package/lib/contracts/FabricConstruction.js.map +0 -1
  134. package/lib/contracts/private-data.cjs +0 -204
  135. package/lib/contracts/private-data.d.ts +0 -0
  136. package/lib/contracts/private-data.js.map +0 -1
  137. package/lib/esm/contracts/ContractPrivateDataAdapter.d.ts +0 -0
  138. package/lib/esm/contracts/ContractPrivateDataAdapter.js +0 -426
  139. package/lib/esm/contracts/ContractPrivateDataAdapter.js.map +0 -1
  140. package/lib/esm/contracts/FabricConstruction.d.ts +0 -305
  141. package/lib/esm/contracts/FabricConstruction.js +0 -433
  142. package/lib/esm/contracts/FabricConstruction.js.map +0 -1
  143. package/lib/esm/contracts/private-data.d.ts +0 -0
  144. package/lib/esm/contracts/private-data.js +0 -204
  145. package/lib/esm/contracts/private-data.js.map +0 -1
@@ -1,305 +0,0 @@
1
- import { RelationsMetadata, Repo } from "@decaf-ts/core";
2
- import { Model } from "@decaf-ts/decorator-validation";
3
- import { ContextOfRepository } from "@decaf-ts/db-decorators";
4
- import { FabricContractRepository } from "./FabricContractRepository";
5
- import { FabricContractContext } from "./ContractContext";
6
- /**
7
- * @description Handles one-to-one relationship creation
8
- * @summary Processes a one-to-one relationship when creating a model, either by referencing an existing model or creating a new one
9
- * @template M - The model type extending Model
10
- * @template R - The repository type extending Repo<M, F, C>
11
- * @template V - The relations metadata type extending RelationsMetadata
12
- * @template F - The repository flags type
13
- * @template C - The context type extending Context<F>
14
- * @param {R} this - The repository instance
15
- * @param {Context<F>} context - The context for the operation
16
- * @param {V} data - The relations metadata
17
- * @param {string} key - The property key of the relationship
18
- * @param {M} model - The model instance
19
- * @return {Promise<void>} A promise that resolves when the operation is complete
20
- * @function oneToOneOnCreate
21
- * @memberOf module:core
22
- * @mermaid
23
- * sequenceDiagram
24
- * participant Caller
25
- * participant oneToOneOnCreate
26
- * participant repositoryFromTypeMetadata
27
- * participant Model
28
- * participant Repository
29
- * participant cacheModelForPopulate
30
- *
31
- * Caller->>oneToOneOnCreate: this, context, data, key, model
32
- * oneToOneOnCreate->>oneToOneOnCreate: check if propertyValue exists
33
- *
34
- * alt propertyValue is not an object
35
- * oneToOneOnCreate->>repositoryFromTypeMetadata: model, key
36
- * repositoryFromTypeMetadata-->>oneToOneOnCreate: innerRepo
37
- * oneToOneOnCreate->>innerRepo: read(propertyValue)
38
- * innerRepo-->>oneToOneOnCreate: read
39
- * oneToOneOnCreate->>cacheModelForPopulate: context, model, key, propertyValue, read
40
- * oneToOneOnCreate->>oneToOneOnCreate: set model[key] = propertyValue
41
- * else propertyValue is an object
42
- * oneToOneOnCreate->>Model: get(data.class)
43
- * Model-->>oneToOneOnCreate: constructor
44
- * oneToOneOnCreate->>Repository: forModel(constructor)
45
- * Repository-->>oneToOneOnCreate: repo
46
- * oneToOneOnCreate->>repo: create(propertyValue)
47
- * repo-->>oneToOneOnCreate: created
48
- * oneToOneOnCreate->>findPrimaryKey: created
49
- * findPrimaryKey-->>oneToOneOnCreate: pk
50
- * oneToOneOnCreate->>cacheModelForPopulate: context, model, key, created[pk], created
51
- * oneToOneOnCreate->>oneToOneOnCreate: set model[key] = created[pk]
52
- * end
53
- *
54
- * oneToOneOnCreate-->>Caller: void
55
- */
56
- export declare function oneToOneOnCreate<M extends Model, R extends FabricContractRepository<M>, V extends RelationsMetadata>(this: R, context: FabricContractContext, data: V, key: keyof M, model: M): Promise<void>;
57
- /**
58
- * @description Handles one-to-one relationship updates
59
- * @summary Processes a one-to-one relationship when updating a model, either by referencing an existing model or updating the related model
60
- * @template M - The model type extending Model
61
- * @template R - The repository type extending Repo<M, F, C>
62
- * @template V - The relations metadata type extending RelationsMetadata
63
- * @template F - The repository flags type
64
- * @template C - The context type extending Context<F>
65
- * @param {R} this - The repository instance
66
- * @param {Context<F>} context - The context for the operation
67
- * @param {V} data - The relations metadata
68
- * @param key - The property key of the relationship
69
- * @param {M} model - The model instance
70
- * @return {Promise<void>} A promise that resolves when the operation is complete
71
- * @function oneToOneOnUpdate
72
- * @memberOf module:core
73
- * @mermaid
74
- * sequenceDiagram
75
- * participant Caller
76
- * participant oneToOneOnUpdate
77
- * participant repositoryFromTypeMetadata
78
- * participant createOrUpdate
79
- * participant findPrimaryKey
80
- * participant cacheModelForPopulate
81
- *
82
- * Caller->>oneToOneOnUpdate: this, context, data, key, model
83
- * oneToOneOnUpdate->>oneToOneOnUpdate: check if propertyValue exists
84
- * oneToOneOnUpdate->>oneToOneOnUpdate: check if cascade.update is CASCADE
85
- *
86
- * alt propertyValue is not an object
87
- * oneToOneOnUpdate->>repositoryFromTypeMetadata: model, key
88
- * repositoryFromTypeMetadata-->>oneToOneOnUpdate: innerRepo
89
- * oneToOneOnUpdate->>innerRepo: read(propertyValue)
90
- * innerRepo-->>oneToOneOnUpdate: read
91
- * oneToOneOnUpdate->>cacheModelForPopulate: context, model, key, propertyValue, read
92
- * oneToOneOnUpdate->>oneToOneOnUpdate: set model[key] = propertyValue
93
- * else propertyValue is an object
94
- * oneToOneOnUpdate->>createOrUpdate: model[key], context
95
- * createOrUpdate-->>oneToOneOnUpdate: updated
96
- * oneToOneOnUpdate->>findPrimaryKey: updated
97
- * findPrimaryKey-->>oneToOneOnUpdate: pk
98
- * oneToOneOnUpdate->>cacheModelForPopulate: context, model, key, updated[pk], updated
99
- * oneToOneOnUpdate->>oneToOneOnUpdate: set model[key] = updated[pk]
100
- * end
101
- *
102
- * oneToOneOnUpdate-->>Caller: void
103
- */
104
- export declare function oneToOneOnUpdate<M extends Model, R extends FabricContractRepository<M>, V extends RelationsMetadata>(this: R, context: FabricContractContext, data: V, key: keyof M, model: M): Promise<void>;
105
- /**
106
- * @description Handles one-to-one relationship deletion
107
- * @summary Processes a one-to-one relationship when deleting a model, deleting the related model if cascade is enabled
108
- * @template M - The model type extending Model
109
- * @template R - The repository type extending Repo<M, F, C>
110
- * @template V - The relations metadata type extending RelationsMetadata
111
- * @template F - The repository flags type
112
- * @template C - The context type extending Context<F>
113
- * @param {R} this - The repository instance
114
- * @param {Context<F>} context - The context for the operation
115
- * @param {V} data - The relations metadata
116
- * @param key - The property key of the relationship
117
- * @param {M} model - The model instance
118
- * @return {Promise<void>} A promise that resolves when the operation is complete
119
- * @function oneToOneOnDelete
120
- * @memberOf module:core
121
- * @mermaid
122
- * sequenceDiagram
123
- * participant Caller
124
- * participant oneToOneOnDelete
125
- * participant repositoryFromTypeMetadata
126
- * participant cacheModelForPopulate
127
- *
128
- * Caller->>oneToOneOnDelete: this, context, data, key, model
129
- * oneToOneOnDelete->>oneToOneOnDelete: check if propertyValue exists
130
- * oneToOneOnDelete->>oneToOneOnDelete: check if cascade.update is CASCADE
131
- *
132
- * oneToOneOnDelete->>repositoryFromTypeMetadata: model, key
133
- * repositoryFromTypeMetadata-->>oneToOneOnDelete: innerRepo
134
- *
135
- * alt propertyValue is not a Model instance
136
- * oneToOneOnDelete->>innerRepo: delete(model[key], context)
137
- * innerRepo-->>oneToOneOnDelete: deleted
138
- * else propertyValue is a Model instance
139
- * oneToOneOnDelete->>innerRepo: delete(model[key][innerRepo.pk], context)
140
- * innerRepo-->>oneToOneOnDelete: deleted
141
- * end
142
- *
143
- * oneToOneOnDelete->>cacheModelForPopulate: context, model, key, deleted[innerRepo.pk], deleted
144
- * oneToOneOnDelete-->>Caller: void
145
- */
146
- export declare function oneToOneOnDelete<M extends Model, R extends FabricContractRepository<M>, V extends RelationsMetadata>(this: R, context: FabricContractContext, data: V, key: keyof M, model: M): Promise<void>;
147
- /**
148
- * @description Handles one-to-many relationship creation
149
- * @summary Processes a one-to-many relationship when creating a model, either by referencing existing models or creating new ones
150
- * @template M - The model type extending Model
151
- * @template R - The repository type extending Repo<M, F, C>
152
- * @template V - The relations metadata type extending RelationsMetadata
153
- * @template F - The repository flags type
154
- * @template C - The context type extending Context<F>
155
- * @param {R} this - The repository instance
156
- * @param {Context<F>} context - The context for the operation
157
- * @param {V} data - The relations metadata
158
- * @param key - The property key of the relationship
159
- * @param {M} model - The model instance
160
- * @return {Promise<void>} A promise that resolves when the operation is complete
161
- * @function oneToManyOnCreate
162
- * @memberOf module:core
163
- * @mermaid
164
- * sequenceDiagram
165
- * participant Caller
166
- * participant oneToManyOnCreate
167
- * participant repositoryFromTypeMetadata
168
- * participant createOrUpdate
169
- * participant findPrimaryKey
170
- * participant cacheModelForPopulate
171
- *
172
- * Caller->>oneToManyOnCreate: this, context, data, key, model
173
- * oneToManyOnCreate->>oneToManyOnCreate: check if propertyValues exists and has length
174
- * oneToManyOnCreate->>oneToManyOnCreate: check if all elements have same type
175
- * oneToManyOnCreate->>oneToManyOnCreate: create uniqueValues set
176
- *
177
- * alt arrayType is not "object"
178
- * oneToManyOnCreate->>repositoryFromTypeMetadata: model, key
179
- * repositoryFromTypeMetadata-->>oneToManyOnCreate: repo
180
- * loop for each id in uniqueValues
181
- * oneToManyOnCreate->>repo: read(id)
182
- * repo-->>oneToManyOnCreate: read
183
- * oneToManyOnCreate->>cacheModelForPopulate: context, model, key, id, read
184
- * end
185
- * oneToManyOnCreate->>oneToManyOnCreate: set model[key] = [...uniqueValues]
186
- * else arrayType is "object"
187
- * oneToManyOnCreate->>findPrimaryKey: propertyValues[0]
188
- * findPrimaryKey-->>oneToManyOnCreate: pkName
189
- * oneToManyOnCreate->>oneToManyOnCreate: create result set
190
- * loop for each m in propertyValues
191
- * oneToManyOnCreate->>createOrUpdate: m, context
192
- * createOrUpdate-->>oneToManyOnCreate: record
193
- * oneToManyOnCreate->>cacheModelForPopulate: context, model, key, record[pkName], record
194
- * oneToManyOnCreate->>oneToManyOnCreate: add record[pkName] to result
195
- * end
196
- * oneToManyOnCreate->>oneToManyOnCreate: set model[key] = [...result]
197
- * end
198
- *
199
- * oneToManyOnCreate-->>Caller: void
200
- */
201
- export declare function oneToManyOnCreate<M extends Model, R extends FabricContractRepository<M>, V extends RelationsMetadata>(this: R, context: FabricContractContext, data: V, key: keyof M, model: M): Promise<void>;
202
- /**
203
- * @description Handles one-to-many relationship deletion
204
- * @summary Processes a one-to-many relationship when deleting a model, deleting all related models if cascade delete is enabled
205
- * @template M - The model type extending Model
206
- * @template R - The repository type extending Repo<M, F, C>
207
- * @template V - The relations metadata type extending RelationsMetadata
208
- * @template F - The repository flags type
209
- * @template C - The context type extending Context<F>
210
- * @param {R} this - The repository instance
211
- * @param {Context<F>} context - The context for the operation
212
- * @param {V} data - The relations metadata
213
- * @param key - The property key of the relationship
214
- * @param {M} model - The model instance
215
- * @return {Promise<void>} A promise that resolves when the operation is complete
216
- * @function oneToManyOnDelete
217
- * @memberOf module:core
218
- * @mermaid
219
- * sequenceDiagram
220
- * participant Caller
221
- * participant oneToManyOnDelete
222
- * participant Repository
223
- * participant repositoryFromTypeMetadata
224
- * participant cacheModelForPopulate
225
- *
226
- * Caller->>oneToManyOnDelete: this, context, data, key, model
227
- * oneToManyOnDelete->>oneToManyOnDelete: check if cascade.delete is CASCADE
228
- * oneToManyOnDelete->>oneToManyOnDelete: check if values exists and has length
229
- * oneToManyOnDelete->>oneToManyOnDelete: check if all elements have same type
230
- *
231
- * alt isInstantiated (arrayType is "object")
232
- * oneToManyOnDelete->>Repository: forModel(values[0])
233
- * Repository-->>oneToManyOnDelete: repo
234
- * else not instantiated
235
- * oneToManyOnDelete->>repositoryFromTypeMetadata: model, key
236
- * repositoryFromTypeMetadata-->>oneToManyOnDelete: repo
237
- * end
238
- *
239
- * oneToManyOnDelete->>oneToManyOnDelete: create uniqueValues set
240
- *
241
- * loop for each id in uniqueValues
242
- * oneToManyOnDelete->>repo: delete(id, context)
243
- * repo-->>oneToManyOnDelete: deleted
244
- * oneToManyOnDelete->>cacheModelForPopulate: context, model, key, id, deleted
245
- * end
246
- *
247
- * oneToManyOnDelete->>oneToManyOnDelete: set model[key] = [...uniqueValues]
248
- * oneToManyOnDelete-->>Caller: void
249
- */
250
- export declare function oneToManyOnDelete<M extends Model, R extends FabricContractRepository<M>, V extends RelationsMetadata>(this: R, context: FabricContractContext, data: V, key: keyof M, model: M): Promise<void>;
251
- /**
252
- * @description Populates a model's relationship
253
- * @summary Retrieves and attaches related models to a model's relationship property
254
- * @template M - The model type extending Model
255
- * @template R - The repository type extending Repo<M, F, C>
256
- * @template V - The relations metadata type extending RelationsMetadata
257
- * @template F - The repository flags type
258
- * @template C - The context type extending Context<F>
259
- * @param {R} this - The repository instance
260
- * @param {Context<F>} context - The context for the operation
261
- * @param {V} data - The relations metadata
262
- * @param key - The property key of the relationship
263
- * @param {M} model - The model instance
264
- * @return {Promise<void>} A promise that resolves when the operation is complete
265
- * @function populate
266
- * @memberOf module:core
267
- * @mermaid
268
- * sequenceDiagram
269
- * participant Caller
270
- * participant populate
271
- * participant fetchPopulateValues
272
- * participant getPopulateKey
273
- * participant Context
274
- * participant repositoryFromTypeMetadata
275
- *
276
- * Caller->>populate: this, context, data, key, model
277
- * populate->>populate: check if data.populate is true
278
- * populate->>populate: get nested value and check if it exists
279
- *
280
- * populate->>fetchPopulateValues: context, model, key, isArr ? nested : [nested]
281
- *
282
- * fetchPopulateValues->>fetchPopulateValues: initialize variables
283
- *
284
- * loop for each proKeyValue in propKeyValues
285
- * fetchPopulateValues->>getPopulateKey: model.constructor.name, propName, proKeyValue
286
- * getPopulateKey-->>fetchPopulateValues: cacheKey
287
- *
288
- * alt try to get from cache
289
- * fetchPopulateValues->>Context: get(cacheKey)
290
- * Context-->>fetchPopulateValues: val
291
- * else catch error
292
- * fetchPopulateValues->>repositoryFromTypeMetadata: model, propName
293
- * repositoryFromTypeMetadata-->>fetchPopulateValues: repo
294
- * fetchPopulateValues->>repo: read(proKeyValue)
295
- * repo-->>fetchPopulateValues: val
296
- * end
297
- *
298
- * fetchPopulateValues->>fetchPopulateValues: add val to results
299
- * end
300
- *
301
- * fetchPopulateValues-->>populate: results
302
- * populate->>populate: set model[key] = isArr ? res : res[0]
303
- * populate-->>Caller: void
304
- */
305
- export declare function populate<M extends Model, R extends Repo<M>, V extends RelationsMetadata>(this: R, context: ContextOfRepository<R>, data: V, key: keyof M, model: M): Promise<void>;