@resistdesign/voltra 3.0.0-alpha.44 → 3.0.0-alpha.45
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/api/ORM/ORMRouteMap.d.ts +16 -1
- package/api/ORM/TypeInfoORMService.d.ts +7 -2
- package/api/ORM/drivers/DynamoDBDataItemDBDriver.d.ts +2 -1
- package/api/ORM/drivers/InMemoryDataItemDBDriver.d.ts +2 -1
- package/api/ORM/drivers/common/Types.d.ts +7 -2
- package/api/index.js +98 -13
- package/app/index.js +5 -3
- package/app/utils/TypeInfoORMClient.d.ts +3 -2
- package/{chunk-7AMEFPPP.js → chunk-RUNXRISF.js} +8 -1
- package/common/TypeInfoORM/Types.d.ts +34 -2
- package/common/index.js +1 -1
- package/package.json +1 -1
package/api/ORM/ORMRouteMap.d.ts
CHANGED
|
@@ -17,6 +17,17 @@
|
|
|
17
17
|
import { BaseTypeInfoORMServiceConfig, TypeInfoORMDACConfig } from "./TypeInfoORMService";
|
|
18
18
|
import { AuthInfo, RouteAuthConfig, RouteMap } from "../Router/Types";
|
|
19
19
|
import { TypeInfoORMAPI } from "../../common/TypeInfoORM";
|
|
20
|
+
/**
|
|
21
|
+
* Optional configuration for Type Info ORM route-map behavior.
|
|
22
|
+
*/
|
|
23
|
+
export type TypeInfoORMRouteMapConfig = {
|
|
24
|
+
/**
|
|
25
|
+
* Whether update handlers should forward field operators from request args.
|
|
26
|
+
*
|
|
27
|
+
* Defaults to `true`.
|
|
28
|
+
*/
|
|
29
|
+
allowUpdateFieldOperators?: boolean;
|
|
30
|
+
};
|
|
20
31
|
/**
|
|
21
32
|
* A collection of errors that can occur when creating or using a Type Info ORM Route Map.
|
|
22
33
|
* */
|
|
@@ -52,4 +63,8 @@ getAccessingRoleId?: (authInfo: AuthInfo) => string,
|
|
|
52
63
|
/**
|
|
53
64
|
* Optional route-level auth configuration.
|
|
54
65
|
*/
|
|
55
|
-
authConfig?: RouteAuthConfig
|
|
66
|
+
authConfig?: RouteAuthConfig,
|
|
67
|
+
/**
|
|
68
|
+
* Optional route-map behavior config.
|
|
69
|
+
*/
|
|
70
|
+
routeMapConfig?: TypeInfoORMRouteMapConfig) => RouteMap;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { LiteralValue, TypeInfo, TypeInfoDataItem, TypeInfoField, TypeInfoMap, TypeOperation } from "../../common/TypeParsing/TypeInfo";
|
|
9
9
|
import { CustomTypeInfoFieldValidatorMap } from "../../common/TypeParsing/Validation";
|
|
10
10
|
import { ComparisonOperators, FieldCriterion, ListItemsConfig, ListItemsResults, ListRelationshipsConfig, SearchCriteria } from "../../common/SearchTypes";
|
|
11
|
-
import { DeleteRelationshipResults, RelationshipOperation, TypeInfoORMAPI, TypeInfoORMContext } from "../../common/TypeInfoORM";
|
|
11
|
+
import { DeleteRelationshipResults, RelationshipOperation, TypeInfoORMAPI, TypeInfoORMContext, TypeInfoORMUpdateConfig } from "../../common/TypeInfoORM";
|
|
12
12
|
import { DataItemDBDriver, IndexingRelationshipDriver, ItemRelationshipDBDriver } from "./drivers";
|
|
13
13
|
import { BaseItemRelationshipInfo, ItemRelationshipInfo, ItemRelationshipInfoKeys, ItemRelationshipInfoType, ItemRelationshipOriginatingItemInfo } from "../../common/ItemRelationshipInfoTypes";
|
|
14
14
|
import { DACAccessResult, DACDataItemResourceAccessResultMap, DACRole } from "../DataAccessControl";
|
|
@@ -738,6 +738,10 @@ export declare class TypeInfoORMService implements TypeInfoORMAPI {
|
|
|
738
738
|
* Whether the item is a partial update.
|
|
739
739
|
*/
|
|
740
740
|
itemIsPartial?: boolean) => void;
|
|
741
|
+
/**
|
|
742
|
+
* Validate update operator config against the target TypeInfo fields.
|
|
743
|
+
*/
|
|
744
|
+
protected validateUpdateConfig: (typeName: string, item: TypeInfoDataItem, updateConfig?: TypeInfoORMUpdateConfig) => void;
|
|
741
745
|
/**
|
|
742
746
|
* @returns Cleaned item with selected fields and DAC constraints applied.
|
|
743
747
|
*/
|
|
@@ -853,9 +857,10 @@ export declare class TypeInfoORMService implements TypeInfoORMAPI {
|
|
|
853
857
|
* The `item` **must always** contain its **primary field value**.
|
|
854
858
|
* @param typeName Type name to update.
|
|
855
859
|
* @param item Item payload to update.
|
|
860
|
+
* @param updateConfig Optional per-field operator config.
|
|
856
861
|
* @returns True when the update succeeded.
|
|
857
862
|
* */
|
|
858
|
-
update: (typeName: string, item: TypeInfoDataItem, context?: TypeInfoORMContext) => Promise<boolean>;
|
|
863
|
+
update: (typeName: string, item: TypeInfoDataItem, updateConfig?: TypeInfoORMUpdateConfig, context?: TypeInfoORMContext) => Promise<boolean>;
|
|
859
864
|
/**
|
|
860
865
|
* Delete an existing item of the given type.
|
|
861
866
|
* @param typeName Type name to delete.
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { DataItemDBDriver, DataItemDBDriverConfig, SupportedDataItemDBDriverEntry } from "./common/Types";
|
|
8
8
|
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
|
|
9
9
|
import { TypeInfoDataItem } from "../../../common/TypeParsing/TypeInfo";
|
|
10
|
+
import { TypeInfoORMUpdateConfig } from "../../../common/TypeInfoORM";
|
|
10
11
|
import { ListItemsConfig, ListItemsResults } from "../../../common/SearchTypes";
|
|
11
12
|
/**
|
|
12
13
|
* A {@link DataItemDBDriver} that uses DynamoDB as its database.
|
|
@@ -59,7 +60,7 @@ export declare class DynamoDBDataItemDBDriver<ItemType extends TypeInfoDataItem,
|
|
|
59
60
|
/**
|
|
60
61
|
* Partial update payload for the item.
|
|
61
62
|
*/
|
|
62
|
-
updatedItem: Partial<ItemType
|
|
63
|
+
updatedItem: Partial<ItemType>, updateConfig?: TypeInfoORMUpdateConfig) => Promise<boolean>;
|
|
63
64
|
/**
|
|
64
65
|
* Delete an item from the database.
|
|
65
66
|
* @returns True when an item was deleted.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DataItemDBDriver, DataItemDBDriverConfig, SupportedDataItemDBDriverEntry } from "./common/Types";
|
|
2
2
|
import type { TypeInfoDataItem } from "../../../common/TypeParsing/TypeInfo";
|
|
3
3
|
import type { ListItemsConfig, ListItemsResults } from "../../../common/SearchTypes";
|
|
4
|
+
import { TypeInfoORMUpdateConfig } from "../../../common/TypeInfoORM";
|
|
4
5
|
/**
|
|
5
6
|
* In-memory data item driver for testing and local usage.
|
|
6
7
|
*/
|
|
@@ -34,7 +35,7 @@ export declare class InMemoryDataItemDBDriver<ItemType extends TypeInfoDataItem,
|
|
|
34
35
|
* @param updatedItem Partial update payload for the item.
|
|
35
36
|
* @returns True when the item was updated.
|
|
36
37
|
*/
|
|
37
|
-
updateItem: (uniqueIdentifier: ItemType[UniquelyIdentifyingFieldName], updatedItem: Partial<ItemType
|
|
38
|
+
updateItem: (uniqueIdentifier: ItemType[UniquelyIdentifyingFieldName], updatedItem: Partial<ItemType>, updateConfig?: TypeInfoORMUpdateConfig) => Promise<boolean>;
|
|
38
39
|
/**
|
|
39
40
|
* Delete an item from memory.
|
|
40
41
|
* @param uniqueIdentifier Unique identifier value for the item.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TypeInfoDataItem, TypeInfoPack } from "../../../../common/TypeParsing/TypeInfo";
|
|
2
2
|
import { ItemRelationshipInfo, ItemRelationshipInfoIdentifyingKeys } from "../../../../common/ItemRelationshipInfoTypes";
|
|
3
3
|
import { ListItemsConfig, ListItemsResults } from "../../../../common/SearchTypes";
|
|
4
|
+
import type { TypeInfoORMUpdateConfig } from "../../../../common/TypeInfoORM/Types";
|
|
4
5
|
/**
|
|
5
6
|
* The errors that can be thrown by a {@link DataItemDBDriver}.
|
|
6
7
|
* */
|
|
@@ -24,7 +25,11 @@ export declare enum DATA_ITEM_DB_DRIVER_ERRORS {
|
|
|
24
25
|
/**
|
|
25
26
|
* Search operator is not supported by the driver.
|
|
26
27
|
*/
|
|
27
|
-
SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED = "SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED"
|
|
28
|
+
SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED = "SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED",
|
|
29
|
+
/**
|
|
30
|
+
* Update operator is not supported by the driver.
|
|
31
|
+
*/
|
|
32
|
+
UPDATE_OPERATOR_NOT_SUPPORTED = "UPDATE_OPERATOR_NOT_SUPPORTED"
|
|
28
33
|
}
|
|
29
34
|
/**
|
|
30
35
|
* The generic type for a database driver configuration.
|
|
@@ -70,7 +75,7 @@ export type DataItemDBDriver<ItemType extends TypeInfoDataItem, UniquelyIdentify
|
|
|
70
75
|
* @param updatedItem Partial update payload for the item.
|
|
71
76
|
* @returns True when the item was updated.
|
|
72
77
|
*/
|
|
73
|
-
updateItem: (uniqueIdentifier: ItemType[UniquelyIdentifyingFieldName], updatedItem: Partial<ItemType
|
|
78
|
+
updateItem: (uniqueIdentifier: ItemType[UniquelyIdentifyingFieldName], updatedItem: Partial<ItemType>, updateConfig?: TypeInfoORMUpdateConfig) => Promise<boolean>;
|
|
74
79
|
/**
|
|
75
80
|
* Delete an item from the data store.
|
|
76
81
|
* @param uniqueIdentifier Unique identifier value for the item.
|
package/api/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ITEM_RELATIONSHIP_DAC_RESOURCE_NAME, ComparisonOperators } from '../chunk-
|
|
1
|
+
import { TypeInfoORMUpdateOperators, ITEM_RELATIONSHIP_DAC_RESOURCE_NAME, ComparisonOperators } from '../chunk-RUNXRISF.js';
|
|
2
2
|
import { getNoErrorDescriptor, getErrorDescriptor, ERROR_MESSAGE_CONSTANTS, validateTypeOperationAllowed, getValidityValue, validateTypeInfoValue, validateTypeInfoFieldValue } from '../chunk-YCTVEW2I.js';
|
|
3
3
|
import { mergeStringPaths, getPathString, getPathArray } from '../chunk-WNFRDIBW.js';
|
|
4
4
|
import '../chunk-I2KLQ2HA.js';
|
|
@@ -4540,6 +4540,7 @@ var DATA_ITEM_DB_DRIVER_ERRORS = /* @__PURE__ */ ((DATA_ITEM_DB_DRIVER_ERRORS2)
|
|
|
4540
4540
|
DATA_ITEM_DB_DRIVER_ERRORS2["ITEM_NOT_FOUND"] = "ITEM_NOT_FOUND";
|
|
4541
4541
|
DATA_ITEM_DB_DRIVER_ERRORS2["MISSING_UNIQUE_IDENTIFIER"] = "MISSING_UNIQUE_IDENTIFIER";
|
|
4542
4542
|
DATA_ITEM_DB_DRIVER_ERRORS2["SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED"] = "SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED";
|
|
4543
|
+
DATA_ITEM_DB_DRIVER_ERRORS2["UPDATE_OPERATOR_NOT_SUPPORTED"] = "UPDATE_OPERATOR_NOT_SUPPORTED";
|
|
4543
4544
|
return DATA_ITEM_DB_DRIVER_ERRORS2;
|
|
4544
4545
|
})(DATA_ITEM_DB_DRIVER_ERRORS || {});
|
|
4545
4546
|
|
|
@@ -5778,8 +5779,9 @@ var createFilterExpression = (fieldCriteria, logicalOperator) => {
|
|
|
5778
5779
|
}
|
|
5779
5780
|
return output;
|
|
5780
5781
|
};
|
|
5781
|
-
var buildUpdateExpression = (updatedItem, uniquelyIdentifyingFieldName) => {
|
|
5782
|
-
const
|
|
5782
|
+
var buildUpdateExpression = (updatedItem, uniquelyIdentifyingFieldName, updateConfig) => {
|
|
5783
|
+
const setExpressionParts = [];
|
|
5784
|
+
const addExpressionParts = [];
|
|
5783
5785
|
const attributeNames = {};
|
|
5784
5786
|
const attributeValues = {};
|
|
5785
5787
|
for (const f in updatedItem) {
|
|
@@ -5787,13 +5789,35 @@ var buildUpdateExpression = (updatedItem, uniquelyIdentifyingFieldName) => {
|
|
|
5787
5789
|
if (f !== uniquelyIdentifyingFieldName && typeof value !== "undefined") {
|
|
5788
5790
|
const placeholderName = `#${f}`;
|
|
5789
5791
|
const placeholderValue = `:${f}`;
|
|
5790
|
-
|
|
5792
|
+
const operator = updateConfig?.fieldOperators?.[f];
|
|
5791
5793
|
attributeNames[placeholderName] = f;
|
|
5792
5794
|
attributeValues[placeholderValue] = marshall(value);
|
|
5795
|
+
if (operator === TypeInfoORMUpdateOperators.NUMBER.INCREMENT) {
|
|
5796
|
+
addExpressionParts.push(`${placeholderName} ${placeholderValue}`);
|
|
5797
|
+
continue;
|
|
5798
|
+
}
|
|
5799
|
+
if (operator === TypeInfoORMUpdateOperators.NUMBER.DECREMENT) {
|
|
5800
|
+
const decrementPlaceholderValue = `:${f}_decrement`;
|
|
5801
|
+
addExpressionParts.push(
|
|
5802
|
+
`${placeholderName} ${decrementPlaceholderValue}`
|
|
5803
|
+
);
|
|
5804
|
+
attributeValues[decrementPlaceholderValue] = marshall(
|
|
5805
|
+
-value
|
|
5806
|
+
);
|
|
5807
|
+
continue;
|
|
5808
|
+
}
|
|
5809
|
+
setExpressionParts.push(`${placeholderName} = ${placeholderValue}`);
|
|
5793
5810
|
}
|
|
5794
5811
|
}
|
|
5812
|
+
const expressionParts = [];
|
|
5813
|
+
if (setExpressionParts.length > 0) {
|
|
5814
|
+
expressionParts.push(`SET ${setExpressionParts.join(", ")}`);
|
|
5815
|
+
}
|
|
5816
|
+
if (addExpressionParts.length > 0) {
|
|
5817
|
+
expressionParts.push(`ADD ${addExpressionParts.join(", ")}`);
|
|
5818
|
+
}
|
|
5795
5819
|
return {
|
|
5796
|
-
UpdateExpression:
|
|
5820
|
+
UpdateExpression: expressionParts.join(" "),
|
|
5797
5821
|
ExpressionAttributeNames: attributeNames,
|
|
5798
5822
|
ExpressionAttributeValues: attributeValues
|
|
5799
5823
|
};
|
|
@@ -5872,7 +5896,7 @@ var DynamoDBDataItemDBDriver = class {
|
|
|
5872
5896
|
* Update an item in the database.
|
|
5873
5897
|
* @returns True when an item was updated.
|
|
5874
5898
|
*/
|
|
5875
|
-
updateItem = async (uniqueIdentifier, updatedItem) => {
|
|
5899
|
+
updateItem = async (uniqueIdentifier, updatedItem, updateConfig) => {
|
|
5876
5900
|
const { tableName, uniquelyIdentifyingFieldName } = this.config;
|
|
5877
5901
|
const {
|
|
5878
5902
|
[uniquelyIdentifyingFieldName]: _unusedUniqueIdentifier,
|
|
@@ -5887,7 +5911,8 @@ var DynamoDBDataItemDBDriver = class {
|
|
|
5887
5911
|
ReturnValues: "ALL_NEW",
|
|
5888
5912
|
...buildUpdateExpression(
|
|
5889
5913
|
cleanUpdatedItem,
|
|
5890
|
-
uniquelyIdentifyingFieldName
|
|
5914
|
+
uniquelyIdentifyingFieldName,
|
|
5915
|
+
updateConfig
|
|
5891
5916
|
)
|
|
5892
5917
|
});
|
|
5893
5918
|
const { Attributes } = await this.dynamoDBClient.send(command);
|
|
@@ -6092,7 +6117,7 @@ var InMemoryDataItemDBDriver = class {
|
|
|
6092
6117
|
* @param updatedItem Partial update payload for the item.
|
|
6093
6118
|
* @returns True when the item was updated.
|
|
6094
6119
|
*/
|
|
6095
|
-
updateItem = async (uniqueIdentifier, updatedItem) => {
|
|
6120
|
+
updateItem = async (uniqueIdentifier, updatedItem, updateConfig) => {
|
|
6096
6121
|
const { uniquelyIdentifyingFieldName } = this.config;
|
|
6097
6122
|
if (typeof uniqueIdentifier === "undefined") {
|
|
6098
6123
|
throw {
|
|
@@ -6110,6 +6135,17 @@ var InMemoryDataItemDBDriver = class {
|
|
|
6110
6135
|
};
|
|
6111
6136
|
for (const [key, value] of Object.entries(cleanUpdatedItem)) {
|
|
6112
6137
|
if (typeof value !== "undefined") {
|
|
6138
|
+
const operator = updateConfig?.fieldOperators?.[key];
|
|
6139
|
+
if (operator === TypeInfoORMUpdateOperators.NUMBER.INCREMENT) {
|
|
6140
|
+
const currentValue = nextItem[key];
|
|
6141
|
+
nextItem[key] = (typeof currentValue === "number" ? currentValue : 0) + value;
|
|
6142
|
+
continue;
|
|
6143
|
+
}
|
|
6144
|
+
if (operator === TypeInfoORMUpdateOperators.NUMBER.DECREMENT) {
|
|
6145
|
+
const currentValue = nextItem[key];
|
|
6146
|
+
nextItem[key] = (typeof currentValue === "number" ? currentValue : 0) - value;
|
|
6147
|
+
continue;
|
|
6148
|
+
}
|
|
6113
6149
|
nextItem[key] = value;
|
|
6114
6150
|
}
|
|
6115
6151
|
}
|
|
@@ -8209,6 +8245,40 @@ var TypeInfoORMService = class {
|
|
|
8209
8245
|
throw validationResults;
|
|
8210
8246
|
}
|
|
8211
8247
|
};
|
|
8248
|
+
/**
|
|
8249
|
+
* Validate update operator config against the target TypeInfo fields.
|
|
8250
|
+
*/
|
|
8251
|
+
validateUpdateConfig = (typeName, item, updateConfig) => {
|
|
8252
|
+
const fieldOperators = updateConfig?.fieldOperators;
|
|
8253
|
+
if (!fieldOperators) {
|
|
8254
|
+
return;
|
|
8255
|
+
}
|
|
8256
|
+
const { fields = {}, primaryField } = this.getTypeInfo(typeName);
|
|
8257
|
+
for (const [fieldName, operator] of Object.entries(fieldOperators)) {
|
|
8258
|
+
const field = fields[fieldName];
|
|
8259
|
+
const itemValue = item[fieldName];
|
|
8260
|
+
const isNumberOperator = Object.values(
|
|
8261
|
+
TypeInfoORMUpdateOperators.NUMBER
|
|
8262
|
+
).includes(
|
|
8263
|
+
operator
|
|
8264
|
+
);
|
|
8265
|
+
if (!field || fieldName === primaryField || !isNumberOperator || field.array || field.type !== "number" || typeof itemValue !== "number") {
|
|
8266
|
+
const validationResults = {
|
|
8267
|
+
typeName,
|
|
8268
|
+
valid: false,
|
|
8269
|
+
error: getErrorDescriptor(
|
|
8270
|
+
"INVALID_UPDATE_OPERATOR" /* INVALID_UPDATE_OPERATOR */
|
|
8271
|
+
),
|
|
8272
|
+
errorMap: {
|
|
8273
|
+
[fieldName]: [
|
|
8274
|
+
getErrorDescriptor("INVALID_UPDATE_OPERATOR" /* INVALID_UPDATE_OPERATOR */)
|
|
8275
|
+
]
|
|
8276
|
+
}
|
|
8277
|
+
};
|
|
8278
|
+
throw validationResults;
|
|
8279
|
+
}
|
|
8280
|
+
}
|
|
8281
|
+
};
|
|
8212
8282
|
/**
|
|
8213
8283
|
* @returns Cleaned item with selected fields and DAC constraints applied.
|
|
8214
8284
|
*/
|
|
@@ -8682,10 +8752,12 @@ var TypeInfoORMService = class {
|
|
|
8682
8752
|
* The `item` **must always** contain its **primary field value**.
|
|
8683
8753
|
* @param typeName Type name to update.
|
|
8684
8754
|
* @param item Item payload to update.
|
|
8755
|
+
* @param updateConfig Optional per-field operator config.
|
|
8685
8756
|
* @returns True when the update succeeded.
|
|
8686
8757
|
* */
|
|
8687
|
-
update = async (typeName, item, context) => {
|
|
8758
|
+
update = async (typeName, item, updateConfig, context) => {
|
|
8688
8759
|
this.validate(typeName, item, "UPDATE" /* UPDATE */, true);
|
|
8760
|
+
this.validateUpdateConfig(typeName, item, updateConfig);
|
|
8689
8761
|
const { primaryField } = this.getTypeInfo(typeName);
|
|
8690
8762
|
const primaryFieldValue = typeof item === "object" && item !== null ? item[primaryField] : void 0;
|
|
8691
8763
|
if (typeof primaryFieldValue === "undefined") {
|
|
@@ -8761,7 +8833,11 @@ var TypeInfoORMService = class {
|
|
|
8761
8833
|
throw error;
|
|
8762
8834
|
}
|
|
8763
8835
|
}
|
|
8764
|
-
const result = await driver.updateItem(
|
|
8836
|
+
const result = await driver.updateItem(
|
|
8837
|
+
primaryFieldValue,
|
|
8838
|
+
cleanItem,
|
|
8839
|
+
updateConfig
|
|
8840
|
+
);
|
|
8765
8841
|
const updatedItem = await driver.readItem(primaryFieldValue);
|
|
8766
8842
|
if (existingItem) {
|
|
8767
8843
|
await this.replaceItemIndexes(typeName, existingItem, updatedItem);
|
|
@@ -9411,7 +9487,7 @@ var TYPE_INFO_ORM_API_PATH_METHOD_NAME_MAP = {
|
|
|
9411
9487
|
delete: "delete",
|
|
9412
9488
|
list: "list"
|
|
9413
9489
|
};
|
|
9414
|
-
var getTypeInfoORMRouteMap = (config, dacConfig, getAccessingRoleId, authConfig) => {
|
|
9490
|
+
var getTypeInfoORMRouteMap = (config, dacConfig, getAccessingRoleId, authConfig, routeMapConfig) => {
|
|
9415
9491
|
if (dacConfig && !getAccessingRoleId) {
|
|
9416
9492
|
throw {
|
|
9417
9493
|
message: "MISSING_ACCESSING_ROLE_GETTER" /* MISSING_ACCESSING_ROLE_GETTER */
|
|
@@ -9430,6 +9506,7 @@ var getTypeInfoORMRouteMap = (config, dacConfig, getAccessingRoleId, authConfig)
|
|
|
9430
9506
|
const defaultAuthConfig = authConfig ?? {
|
|
9431
9507
|
anyAuthorized: true
|
|
9432
9508
|
};
|
|
9509
|
+
const allowUpdateFieldOperators = routeMapConfig?.allowUpdateFieldOperators ?? true;
|
|
9433
9510
|
const resolveContext = (eventData) => getContextFromEventData(eventData, dacConfig, getAccessingRoleId);
|
|
9434
9511
|
const createRoute = (path, handlerFactory) => ({
|
|
9435
9512
|
path,
|
|
@@ -9450,10 +9527,18 @@ var getTypeInfoORMRouteMap = (config, dacConfig, getAccessingRoleId, authConfig)
|
|
|
9450
9527
|
};
|
|
9451
9528
|
const updateHandlerFactory = (eventData) => {
|
|
9452
9529
|
if (!dacConfig) {
|
|
9453
|
-
|
|
9530
|
+
if (allowUpdateFieldOperators) {
|
|
9531
|
+
return orm.update;
|
|
9532
|
+
}
|
|
9533
|
+
return ((typeName, item) => orm.update(typeName, item, void 0));
|
|
9454
9534
|
}
|
|
9455
9535
|
const context = resolveContext(eventData);
|
|
9456
|
-
return ((typeName, item) => orm.update(
|
|
9536
|
+
return ((typeName, item, updateConfig) => orm.update(
|
|
9537
|
+
typeName,
|
|
9538
|
+
item,
|
|
9539
|
+
allowUpdateFieldOperators ? updateConfig : void 0,
|
|
9540
|
+
context
|
|
9541
|
+
));
|
|
9457
9542
|
};
|
|
9458
9543
|
const deleteHandlerFactory = (eventData) => {
|
|
9459
9544
|
if (!dacConfig) {
|
package/app/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createEasyLayout, getEasyLayoutTemplateDetails, getPascalCaseAreaName } from '../chunk-CMH6L5QQ.js';
|
|
2
2
|
export { computeTrackPixels } from '../chunk-TJFTWPXQ.js';
|
|
3
3
|
export { AutoForm, AutoFormView, Route, RouteContext, RouteContextConsumer, RouteContextProvider, RouteProvider, buildHistoryPath, buildQueryString, buildRoutePath, canUseBrowserHistory, computeAreaBounds, createAutoField, createBrowserRouteAdapter, createFormRenderer, createHistoryBackHandler, createManualRouteAdapter, createMemoryHistory, createNativeRouteAdapter, createRouteAdapterFromHistory, createUniversalAdapter, defaultTranslateValidationErrorCode, getFieldKind, parseHistoryPath, parseTemplate, resolveSuite, useFormEngine, useRouteContext, validateAreas, wrapRouteAdapterWithPathResolver } from '../chunk-44BMFTKD.js';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-RUNXRISF.js';
|
|
5
5
|
import '../chunk-YCTVEW2I.js';
|
|
6
6
|
import { mergeStringPaths, PATH_DELIMITER } from '../chunk-WNFRDIBW.js';
|
|
7
7
|
import '../chunk-I2KLQ2HA.js';
|
|
@@ -473,12 +473,14 @@ var TypeInfoORMClient = class {
|
|
|
473
473
|
*
|
|
474
474
|
* @param typeName - TypeInfo type name.
|
|
475
475
|
* @param item - Updated item payload.
|
|
476
|
+
* @param updateConfig - Optional per-field operator config.
|
|
476
477
|
* @returns Whether the update succeeded.
|
|
477
478
|
*/
|
|
478
|
-
update = async (typeName, item) => {
|
|
479
|
+
update = async (typeName, item, updateConfig) => {
|
|
479
480
|
return await this.makeRequest("update" /* UPDATE */, [
|
|
480
481
|
typeName,
|
|
481
|
-
item
|
|
482
|
+
item,
|
|
483
|
+
updateConfig
|
|
482
484
|
]);
|
|
483
485
|
};
|
|
484
486
|
/**
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Client wrapper around the TypeInfoORM API RouteMap. Uses ServiceConfig to
|
|
5
5
|
* route requests to the server-side TypeInfoORM routes.
|
|
6
6
|
*/
|
|
7
|
-
import { DeleteRelationshipResults, TypeInfoORMClientAPI, TypeInfoORMAPIRoutePaths } from "../../common/TypeInfoORM";
|
|
7
|
+
import { DeleteRelationshipResults, TypeInfoORMClientAPI, TypeInfoORMAPIRoutePaths, TypeInfoORMUpdateConfig } from "../../common/TypeInfoORM";
|
|
8
8
|
import { ServiceConfig } from "./Service";
|
|
9
9
|
import { TypeInfoDataItem } from "../../common/TypeParsing/TypeInfo";
|
|
10
10
|
import { ListItemsConfig, ListItemsResults, ListRelationshipsConfig } from "../../common/SearchTypes";
|
|
@@ -51,9 +51,10 @@ export declare class TypeInfoORMClient implements TypeInfoORMClientAPI {
|
|
|
51
51
|
*
|
|
52
52
|
* @param typeName - TypeInfo type name.
|
|
53
53
|
* @param item - Updated item payload.
|
|
54
|
+
* @param updateConfig - Optional per-field operator config.
|
|
54
55
|
* @returns Whether the update succeeded.
|
|
55
56
|
*/
|
|
56
|
-
update: (typeName: string, item: TypeInfoDataItem) => Promise<boolean>;
|
|
57
|
+
update: (typeName: string, item: TypeInfoDataItem, updateConfig?: TypeInfoORMUpdateConfig) => Promise<boolean>;
|
|
57
58
|
/**
|
|
58
59
|
* Delete an item by its primary field value.
|
|
59
60
|
*
|
|
@@ -54,6 +54,7 @@ var TypeInfoORMServiceError = /* @__PURE__ */ ((TypeInfoORMServiceError2) => {
|
|
|
54
54
|
TypeInfoORMServiceError2["TYPE_INFO_MISSING_PRIMARY_FIELD"] = "TYPE_INFO_MISSING_PRIMARY_FIELD";
|
|
55
55
|
TypeInfoORMServiceError2["INVALID_RELATIONSHIP"] = "INVALID_RELATIONSHIP";
|
|
56
56
|
TypeInfoORMServiceError2["INVALID_OPERATION"] = "INVALID_OPERATION";
|
|
57
|
+
TypeInfoORMServiceError2["INVALID_UPDATE_OPERATOR"] = "INVALID_UPDATE_OPERATOR";
|
|
57
58
|
TypeInfoORMServiceError2["MISSING_ACCESSING_ROLE"] = "MISSING_ACCESSING_ROLE";
|
|
58
59
|
TypeInfoORMServiceError2["INDEXING_UNSUPPORTED_CRITERIA"] = "INDEXING_UNSUPPORTED_CRITERIA";
|
|
59
60
|
TypeInfoORMServiceError2["INDEXING_UNSUPPORTED_COMBINATION"] = "INDEXING_UNSUPPORTED_COMBINATION";
|
|
@@ -74,5 +75,11 @@ var TypeInfoORMAPIRoutePaths = /* @__PURE__ */ ((TypeInfoORMAPIRoutePaths2) => {
|
|
|
74
75
|
TypeInfoORMAPIRoutePaths2["LIST_RELATED_ITEMS"] = "list-related-items";
|
|
75
76
|
return TypeInfoORMAPIRoutePaths2;
|
|
76
77
|
})(TypeInfoORMAPIRoutePaths || {});
|
|
78
|
+
var TypeInfoORMUpdateOperators = {
|
|
79
|
+
NUMBER: {
|
|
80
|
+
INCREMENT: "INCREMENT",
|
|
81
|
+
DECREMENT: "DECREMENT"
|
|
82
|
+
}
|
|
83
|
+
};
|
|
77
84
|
|
|
78
|
-
export { ComparisonOperators, ITEM_RELATIONSHIP_DAC_RESOURCE_NAME, LogicalOperators, OperationGroup, RelationshipOperation, TypeInfoORMAPIRoutePaths, TypeInfoORMServiceError };
|
|
85
|
+
export { ComparisonOperators, ITEM_RELATIONSHIP_DAC_RESOURCE_NAME, LogicalOperators, OperationGroup, RelationshipOperation, TypeInfoORMAPIRoutePaths, TypeInfoORMServiceError, TypeInfoORMUpdateOperators };
|
|
@@ -91,6 +91,10 @@ export declare enum TypeInfoORMServiceError {
|
|
|
91
91
|
* Operation is not supported.
|
|
92
92
|
* */
|
|
93
93
|
INVALID_OPERATION = "INVALID_OPERATION",
|
|
94
|
+
/**
|
|
95
|
+
* Update operator config is invalid.
|
|
96
|
+
* */
|
|
97
|
+
INVALID_UPDATE_OPERATOR = "INVALID_UPDATE_OPERATOR",
|
|
94
98
|
/**
|
|
95
99
|
* Accessing role is missing when DAC is required.
|
|
96
100
|
* */
|
|
@@ -181,6 +185,32 @@ export type TypeInfoORMContext = {
|
|
|
181
185
|
*/
|
|
182
186
|
accessingRoleId: string;
|
|
183
187
|
};
|
|
188
|
+
/**
|
|
189
|
+
* Supported numeric field update operators.
|
|
190
|
+
*/
|
|
191
|
+
export declare const TypeInfoORMUpdateOperators: {
|
|
192
|
+
readonly NUMBER: {
|
|
193
|
+
readonly INCREMENT: "INCREMENT";
|
|
194
|
+
readonly DECREMENT: "DECREMENT";
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Supported numeric field update operator values.
|
|
199
|
+
*/
|
|
200
|
+
export type TypeInfoORMNumberFieldUpdateOperator = (typeof TypeInfoORMUpdateOperators.NUMBER)[keyof typeof TypeInfoORMUpdateOperators.NUMBER];
|
|
201
|
+
/**
|
|
202
|
+
* Supported field update operator values.
|
|
203
|
+
*/
|
|
204
|
+
export type TypeInfoORMFieldUpdateOperator = TypeInfoORMNumberFieldUpdateOperator;
|
|
205
|
+
/**
|
|
206
|
+
* Optional config for TypeInfo ORM update calls.
|
|
207
|
+
*/
|
|
208
|
+
export type TypeInfoORMUpdateConfig = {
|
|
209
|
+
/**
|
|
210
|
+
* Optional per-field operator map applied during update.
|
|
211
|
+
*/
|
|
212
|
+
fieldOperators?: Record<string, TypeInfoORMFieldUpdateOperator>;
|
|
213
|
+
};
|
|
184
214
|
/**
|
|
185
215
|
* Server-side TypeInfoORM API contract.
|
|
186
216
|
*
|
|
@@ -239,9 +269,10 @@ export type TypeInfoORMAPI = {
|
|
|
239
269
|
*
|
|
240
270
|
* @param typeName - Type name to update.
|
|
241
271
|
* @param item - Updated item payload.
|
|
272
|
+
* @param updateConfig - Optional per-field operator config.
|
|
242
273
|
* @returns Whether the update succeeded.
|
|
243
274
|
*/
|
|
244
|
-
update: (typeName: string, item: TypeInfoDataItem, context?: TypeInfoORMContext) => Promise<boolean>;
|
|
275
|
+
update: (typeName: string, item: TypeInfoDataItem, updateConfig?: TypeInfoORMUpdateConfig, context?: TypeInfoORMContext) => Promise<boolean>;
|
|
245
276
|
/**
|
|
246
277
|
* Delete an item by primary field value.
|
|
247
278
|
*
|
|
@@ -319,9 +350,10 @@ export type TypeInfoORMClientAPI = {
|
|
|
319
350
|
*
|
|
320
351
|
* @param typeName - Type name to update.
|
|
321
352
|
* @param item - Updated item payload.
|
|
353
|
+
* @param updateConfig - Optional per-field operator config.
|
|
322
354
|
* @returns Whether the update succeeded.
|
|
323
355
|
*/
|
|
324
|
-
update: (typeName: string, item: TypeInfoDataItem) => Promise<boolean>;
|
|
356
|
+
update: (typeName: string, item: TypeInfoDataItem, updateConfig?: TypeInfoORMUpdateConfig) => Promise<boolean>;
|
|
325
357
|
/**
|
|
326
358
|
* Delete an item by primary field value.
|
|
327
359
|
*
|
package/common/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ComparisonOperators, ITEM_RELATIONSHIP_DAC_RESOURCE_NAME, LogicalOperators, OperationGroup, RelationshipOperation, TypeInfoORMAPIRoutePaths, TypeInfoORMServiceError } from '../chunk-
|
|
1
|
+
export { ComparisonOperators, ITEM_RELATIONSHIP_DAC_RESOURCE_NAME, LogicalOperators, OperationGroup, RelationshipOperation, TypeInfoORMAPIRoutePaths, TypeInfoORMServiceError, TypeInfoORMUpdateOperators } from '../chunk-RUNXRISF.js';
|
|
2
2
|
export { DENIED_TYPE_OPERATIONS, ERROR_MESSAGE_CONSTANTS, INVALID_CUSTOM_TYPE, PRIMITIVE_ERROR_MESSAGE_CONSTANTS, RelationshipValidationType, TYPE_KEYWORD_ERROR_MESSAGE_CONSTANTS, TYPE_KEYWORD_VALIDATORS, TypeOperation, getArrayItemErrorMap, getErrorDescriptor, getErrorDescriptors, getNoErrorDescriptor, getValidityValue, hasValue, isArrayErrorDescriptorCollection, validateArrayOfTypeInfoFieldValues, validateCustomType, validateKeywordType, validateTypeInfoDataItem, validateTypeInfoFieldOperationAllowed, validateTypeInfoFieldValue, validateTypeInfoValue, validateTypeOperationAllowed, validateValueMatchesPattern } from '../chunk-YCTVEW2I.js';
|
|
3
3
|
import '../chunk-WNFRDIBW.js';
|
|
4
4
|
import '../chunk-I2KLQ2HA.js';
|