@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.
- package/dist/for-fabric.cjs +1 -1
- package/dist/for-fabric.cjs.map +1 -1
- package/dist/for-fabric.js +1 -1
- package/dist/for-fabric.js.map +1 -1
- package/lib/client/FabricClientAdapter.cjs +4 -7
- package/lib/client/FabricClientAdapter.js.map +1 -1
- package/lib/client/services/FabricIdentityService.cjs +3 -2
- package/lib/client/services/FabricIdentityService.js.map +1 -1
- package/lib/contract/OtherMarketContract.cjs +30 -0
- package/lib/contract/OtherMarketContract.d.ts +5 -0
- package/lib/contract/OtherMarketContract.js.map +1 -0
- package/lib/contract/OtherProductStrengthContract.cjs +30 -0
- package/lib/contract/OtherProductStrengthContract.d.ts +5 -0
- package/lib/contract/OtherProductStrengthContract.js.map +1 -0
- package/lib/contract/index.cjs +4 -0
- package/lib/contract/index.js.map +1 -1
- package/lib/contract/models/Audit.js.map +1 -1
- package/lib/contract/models/OtherAudit.cjs +105 -0
- package/lib/contract/models/OtherAudit.d.ts +13 -0
- package/lib/contract/models/OtherAudit.js.map +1 -0
- package/lib/contract/models/OtherMarket.cjs +78 -0
- package/lib/contract/models/OtherMarket.d.ts +12 -0
- package/lib/contract/models/OtherMarket.js.map +1 -0
- package/lib/contract/models/OtherProductShared.cjs +15 -4
- package/lib/contract/models/OtherProductShared.d.ts +4 -0
- package/lib/contract/models/OtherProductShared.js.map +1 -1
- package/lib/contract/models/OtherProductStrength.cjs +81 -0
- package/lib/contract/models/OtherProductStrength.d.ts +11 -0
- package/lib/contract/models/OtherProductStrength.js.map +1 -0
- package/lib/contract/models/Product.cjs +1 -1
- package/lib/contract/models/Product.js.map +1 -1
- package/lib/contract/models/ProductStrength.js.map +1 -1
- package/lib/contract/models/decorators-private.cjs +88 -0
- package/lib/contract/models/decorators-private.d.ts +16 -0
- package/lib/contract/models/decorators-private.js.map +1 -0
- package/lib/contract/models/decorators.cjs +31 -2
- package/lib/contract/models/decorators.d.ts +6 -1
- package/lib/contract/models/decorators.js.map +1 -1
- package/lib/contracts/ContractAdapter.cjs +259 -409
- package/lib/contracts/ContractAdapter.d.ts +5 -29
- package/lib/contracts/ContractAdapter.js.map +1 -1
- package/lib/contracts/ContractContext.cjs +41 -13
- package/lib/contracts/ContractContext.d.ts +13 -8
- package/lib/contracts/ContractContext.js.map +1 -1
- package/lib/contracts/FabricContractRepository.cjs +70 -0
- package/lib/contracts/FabricContractRepository.d.ts +6 -0
- package/lib/contracts/FabricContractRepository.js.map +1 -1
- package/lib/contracts/FabricContractSequence.cjs +7 -23
- package/lib/contracts/FabricContractSequence.js.map +1 -1
- package/lib/contracts/FabricContractStatement.cjs +136 -1
- package/lib/contracts/FabricContractStatement.d.ts +5 -2
- package/lib/contracts/FabricContractStatement.js.map +1 -1
- package/lib/contracts/crud/crud-contract.cjs +42 -17
- package/lib/contracts/crud/crud-contract.d.ts +6 -5
- package/lib/contracts/crud/crud-contract.js.map +1 -1
- package/lib/contracts/types.d.ts +9 -2
- package/lib/esm/client/FabricClientAdapter.js +4 -7
- package/lib/esm/client/FabricClientAdapter.js.map +1 -1
- package/lib/esm/client/services/FabricIdentityService.js +3 -2
- package/lib/esm/client/services/FabricIdentityService.js.map +1 -1
- package/lib/esm/contract/OtherMarketContract.d.ts +5 -0
- package/lib/esm/contract/OtherMarketContract.js +27 -0
- package/lib/esm/contract/OtherMarketContract.js.map +1 -0
- package/lib/esm/contract/OtherProductStrengthContract.d.ts +5 -0
- package/lib/esm/contract/OtherProductStrengthContract.js +27 -0
- package/lib/esm/contract/OtherProductStrengthContract.js.map +1 -0
- package/lib/esm/contract/index.js +4 -0
- package/lib/esm/contract/index.js.map +1 -1
- package/lib/esm/contract/models/Audit.js +1 -1
- package/lib/esm/contract/models/Audit.js.map +1 -1
- package/lib/esm/contract/models/OtherAudit.d.ts +13 -0
- package/lib/esm/contract/models/OtherAudit.js +102 -0
- package/lib/esm/contract/models/OtherAudit.js.map +1 -0
- package/lib/esm/contract/models/OtherMarket.d.ts +12 -0
- package/lib/esm/contract/models/OtherMarket.js +75 -0
- package/lib/esm/contract/models/OtherMarket.js.map +1 -0
- package/lib/esm/contract/models/OtherProductShared.d.ts +4 -0
- package/lib/esm/contract/models/OtherProductShared.js +16 -5
- package/lib/esm/contract/models/OtherProductShared.js.map +1 -1
- package/lib/esm/contract/models/OtherProductStrength.d.ts +11 -0
- package/lib/esm/contract/models/OtherProductStrength.js +78 -0
- package/lib/esm/contract/models/OtherProductStrength.js.map +1 -0
- package/lib/esm/contract/models/Product.js +1 -1
- package/lib/esm/contract/models/Product.js.map +1 -1
- package/lib/esm/contract/models/ProductStrength.js +1 -1
- package/lib/esm/contract/models/ProductStrength.js.map +1 -1
- package/lib/esm/contract/models/decorators-private.d.ts +16 -0
- package/lib/esm/contract/models/decorators-private.js +81 -0
- package/lib/esm/contract/models/decorators-private.js.map +1 -0
- package/lib/esm/contract/models/decorators.d.ts +6 -1
- package/lib/esm/contract/models/decorators.js +30 -2
- package/lib/esm/contract/models/decorators.js.map +1 -1
- package/lib/esm/contracts/ContractAdapter.d.ts +5 -29
- package/lib/esm/contracts/ContractAdapter.js +262 -412
- package/lib/esm/contracts/ContractAdapter.js.map +1 -1
- package/lib/esm/contracts/ContractContext.d.ts +13 -8
- package/lib/esm/contracts/ContractContext.js +41 -13
- package/lib/esm/contracts/ContractContext.js.map +1 -1
- package/lib/esm/contracts/FabricContractRepository.d.ts +6 -0
- package/lib/esm/contracts/FabricContractRepository.js +70 -0
- package/lib/esm/contracts/FabricContractRepository.js.map +1 -1
- package/lib/esm/contracts/FabricContractSequence.js +9 -25
- package/lib/esm/contracts/FabricContractSequence.js.map +1 -1
- package/lib/esm/contracts/FabricContractStatement.d.ts +5 -2
- package/lib/esm/contracts/FabricContractStatement.js +135 -0
- package/lib/esm/contracts/FabricContractStatement.js.map +1 -1
- package/lib/esm/contracts/crud/crud-contract.d.ts +6 -5
- package/lib/esm/contracts/crud/crud-contract.js +42 -17
- package/lib/esm/contracts/crud/crud-contract.js.map +1 -1
- package/lib/esm/contracts/types.d.ts +9 -2
- package/lib/esm/shared/decorators.d.ts +8 -0
- package/lib/esm/shared/decorators.js +90 -83
- package/lib/esm/shared/decorators.js.map +1 -1
- package/lib/esm/shared/overrides/overrides.js +7 -6
- package/lib/esm/shared/overrides/overrides.js.map +1 -1
- package/lib/esm/shared/types.d.ts +3 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/shared/decorators.cjs +91 -82
- package/lib/shared/decorators.d.ts +8 -0
- package/lib/shared/decorators.js.map +1 -1
- package/lib/shared/overrides/overrides.cjs +7 -6
- package/lib/shared/overrides/overrides.js.map +1 -1
- package/lib/shared/types.d.ts +3 -2
- package/lib/version.cjs +1 -1
- package/lib/version.d.ts +1 -1
- package/package.json +3 -3
- package/lib/contracts/ContractPrivateDataAdapter.cjs +0 -426
- package/lib/contracts/ContractPrivateDataAdapter.d.ts +0 -0
- package/lib/contracts/ContractPrivateDataAdapter.js.map +0 -1
- package/lib/contracts/FabricConstruction.cjs +0 -441
- package/lib/contracts/FabricConstruction.d.ts +0 -305
- package/lib/contracts/FabricConstruction.js.map +0 -1
- package/lib/contracts/private-data.cjs +0 -204
- package/lib/contracts/private-data.d.ts +0 -0
- package/lib/contracts/private-data.js.map +0 -1
- package/lib/esm/contracts/ContractPrivateDataAdapter.d.ts +0 -0
- package/lib/esm/contracts/ContractPrivateDataAdapter.js +0 -426
- package/lib/esm/contracts/ContractPrivateDataAdapter.js.map +0 -1
- package/lib/esm/contracts/FabricConstruction.d.ts +0 -305
- package/lib/esm/contracts/FabricConstruction.js +0 -433
- package/lib/esm/contracts/FabricConstruction.js.map +0 -1
- package/lib/esm/contracts/private-data.d.ts +0 -0
- package/lib/esm/contracts/private-data.js +0 -204
- 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>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FabricConstruction.js","sourceRoot":"","sources":["../../src/contracts/FabricConstruction.ts"],"names":[],"mappings":";;AAiEA,4CAqCC;AAiDD,4CA0CC;AA2CD,4CAkCC;AAwDD,8CAwCC;AAkDD,8CAsCC;AAwDD,4BAoDC;AAljBD,yCASwB;AACxB,yEAAuD;AACvD,2DAA6E;AAI7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACI,KAAK,UAAU,gBAAgB,CAMpC,OAA8B,EAC9B,IAAO,EACP,GAAY,EACZ,KAAQ;IAER,MAAM,aAAa,GAAQ,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,CA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ACnB,KAAK,CACN,CAAC;gBACF,IAAI,CAAC,IAAI;oBAAE,MAAM,IAAI,6BAAa,CAAC,qBAAqB,CAAC,CAAC;gBAC1D,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,mBAAmB,CACnC,OAAO,EACP,KAAK,EACL,GAAa,EACb,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EACzB,IAAI,CAAC,OAAO,CAAC,KAAK,CACnB,CAAC;IACD,KAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { InternalError, SerializationError } from "@decaf-ts/db-decorators";
|
|
3
|
-
// import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
-
// import { FabricModelKeys } from "../shared/constants";
|
|
5
|
-
// import { Constructor, Metadata } from "@decaf-ts/decoration";
|
|
6
|
-
//
|
|
7
|
-
// export const MISSING_PRIVATE_DATA_REGEX =
|
|
8
|
-
// /private\s+data\s+matching\s+public\s+hash\s+version\s+is\s+not\s+available/i;
|
|
9
|
-
//
|
|
10
|
-
// export const MISSING_PRIVATE_DATA_ERROR_MESSAGE =
|
|
11
|
-
// "private data matching public hash version is not available ...";
|
|
12
|
-
//
|
|
13
|
-
// export function processModel<M extends Model>(adapter: any, model: M) {
|
|
14
|
-
// const transient = Model.segregate(model);
|
|
15
|
-
// const privateData = modelToPrivate(model);
|
|
16
|
-
//
|
|
17
|
-
// const transformModel = (model: any) => {
|
|
18
|
-
// return Object.entries(model).reduce(
|
|
19
|
-
// (accum: Record<string, any>, [key, val]) => {
|
|
20
|
-
// if (typeof val === "undefined") return accum;
|
|
21
|
-
// const mappedProp = Model.columnName(
|
|
22
|
-
// model.constructor as Constructor,
|
|
23
|
-
// key as any
|
|
24
|
-
// );
|
|
25
|
-
// if (adapter.isReserved(mappedProp))
|
|
26
|
-
// throw new InternalError(`Property name ${mappedProp} is reserved`);
|
|
27
|
-
// accum[mappedProp] = val;
|
|
28
|
-
// return accum;
|
|
29
|
-
// },
|
|
30
|
-
// {}
|
|
31
|
-
// );
|
|
32
|
-
// };
|
|
33
|
-
//
|
|
34
|
-
// if (privateData.private) {
|
|
35
|
-
// const collections = Object.keys(privateData.private);
|
|
36
|
-
//
|
|
37
|
-
// for (const collection of collections) {
|
|
38
|
-
// privateData.private![collection] = transformModel(
|
|
39
|
-
// privateData.private![collection]
|
|
40
|
-
// );
|
|
41
|
-
// }
|
|
42
|
-
// }
|
|
43
|
-
//
|
|
44
|
-
// return {
|
|
45
|
-
// model: transient.model,
|
|
46
|
-
// transient: transient.transient,
|
|
47
|
-
// privateData: privateData.private,
|
|
48
|
-
// result: transformModel(transient.model),
|
|
49
|
-
// };
|
|
50
|
-
// }
|
|
51
|
-
//
|
|
52
|
-
// export function hasPrivateData<M extends Model>(model: M) {
|
|
53
|
-
// return !!getClassPrivateDataMetadata(model);
|
|
54
|
-
// }
|
|
55
|
-
//
|
|
56
|
-
// export function getClassPrivateDataMetadata<M extends Model>(
|
|
57
|
-
// model: M
|
|
58
|
-
// ): Record<string, any> | undefined {
|
|
59
|
-
// const constr = model.constructor as Constructor;
|
|
60
|
-
// const rootMetadata = Metadata.get(constr) || {};
|
|
61
|
-
// if (rootMetadata && rootMetadata[FabricModelKeys.PRIVATE])
|
|
62
|
-
// return rootMetadata[FabricModelKeys.PRIVATE];
|
|
63
|
-
// if (
|
|
64
|
-
// rootMetadata &&
|
|
65
|
-
// rootMetadata[FabricModelKeys.FABRIC + FabricModelKeys.PRIVATE]
|
|
66
|
-
// )
|
|
67
|
-
// return rootMetadata[FabricModelKeys.FABRIC + FabricModelKeys.PRIVATE];
|
|
68
|
-
// const flattened = Object.keys(rootMetadata || {}).reduce(
|
|
69
|
-
// (accum: Record<string, any>, key) => {
|
|
70
|
-
// if (key.includes(FabricModelKeys.PRIVATE)) {
|
|
71
|
-
// const property = key.split(Metadata.splitter).pop();
|
|
72
|
-
// if (property) accum[property] = Metadata.get(constr, key);
|
|
73
|
-
// }
|
|
74
|
-
// return accum;
|
|
75
|
-
// },
|
|
76
|
-
// {} as Record<string, any>
|
|
77
|
-
// );
|
|
78
|
-
// if (Object.keys(flattened).length) return flattened;
|
|
79
|
-
// const classKey = Metadata.key(
|
|
80
|
-
// FabricModelKeys.FABRIC + FabricModelKeys.PRIVATE
|
|
81
|
-
// );
|
|
82
|
-
// const classMetadata =
|
|
83
|
-
// Metadata.get(constr, classKey) ??
|
|
84
|
-
// Metadata.get(constr, FabricModelKeys.PRIVATE);
|
|
85
|
-
// if (classMetadata) return classMetadata;
|
|
86
|
-
// const props = Metadata.properties(constr) || [];
|
|
87
|
-
// const metadata: Record<string, any> = {};
|
|
88
|
-
// for (const prop of props) {
|
|
89
|
-
// const keys = [
|
|
90
|
-
// Metadata.key(FabricModelKeys.PRIVATE, prop),
|
|
91
|
-
// Metadata.key(classKey, prop),
|
|
92
|
-
// ];
|
|
93
|
-
// const propMetadata = keys
|
|
94
|
-
// .map((key) => Metadata.get(constr, key))
|
|
95
|
-
// .find(Boolean);
|
|
96
|
-
// if (propMetadata) metadata[prop] = propMetadata;
|
|
97
|
-
// }
|
|
98
|
-
// return Object.keys(metadata).length ? metadata : undefined;
|
|
99
|
-
// }
|
|
100
|
-
//
|
|
101
|
-
// export function isModelPrivate<M extends Model>(model: M): boolean {
|
|
102
|
-
// const classMetadata = Metadata.get(
|
|
103
|
-
// model.constructor as Constructor,
|
|
104
|
-
// Metadata.key(FabricModelKeys.FABRIC + FabricModelKeys.PRIVATE)
|
|
105
|
-
// );
|
|
106
|
-
// return Boolean(classMetadata?.isPrivate);
|
|
107
|
-
// }
|
|
108
|
-
//
|
|
109
|
-
// export function modelToPrivate<M extends Model>(
|
|
110
|
-
// model: M
|
|
111
|
-
// ): { model: M; private?: Record<string, Record<string, any>> } {
|
|
112
|
-
// if (!hasPrivateData(model)) return { model: model };
|
|
113
|
-
//
|
|
114
|
-
// const isPrivate = isModelPrivate(model);
|
|
115
|
-
// const modelCollections: Record<string, any> =
|
|
116
|
-
// getClassPrivateDataMetadata(model);
|
|
117
|
-
//
|
|
118
|
-
// let result: { model: Record<string, any>; private?: Record<string, any> } = {
|
|
119
|
-
// model: model as Record<string, any>,
|
|
120
|
-
// private: undefined,
|
|
121
|
-
// };
|
|
122
|
-
//
|
|
123
|
-
// // TODO: the is private is not workign correctly. If no properties it doesn't create the private part.
|
|
124
|
-
// if (isPrivate) {
|
|
125
|
-
// const privatePart = modelCollections.collections;
|
|
126
|
-
// result = (
|
|
127
|
-
// Metadata.properties(model.constructor as Constructor) || []
|
|
128
|
-
// ).reduce(
|
|
129
|
-
// (
|
|
130
|
-
// accum: { model: Record<string, any>; private?: Record<string, any> },
|
|
131
|
-
// k
|
|
132
|
-
// ) => {
|
|
133
|
-
// const collections = modelCollections.collections;
|
|
134
|
-
// accum.private = accum.private || {};
|
|
135
|
-
//
|
|
136
|
-
// for (const collection of collections) {
|
|
137
|
-
// try {
|
|
138
|
-
// accum.private[collection] = accum.private[collection] || {};
|
|
139
|
-
// accum.private[collection][k] = model[k as keyof M];
|
|
140
|
-
// } catch (e: unknown) {
|
|
141
|
-
// throw new SerializationError(
|
|
142
|
-
// `Failed to serialize private property ${k}: ${e}`
|
|
143
|
-
// );
|
|
144
|
-
// }
|
|
145
|
-
// }
|
|
146
|
-
//
|
|
147
|
-
// return accum;
|
|
148
|
-
// },
|
|
149
|
-
// { model: {}, private: privatePart } as {
|
|
150
|
-
// model: Record<string, any>;
|
|
151
|
-
// private?: Record<string, any>;
|
|
152
|
-
// }
|
|
153
|
-
// );
|
|
154
|
-
// } else {
|
|
155
|
-
// result = Object.entries(modelCollections).reduce(
|
|
156
|
-
// (
|
|
157
|
-
// accum: { model: Record<string, any>; private?: Record<string, any> },
|
|
158
|
-
// [k, val]
|
|
159
|
-
// ) => {
|
|
160
|
-
// const props = Metadata.properties(model.constructor as Constructor);
|
|
161
|
-
// if (!props?.includes(k)) return accum;
|
|
162
|
-
//
|
|
163
|
-
// const collections = (val as Record<string, any>).collections;
|
|
164
|
-
//
|
|
165
|
-
// if (collections?.length) {
|
|
166
|
-
// accum.private = accum.private || {};
|
|
167
|
-
//
|
|
168
|
-
// for (const collection of collections) {
|
|
169
|
-
// try {
|
|
170
|
-
// accum.private[collection] = accum.private[collection] || {};
|
|
171
|
-
// accum.private[collection][k] = model[k as keyof M];
|
|
172
|
-
// } catch (e: unknown) {
|
|
173
|
-
// throw new SerializationError(
|
|
174
|
-
// `Failed to serialize private property ${k}: ${e}`
|
|
175
|
-
// );
|
|
176
|
-
// }
|
|
177
|
-
// }
|
|
178
|
-
// } else {
|
|
179
|
-
// accum.model = accum.model || {};
|
|
180
|
-
// accum.model[k] = (model as Record<string, any>)[k];
|
|
181
|
-
// }
|
|
182
|
-
// return accum;
|
|
183
|
-
// },
|
|
184
|
-
// {} as { model: Record<string, any>; private?: Record<string, any> }
|
|
185
|
-
// );
|
|
186
|
-
// }
|
|
187
|
-
//
|
|
188
|
-
// result.model = result.model || {};
|
|
189
|
-
//
|
|
190
|
-
// result.model = Model.build(result.model, model.constructor.name);
|
|
191
|
-
//
|
|
192
|
-
// if (result.private) {
|
|
193
|
-
// const collections = Object.keys(result.private);
|
|
194
|
-
//
|
|
195
|
-
// for (const collection of collections) {
|
|
196
|
-
// result.private![collection] = Model.build(
|
|
197
|
-
// result.private![collection],
|
|
198
|
-
// model.constructor.name
|
|
199
|
-
// );
|
|
200
|
-
// }
|
|
201
|
-
// }
|
|
202
|
-
// return result as { model: M; private?: Record<string, Record<string, any>> };
|
|
203
|
-
// }
|
|
204
|
-
//# sourceMappingURL=private-data.js.map
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"private-data.js","sourceRoot":"","sources":["../../src/contracts/private-data.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,0DAA0D;AAC1D,yDAAyD;AACzD,gEAAgE;AAChE,EAAE;AACF,4CAA4C;AAC5C,mFAAmF;AACnF,EAAE;AACF,oDAAoD;AACpD,sEAAsE;AACtE,EAAE;AACF,0EAA0E;AAC1E,8CAA8C;AAC9C,+CAA+C;AAC/C,EAAE;AACF,6CAA6C;AAC7C,2CAA2C;AAC3C,sDAAsD;AACtD,wDAAwD;AACxD,+CAA+C;AAC/C,8CAA8C;AAC9C,uBAAuB;AACvB,aAAa;AACb,8CAA8C;AAC9C,gFAAgF;AAChF,mCAAmC;AACnC,wBAAwB;AACxB,WAAW;AACX,WAAW;AACX,SAAS;AACT,OAAO;AACP,EAAE;AACF,+BAA+B;AAC/B,4DAA4D;AAC5D,EAAE;AACF,8CAA8C;AAC9C,2DAA2D;AAC3D,2CAA2C;AAC3C,WAAW;AACX,QAAQ;AACR,MAAM;AACN,EAAE;AACF,aAAa;AACb,8BAA8B;AAC9B,sCAAsC;AACtC,wCAAwC;AACxC,+CAA+C;AAC/C,OAAO;AACP,IAAI;AACJ,EAAE;AACF,8DAA8D;AAC9D,iDAAiD;AACjD,IAAI;AACJ,EAAE;AACF,gEAAgE;AAChE,aAAa;AACb,uCAAuC;AACvC,qDAAqD;AACrD,qDAAqD;AACrD,+DAA+D;AAC/D,oDAAoD;AACpD,SAAS;AACT,sBAAsB;AACtB,qEAAqE;AACrE,MAAM;AACN,6EAA6E;AAC7E,8DAA8D;AAC9D,6CAA6C;AAC7C,qDAAqD;AACrD,+DAA+D;AAC/D,qEAAqE;AACrE,UAAU;AACV,sBAAsB;AACtB,SAAS;AACT,gCAAgC;AAChC,OAAO;AACP,yDAAyD;AACzD,mCAAmC;AACnC,uDAAuD;AACv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