@resistdesign/voltra 3.0.0-alpha.5 → 3.0.0-alpha.7
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/README.md +36 -7
- package/api/index.d.ts +1 -1
- package/api/index.js +1810 -1380
- package/common/index.d.ts +1 -1
- package/common/index.js +64 -606
- package/iac/index.d.ts +2 -2
- package/iac/index.js +4 -2
- package/iac/packs/index.d.ts +1 -1
- package/iac/packs/index.js +4 -2
- package/{index-BkFZlfit.d.ts → index-BjFkoQmK.d.ts} +1 -1
- package/{index-CK5Qwvfb.d.ts → index-DbLgMAxB.d.ts} +6 -0
- package/{index-DcvJOZ_c.d.ts → index-DgOzPKdr.d.ts} +8 -0
- package/{index-C3-iD9Mh.d.ts → index-sIX5qe0K.d.ts} +2 -12
- package/index.d.ts +4 -4
- package/index.js +1641 -1186
- package/package.json +6 -1
package/api/index.js
CHANGED
|
@@ -4,11 +4,9 @@ import { QueryCommand, DynamoDBClient, PutItemCommand, GetItemCommand, UpdateIte
|
|
|
4
4
|
import { marshall, unmarshall } from '@aws-sdk/util-dynamodb';
|
|
5
5
|
import { S3, PutObjectCommand, HeadObjectCommand, CopyObjectCommand, GetObjectCommand, DeleteObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3';
|
|
6
6
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
7
|
+
import { v4 } from 'uuid';
|
|
7
8
|
import Path from 'path';
|
|
8
|
-
import FS from 'fs';
|
|
9
9
|
import { fileURLToPath } from 'url';
|
|
10
|
-
import { SyntaxKind, isLiteralTypeNode, isStringLiteral, isNumericLiteral, createSourceFile, ScriptTarget } from 'typescript';
|
|
11
|
-
import { v4 } from 'uuid';
|
|
12
10
|
|
|
13
11
|
var __defProp = Object.defineProperty;
|
|
14
12
|
var __export = (target, all) => {
|
|
@@ -3964,1433 +3962,1512 @@ var DATA_ITEM_DB_DRIVER_ERRORS = /* @__PURE__ */ ((DATA_ITEM_DB_DRIVER_ERRORS2)
|
|
|
3964
3962
|
DATA_ITEM_DB_DRIVER_ERRORS2["SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED"] = "SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED";
|
|
3965
3963
|
return DATA_ITEM_DB_DRIVER_ERRORS2;
|
|
3966
3964
|
})(DATA_ITEM_DB_DRIVER_ERRORS || {});
|
|
3967
|
-
var convertASTToMap = (node, map = {}, parentName) => {
|
|
3968
|
-
node.forEachChild((child) => {
|
|
3969
|
-
const { kind: childKind } = child;
|
|
3970
|
-
if (childKind === SyntaxKind.ModuleDeclaration) {
|
|
3971
|
-
const moduleNode = child;
|
|
3972
|
-
const { name: moduleName } = moduleNode;
|
|
3973
|
-
const textModuleName = moduleName.getText();
|
|
3974
|
-
const fullModuleName = parentName ? `${parentName}.${textModuleName}` : textModuleName;
|
|
3975
|
-
convertASTToMap(moduleNode, map, fullModuleName);
|
|
3976
|
-
}
|
|
3977
|
-
if (childKind === SyntaxKind.ModuleBlock) {
|
|
3978
|
-
convertASTToMap(child, map, parentName);
|
|
3979
|
-
}
|
|
3980
|
-
if (childKind === SyntaxKind.TypeAliasDeclaration) {
|
|
3981
|
-
const typeAliasDec = child;
|
|
3982
|
-
const {
|
|
3983
|
-
name: { text: typeName }
|
|
3984
|
-
} = typeAliasDec;
|
|
3985
|
-
const fullTypeName = parentName ? `${parentName}.${typeName}` : typeName;
|
|
3986
|
-
map[fullTypeName] = typeAliasDec;
|
|
3987
|
-
}
|
|
3988
|
-
});
|
|
3989
|
-
return map;
|
|
3990
|
-
};
|
|
3991
3965
|
|
|
3992
|
-
// src/
|
|
3993
|
-
var
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
if (i === 0) {
|
|
4036
|
-
if (!baseObject) {
|
|
4037
|
-
baseParentObject = isNum ? [] : {};
|
|
4038
|
-
} else {
|
|
4039
|
-
baseParentObject = isNum ? [...Array.isArray(baseObject) ? baseObject : []] : {
|
|
4040
|
-
...typeof baseObject === "object" ? baseObject : {}
|
|
4041
|
-
};
|
|
4042
|
-
}
|
|
4043
|
-
currentParent = baseParentObject;
|
|
4044
|
-
}
|
|
4045
|
-
if (i < path.length - 1) {
|
|
4046
|
-
const existingNewCurrentParent = currentParent[cleanPathPart];
|
|
4047
|
-
newCurrentParent = isNum ? [
|
|
4048
|
-
...Array.isArray(existingNewCurrentParent) ? existingNewCurrentParent : []
|
|
4049
|
-
] : {
|
|
4050
|
-
...typeof existingNewCurrentParent === "object" ? existingNewCurrentParent : {}
|
|
4051
|
-
};
|
|
4052
|
-
currentParent[cleanPathPart] = newCurrentParent;
|
|
4053
|
-
currentParent = newCurrentParent;
|
|
4054
|
-
} else {
|
|
4055
|
-
currentParent[cleanPathPart] = value;
|
|
3966
|
+
// src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypeInfoMap.json
|
|
3967
|
+
var ConfigTypeInfoMap_default = {
|
|
3968
|
+
Logger: {
|
|
3969
|
+
fields: {
|
|
3970
|
+
trace: {
|
|
3971
|
+
type: "string",
|
|
3972
|
+
array: false,
|
|
3973
|
+
readonly: false,
|
|
3974
|
+
optional: true,
|
|
3975
|
+
possibleValues: [],
|
|
3976
|
+
tags: {}
|
|
3977
|
+
},
|
|
3978
|
+
debug: {
|
|
3979
|
+
type: "string",
|
|
3980
|
+
array: false,
|
|
3981
|
+
readonly: false,
|
|
3982
|
+
optional: false,
|
|
3983
|
+
typeReference: "Trace",
|
|
3984
|
+
tags: {}
|
|
3985
|
+
},
|
|
3986
|
+
info: {
|
|
3987
|
+
type: "string",
|
|
3988
|
+
array: false,
|
|
3989
|
+
readonly: false,
|
|
3990
|
+
optional: false,
|
|
3991
|
+
typeReference: "Trace",
|
|
3992
|
+
tags: {}
|
|
3993
|
+
},
|
|
3994
|
+
warn: {
|
|
3995
|
+
type: "string",
|
|
3996
|
+
array: false,
|
|
3997
|
+
readonly: false,
|
|
3998
|
+
optional: false,
|
|
3999
|
+
typeReference: "Trace",
|
|
4000
|
+
tags: {}
|
|
4001
|
+
},
|
|
4002
|
+
error: {
|
|
4003
|
+
type: "string",
|
|
4004
|
+
array: false,
|
|
4005
|
+
readonly: false,
|
|
4006
|
+
optional: false,
|
|
4007
|
+
typeReference: "Trace",
|
|
4008
|
+
tags: {}
|
|
4056
4009
|
}
|
|
4057
|
-
}
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
}
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
tags
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4010
|
+
},
|
|
4011
|
+
tags: {},
|
|
4012
|
+
primaryField: "trace"
|
|
4013
|
+
},
|
|
4014
|
+
Endpoint: {
|
|
4015
|
+
fields: {
|
|
4016
|
+
protocol: {
|
|
4017
|
+
type: "string",
|
|
4018
|
+
array: false,
|
|
4019
|
+
readonly: false,
|
|
4020
|
+
optional: false,
|
|
4021
|
+
tags: {}
|
|
4022
|
+
},
|
|
4023
|
+
hostname: {
|
|
4024
|
+
type: "string",
|
|
4025
|
+
array: false,
|
|
4026
|
+
readonly: false,
|
|
4027
|
+
optional: false,
|
|
4028
|
+
tags: {}
|
|
4029
|
+
},
|
|
4030
|
+
port: {
|
|
4031
|
+
type: "string",
|
|
4032
|
+
array: false,
|
|
4033
|
+
readonly: false,
|
|
4034
|
+
optional: true,
|
|
4035
|
+
tags: {}
|
|
4036
|
+
},
|
|
4037
|
+
path: {
|
|
4038
|
+
type: "string",
|
|
4039
|
+
array: false,
|
|
4040
|
+
readonly: false,
|
|
4041
|
+
optional: false,
|
|
4042
|
+
tags: {}
|
|
4043
|
+
},
|
|
4044
|
+
query: {
|
|
4045
|
+
type: "string",
|
|
4046
|
+
array: false,
|
|
4047
|
+
readonly: false,
|
|
4048
|
+
optional: true,
|
|
4049
|
+
tags: {}
|
|
4077
4050
|
}
|
|
4078
|
-
}
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
}
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
if (detectedTypeKeyword === "string") {
|
|
4091
|
-
literalValues.push(literal.text);
|
|
4092
|
-
}
|
|
4093
|
-
} else if (isNumericLiteral(literal)) {
|
|
4094
|
-
if (!detectedTypeKeyword) detectedTypeKeyword = "number";
|
|
4095
|
-
if (detectedTypeKeyword === "number") {
|
|
4096
|
-
literalValues.push(Number(literal.text));
|
|
4097
|
-
}
|
|
4098
|
-
} else if (literal.kind === SyntaxKind.TrueKeyword || literal.kind === SyntaxKind.FalseKeyword) {
|
|
4099
|
-
if (!detectedTypeKeyword) detectedTypeKeyword = "boolean";
|
|
4100
|
-
if (detectedTypeKeyword === "boolean") {
|
|
4101
|
-
literalValues.push(literal.kind === SyntaxKind.TrueKeyword);
|
|
4102
|
-
}
|
|
4103
|
-
} else if (literal.kind === SyntaxKind.NullKeyword) {
|
|
4104
|
-
literalValues.push(null);
|
|
4051
|
+
},
|
|
4052
|
+
tags: {},
|
|
4053
|
+
primaryField: "protocol"
|
|
4054
|
+
},
|
|
4055
|
+
Properties: {
|
|
4056
|
+
fields: {
|
|
4057
|
+
authSchemes: {
|
|
4058
|
+
type: "string",
|
|
4059
|
+
array: false,
|
|
4060
|
+
readonly: false,
|
|
4061
|
+
optional: true,
|
|
4062
|
+
tags: {}
|
|
4105
4063
|
}
|
|
4106
|
-
}
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
}
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
switch (node.kind) {
|
|
4126
|
-
case SyntaxKind.StringKeyword:
|
|
4127
|
-
return "string";
|
|
4128
|
-
case SyntaxKind.NumberKeyword:
|
|
4129
|
-
return "number";
|
|
4130
|
-
case SyntaxKind.BooleanKeyword:
|
|
4131
|
-
return "boolean";
|
|
4132
|
-
default:
|
|
4133
|
-
return "string";
|
|
4134
|
-
}
|
|
4135
|
-
};
|
|
4136
|
-
|
|
4137
|
-
// src/common/TypeParsing/ParsingUtils/checkType.ts
|
|
4138
|
-
var checkType = (node) => {
|
|
4139
|
-
let typeReference;
|
|
4140
|
-
let isArray = false;
|
|
4141
|
-
let typeKeyword;
|
|
4142
|
-
let options;
|
|
4143
|
-
if (node.kind === SyntaxKind.TypeReference) {
|
|
4144
|
-
typeReference = node.typeName.getText();
|
|
4145
|
-
typeKeyword = "string";
|
|
4146
|
-
} else if (node.kind === SyntaxKind.ArrayType) {
|
|
4147
|
-
isArray = true;
|
|
4148
|
-
const elementType = node.elementType;
|
|
4149
|
-
const {
|
|
4150
|
-
typeReference: elementReference,
|
|
4151
|
-
isArray: elementIsArray,
|
|
4152
|
-
typeKeyword: elementKeyword,
|
|
4153
|
-
options: elementOptions
|
|
4154
|
-
} = checkType(elementType);
|
|
4155
|
-
typeReference = elementReference;
|
|
4156
|
-
isArray = !!elementIsArray;
|
|
4157
|
-
typeKeyword = elementKeyword || "string";
|
|
4158
|
-
options = elementOptions;
|
|
4159
|
-
} else if (node.kind === SyntaxKind.UnionType) {
|
|
4160
|
-
const { types: unionTypes } = node;
|
|
4161
|
-
const { options: unionOptions, typeKeyword: unionTypeKeyword } = checkUnionType(node);
|
|
4162
|
-
options = unionOptions;
|
|
4163
|
-
typeKeyword = unionTypeKeyword;
|
|
4164
|
-
if (!options) {
|
|
4165
|
-
typeKeyword = getTypeKeyword(unionTypes[0]);
|
|
4166
|
-
}
|
|
4167
|
-
} else if (node.kind === SyntaxKind.ParenthesizedType) {
|
|
4168
|
-
const {
|
|
4169
|
-
typeReference: parenthesizedReference,
|
|
4170
|
-
isArray: parenthesizedIsArray,
|
|
4171
|
-
typeKeyword: parenthesizedKeyword,
|
|
4172
|
-
options: parenthesizedOptions
|
|
4173
|
-
} = checkType(node.type);
|
|
4174
|
-
typeReference = parenthesizedReference;
|
|
4175
|
-
isArray = !!parenthesizedIsArray;
|
|
4176
|
-
typeKeyword = parenthesizedKeyword || "string";
|
|
4177
|
-
options = parenthesizedOptions;
|
|
4178
|
-
} else {
|
|
4179
|
-
typeKeyword = getTypeKeyword(node);
|
|
4180
|
-
}
|
|
4181
|
-
return { typeReference, isArray, typeKeyword, options };
|
|
4182
|
-
};
|
|
4183
|
-
|
|
4184
|
-
// src/common/TypeParsing/ParsingUtils/extractTypeDetails.ts
|
|
4185
|
-
var extractTypeDetails = (type) => {
|
|
4186
|
-
const { isArray, typeReference, options, typeKeyword } = checkType(type);
|
|
4187
|
-
return {
|
|
4188
|
-
type: typeKeyword || "string",
|
|
4189
|
-
typeReference,
|
|
4190
|
-
array: !!isArray,
|
|
4191
|
-
options
|
|
4192
|
-
};
|
|
4193
|
-
};
|
|
4194
|
-
|
|
4195
|
-
// src/common/TypeParsing/ParsingUtils/getTypeInfoField.ts
|
|
4196
|
-
var getTypeInfoField = (propertySignature) => {
|
|
4197
|
-
const { type, modifiers } = propertySignature;
|
|
4198
|
-
const {
|
|
4199
|
-
array,
|
|
4200
|
-
typeReference,
|
|
4201
|
-
type: typeKeyword,
|
|
4202
|
-
options
|
|
4203
|
-
} = type ? extractTypeDetails(type) : {
|
|
4204
|
-
array: false,
|
|
4205
|
-
typeReference: void 0,
|
|
4206
|
-
type: "string",
|
|
4207
|
-
options: void 0
|
|
4208
|
-
};
|
|
4209
|
-
const readonly = modifiers ? modifiers.some((modifier) => modifier.kind === SyntaxKind.ReadonlyKeyword) : false;
|
|
4210
|
-
const optional = !!propertySignature.questionToken;
|
|
4211
|
-
let tags = extractCommentTags(propertySignature);
|
|
4212
|
-
if (readonly) {
|
|
4213
|
-
const {
|
|
4214
|
-
deniedOperations,
|
|
4215
|
-
deniedOperations: { CREATE, UPDATE, DELETE } = {}
|
|
4216
|
-
} = tags || {};
|
|
4217
|
-
tags = {
|
|
4218
|
-
...tags,
|
|
4219
|
-
deniedOperations: {
|
|
4220
|
-
...deniedOperations,
|
|
4221
|
-
create: CREATE ?? true,
|
|
4222
|
-
update: UPDATE ?? true,
|
|
4223
|
-
delete: DELETE ?? true
|
|
4064
|
+
},
|
|
4065
|
+
tags: {},
|
|
4066
|
+
primaryField: "authSchemes"
|
|
4067
|
+
},
|
|
4068
|
+
RetryStrategy: {
|
|
4069
|
+
fields: {
|
|
4070
|
+
mode: {
|
|
4071
|
+
type: "string",
|
|
4072
|
+
array: false,
|
|
4073
|
+
readonly: false,
|
|
4074
|
+
optional: true,
|
|
4075
|
+
tags: {}
|
|
4076
|
+
},
|
|
4077
|
+
retry: {
|
|
4078
|
+
type: "string",
|
|
4079
|
+
array: false,
|
|
4080
|
+
readonly: false,
|
|
4081
|
+
optional: false,
|
|
4082
|
+
tags: {}
|
|
4224
4083
|
}
|
|
4225
|
-
}
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
}
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
}
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
}
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
let nextTypeInfo;
|
|
4266
|
-
if (kind2 === SyntaxKind.TypeReference) {
|
|
4267
|
-
const { typeName } = t;
|
|
4268
|
-
const refNode = typeMap[typeName.getText()];
|
|
4269
|
-
if (refNode) {
|
|
4270
|
-
nextTypeInfo = getTypeInfoFromTypeAlias(refNode, typeMap);
|
|
4084
|
+
},
|
|
4085
|
+
tags: {},
|
|
4086
|
+
primaryField: "mode"
|
|
4087
|
+
},
|
|
4088
|
+
Credentials: {
|
|
4089
|
+
fields: {
|
|
4090
|
+
accessKeyId: {
|
|
4091
|
+
type: "string",
|
|
4092
|
+
array: false,
|
|
4093
|
+
readonly: false,
|
|
4094
|
+
optional: false,
|
|
4095
|
+
tags: {}
|
|
4096
|
+
},
|
|
4097
|
+
secretAccessKey: {
|
|
4098
|
+
type: "string",
|
|
4099
|
+
array: false,
|
|
4100
|
+
readonly: false,
|
|
4101
|
+
optional: false,
|
|
4102
|
+
tags: {}
|
|
4103
|
+
},
|
|
4104
|
+
sessionToken: {
|
|
4105
|
+
type: "string",
|
|
4106
|
+
array: false,
|
|
4107
|
+
readonly: false,
|
|
4108
|
+
optional: true,
|
|
4109
|
+
tags: {}
|
|
4110
|
+
},
|
|
4111
|
+
credentialScope: {
|
|
4112
|
+
type: "string",
|
|
4113
|
+
array: false,
|
|
4114
|
+
readonly: false,
|
|
4115
|
+
optional: true,
|
|
4116
|
+
tags: {}
|
|
4117
|
+
},
|
|
4118
|
+
expiration: {
|
|
4119
|
+
type: "string",
|
|
4120
|
+
array: false,
|
|
4121
|
+
readonly: false,
|
|
4122
|
+
optional: true,
|
|
4123
|
+
tags: {}
|
|
4271
4124
|
}
|
|
4272
|
-
}
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
...typeInfo,
|
|
4285
|
-
unionFieldSets: [
|
|
4286
|
-
...existingFieldSets,
|
|
4287
|
-
...nextUnionFieldSets,
|
|
4288
|
-
newUnionFieldSet
|
|
4289
|
-
]
|
|
4290
|
-
};
|
|
4125
|
+
},
|
|
4126
|
+
tags: {},
|
|
4127
|
+
primaryField: "accessKeyId"
|
|
4128
|
+
},
|
|
4129
|
+
Signer: {
|
|
4130
|
+
fields: {
|
|
4131
|
+
sign: {
|
|
4132
|
+
type: "string",
|
|
4133
|
+
array: false,
|
|
4134
|
+
readonly: false,
|
|
4135
|
+
optional: false,
|
|
4136
|
+
tags: {}
|
|
4291
4137
|
}
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4138
|
+
},
|
|
4139
|
+
tags: {},
|
|
4140
|
+
primaryField: "sign"
|
|
4141
|
+
},
|
|
4142
|
+
AbridgedS3ClientConfig: {
|
|
4143
|
+
fields: {
|
|
4144
|
+
requestHandler: {
|
|
4145
|
+
type: "string",
|
|
4146
|
+
array: false,
|
|
4147
|
+
readonly: false,
|
|
4148
|
+
optional: true,
|
|
4149
|
+
tags: {}
|
|
4150
|
+
},
|
|
4151
|
+
apiVersion: {
|
|
4152
|
+
type: "string",
|
|
4153
|
+
array: false,
|
|
4154
|
+
readonly: false,
|
|
4155
|
+
optional: true,
|
|
4156
|
+
tags: {}
|
|
4157
|
+
},
|
|
4158
|
+
sha256: {
|
|
4159
|
+
type: "string",
|
|
4160
|
+
array: false,
|
|
4161
|
+
readonly: false,
|
|
4162
|
+
optional: true,
|
|
4163
|
+
tags: {}
|
|
4164
|
+
},
|
|
4165
|
+
urlParser: {
|
|
4166
|
+
type: "string",
|
|
4167
|
+
array: false,
|
|
4168
|
+
readonly: false,
|
|
4169
|
+
optional: true,
|
|
4170
|
+
tags: {}
|
|
4171
|
+
},
|
|
4172
|
+
bodyLengthChecker: {
|
|
4173
|
+
type: "string",
|
|
4174
|
+
array: false,
|
|
4175
|
+
readonly: false,
|
|
4176
|
+
optional: true,
|
|
4177
|
+
tags: {}
|
|
4178
|
+
},
|
|
4179
|
+
streamCollector: {
|
|
4180
|
+
type: "string",
|
|
4181
|
+
array: false,
|
|
4182
|
+
readonly: false,
|
|
4183
|
+
optional: true,
|
|
4184
|
+
tags: {}
|
|
4185
|
+
},
|
|
4186
|
+
base64Decoder: {
|
|
4187
|
+
type: "string",
|
|
4188
|
+
array: false,
|
|
4189
|
+
readonly: false,
|
|
4190
|
+
optional: true,
|
|
4191
|
+
tags: {}
|
|
4192
|
+
},
|
|
4193
|
+
base64Encoder: {
|
|
4194
|
+
type: "string",
|
|
4195
|
+
array: false,
|
|
4196
|
+
readonly: false,
|
|
4197
|
+
optional: true,
|
|
4198
|
+
tags: {}
|
|
4199
|
+
},
|
|
4200
|
+
utf8Decoder: {
|
|
4201
|
+
type: "string",
|
|
4202
|
+
array: false,
|
|
4203
|
+
readonly: false,
|
|
4204
|
+
optional: true,
|
|
4205
|
+
tags: {}
|
|
4206
|
+
},
|
|
4207
|
+
utf8Encoder: {
|
|
4208
|
+
type: "string",
|
|
4209
|
+
array: false,
|
|
4210
|
+
readonly: false,
|
|
4211
|
+
optional: true,
|
|
4212
|
+
tags: {}
|
|
4213
|
+
},
|
|
4214
|
+
runtime: {
|
|
4215
|
+
type: "string",
|
|
4216
|
+
array: false,
|
|
4217
|
+
readonly: false,
|
|
4218
|
+
optional: true,
|
|
4219
|
+
tags: {}
|
|
4220
|
+
},
|
|
4221
|
+
disableHostPrefix: {
|
|
4222
|
+
type: "string",
|
|
4223
|
+
array: false,
|
|
4224
|
+
readonly: false,
|
|
4225
|
+
optional: true,
|
|
4226
|
+
possibleValues: [],
|
|
4227
|
+
tags: {}
|
|
4228
|
+
},
|
|
4229
|
+
serviceId: {
|
|
4230
|
+
type: "string",
|
|
4231
|
+
array: false,
|
|
4232
|
+
readonly: false,
|
|
4233
|
+
optional: true,
|
|
4234
|
+
tags: {}
|
|
4235
|
+
},
|
|
4236
|
+
useDualstackEndpoint: {
|
|
4237
|
+
type: "string",
|
|
4238
|
+
array: false,
|
|
4239
|
+
readonly: false,
|
|
4240
|
+
optional: true,
|
|
4241
|
+
possibleValues: [],
|
|
4242
|
+
tags: {}
|
|
4243
|
+
},
|
|
4244
|
+
useFipsEndpoint: {
|
|
4245
|
+
type: "string",
|
|
4246
|
+
array: false,
|
|
4247
|
+
readonly: false,
|
|
4248
|
+
optional: true,
|
|
4249
|
+
possibleValues: [],
|
|
4250
|
+
tags: {}
|
|
4251
|
+
},
|
|
4252
|
+
region: {
|
|
4253
|
+
type: "string",
|
|
4254
|
+
array: false,
|
|
4255
|
+
readonly: false,
|
|
4256
|
+
optional: true,
|
|
4257
|
+
tags: {}
|
|
4258
|
+
},
|
|
4259
|
+
credentialDefaultProvider: {
|
|
4260
|
+
type: "string",
|
|
4261
|
+
array: false,
|
|
4262
|
+
readonly: false,
|
|
4263
|
+
optional: true,
|
|
4264
|
+
tags: {}
|
|
4265
|
+
},
|
|
4266
|
+
signingEscapePath: {
|
|
4267
|
+
type: "string",
|
|
4268
|
+
array: false,
|
|
4269
|
+
readonly: false,
|
|
4270
|
+
optional: true,
|
|
4271
|
+
possibleValues: [],
|
|
4272
|
+
tags: {}
|
|
4273
|
+
},
|
|
4274
|
+
useArnRegion: {
|
|
4275
|
+
type: "string",
|
|
4276
|
+
array: false,
|
|
4277
|
+
readonly: false,
|
|
4278
|
+
optional: true,
|
|
4279
|
+
possibleValues: [],
|
|
4280
|
+
tags: {}
|
|
4281
|
+
},
|
|
4282
|
+
defaultUserAgentProvider: {
|
|
4283
|
+
type: "string",
|
|
4284
|
+
array: false,
|
|
4285
|
+
readonly: false,
|
|
4286
|
+
optional: true,
|
|
4287
|
+
tags: {}
|
|
4288
|
+
},
|
|
4289
|
+
streamHasher: {
|
|
4290
|
+
type: "string",
|
|
4291
|
+
array: false,
|
|
4292
|
+
readonly: false,
|
|
4293
|
+
optional: true,
|
|
4294
|
+
tags: {}
|
|
4295
|
+
},
|
|
4296
|
+
md5: {
|
|
4297
|
+
type: "string",
|
|
4298
|
+
array: false,
|
|
4299
|
+
readonly: false,
|
|
4300
|
+
optional: true,
|
|
4301
|
+
tags: {}
|
|
4302
|
+
},
|
|
4303
|
+
sha1: {
|
|
4304
|
+
type: "string",
|
|
4305
|
+
array: false,
|
|
4306
|
+
readonly: false,
|
|
4307
|
+
optional: true,
|
|
4308
|
+
tags: {}
|
|
4309
|
+
},
|
|
4310
|
+
getAwsChunkedEncodingStream: {
|
|
4311
|
+
type: "string",
|
|
4312
|
+
array: false,
|
|
4313
|
+
readonly: false,
|
|
4314
|
+
optional: true,
|
|
4315
|
+
tags: {}
|
|
4316
|
+
},
|
|
4317
|
+
maxAttempts: {
|
|
4318
|
+
type: "string",
|
|
4319
|
+
array: false,
|
|
4320
|
+
readonly: false,
|
|
4321
|
+
optional: true,
|
|
4322
|
+
tags: {}
|
|
4323
|
+
},
|
|
4324
|
+
retryMode: {
|
|
4325
|
+
type: "string",
|
|
4326
|
+
array: false,
|
|
4327
|
+
readonly: false,
|
|
4328
|
+
optional: true,
|
|
4329
|
+
tags: {}
|
|
4330
|
+
},
|
|
4331
|
+
logger: {
|
|
4332
|
+
type: "string",
|
|
4333
|
+
array: false,
|
|
4334
|
+
readonly: false,
|
|
4335
|
+
optional: true,
|
|
4336
|
+
possibleValues: [],
|
|
4337
|
+
tags: {}
|
|
4338
|
+
},
|
|
4339
|
+
extensions: {
|
|
4340
|
+
type: "string",
|
|
4341
|
+
array: false,
|
|
4342
|
+
readonly: false,
|
|
4343
|
+
optional: true,
|
|
4344
|
+
tags: {}
|
|
4345
|
+
},
|
|
4346
|
+
eventStreamSerdeProvider: {
|
|
4347
|
+
type: "string",
|
|
4348
|
+
array: false,
|
|
4349
|
+
readonly: false,
|
|
4350
|
+
optional: true,
|
|
4351
|
+
tags: {}
|
|
4352
|
+
},
|
|
4353
|
+
defaultsMode: {
|
|
4354
|
+
type: "string",
|
|
4355
|
+
array: false,
|
|
4356
|
+
readonly: false,
|
|
4357
|
+
optional: true,
|
|
4358
|
+
possibleValues: [
|
|
4359
|
+
"standard",
|
|
4360
|
+
"in-region",
|
|
4361
|
+
"cross-region",
|
|
4362
|
+
"mobile",
|
|
4363
|
+
"auto",
|
|
4364
|
+
"legacy"
|
|
4365
|
+
],
|
|
4366
|
+
tags: {
|
|
4367
|
+
allowCustomSelection: true
|
|
4297
4368
|
}
|
|
4298
|
-
}
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4369
|
+
},
|
|
4370
|
+
sdkStreamMixin: {
|
|
4371
|
+
type: "string",
|
|
4372
|
+
array: false,
|
|
4373
|
+
readonly: false,
|
|
4374
|
+
optional: true,
|
|
4375
|
+
tags: {}
|
|
4376
|
+
},
|
|
4377
|
+
endpoint: {
|
|
4378
|
+
type: "string",
|
|
4379
|
+
array: false,
|
|
4380
|
+
readonly: false,
|
|
4381
|
+
optional: true,
|
|
4382
|
+
possibleValues: [],
|
|
4383
|
+
tags: {}
|
|
4384
|
+
},
|
|
4385
|
+
endpointProvider: {
|
|
4386
|
+
type: "string",
|
|
4387
|
+
array: false,
|
|
4388
|
+
readonly: false,
|
|
4389
|
+
optional: true,
|
|
4390
|
+
tags: {}
|
|
4391
|
+
},
|
|
4392
|
+
tls: {
|
|
4393
|
+
type: "string",
|
|
4394
|
+
array: false,
|
|
4395
|
+
readonly: false,
|
|
4396
|
+
optional: true,
|
|
4397
|
+
possibleValues: [],
|
|
4398
|
+
tags: {}
|
|
4399
|
+
},
|
|
4400
|
+
retryStrategy: {
|
|
4401
|
+
type: "string",
|
|
4402
|
+
array: false,
|
|
4403
|
+
readonly: false,
|
|
4404
|
+
optional: true,
|
|
4405
|
+
possibleValues: [],
|
|
4406
|
+
tags: {}
|
|
4407
|
+
},
|
|
4408
|
+
credentials: {
|
|
4409
|
+
type: "string",
|
|
4410
|
+
array: false,
|
|
4411
|
+
readonly: false,
|
|
4412
|
+
optional: true,
|
|
4413
|
+
possibleValues: [],
|
|
4414
|
+
tags: {}
|
|
4415
|
+
},
|
|
4416
|
+
signer: {
|
|
4417
|
+
type: "string",
|
|
4418
|
+
array: false,
|
|
4419
|
+
readonly: false,
|
|
4420
|
+
optional: true,
|
|
4421
|
+
possibleValues: [],
|
|
4422
|
+
tags: {}
|
|
4423
|
+
},
|
|
4424
|
+
systemClockOffset: {
|
|
4425
|
+
type: "string",
|
|
4426
|
+
array: false,
|
|
4427
|
+
readonly: false,
|
|
4428
|
+
optional: true,
|
|
4429
|
+
tags: {}
|
|
4430
|
+
},
|
|
4431
|
+
signingRegion: {
|
|
4432
|
+
type: "string",
|
|
4433
|
+
array: false,
|
|
4434
|
+
readonly: false,
|
|
4435
|
+
optional: true,
|
|
4436
|
+
tags: {}
|
|
4437
|
+
},
|
|
4438
|
+
signerConstructor: {
|
|
4439
|
+
type: "string",
|
|
4440
|
+
array: false,
|
|
4441
|
+
readonly: false,
|
|
4442
|
+
optional: true,
|
|
4443
|
+
tags: {}
|
|
4444
|
+
},
|
|
4445
|
+
forcePathStyle: {
|
|
4446
|
+
type: "string",
|
|
4447
|
+
array: false,
|
|
4448
|
+
readonly: false,
|
|
4449
|
+
optional: true,
|
|
4450
|
+
possibleValues: [],
|
|
4451
|
+
tags: {}
|
|
4452
|
+
},
|
|
4453
|
+
useAccelerateEndpoint: {
|
|
4454
|
+
type: "string",
|
|
4455
|
+
array: false,
|
|
4456
|
+
readonly: false,
|
|
4457
|
+
optional: true,
|
|
4458
|
+
possibleValues: [],
|
|
4459
|
+
tags: {}
|
|
4460
|
+
},
|
|
4461
|
+
disableMultiregionAccessPoints: {
|
|
4462
|
+
type: "string",
|
|
4463
|
+
array: false,
|
|
4464
|
+
readonly: false,
|
|
4465
|
+
optional: true,
|
|
4466
|
+
possibleValues: [],
|
|
4467
|
+
tags: {}
|
|
4468
|
+
},
|
|
4469
|
+
followRegionRedirects: {
|
|
4470
|
+
type: "string",
|
|
4471
|
+
array: false,
|
|
4472
|
+
readonly: false,
|
|
4473
|
+
optional: true,
|
|
4474
|
+
possibleValues: [],
|
|
4475
|
+
tags: {}
|
|
4476
|
+
},
|
|
4477
|
+
s3ExpressIdentityProvider: {
|
|
4478
|
+
type: "string",
|
|
4479
|
+
array: false,
|
|
4480
|
+
readonly: false,
|
|
4481
|
+
optional: true,
|
|
4482
|
+
tags: {}
|
|
4483
|
+
},
|
|
4484
|
+
customUserAgent: {
|
|
4485
|
+
type: "string",
|
|
4486
|
+
array: false,
|
|
4487
|
+
readonly: false,
|
|
4488
|
+
optional: true,
|
|
4489
|
+
tags: {}
|
|
4490
|
+
},
|
|
4491
|
+
useGlobalEndpoint: {
|
|
4492
|
+
type: "string",
|
|
4493
|
+
array: false,
|
|
4494
|
+
readonly: false,
|
|
4495
|
+
optional: true,
|
|
4496
|
+
possibleValues: [],
|
|
4497
|
+
tags: {}
|
|
4498
|
+
},
|
|
4499
|
+
disableS3ExpressSessionAuth: {
|
|
4500
|
+
type: "string",
|
|
4501
|
+
array: false,
|
|
4502
|
+
readonly: false,
|
|
4503
|
+
optional: true,
|
|
4504
|
+
possibleValues: [],
|
|
4505
|
+
tags: {}
|
|
4318
4506
|
}
|
|
4319
|
-
}
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4507
|
+
},
|
|
4508
|
+
tags: {},
|
|
4509
|
+
primaryField: "requestHandler"
|
|
4510
|
+
},
|
|
4511
|
+
S3SpecificConfig: {
|
|
4512
|
+
fields: {
|
|
4513
|
+
s3Config: {
|
|
4514
|
+
type: "string",
|
|
4515
|
+
array: false,
|
|
4516
|
+
readonly: false,
|
|
4517
|
+
optional: true,
|
|
4518
|
+
typeReference: "AbridgedS3ClientConfig",
|
|
4519
|
+
tags: {}
|
|
4520
|
+
},
|
|
4521
|
+
bucketName: {
|
|
4522
|
+
type: "string",
|
|
4523
|
+
array: false,
|
|
4524
|
+
readonly: false,
|
|
4525
|
+
optional: false,
|
|
4526
|
+
tags: {}
|
|
4527
|
+
},
|
|
4528
|
+
urlExpirationInSeconds: {
|
|
4529
|
+
type: "number",
|
|
4530
|
+
array: false,
|
|
4531
|
+
readonly: false,
|
|
4532
|
+
optional: true,
|
|
4533
|
+
tags: {}
|
|
4323
4534
|
}
|
|
4324
|
-
}
|
|
4535
|
+
},
|
|
4536
|
+
tags: {},
|
|
4537
|
+
primaryField: "s3Config"
|
|
4325
4538
|
}
|
|
4326
|
-
return values;
|
|
4327
4539
|
};
|
|
4328
4540
|
|
|
4329
|
-
// src/
|
|
4330
|
-
var
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
const
|
|
4337
|
-
const
|
|
4338
|
-
|
|
4339
|
-
|
|
4541
|
+
// src/api/ORM/drivers/S3FileItemDBDriver.ts
|
|
4542
|
+
var S3FileItemDBDriver = class {
|
|
4543
|
+
/**
|
|
4544
|
+
* @param config Driver configuration including S3 settings.
|
|
4545
|
+
*/
|
|
4546
|
+
constructor(config) {
|
|
4547
|
+
this.config = config;
|
|
4548
|
+
const { dbSpecificConfig } = config;
|
|
4549
|
+
const { s3Config, bucketName, urlExpirationInSeconds } = dbSpecificConfig;
|
|
4550
|
+
this.specificConfig = dbSpecificConfig;
|
|
4551
|
+
this.s3 = new S3(s3Config);
|
|
4552
|
+
this.s3FileDriver = new S3FileDriver({
|
|
4553
|
+
s3Config,
|
|
4554
|
+
bucketName,
|
|
4555
|
+
urlExpirationInSeconds
|
|
4556
|
+
});
|
|
4557
|
+
}
|
|
4558
|
+
specificConfig;
|
|
4559
|
+
s3;
|
|
4560
|
+
s3FileDriver;
|
|
4561
|
+
/**
|
|
4562
|
+
* Create a new @{@link BaseFileItem}.
|
|
4563
|
+
* @param item New file item payload without the id field.
|
|
4564
|
+
* @returns Generated file id.
|
|
4565
|
+
* */
|
|
4566
|
+
createItem = async (item) => {
|
|
4567
|
+
const { tableName } = this.config;
|
|
4568
|
+
const { bucketName } = this.specificConfig;
|
|
4569
|
+
await this.s3.send(
|
|
4570
|
+
new PutObjectCommand({
|
|
4571
|
+
Bucket: bucketName,
|
|
4572
|
+
Key: getFullFileKey({
|
|
4573
|
+
file: item,
|
|
4574
|
+
// SECURITY: `baseDirectory` is only used internally here, and not as part of the `id`.
|
|
4575
|
+
baseDirectory: tableName
|
|
4576
|
+
}),
|
|
4577
|
+
Body: ""
|
|
4578
|
+
})
|
|
4579
|
+
);
|
|
4580
|
+
return getFullFileKey({
|
|
4581
|
+
file: item
|
|
4582
|
+
});
|
|
4583
|
+
};
|
|
4584
|
+
/**
|
|
4585
|
+
* Read a @{@link BaseFileItem} by its id.
|
|
4586
|
+
* @param id Unique identifier value for the file.
|
|
4587
|
+
* @param selectFields Optional fields to select from the file item.
|
|
4588
|
+
* @returns File item payload (partial when selected fields are used).
|
|
4589
|
+
* */
|
|
4590
|
+
readItem = async (id, selectFields) => {
|
|
4591
|
+
const { tableName } = this.config;
|
|
4592
|
+
const { bucketName } = this.specificConfig;
|
|
4593
|
+
if (typeof id === "undefined") {
|
|
4594
|
+
throw new Error("MISSING_ID" /* MISSING_ID */);
|
|
4595
|
+
} else {
|
|
4596
|
+
const itemLoc = getBaseFileLocationInfo(id);
|
|
4340
4597
|
const {
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
acc[key] = existingFields[key];
|
|
4352
|
-
}
|
|
4353
|
-
return acc;
|
|
4354
|
-
},
|
|
4355
|
-
{}
|
|
4598
|
+
ContentType = "",
|
|
4599
|
+
ContentLength = 0,
|
|
4600
|
+
LastModified} = await this.s3.send(
|
|
4601
|
+
new HeadObjectCommand({
|
|
4602
|
+
Bucket: bucketName,
|
|
4603
|
+
Key: getFullFileKey({
|
|
4604
|
+
file: itemLoc,
|
|
4605
|
+
baseDirectory: tableName
|
|
4606
|
+
})
|
|
4607
|
+
})
|
|
4356
4608
|
);
|
|
4357
|
-
const
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
)
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4609
|
+
const item = {
|
|
4610
|
+
...itemLoc,
|
|
4611
|
+
id,
|
|
4612
|
+
updatedOn: LastModified?.getTime() || 0,
|
|
4613
|
+
mimeType: ContentType,
|
|
4614
|
+
sizeInBytes: ContentLength,
|
|
4615
|
+
isDirectory: ContentType === "application/x-directory",
|
|
4616
|
+
uploadUrl: selectFields && selectFields.includes("uploadUrl") ? await this.s3FileDriver.getFileUploadUrl(itemLoc, tableName) : void 0,
|
|
4617
|
+
downloadUrl: selectFields && selectFields.includes("downloadUrl") ? await this.s3FileDriver.getFileDownloadUrl(itemLoc, tableName) : void 0
|
|
4366
4618
|
};
|
|
4619
|
+
return item;
|
|
4367
4620
|
}
|
|
4368
|
-
}
|
|
4369
|
-
|
|
4370
|
-
}
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
const
|
|
4377
|
-
const
|
|
4378
|
-
const
|
|
4379
|
-
const
|
|
4380
|
-
const
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
return acc;
|
|
4400
|
-
},
|
|
4401
|
-
{}
|
|
4402
|
-
);
|
|
4403
|
-
const cleanUnionFieldSets = existingUnionFieldSets ? existingUnionFieldSets.map(
|
|
4404
|
-
(fieldSet) => fieldSet.filter((field) => !excludeFieldNames.includes(field))
|
|
4405
|
-
) : void 0;
|
|
4406
|
-
typeInfo = {
|
|
4407
|
-
...baseTypeInfo,
|
|
4408
|
-
fields: cleanTypeInfoFields,
|
|
4409
|
-
unionFieldSets: cleanUnionFieldSets
|
|
4410
|
-
};
|
|
4411
|
-
}
|
|
4412
|
-
}
|
|
4413
|
-
}
|
|
4414
|
-
return typeInfo;
|
|
4415
|
-
};
|
|
4416
|
-
var defaultFieldFilterProcessor = (typeNameStr, typeRef, typeMap) => {
|
|
4417
|
-
const refNode = typeNameStr ? typeMap[typeNameStr] : void 0;
|
|
4418
|
-
let typeInfo;
|
|
4419
|
-
if (refNode) {
|
|
4420
|
-
typeInfo = getTypeInfoFromTypeAlias(refNode, typeMap);
|
|
4421
|
-
}
|
|
4422
|
-
return typeInfo;
|
|
4423
|
-
};
|
|
4424
|
-
var FIELD_FILTER_PROCESSORS = {
|
|
4425
|
-
[FIELD_FILTERS.PICK]: getTypeInfoFromPickOmitFieldFilters,
|
|
4426
|
-
[FIELD_FILTERS.OMIT]: getTypeInfoFromPickOmitFieldFilters,
|
|
4427
|
-
[FIELD_FILTERS.EXCLUDE]: getTypeInfoFromExcludeFieldFilter
|
|
4428
|
-
};
|
|
4429
|
-
var getTypeInfoFromFieldFilter = (typeNameStr, typeRef, typeMap) => {
|
|
4430
|
-
const processor = typeNameStr ? FIELD_FILTER_PROCESSORS[typeNameStr] : void 0;
|
|
4431
|
-
return processor ? processor(typeNameStr, typeRef, typeMap) : defaultFieldFilterProcessor(typeNameStr, typeRef, typeMap);
|
|
4432
|
-
};
|
|
4433
|
-
|
|
4434
|
-
// src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.ts
|
|
4435
|
-
var getTypeInfoFromTypeLiteral = (type) => getTypeInfo(type);
|
|
4436
|
-
var getTypeInfoFromUnionOrIntersectionType = (type, typeMap) => getUnionOrIntersectionTypeInfo(type, typeMap);
|
|
4437
|
-
var getTypeInfoFromTypeReference = (type, typeMap) => {
|
|
4438
|
-
const typeRef = type;
|
|
4439
|
-
const { typeName } = typeRef;
|
|
4440
|
-
const typeNameStr = typeName.getText();
|
|
4441
|
-
return getTypeInfoFromFieldFilter(typeNameStr, typeRef, typeMap);
|
|
4442
|
-
};
|
|
4443
|
-
var ALIAS_TYPE_PROCESSORS = {
|
|
4444
|
-
[SyntaxKind.TypeLiteral]: getTypeInfoFromTypeLiteral,
|
|
4445
|
-
[SyntaxKind.UnionType]: getTypeInfoFromUnionOrIntersectionType,
|
|
4446
|
-
[SyntaxKind.IntersectionType]: getTypeInfoFromUnionOrIntersectionType,
|
|
4447
|
-
[SyntaxKind.TypeReference]: getTypeInfoFromTypeReference
|
|
4448
|
-
};
|
|
4449
|
-
var getTypeInfoFromAliasType = (type, typeMap) => {
|
|
4450
|
-
const { kind } = type;
|
|
4451
|
-
const processor = ALIAS_TYPE_PROCESSORS[kind];
|
|
4452
|
-
const typeInfo = processor ? processor(type, typeMap) : void 0;
|
|
4453
|
-
return typeInfo;
|
|
4454
|
-
};
|
|
4455
|
-
|
|
4456
|
-
// src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.ts
|
|
4457
|
-
var getTypeInfoFromTypeAlias = (typeAliasDec, typeMap) => {
|
|
4458
|
-
const { type } = typeAliasDec;
|
|
4459
|
-
const tags = extractCommentTags(typeAliasDec);
|
|
4460
|
-
const typeInfo = getTypeInfoFromAliasType(type, typeMap);
|
|
4461
|
-
return typeInfo ? {
|
|
4462
|
-
...typeInfo,
|
|
4463
|
-
tags: {
|
|
4464
|
-
...tags,
|
|
4465
|
-
...typeInfo.tags
|
|
4466
|
-
}
|
|
4467
|
-
} : void 0;
|
|
4468
|
-
};
|
|
4469
|
-
|
|
4470
|
-
// src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.ts
|
|
4471
|
-
var getPrimaryFieldForTypeInfo = (typeInfo) => {
|
|
4472
|
-
const { fields } = typeInfo;
|
|
4473
|
-
let primaryField = void 0, primaryFieldReadDenied = false;
|
|
4474
|
-
for (const fieldName in fields) {
|
|
4475
|
-
const field = fields[fieldName];
|
|
4476
|
-
const {
|
|
4477
|
-
tags: {
|
|
4478
|
-
primaryField: isPrimaryField = false,
|
|
4479
|
-
deniedOperations: { READ: readDenied = false } = {}
|
|
4480
|
-
} = {}
|
|
4481
|
-
} = field;
|
|
4482
|
-
if (isPrimaryField || !primaryField) {
|
|
4483
|
-
primaryField = fieldName;
|
|
4484
|
-
primaryFieldReadDenied = readDenied;
|
|
4621
|
+
};
|
|
4622
|
+
/**
|
|
4623
|
+
* Update a @{@link BaseFileItem}.
|
|
4624
|
+
* @param uniqueIdentifier Unique identifier value for the file.
|
|
4625
|
+
* @param item Partial update payload for the file.
|
|
4626
|
+
* @returns True when the item was updated.
|
|
4627
|
+
* */
|
|
4628
|
+
updateItem = async (uniqueIdentifier, item) => {
|
|
4629
|
+
const { directory, name } = item;
|
|
4630
|
+
const { tableName } = this.config;
|
|
4631
|
+
const { bucketName } = this.specificConfig;
|
|
4632
|
+
const oldItemLoc = getBaseFileLocationInfo(uniqueIdentifier);
|
|
4633
|
+
const { name: oldName, directory: oldDirectory } = oldItemLoc;
|
|
4634
|
+
if (name && (name !== oldName || directory !== oldDirectory)) {
|
|
4635
|
+
await this.s3.send(
|
|
4636
|
+
new CopyObjectCommand({
|
|
4637
|
+
Bucket: bucketName,
|
|
4638
|
+
Key: getFullFileKey({
|
|
4639
|
+
file: {
|
|
4640
|
+
directory,
|
|
4641
|
+
name
|
|
4642
|
+
},
|
|
4643
|
+
baseDirectory: tableName
|
|
4644
|
+
}),
|
|
4645
|
+
CopySource: getFullFileKey({
|
|
4646
|
+
file: oldItemLoc,
|
|
4647
|
+
baseDirectory: tableName
|
|
4648
|
+
})
|
|
4649
|
+
})
|
|
4650
|
+
);
|
|
4651
|
+
await this.s3FileDriver.deleteFile(oldItemLoc, tableName);
|
|
4485
4652
|
}
|
|
4486
|
-
|
|
4487
|
-
|
|
4653
|
+
await this.readItem(uniqueIdentifier);
|
|
4654
|
+
return true;
|
|
4655
|
+
};
|
|
4656
|
+
/**
|
|
4657
|
+
* Delete a @{@link BaseFileItem} by its id.
|
|
4658
|
+
* @param id Unique identifier value for the file.
|
|
4659
|
+
* @returns True when the item was deleted.
|
|
4660
|
+
*/
|
|
4661
|
+
deleteItem = async (id) => {
|
|
4662
|
+
const { tableName } = this.config;
|
|
4663
|
+
if (typeof id === "undefined") {
|
|
4664
|
+
throw new Error("MISSING_ID" /* MISSING_ID */);
|
|
4665
|
+
} else {
|
|
4666
|
+
await this.readItem(id);
|
|
4667
|
+
await this.s3FileDriver.deleteFile(
|
|
4668
|
+
getBaseFileLocationInfo(id),
|
|
4669
|
+
tableName
|
|
4670
|
+
);
|
|
4488
4671
|
}
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4672
|
+
return true;
|
|
4673
|
+
};
|
|
4674
|
+
/**
|
|
4675
|
+
* List @{@link BaseFileItem}s by a given criteria.
|
|
4676
|
+
* @param config List configuration and criteria.
|
|
4677
|
+
* @param selectFields Optional fields to select from each file item.
|
|
4678
|
+
* @returns List results with items and cursor.
|
|
4679
|
+
*/
|
|
4680
|
+
listItems = async (config, selectFields) => {
|
|
4681
|
+
const { tableName } = this.config;
|
|
4682
|
+
const {
|
|
4683
|
+
itemsPerPage = Infinity,
|
|
4684
|
+
cursor,
|
|
4685
|
+
sortFields = [],
|
|
4686
|
+
criteria
|
|
4687
|
+
} = config;
|
|
4688
|
+
const { files: baseFileList = [], cursor: newCursor } = await this.s3FileDriver.listFiles(
|
|
4689
|
+
void 0,
|
|
4690
|
+
tableName,
|
|
4691
|
+
itemsPerPage,
|
|
4692
|
+
cursor
|
|
4493
4693
|
);
|
|
4694
|
+
const currentFileItems = baseFileList.map((bF) => ({
|
|
4695
|
+
id: getFullFileKey({
|
|
4696
|
+
file: bF
|
|
4697
|
+
}),
|
|
4698
|
+
...bF
|
|
4699
|
+
}));
|
|
4700
|
+
const filteredFiles = criteria ? getFilterTypeInfoDataItemsBySearchCriteria(
|
|
4701
|
+
criteria,
|
|
4702
|
+
currentFileItems
|
|
4703
|
+
) : currentFileItems;
|
|
4704
|
+
const expandedFiles = [];
|
|
4705
|
+
for (const fF of filteredFiles) {
|
|
4706
|
+
expandedFiles.push({
|
|
4707
|
+
...fF,
|
|
4708
|
+
uploadUrl: selectFields?.includes("uploadUrl") ? await this.s3FileDriver.getFileUploadUrl(fF, tableName) : void 0,
|
|
4709
|
+
downloadUrl: selectFields?.includes("downloadUrl") ? await this.s3FileDriver.getFileDownloadUrl(fF, tableName) : void 0
|
|
4710
|
+
});
|
|
4711
|
+
}
|
|
4712
|
+
return {
|
|
4713
|
+
items: getSortedItems(
|
|
4714
|
+
sortFields,
|
|
4715
|
+
expandedFiles
|
|
4716
|
+
),
|
|
4717
|
+
cursor: newCursor
|
|
4718
|
+
};
|
|
4719
|
+
};
|
|
4720
|
+
};
|
|
4721
|
+
var S3SupportedFileItemDBDriverEntry = {
|
|
4722
|
+
/**
|
|
4723
|
+
* @param config Driver configuration.
|
|
4724
|
+
* @returns S3 file driver instance.
|
|
4725
|
+
*/
|
|
4726
|
+
factory: (config) => {
|
|
4727
|
+
return new S3FileItemDBDriver(config);
|
|
4728
|
+
},
|
|
4729
|
+
/**
|
|
4730
|
+
* @returns Type info pack for the S3 config.
|
|
4731
|
+
*/
|
|
4732
|
+
getDBSpecificConfigTypeInfo: () => {
|
|
4733
|
+
return {
|
|
4734
|
+
entryTypeName: "S3SpecificConfig",
|
|
4735
|
+
typeInfoMap: ConfigTypeInfoMap_default
|
|
4736
|
+
};
|
|
4494
4737
|
}
|
|
4495
|
-
return primaryField;
|
|
4496
4738
|
};
|
|
4497
4739
|
|
|
4498
|
-
// src/
|
|
4499
|
-
var
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4740
|
+
// src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypeInfoMap.json
|
|
4741
|
+
var ConfigTypeInfoMap_default2 = {
|
|
4742
|
+
Logger: {
|
|
4743
|
+
fields: {
|
|
4744
|
+
trace: {
|
|
4745
|
+
type: "string",
|
|
4746
|
+
array: false,
|
|
4747
|
+
readonly: false,
|
|
4748
|
+
optional: true,
|
|
4749
|
+
possibleValues: [],
|
|
4750
|
+
tags: {}
|
|
4751
|
+
},
|
|
4752
|
+
debug: {
|
|
4753
|
+
type: "string",
|
|
4754
|
+
array: false,
|
|
4755
|
+
readonly: false,
|
|
4756
|
+
optional: false,
|
|
4757
|
+
typeReference: "Trace",
|
|
4758
|
+
tags: {}
|
|
4759
|
+
},
|
|
4760
|
+
info: {
|
|
4761
|
+
type: "string",
|
|
4762
|
+
array: false,
|
|
4763
|
+
readonly: false,
|
|
4764
|
+
optional: false,
|
|
4765
|
+
typeReference: "Trace",
|
|
4766
|
+
tags: {}
|
|
4767
|
+
},
|
|
4768
|
+
warn: {
|
|
4769
|
+
type: "string",
|
|
4770
|
+
array: false,
|
|
4771
|
+
readonly: false,
|
|
4772
|
+
optional: false,
|
|
4773
|
+
typeReference: "Trace",
|
|
4774
|
+
tags: {}
|
|
4775
|
+
},
|
|
4776
|
+
error: {
|
|
4777
|
+
type: "string",
|
|
4778
|
+
array: false,
|
|
4779
|
+
readonly: false,
|
|
4780
|
+
optional: false,
|
|
4781
|
+
typeReference: "Trace",
|
|
4782
|
+
tags: {}
|
|
4783
|
+
}
|
|
4784
|
+
},
|
|
4785
|
+
tags: {},
|
|
4786
|
+
primaryField: "trace"
|
|
4787
|
+
},
|
|
4788
|
+
Endpoint: {
|
|
4789
|
+
fields: {
|
|
4790
|
+
protocol: {
|
|
4791
|
+
type: "string",
|
|
4792
|
+
array: false,
|
|
4793
|
+
readonly: false,
|
|
4794
|
+
optional: false,
|
|
4795
|
+
tags: {}
|
|
4796
|
+
},
|
|
4797
|
+
hostname: {
|
|
4798
|
+
type: "string",
|
|
4799
|
+
array: false,
|
|
4800
|
+
readonly: false,
|
|
4801
|
+
optional: false,
|
|
4802
|
+
tags: {}
|
|
4803
|
+
},
|
|
4804
|
+
port: {
|
|
4805
|
+
type: "string",
|
|
4806
|
+
array: false,
|
|
4807
|
+
readonly: false,
|
|
4808
|
+
optional: true,
|
|
4809
|
+
tags: {}
|
|
4810
|
+
},
|
|
4811
|
+
path: {
|
|
4812
|
+
type: "string",
|
|
4813
|
+
array: false,
|
|
4814
|
+
readonly: false,
|
|
4815
|
+
optional: false,
|
|
4816
|
+
tags: {}
|
|
4817
|
+
},
|
|
4818
|
+
query: {
|
|
4819
|
+
type: "string",
|
|
4820
|
+
array: false,
|
|
4821
|
+
readonly: false,
|
|
4822
|
+
optional: true,
|
|
4823
|
+
tags: {}
|
|
4824
|
+
}
|
|
4825
|
+
},
|
|
4826
|
+
tags: {},
|
|
4827
|
+
primaryField: "protocol"
|
|
4828
|
+
},
|
|
4829
|
+
RetryStrategy: {
|
|
4830
|
+
fields: {
|
|
4831
|
+
mode: {
|
|
4832
|
+
type: "string",
|
|
4833
|
+
array: false,
|
|
4834
|
+
readonly: false,
|
|
4835
|
+
optional: true,
|
|
4836
|
+
tags: {}
|
|
4837
|
+
},
|
|
4838
|
+
retry: {
|
|
4839
|
+
type: "string",
|
|
4840
|
+
array: false,
|
|
4841
|
+
readonly: false,
|
|
4842
|
+
optional: false,
|
|
4843
|
+
tags: {}
|
|
4844
|
+
}
|
|
4845
|
+
},
|
|
4846
|
+
tags: {},
|
|
4847
|
+
primaryField: "mode"
|
|
4848
|
+
},
|
|
4849
|
+
DynamoDBSpecificConfig: {
|
|
4850
|
+
fields: {
|
|
4851
|
+
requestHandler: {
|
|
4852
|
+
type: "string",
|
|
4853
|
+
array: false,
|
|
4854
|
+
readonly: false,
|
|
4855
|
+
optional: true,
|
|
4856
|
+
tags: {}
|
|
4857
|
+
},
|
|
4858
|
+
apiVersion: {
|
|
4859
|
+
type: "string",
|
|
4860
|
+
array: false,
|
|
4861
|
+
readonly: false,
|
|
4862
|
+
optional: true,
|
|
4863
|
+
tags: {}
|
|
4864
|
+
},
|
|
4865
|
+
sha256: {
|
|
4866
|
+
type: "string",
|
|
4867
|
+
array: false,
|
|
4868
|
+
readonly: false,
|
|
4869
|
+
optional: true,
|
|
4870
|
+
tags: {}
|
|
4871
|
+
},
|
|
4872
|
+
urlParser: {
|
|
4873
|
+
type: "string",
|
|
4874
|
+
array: false,
|
|
4875
|
+
readonly: false,
|
|
4876
|
+
optional: true,
|
|
4877
|
+
tags: {}
|
|
4878
|
+
},
|
|
4879
|
+
bodyLengthChecker: {
|
|
4880
|
+
type: "string",
|
|
4881
|
+
array: false,
|
|
4882
|
+
readonly: false,
|
|
4883
|
+
optional: true,
|
|
4884
|
+
tags: {}
|
|
4885
|
+
},
|
|
4886
|
+
streamCollector: {
|
|
4887
|
+
type: "string",
|
|
4888
|
+
array: false,
|
|
4889
|
+
readonly: false,
|
|
4890
|
+
optional: true,
|
|
4891
|
+
tags: {}
|
|
4892
|
+
},
|
|
4893
|
+
base64Decoder: {
|
|
4894
|
+
type: "string",
|
|
4895
|
+
array: false,
|
|
4896
|
+
readonly: false,
|
|
4897
|
+
optional: true,
|
|
4898
|
+
tags: {}
|
|
4899
|
+
},
|
|
4900
|
+
base64Encoder: {
|
|
4901
|
+
type: "string",
|
|
4902
|
+
array: false,
|
|
4903
|
+
readonly: false,
|
|
4904
|
+
optional: true,
|
|
4905
|
+
tags: {}
|
|
4906
|
+
},
|
|
4907
|
+
utf8Decoder: {
|
|
4908
|
+
type: "string",
|
|
4909
|
+
array: false,
|
|
4910
|
+
readonly: false,
|
|
4911
|
+
optional: true,
|
|
4912
|
+
tags: {}
|
|
4913
|
+
},
|
|
4914
|
+
utf8Encoder: {
|
|
4915
|
+
type: "string",
|
|
4916
|
+
array: false,
|
|
4917
|
+
readonly: false,
|
|
4918
|
+
optional: true,
|
|
4919
|
+
tags: {}
|
|
4920
|
+
},
|
|
4921
|
+
runtime: {
|
|
4922
|
+
type: "string",
|
|
4923
|
+
array: false,
|
|
4924
|
+
readonly: false,
|
|
4925
|
+
optional: true,
|
|
4926
|
+
tags: {}
|
|
4927
|
+
},
|
|
4928
|
+
disableHostPrefix: {
|
|
4929
|
+
type: "string",
|
|
4930
|
+
array: false,
|
|
4931
|
+
readonly: false,
|
|
4932
|
+
optional: true,
|
|
4933
|
+
possibleValues: [],
|
|
4934
|
+
tags: {}
|
|
4935
|
+
},
|
|
4936
|
+
serviceId: {
|
|
4937
|
+
type: "string",
|
|
4938
|
+
array: false,
|
|
4939
|
+
readonly: false,
|
|
4940
|
+
optional: true,
|
|
4941
|
+
tags: {}
|
|
4942
|
+
},
|
|
4943
|
+
useDualstackEndpoint: {
|
|
4944
|
+
type: "string",
|
|
4945
|
+
array: false,
|
|
4946
|
+
readonly: false,
|
|
4947
|
+
optional: true,
|
|
4948
|
+
possibleValues: [],
|
|
4949
|
+
tags: {}
|
|
4950
|
+
},
|
|
4951
|
+
useFipsEndpoint: {
|
|
4952
|
+
type: "string",
|
|
4953
|
+
array: false,
|
|
4954
|
+
readonly: false,
|
|
4955
|
+
optional: true,
|
|
4956
|
+
possibleValues: [],
|
|
4957
|
+
tags: {}
|
|
4958
|
+
},
|
|
4959
|
+
defaultUserAgentProvider: {
|
|
4960
|
+
type: "string",
|
|
4961
|
+
array: false,
|
|
4962
|
+
readonly: false,
|
|
4963
|
+
optional: true,
|
|
4964
|
+
tags: {}
|
|
4965
|
+
},
|
|
4966
|
+
region: {
|
|
4967
|
+
type: "string",
|
|
4968
|
+
array: false,
|
|
4969
|
+
readonly: false,
|
|
4970
|
+
optional: true,
|
|
4971
|
+
tags: {}
|
|
4972
|
+
},
|
|
4973
|
+
credentialDefaultProvider: {
|
|
4974
|
+
type: "string",
|
|
4975
|
+
array: false,
|
|
4976
|
+
readonly: false,
|
|
4977
|
+
optional: true,
|
|
4978
|
+
tags: {}
|
|
4979
|
+
},
|
|
4980
|
+
maxAttempts: {
|
|
4981
|
+
type: "string",
|
|
4982
|
+
array: false,
|
|
4983
|
+
readonly: false,
|
|
4984
|
+
optional: true,
|
|
4985
|
+
tags: {}
|
|
4986
|
+
},
|
|
4987
|
+
retryMode: {
|
|
4988
|
+
type: "string",
|
|
4989
|
+
array: false,
|
|
4990
|
+
readonly: false,
|
|
4991
|
+
optional: true,
|
|
4992
|
+
tags: {}
|
|
4993
|
+
},
|
|
4994
|
+
logger: {
|
|
4995
|
+
type: "string",
|
|
4996
|
+
array: false,
|
|
4997
|
+
readonly: false,
|
|
4998
|
+
optional: true,
|
|
4999
|
+
possibleValues: [],
|
|
5000
|
+
tags: {}
|
|
5001
|
+
},
|
|
5002
|
+
extensions: {
|
|
5003
|
+
type: "string",
|
|
5004
|
+
array: false,
|
|
5005
|
+
readonly: false,
|
|
5006
|
+
optional: true,
|
|
5007
|
+
tags: {}
|
|
5008
|
+
},
|
|
5009
|
+
defaultsMode: {
|
|
5010
|
+
type: "string",
|
|
5011
|
+
array: false,
|
|
5012
|
+
readonly: false,
|
|
5013
|
+
optional: true,
|
|
5014
|
+
possibleValues: [
|
|
5015
|
+
"standard",
|
|
5016
|
+
"in-region",
|
|
5017
|
+
"cross-region",
|
|
5018
|
+
"mobile",
|
|
5019
|
+
"auto",
|
|
5020
|
+
"legacy"
|
|
5021
|
+
],
|
|
5022
|
+
tags: {
|
|
5023
|
+
allowCustomSelection: true
|
|
4517
5024
|
}
|
|
4518
|
-
}
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
5025
|
+
},
|
|
5026
|
+
endpointDiscoveryEnabledProvider: {
|
|
5027
|
+
type: "string",
|
|
5028
|
+
array: false,
|
|
5029
|
+
readonly: false,
|
|
5030
|
+
optional: true,
|
|
5031
|
+
tags: {}
|
|
5032
|
+
},
|
|
5033
|
+
endpoint: {
|
|
5034
|
+
type: "string",
|
|
5035
|
+
array: false,
|
|
5036
|
+
readonly: false,
|
|
5037
|
+
optional: true,
|
|
5038
|
+
possibleValues: [],
|
|
5039
|
+
tags: {}
|
|
5040
|
+
},
|
|
5041
|
+
endpointProvider: {
|
|
5042
|
+
type: "string",
|
|
5043
|
+
array: false,
|
|
5044
|
+
readonly: false,
|
|
5045
|
+
optional: true,
|
|
5046
|
+
tags: {}
|
|
5047
|
+
},
|
|
5048
|
+
tls: {
|
|
5049
|
+
type: "string",
|
|
5050
|
+
array: false,
|
|
5051
|
+
readonly: false,
|
|
5052
|
+
optional: true,
|
|
5053
|
+
possibleValues: [],
|
|
5054
|
+
tags: {}
|
|
5055
|
+
},
|
|
5056
|
+
retryStrategy: {
|
|
5057
|
+
type: "string",
|
|
5058
|
+
array: false,
|
|
5059
|
+
readonly: false,
|
|
5060
|
+
optional: true,
|
|
5061
|
+
possibleValues: [],
|
|
5062
|
+
tags: {}
|
|
5063
|
+
},
|
|
5064
|
+
customUserAgent: {
|
|
5065
|
+
type: "string",
|
|
5066
|
+
array: false,
|
|
5067
|
+
readonly: false,
|
|
5068
|
+
optional: true,
|
|
5069
|
+
tags: {}
|
|
5070
|
+
},
|
|
5071
|
+
httpAuthSchemes: {
|
|
5072
|
+
type: "string",
|
|
5073
|
+
array: false,
|
|
5074
|
+
readonly: false,
|
|
5075
|
+
optional: true,
|
|
5076
|
+
tags: {}
|
|
5077
|
+
},
|
|
5078
|
+
httpAuthSchemeProvider: {
|
|
5079
|
+
type: "string",
|
|
5080
|
+
array: false,
|
|
5081
|
+
readonly: false,
|
|
5082
|
+
optional: true,
|
|
5083
|
+
tags: {}
|
|
5084
|
+
},
|
|
5085
|
+
credentials: {
|
|
5086
|
+
type: "string",
|
|
5087
|
+
array: false,
|
|
5088
|
+
readonly: false,
|
|
5089
|
+
optional: true,
|
|
5090
|
+
tags: {}
|
|
5091
|
+
},
|
|
5092
|
+
signer: {
|
|
5093
|
+
type: "string",
|
|
5094
|
+
array: false,
|
|
5095
|
+
readonly: false,
|
|
5096
|
+
optional: true,
|
|
5097
|
+
tags: {}
|
|
5098
|
+
},
|
|
5099
|
+
signingEscapePath: {
|
|
5100
|
+
type: "string",
|
|
5101
|
+
array: false,
|
|
5102
|
+
readonly: false,
|
|
5103
|
+
optional: true,
|
|
5104
|
+
possibleValues: [],
|
|
5105
|
+
tags: {}
|
|
5106
|
+
},
|
|
5107
|
+
systemClockOffset: {
|
|
5108
|
+
type: "string",
|
|
5109
|
+
array: false,
|
|
5110
|
+
readonly: false,
|
|
5111
|
+
optional: true,
|
|
5112
|
+
tags: {}
|
|
5113
|
+
},
|
|
5114
|
+
signingRegion: {
|
|
5115
|
+
type: "string",
|
|
5116
|
+
array: false,
|
|
5117
|
+
readonly: false,
|
|
5118
|
+
optional: true,
|
|
5119
|
+
tags: {}
|
|
5120
|
+
},
|
|
5121
|
+
signerConstructor: {
|
|
5122
|
+
type: "string",
|
|
5123
|
+
array: false,
|
|
5124
|
+
readonly: false,
|
|
5125
|
+
optional: true,
|
|
5126
|
+
tags: {}
|
|
5127
|
+
},
|
|
5128
|
+
endpointCacheSize: {
|
|
5129
|
+
type: "string",
|
|
5130
|
+
array: false,
|
|
5131
|
+
readonly: false,
|
|
5132
|
+
optional: true,
|
|
5133
|
+
tags: {}
|
|
5134
|
+
},
|
|
5135
|
+
endpointDiscoveryEnabled: {
|
|
5136
|
+
type: "string",
|
|
5137
|
+
array: false,
|
|
5138
|
+
readonly: false,
|
|
5139
|
+
optional: true,
|
|
5140
|
+
possibleValues: [],
|
|
5141
|
+
tags: {}
|
|
4527
5142
|
}
|
|
4528
|
-
}
|
|
5143
|
+
},
|
|
5144
|
+
tags: {},
|
|
5145
|
+
primaryField: "requestHandler"
|
|
4529
5146
|
}
|
|
4530
|
-
return typeInfoMap;
|
|
4531
5147
|
};
|
|
4532
5148
|
|
|
4533
|
-
// src/
|
|
4534
|
-
|
|
4535
|
-
var
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
}
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
}
|
|
4551
|
-
var DENIED_TYPE_OPERATIONS = {
|
|
4552
|
-
CREATE: "DENIED_TYPE_OPERATION_CREATE",
|
|
4553
|
-
READ: "DENIED_TYPE_OPERATION_READ",
|
|
4554
|
-
UPDATE: "DENIED_TYPE_OPERATION_UPDATE",
|
|
4555
|
-
DELETE: "DENIED_TYPE_OPERATION_DELETE"
|
|
5149
|
+
// src/api/ORM/drivers/DynamoDBDataItemDBDriver.ts
|
|
5150
|
+
typeof __dirname === "string" ? __dirname : Path.dirname(fileURLToPath(import.meta.url));
|
|
5151
|
+
var DynamoDBOperatorMappings = {
|
|
5152
|
+
["EQUALS" /* EQUALS */]: (fieldName) => `#${fieldName} = :${fieldName}`,
|
|
5153
|
+
["NOT_EQUALS" /* NOT_EQUALS */]: (fieldName) => `#${fieldName} <> :${fieldName}`,
|
|
5154
|
+
["GREATER_THAN" /* GREATER_THAN */]: (fieldName) => `#${fieldName} > :${fieldName}`,
|
|
5155
|
+
["GREATER_THAN_OR_EQUAL" /* GREATER_THAN_OR_EQUAL */]: (fieldName) => `#${fieldName} >= :${fieldName}`,
|
|
5156
|
+
["LESS_THAN" /* LESS_THAN */]: (fieldName) => `#${fieldName} < :${fieldName}`,
|
|
5157
|
+
["LESS_THAN_OR_EQUAL" /* LESS_THAN_OR_EQUAL */]: (fieldName) => `#${fieldName} <= :${fieldName}`,
|
|
5158
|
+
["IN" /* IN */]: (fieldName) => `#${fieldName} IN (:${fieldName})`,
|
|
5159
|
+
["LIKE" /* LIKE */]: (fieldName) => `contains(#${fieldName}, :${fieldName})`,
|
|
5160
|
+
["EXISTS" /* EXISTS */]: (fieldName) => `attribute_exists(#${fieldName})`,
|
|
5161
|
+
["NOT_EXISTS" /* NOT_EXISTS */]: (fieldName) => `attribute_not_exists(#${fieldName})`,
|
|
5162
|
+
["IS_EMPTY" /* IS_EMPTY */]: (fieldName) => `size(#${fieldName}) = 0`,
|
|
5163
|
+
["IS_NOT_EMPTY" /* IS_NOT_EMPTY */]: (fieldName) => `size(#${fieldName}) > 0`,
|
|
5164
|
+
["BETWEEN" /* BETWEEN */]: (fieldName) => `#${fieldName} BETWEEN :${fieldName}_start AND :${fieldName}_end`,
|
|
5165
|
+
["CONTAINS" /* CONTAINS */]: (fieldName) => `contains(#${fieldName}, :${fieldName})`,
|
|
5166
|
+
["STARTS_WITH" /* STARTS_WITH */]: (fieldName) => `begins_with(#${fieldName}, :${fieldName})`
|
|
4556
5167
|
};
|
|
4557
|
-
var
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
valid: true,
|
|
4561
|
-
error: "",
|
|
4562
|
-
errorMap: {}
|
|
4563
|
-
};
|
|
4564
|
-
{
|
|
4565
|
-
try {
|
|
4566
|
-
const regex = new RegExp(pattern);
|
|
4567
|
-
const testResult = typeof value === "string" && regex.test(value);
|
|
4568
|
-
if (!testResult) {
|
|
4569
|
-
results.valid = false;
|
|
4570
|
-
results.error = ERROR_MESSAGE_CONSTANTS.VALUE_DOES_NOT_MATCH_PATTERN;
|
|
4571
|
-
}
|
|
4572
|
-
} catch (e) {
|
|
4573
|
-
results.valid = false;
|
|
4574
|
-
results.error = ERROR_MESSAGE_CONSTANTS.INVALID_PATTERN;
|
|
4575
|
-
}
|
|
4576
|
-
}
|
|
4577
|
-
return results;
|
|
5168
|
+
var DynamoDBLogicalOperatorMappings = {
|
|
5169
|
+
["AND" /* AND */]: "AND",
|
|
5170
|
+
["OR" /* OR */]: "OR"
|
|
4578
5171
|
};
|
|
4579
|
-
var
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
};
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
};
|
|
4594
|
-
var validateCustomType = (value, customType, customValidators) => {
|
|
4595
|
-
let valid = true;
|
|
4596
|
-
if (customValidators && customType) {
|
|
4597
|
-
const validator = customValidators[customType];
|
|
4598
|
-
if (validator) {
|
|
4599
|
-
try {
|
|
4600
|
-
valid = validator(value);
|
|
4601
|
-
} catch (e) {
|
|
4602
|
-
valid = false;
|
|
5172
|
+
var createFilterExpression = (fieldCriteria, logicalOperator) => {
|
|
5173
|
+
let output = {};
|
|
5174
|
+
if (fieldCriteria && fieldCriteria.length > 0) {
|
|
5175
|
+
const expressions = [];
|
|
5176
|
+
const attributeNames = {};
|
|
5177
|
+
const attributeValues = {};
|
|
5178
|
+
for (const criterion of fieldCriteria) {
|
|
5179
|
+
const { fieldName, operator, value } = criterion;
|
|
5180
|
+
const createExpression = DynamoDBOperatorMappings[operator];
|
|
5181
|
+
if (!createExpression) {
|
|
5182
|
+
throw {
|
|
5183
|
+
message: "SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED" /* SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED */,
|
|
5184
|
+
operator,
|
|
5185
|
+
fieldName
|
|
5186
|
+
};
|
|
4603
5187
|
}
|
|
5188
|
+
expressions.push(createExpression(fieldName));
|
|
5189
|
+
attributeNames[`#${fieldName}`] = fieldName;
|
|
5190
|
+
attributeValues[`:${fieldName}`] = value;
|
|
4604
5191
|
}
|
|
5192
|
+
output = {
|
|
5193
|
+
FilterExpression: expressions.join(
|
|
5194
|
+
` ${DynamoDBLogicalOperatorMappings[logicalOperator]} `
|
|
5195
|
+
),
|
|
5196
|
+
ExpressionAttributeNames: attributeNames,
|
|
5197
|
+
ExpressionAttributeValues: marshall(attributeValues)
|
|
5198
|
+
};
|
|
4605
5199
|
}
|
|
4606
|
-
return
|
|
5200
|
+
return output;
|
|
4607
5201
|
};
|
|
4608
|
-
var
|
|
4609
|
-
const
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
error: "",
|
|
4621
|
-
errorMap: {}
|
|
4622
|
-
};
|
|
4623
|
-
const requiredValueAllowed = !typeReference || relationshipValidationType === "INCLUDE" /* INCLUDE */;
|
|
4624
|
-
if (requiredValueAllowed && !itemIsPartial && !optional && !hasValue(value)) {
|
|
4625
|
-
results.valid = false;
|
|
4626
|
-
results.error = ERROR_MESSAGE_CONSTANTS.MISSING;
|
|
4627
|
-
} else if (array && !ignoreArray) {
|
|
4628
|
-
const {
|
|
4629
|
-
valid: validArray,
|
|
4630
|
-
error: arrayError,
|
|
4631
|
-
errorMap: arrayErrorMap
|
|
4632
|
-
} = validateArrayOfTypeInfoFieldValues(
|
|
4633
|
-
value,
|
|
4634
|
-
typeInfoField,
|
|
4635
|
-
typeInfoMap,
|
|
4636
|
-
strict,
|
|
4637
|
-
customValidators,
|
|
4638
|
-
typeOperation,
|
|
4639
|
-
relationshipValidationType,
|
|
4640
|
-
itemIsPartial
|
|
4641
|
-
);
|
|
4642
|
-
results.valid = getValidityValue(results.valid, validArray);
|
|
4643
|
-
results.error = arrayError;
|
|
4644
|
-
results.errorMap = arrayErrorMap;
|
|
4645
|
-
} else {
|
|
4646
|
-
if (typeReference) {
|
|
4647
|
-
if (relationshipValidationType === "INCLUDE" /* INCLUDE */) {
|
|
4648
|
-
const {
|
|
4649
|
-
valid: validTypeInfo,
|
|
4650
|
-
error: typeInfoError,
|
|
4651
|
-
errorMap: typeInfoErrorMap
|
|
4652
|
-
} = validateTypeInfoValue(
|
|
4653
|
-
value,
|
|
4654
|
-
typeReference,
|
|
4655
|
-
typeInfoMap,
|
|
4656
|
-
strict,
|
|
4657
|
-
customValidators,
|
|
4658
|
-
typeOperation,
|
|
4659
|
-
relationshipValidationType,
|
|
4660
|
-
itemIsPartial
|
|
4661
|
-
);
|
|
4662
|
-
results.valid = getValidityValue(results.valid, validTypeInfo);
|
|
4663
|
-
results.error = typeInfoError;
|
|
4664
|
-
results.errorMap = typeInfoErrorMap;
|
|
4665
|
-
} else if (relationshipValidationType === "STRICT_EXCLUDE" /* STRICT_EXCLUDE */) {
|
|
4666
|
-
const valueSupplied = typeof value !== "undefined";
|
|
4667
|
-
if (valueSupplied) {
|
|
4668
|
-
results.valid = false;
|
|
4669
|
-
results.error = ERROR_MESSAGE_CONSTANTS.RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED;
|
|
4670
|
-
}
|
|
4671
|
-
} else if (relationshipValidationType === "EXCLUDE" /* EXCLUDE */) {
|
|
4672
|
-
results.valid = getValidityValue(results.valid, true);
|
|
4673
|
-
}
|
|
4674
|
-
} else if (possibleValues && !possibleValues.includes(value)) {
|
|
4675
|
-
results.valid = false;
|
|
4676
|
-
results.error = ERROR_MESSAGE_CONSTANTS.INVALID_OPTION;
|
|
4677
|
-
} else {
|
|
4678
|
-
const pendingValid = validateKeywordType(value, type);
|
|
4679
|
-
const customValid = validateCustomType(
|
|
4680
|
-
value,
|
|
4681
|
-
customType,
|
|
4682
|
-
customValidators
|
|
4683
|
-
);
|
|
4684
|
-
results.valid = getValidityValue(results.valid, pendingValid);
|
|
4685
|
-
results.valid = getValidityValue(results.valid, customValid);
|
|
4686
|
-
if (type === "string" && typeof pattern === "string") {
|
|
4687
|
-
const { valid: patternValid, error: patternError } = validateValueMatchesPattern(value, pattern);
|
|
4688
|
-
results.valid = getValidityValue(results.valid, patternValid);
|
|
4689
|
-
results.error = patternError;
|
|
4690
|
-
}
|
|
4691
|
-
if (!customValid) {
|
|
4692
|
-
results.error = INVALID_CUSTOM_TYPE;
|
|
4693
|
-
} else if (!results.valid) {
|
|
4694
|
-
results.error = results.error ? results.error : PRIMITIVE_ERROR_MESSAGE_CONSTANTS[type];
|
|
4695
|
-
}
|
|
5202
|
+
var buildUpdateExpression = (updatedItem, uniquelyIdentifyingFieldName) => {
|
|
5203
|
+
const updateExpressionParts = [];
|
|
5204
|
+
const attributeNames = {};
|
|
5205
|
+
const attributeValues = {};
|
|
5206
|
+
for (const f in updatedItem) {
|
|
5207
|
+
const value = updatedItem[f];
|
|
5208
|
+
if (f !== uniquelyIdentifyingFieldName && typeof value !== "undefined") {
|
|
5209
|
+
const placeholderName = `#${f}`;
|
|
5210
|
+
const placeholderValue = `:${f}`;
|
|
5211
|
+
updateExpressionParts.push(`${placeholderName} = ${placeholderValue}`);
|
|
5212
|
+
attributeNames[placeholderName] = f;
|
|
5213
|
+
attributeValues[placeholderValue] = marshall(value);
|
|
4696
5214
|
}
|
|
4697
5215
|
}
|
|
4698
|
-
return
|
|
4699
|
-
}
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
const results = {
|
|
4703
|
-
typeName: typeReference ?? type,
|
|
4704
|
-
valid: true,
|
|
4705
|
-
error: "",
|
|
4706
|
-
errorMap: {}
|
|
5216
|
+
return {
|
|
5217
|
+
UpdateExpression: `SET ${updateExpressionParts.join(", ")}`,
|
|
5218
|
+
ExpressionAttributeNames: attributeNames,
|
|
5219
|
+
ExpressionAttributeValues: attributeValues
|
|
4707
5220
|
};
|
|
4708
|
-
for (let i = 0; i < values.length; i++) {
|
|
4709
|
-
const v = values[i];
|
|
4710
|
-
const {
|
|
4711
|
-
valid: indexValid,
|
|
4712
|
-
error: indexError = "",
|
|
4713
|
-
errorMap: indexErrorMap
|
|
4714
|
-
} = validateTypeInfoFieldValue(
|
|
4715
|
-
v,
|
|
4716
|
-
typeInfoField,
|
|
4717
|
-
typeInfoMap,
|
|
4718
|
-
true,
|
|
4719
|
-
strict,
|
|
4720
|
-
customValidators,
|
|
4721
|
-
typeOperation,
|
|
4722
|
-
relationshipValidationType,
|
|
4723
|
-
itemIsPartial
|
|
4724
|
-
);
|
|
4725
|
-
results.valid = getValidityValue(results.valid, indexValid);
|
|
4726
|
-
results.errorMap[getPathString([i])] = [indexError];
|
|
4727
|
-
for (const er in indexErrorMap) {
|
|
4728
|
-
results.errorMap[getPathString([i, er])] = indexErrorMap[er];
|
|
4729
|
-
}
|
|
4730
|
-
}
|
|
4731
|
-
return results;
|
|
4732
5221
|
};
|
|
4733
|
-
var
|
|
4734
|
-
const
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
const { deniedOperations: { [fieldOperation]: denied = false } = {} } = tags;
|
|
4747
|
-
results.typeName = typeReference ?? type;
|
|
4748
|
-
results.valid = !denied;
|
|
4749
|
-
if (!results.valid) {
|
|
4750
|
-
results.error = DENIED_TYPE_OPERATIONS[fieldOperation];
|
|
4751
|
-
results.errorMap[fieldName] = [results.error];
|
|
4752
|
-
}
|
|
4753
|
-
}
|
|
4754
|
-
return results;
|
|
5222
|
+
var buildSelectedFieldParams = (selectedFields) => {
|
|
5223
|
+
const selectedFieldParams = typeof (selectedFields ?? false) && Array.isArray(selectedFields) ? {
|
|
5224
|
+
ExpressionAttributeNames: selectedFields.reduce(
|
|
5225
|
+
(acc, field) => {
|
|
5226
|
+
const fieldAsString = String(field);
|
|
5227
|
+
acc[`#${fieldAsString}`] = fieldAsString;
|
|
5228
|
+
return acc;
|
|
5229
|
+
},
|
|
5230
|
+
{}
|
|
5231
|
+
),
|
|
5232
|
+
ProjectionExpression: selectedFields.map((field) => `#${String(field)}`).join(", ")
|
|
5233
|
+
} : {};
|
|
5234
|
+
return selectedFieldParams;
|
|
4755
5235
|
};
|
|
4756
|
-
var
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
results.valid = false;
|
|
4767
|
-
results.error = DENIED_TYPE_OPERATIONS[typeOperation];
|
|
4768
|
-
} else {
|
|
4769
|
-
for (const vF of valueFields) {
|
|
4770
|
-
const vFieldInfo = fields[vF];
|
|
4771
|
-
const { valid: vFValid, error: vFError } = validateTypeInfoFieldOperationAllowed(vF, typeOperation, vFieldInfo);
|
|
4772
|
-
results.valid = getValidityValue(results.valid, vFValid);
|
|
4773
|
-
if (!vFValid) {
|
|
4774
|
-
results.errorMap[vF] = [vFError];
|
|
4775
|
-
}
|
|
4776
|
-
}
|
|
5236
|
+
var DynamoDBDataItemDBDriver = class {
|
|
5237
|
+
/**
|
|
5238
|
+
* @param config Driver configuration including DynamoDB client settings.
|
|
5239
|
+
*/
|
|
5240
|
+
constructor(config) {
|
|
5241
|
+
this.config = config;
|
|
5242
|
+
const { dbSpecificConfig } = config;
|
|
5243
|
+
this.dynamoDBClient = new DynamoDBClient(
|
|
5244
|
+
dbSpecificConfig
|
|
5245
|
+
);
|
|
4777
5246
|
}
|
|
4778
|
-
|
|
4779
|
-
};
|
|
4780
|
-
var validateTypeInfoValue = (value, typeInfoFullName, typeInfoMap, strict = false, customValidators, typeOperation, relationshipValidationType, itemIsPartial) => {
|
|
4781
|
-
const typeInfo = typeInfoMap[typeInfoFullName];
|
|
4782
|
-
const results = {
|
|
4783
|
-
typeName: typeInfoFullName,
|
|
4784
|
-
valid: !!typeInfo,
|
|
4785
|
-
error: !!typeInfo ? "" : ERROR_MESSAGE_CONSTANTS.TYPE_DOES_NOT_EXIST,
|
|
4786
|
-
errorMap: {}
|
|
4787
|
-
};
|
|
4788
|
-
if (typeInfo) {
|
|
4789
|
-
const { primaryField, fields, unionFieldSets } = typeInfo;
|
|
4790
|
-
if (typeOperation) {
|
|
4791
|
-
const valueFields = typeof value === "object" ? Object.keys(value ?? {}) : [];
|
|
4792
|
-
const {
|
|
4793
|
-
valid: operationValid,
|
|
4794
|
-
error: operationError,
|
|
4795
|
-
errorMap: operationErrorMap
|
|
4796
|
-
} = validateTypeOperationAllowed(
|
|
4797
|
-
typeInfoFullName,
|
|
4798
|
-
valueFields,
|
|
4799
|
-
typeOperation,
|
|
4800
|
-
typeInfo
|
|
4801
|
-
);
|
|
4802
|
-
results.valid = getValidityValue(results.valid, operationValid);
|
|
4803
|
-
results.error = operationError;
|
|
4804
|
-
for (const oE in operationErrorMap) {
|
|
4805
|
-
const existingError = results.errorMap[oE] ?? [];
|
|
4806
|
-
results.errorMap[oE] = existingError ? [...existingError, ...operationErrorMap[oE]] : operationErrorMap[oE];
|
|
4807
|
-
}
|
|
4808
|
-
if (!operationValid && operationError) {
|
|
4809
|
-
results.error = operationError;
|
|
4810
|
-
}
|
|
4811
|
-
}
|
|
4812
|
-
if (unionFieldSets) {
|
|
4813
|
-
const valueFields = Object.keys(value || {});
|
|
4814
|
-
let valid = false;
|
|
4815
|
-
for (const uFS of unionFieldSets) {
|
|
4816
|
-
valid = valueFields.every((vF) => uFS.includes(vF));
|
|
4817
|
-
if (valid) {
|
|
4818
|
-
break;
|
|
4819
|
-
}
|
|
4820
|
-
}
|
|
4821
|
-
if (!valid) {
|
|
4822
|
-
results.valid = false;
|
|
4823
|
-
results.error = ERROR_MESSAGE_CONSTANTS.NO_UNION_TYPE_MATCHED;
|
|
4824
|
-
}
|
|
4825
|
-
} else if (strict) {
|
|
4826
|
-
const knownFields = Object.keys(fields || {});
|
|
4827
|
-
const valueFields = Object.keys(value || {});
|
|
4828
|
-
for (const vF of valueFields) {
|
|
4829
|
-
if (!knownFields.includes(vF)) {
|
|
4830
|
-
results.valid = false;
|
|
4831
|
-
results.errorMap[vF] = [ERROR_MESSAGE_CONSTANTS.INVALID_FIELD];
|
|
4832
|
-
}
|
|
4833
|
-
}
|
|
4834
|
-
}
|
|
4835
|
-
if (fields) {
|
|
4836
|
-
for (const key in fields) {
|
|
4837
|
-
if (typeOperation !== "CREATE" /* CREATE */ || typeof primaryField !== "string" || key !== primaryField) {
|
|
4838
|
-
const typeInfoField = fields[key];
|
|
4839
|
-
const fieldValue = value[key];
|
|
4840
|
-
const {
|
|
4841
|
-
valid: fieldValid,
|
|
4842
|
-
error: fieldError,
|
|
4843
|
-
errorMap: fieldErrorMap
|
|
4844
|
-
} = validateTypeInfoFieldValue(
|
|
4845
|
-
fieldValue,
|
|
4846
|
-
typeInfoField,
|
|
4847
|
-
typeInfoMap,
|
|
4848
|
-
false,
|
|
4849
|
-
strict,
|
|
4850
|
-
customValidators,
|
|
4851
|
-
typeOperation,
|
|
4852
|
-
relationshipValidationType,
|
|
4853
|
-
itemIsPartial
|
|
4854
|
-
);
|
|
4855
|
-
results.valid = getValidityValue(results.valid, fieldValid);
|
|
4856
|
-
results.errorMap[key] = [fieldError];
|
|
4857
|
-
for (const fE in fieldErrorMap) {
|
|
4858
|
-
results.errorMap[getPathString([key, fE])] = fieldErrorMap[fE];
|
|
4859
|
-
}
|
|
4860
|
-
}
|
|
4861
|
-
}
|
|
4862
|
-
}
|
|
4863
|
-
if (!results.valid && !results.error) {
|
|
4864
|
-
results.error = ERROR_MESSAGE_CONSTANTS.INVALID_TYPE;
|
|
4865
|
-
}
|
|
4866
|
-
}
|
|
4867
|
-
return results;
|
|
4868
|
-
};
|
|
4869
|
-
|
|
4870
|
-
// src/api/ORM/drivers/S3FileItemDBDriver.ts
|
|
4871
|
-
var moduleDirname = typeof __dirname === "string" ? __dirname : Path.dirname(fileURLToPath(import.meta.url));
|
|
4872
|
-
var S3FileItemDBDriver = class {
|
|
5247
|
+
dynamoDBClient;
|
|
4873
5248
|
/**
|
|
4874
|
-
*
|
|
5249
|
+
* Create an item in the database.
|
|
5250
|
+
* @returns Generated identifier for the created item.
|
|
4875
5251
|
*/
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
5252
|
+
createItem = async (newItem) => {
|
|
5253
|
+
const {
|
|
5254
|
+
tableName,
|
|
5255
|
+
uniquelyIdentifyingFieldName,
|
|
5256
|
+
generateUniqueIdentifier = () => v4()
|
|
5257
|
+
} = this.config;
|
|
5258
|
+
const newItemId = generateUniqueIdentifier(newItem);
|
|
5259
|
+
const cleanNewItemWithId = {
|
|
5260
|
+
...newItem,
|
|
5261
|
+
[uniquelyIdentifyingFieldName]: newItemId
|
|
5262
|
+
};
|
|
5263
|
+
const command = new PutItemCommand({
|
|
5264
|
+
TableName: tableName,
|
|
5265
|
+
Item: marshall(cleanNewItemWithId)
|
|
4886
5266
|
});
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
s3FileDriver;
|
|
5267
|
+
await this.dynamoDBClient.send(command);
|
|
5268
|
+
return newItemId;
|
|
5269
|
+
};
|
|
4891
5270
|
/**
|
|
4892
|
-
*
|
|
4893
|
-
* @
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
const
|
|
4898
|
-
const
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
// SECURITY: `baseDirectory` is only used internally here, and not as part of the `id`.
|
|
4905
|
-
baseDirectory: tableName
|
|
4906
|
-
}),
|
|
4907
|
-
Body: ""
|
|
4908
|
-
})
|
|
4909
|
-
);
|
|
4910
|
-
return getFullFileKey({
|
|
4911
|
-
file: item
|
|
5271
|
+
* Read an item from the database.
|
|
5272
|
+
* @returns Item payload (partial when selected fields are used).
|
|
5273
|
+
*/
|
|
5274
|
+
readItem = async (uniqueIdentifier, selectedFields) => {
|
|
5275
|
+
const { tableName, uniquelyIdentifyingFieldName } = this.config;
|
|
5276
|
+
const selectedFieldParams = buildSelectedFieldParams(selectedFields);
|
|
5277
|
+
const command = new GetItemCommand({
|
|
5278
|
+
TableName: tableName,
|
|
5279
|
+
Key: marshall({
|
|
5280
|
+
[uniquelyIdentifyingFieldName]: uniqueIdentifier
|
|
5281
|
+
}),
|
|
5282
|
+
...selectedFieldParams
|
|
4912
5283
|
});
|
|
5284
|
+
const { Item } = await this.dynamoDBClient.send(command);
|
|
5285
|
+
if (typeof Item === "undefined") {
|
|
5286
|
+
throw new Error("ITEM_NOT_FOUND" /* ITEM_NOT_FOUND */);
|
|
5287
|
+
} else {
|
|
5288
|
+
const cleanItem = unmarshall(Item);
|
|
5289
|
+
return cleanItem;
|
|
5290
|
+
}
|
|
4913
5291
|
};
|
|
4914
5292
|
/**
|
|
4915
|
-
*
|
|
4916
|
-
* @
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
5293
|
+
* Update an item in the database.
|
|
5294
|
+
* @returns True when an item was updated.
|
|
5295
|
+
*/
|
|
5296
|
+
updateItem = async (uniqueIdentifier, updatedItem) => {
|
|
5297
|
+
const { tableName, uniquelyIdentifyingFieldName } = this.config;
|
|
5298
|
+
const {
|
|
5299
|
+
[uniquelyIdentifyingFieldName]: _unusedUniqueIdentifier,
|
|
5300
|
+
...cleanUpdatedItem
|
|
5301
|
+
} = updatedItem;
|
|
5302
|
+
if (typeof uniqueIdentifier !== "undefined") {
|
|
5303
|
+
const command = new UpdateItemCommand({
|
|
5304
|
+
TableName: tableName,
|
|
5305
|
+
Key: marshall({
|
|
5306
|
+
[uniquelyIdentifyingFieldName]: uniqueIdentifier
|
|
5307
|
+
}),
|
|
5308
|
+
ReturnValues: "ALL_NEW",
|
|
5309
|
+
...buildUpdateExpression(
|
|
5310
|
+
cleanUpdatedItem,
|
|
5311
|
+
uniquelyIdentifyingFieldName
|
|
5312
|
+
)
|
|
5313
|
+
});
|
|
5314
|
+
const { Attributes } = await this.dynamoDBClient.send(command);
|
|
5315
|
+
return !!Attributes;
|
|
4925
5316
|
} else {
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
ContentLength = 0,
|
|
4930
|
-
LastModified} = await this.s3.send(
|
|
4931
|
-
new HeadObjectCommand({
|
|
4932
|
-
Bucket: bucketName,
|
|
4933
|
-
Key: getFullFileKey({
|
|
4934
|
-
file: itemLoc,
|
|
4935
|
-
baseDirectory: tableName
|
|
4936
|
-
})
|
|
4937
|
-
})
|
|
4938
|
-
);
|
|
4939
|
-
const item = {
|
|
4940
|
-
...itemLoc,
|
|
4941
|
-
id,
|
|
4942
|
-
updatedOn: LastModified?.getTime() || 0,
|
|
4943
|
-
mimeType: ContentType,
|
|
4944
|
-
sizeInBytes: ContentLength,
|
|
4945
|
-
isDirectory: ContentType === "application/x-directory",
|
|
4946
|
-
uploadUrl: selectFields && selectFields.includes("uploadUrl") ? await this.s3FileDriver.getFileUploadUrl(itemLoc, tableName) : void 0,
|
|
4947
|
-
downloadUrl: selectFields && selectFields.includes("downloadUrl") ? await this.s3FileDriver.getFileDownloadUrl(itemLoc, tableName) : void 0
|
|
5317
|
+
throw {
|
|
5318
|
+
message: "MISSING_UNIQUE_IDENTIFIER" /* MISSING_UNIQUE_IDENTIFIER */,
|
|
5319
|
+
uniquelyIdentifyingFieldName
|
|
4948
5320
|
};
|
|
4949
|
-
return item;
|
|
4950
5321
|
}
|
|
4951
5322
|
};
|
|
4952
5323
|
/**
|
|
4953
|
-
*
|
|
4954
|
-
* @
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
baseDirectory: tableName
|
|
4974
|
-
}),
|
|
4975
|
-
CopySource: getFullFileKey({
|
|
4976
|
-
file: oldItemLoc,
|
|
4977
|
-
baseDirectory: tableName
|
|
4978
|
-
})
|
|
4979
|
-
})
|
|
4980
|
-
);
|
|
4981
|
-
await this.s3FileDriver.deleteFile(oldItemLoc, tableName);
|
|
4982
|
-
}
|
|
4983
|
-
await this.readItem(uniqueIdentifier);
|
|
4984
|
-
return true;
|
|
4985
|
-
};
|
|
4986
|
-
/**
|
|
4987
|
-
* Delete a @{@link BaseFileItem} by its id.
|
|
4988
|
-
* @param id Unique identifier value for the file.
|
|
4989
|
-
* @returns True when the item was deleted.
|
|
4990
|
-
*/
|
|
4991
|
-
deleteItem = async (id) => {
|
|
4992
|
-
const { tableName } = this.config;
|
|
4993
|
-
if (typeof id === "undefined") {
|
|
4994
|
-
throw new Error("MISSING_ID" /* MISSING_ID */);
|
|
4995
|
-
} else {
|
|
4996
|
-
await this.readItem(id);
|
|
4997
|
-
await this.s3FileDriver.deleteFile(
|
|
4998
|
-
getBaseFileLocationInfo(id),
|
|
4999
|
-
tableName
|
|
5000
|
-
);
|
|
5001
|
-
}
|
|
5002
|
-
return true;
|
|
5003
|
-
};
|
|
5004
|
-
/**
|
|
5005
|
-
* List @{@link BaseFileItem}s by a given criteria.
|
|
5006
|
-
* @param config List configuration and criteria.
|
|
5007
|
-
* @param selectFields Optional fields to select from each file item.
|
|
5008
|
-
* @returns List results with items and cursor.
|
|
5009
|
-
*/
|
|
5010
|
-
listItems = async (config, selectFields) => {
|
|
5324
|
+
* Delete an item from the database.
|
|
5325
|
+
* @returns True when an item was deleted.
|
|
5326
|
+
*/
|
|
5327
|
+
deleteItem = async (uniqueIdentifier) => {
|
|
5328
|
+
const { tableName, uniquelyIdentifyingFieldName } = this.config;
|
|
5329
|
+
const command = new DeleteItemCommand({
|
|
5330
|
+
TableName: tableName,
|
|
5331
|
+
Key: marshall({
|
|
5332
|
+
[uniquelyIdentifyingFieldName]: uniqueIdentifier
|
|
5333
|
+
}),
|
|
5334
|
+
ReturnValues: "ALL_OLD"
|
|
5335
|
+
});
|
|
5336
|
+
const { Attributes } = await this.dynamoDBClient.send(command);
|
|
5337
|
+
return !!Attributes;
|
|
5338
|
+
};
|
|
5339
|
+
/**
|
|
5340
|
+
* List items from the database.
|
|
5341
|
+
* @returns List results with items and cursor.
|
|
5342
|
+
*/
|
|
5343
|
+
listItems = async (config, selectedFields) => {
|
|
5011
5344
|
const { tableName } = this.config;
|
|
5012
5345
|
const {
|
|
5013
|
-
itemsPerPage =
|
|
5346
|
+
itemsPerPage = 10,
|
|
5014
5347
|
cursor,
|
|
5015
|
-
sortFields
|
|
5016
|
-
criteria
|
|
5348
|
+
sortFields,
|
|
5349
|
+
criteria: {
|
|
5350
|
+
logicalOperator = "AND" /* AND */,
|
|
5351
|
+
fieldCriteria = []
|
|
5352
|
+
} = {}
|
|
5017
5353
|
} = config;
|
|
5018
|
-
const {
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5354
|
+
const {
|
|
5355
|
+
ProjectionExpression,
|
|
5356
|
+
ExpressionAttributeNames: selectFieldParamsAttributeNames
|
|
5357
|
+
} = buildSelectedFieldParams(selectedFields);
|
|
5358
|
+
const {
|
|
5359
|
+
FilterExpression,
|
|
5360
|
+
ExpressionAttributeNames,
|
|
5361
|
+
ExpressionAttributeValues
|
|
5362
|
+
} = createFilterExpression(fieldCriteria, logicalOperator);
|
|
5363
|
+
const params = {
|
|
5364
|
+
TableName: tableName,
|
|
5365
|
+
Select: selectedFields && selectedFields.length > 0 ? "SPECIFIC_ATTRIBUTES" : "ALL_ATTRIBUTES",
|
|
5366
|
+
...ProjectionExpression ? {
|
|
5367
|
+
ProjectionExpression
|
|
5368
|
+
} : {},
|
|
5369
|
+
...FilterExpression ? {
|
|
5370
|
+
FilterExpression
|
|
5371
|
+
} : {},
|
|
5372
|
+
...FilterExpression ? {
|
|
5373
|
+
ExpressionAttributeNames: {
|
|
5374
|
+
...selectFieldParamsAttributeNames,
|
|
5375
|
+
...ExpressionAttributeNames
|
|
5376
|
+
}
|
|
5377
|
+
} : ProjectionExpression ? {
|
|
5378
|
+
ExpressionAttributeNames: {
|
|
5379
|
+
...selectFieldParamsAttributeNames
|
|
5380
|
+
}
|
|
5381
|
+
} : {},
|
|
5382
|
+
...FilterExpression ? {
|
|
5383
|
+
ExpressionAttributeValues
|
|
5384
|
+
} : {}
|
|
5385
|
+
};
|
|
5386
|
+
let structuredCursor = void 0;
|
|
5387
|
+
if (typeof cursor === "string") {
|
|
5388
|
+
try {
|
|
5389
|
+
structuredCursor = marshall(JSON.parse(cursor));
|
|
5390
|
+
} catch (error) {
|
|
5391
|
+
throw {
|
|
5392
|
+
message: "INVALID_CURSOR" /* INVALID_CURSOR */,
|
|
5393
|
+
cursor
|
|
5394
|
+
};
|
|
5395
|
+
}
|
|
5041
5396
|
}
|
|
5397
|
+
const command = new ScanCommand({
|
|
5398
|
+
...params,
|
|
5399
|
+
ExclusiveStartKey: structuredCursor,
|
|
5400
|
+
Limit: itemsPerPage
|
|
5401
|
+
});
|
|
5402
|
+
const { Items = [], LastEvaluatedKey } = await this.dynamoDBClient.send(command);
|
|
5403
|
+
const unmarshalledItems = Items.map((item) => unmarshall(item));
|
|
5404
|
+
const sortedItems = getSortedItems(sortFields, unmarshalledItems);
|
|
5042
5405
|
return {
|
|
5043
|
-
items:
|
|
5044
|
-
|
|
5045
|
-
expandedFiles
|
|
5046
|
-
),
|
|
5047
|
-
cursor: newCursor
|
|
5406
|
+
items: sortedItems,
|
|
5407
|
+
cursor: LastEvaluatedKey ? JSON.stringify(unmarshall(LastEvaluatedKey)) : void 0
|
|
5048
5408
|
};
|
|
5049
5409
|
};
|
|
5050
5410
|
};
|
|
5051
|
-
var
|
|
5411
|
+
var DynamoDBSupportedDataItemDBDriverEntry = {
|
|
5052
5412
|
/**
|
|
5053
5413
|
* @param config Driver configuration.
|
|
5054
|
-
* @returns
|
|
5414
|
+
* @returns DynamoDB-backed driver instance.
|
|
5055
5415
|
*/
|
|
5056
5416
|
factory: (config) => {
|
|
5057
|
-
return new
|
|
5417
|
+
return new DynamoDBDataItemDBDriver(config);
|
|
5058
5418
|
},
|
|
5059
5419
|
/**
|
|
5060
|
-
* @returns Type info pack for the
|
|
5420
|
+
* @returns Type info pack for the DynamoDB-specific config.
|
|
5061
5421
|
*/
|
|
5062
5422
|
getDBSpecificConfigTypeInfo: () => {
|
|
5063
|
-
const configTypesPath = Path.join(
|
|
5064
|
-
moduleDirname,
|
|
5065
|
-
"S3FileItemDBDriver",
|
|
5066
|
-
"ConfigTypes.ts"
|
|
5067
|
-
);
|
|
5068
|
-
const configTypesTS = FS.readFileSync(configTypesPath, "utf8");
|
|
5069
|
-
const typeInfoMap = getTypeInfoMapFromTypeScript(configTypesTS);
|
|
5070
5423
|
return {
|
|
5071
|
-
entryTypeName: "
|
|
5072
|
-
typeInfoMap
|
|
5424
|
+
entryTypeName: "DynamoDBSpecificConfig",
|
|
5425
|
+
typeInfoMap: ConfigTypeInfoMap_default2
|
|
5073
5426
|
};
|
|
5074
5427
|
}
|
|
5075
5428
|
};
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
["LESS_THAN_OR_EQUAL" /* LESS_THAN_OR_EQUAL */]: (fieldName) => `#${fieldName} <= :${fieldName}`,
|
|
5084
|
-
["IN" /* IN */]: (fieldName) => `#${fieldName} IN (:${fieldName})`,
|
|
5085
|
-
["LIKE" /* LIKE */]: (fieldName) => `contains(#${fieldName}, :${fieldName})`,
|
|
5086
|
-
["EXISTS" /* EXISTS */]: (fieldName) => `attribute_exists(#${fieldName})`,
|
|
5087
|
-
["NOT_EXISTS" /* NOT_EXISTS */]: (fieldName) => `attribute_not_exists(#${fieldName})`,
|
|
5088
|
-
["IS_EMPTY" /* IS_EMPTY */]: (fieldName) => `size(#${fieldName}) = 0`,
|
|
5089
|
-
["IS_NOT_EMPTY" /* IS_NOT_EMPTY */]: (fieldName) => `size(#${fieldName}) > 0`,
|
|
5090
|
-
["BETWEEN" /* BETWEEN */]: (fieldName) => `#${fieldName} BETWEEN :${fieldName}_start AND :${fieldName}_end`,
|
|
5091
|
-
["CONTAINS" /* CONTAINS */]: (fieldName) => `contains(#${fieldName}, :${fieldName})`,
|
|
5092
|
-
["STARTS_WITH" /* STARTS_WITH */]: (fieldName) => `begins_with(#${fieldName}, :${fieldName})`
|
|
5093
|
-
};
|
|
5094
|
-
var DynamoDBLogicalOperatorMappings = {
|
|
5095
|
-
["AND" /* AND */]: "AND",
|
|
5096
|
-
["OR" /* OR */]: "OR"
|
|
5429
|
+
|
|
5430
|
+
// src/api/ORM/drivers/InMemoryDataItemDBDriver/ConfigTypeInfoMap.json
|
|
5431
|
+
var ConfigTypeInfoMap_default3 = {
|
|
5432
|
+
InMemorySpecificConfig: {
|
|
5433
|
+
fields: {},
|
|
5434
|
+
tags: {}
|
|
5435
|
+
}
|
|
5097
5436
|
};
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
operator,
|
|
5111
|
-
fieldName
|
|
5112
|
-
};
|
|
5113
|
-
}
|
|
5114
|
-
expressions.push(createExpression(fieldName));
|
|
5115
|
-
attributeNames[`#${fieldName}`] = fieldName;
|
|
5116
|
-
attributeValues[`:${fieldName}`] = value;
|
|
5437
|
+
|
|
5438
|
+
// src/api/ORM/drivers/InMemoryDataItemDBDriver.ts
|
|
5439
|
+
typeof __dirname === "string" ? __dirname : Path.dirname(fileURLToPath(import.meta.url));
|
|
5440
|
+
var decodeCursor2 = (cursor) => {
|
|
5441
|
+
if (!cursor) {
|
|
5442
|
+
return 0;
|
|
5443
|
+
}
|
|
5444
|
+
try {
|
|
5445
|
+
const parsed = JSON.parse(cursor);
|
|
5446
|
+
const offset = parsed.offset ?? 0;
|
|
5447
|
+
if (!Number.isFinite(offset) || offset < 0) {
|
|
5448
|
+
throw new Error("Invalid cursor offset.");
|
|
5117
5449
|
}
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
ExpressionAttributeValues: marshall(attributeValues)
|
|
5450
|
+
return offset;
|
|
5451
|
+
} catch (_error) {
|
|
5452
|
+
throw {
|
|
5453
|
+
message: "INVALID_CURSOR" /* INVALID_CURSOR */,
|
|
5454
|
+
cursor
|
|
5124
5455
|
};
|
|
5125
5456
|
}
|
|
5126
|
-
return output;
|
|
5127
5457
|
};
|
|
5128
|
-
var
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
for (const f in updatedItem) {
|
|
5133
|
-
const value = updatedItem[f];
|
|
5134
|
-
if (f !== uniquelyIdentifyingFieldName && typeof value !== "undefined") {
|
|
5135
|
-
const placeholderName = `#${f}`;
|
|
5136
|
-
const placeholderValue = `:${f}`;
|
|
5137
|
-
updateExpressionParts.push(`${placeholderName} = ${placeholderValue}`);
|
|
5138
|
-
attributeNames[placeholderName] = f;
|
|
5139
|
-
attributeValues[placeholderValue] = marshall(value);
|
|
5140
|
-
}
|
|
5458
|
+
var encodeCursor2 = (offset) => JSON.stringify({ offset });
|
|
5459
|
+
var selectFieldsFromItem = (item, selectedFields) => {
|
|
5460
|
+
if (!selectedFields || selectedFields.length === 0) {
|
|
5461
|
+
return { ...item };
|
|
5141
5462
|
}
|
|
5142
|
-
return {
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
};
|
|
5148
|
-
var buildSelectedFieldParams = (selectedFields) => {
|
|
5149
|
-
const selectedFieldParams = typeof (selectedFields ?? false) && Array.isArray(selectedFields) ? {
|
|
5150
|
-
ExpressionAttributeNames: selectedFields.reduce(
|
|
5151
|
-
(acc, field) => {
|
|
5152
|
-
const fieldAsString = String(field);
|
|
5153
|
-
acc[`#${fieldAsString}`] = fieldAsString;
|
|
5154
|
-
return acc;
|
|
5155
|
-
},
|
|
5156
|
-
{}
|
|
5157
|
-
),
|
|
5158
|
-
ProjectionExpression: selectedFields.map((field) => `#${String(field)}`).join(", ")
|
|
5159
|
-
} : {};
|
|
5160
|
-
return selectedFieldParams;
|
|
5463
|
+
return selectedFields.reduce((accumulator, field) => {
|
|
5464
|
+
if (field in item) {
|
|
5465
|
+
accumulator[field] = item[field];
|
|
5466
|
+
}
|
|
5467
|
+
return accumulator;
|
|
5468
|
+
}, {});
|
|
5161
5469
|
};
|
|
5162
|
-
var
|
|
5163
|
-
/**
|
|
5164
|
-
* @param config Driver configuration including DynamoDB client settings.
|
|
5165
|
-
*/
|
|
5166
|
-
constructor(config) {
|
|
5167
|
-
this.config = config;
|
|
5168
|
-
const { dbSpecificConfig } = config;
|
|
5169
|
-
this.dynamoDBClient = new DynamoDBClient(
|
|
5170
|
-
dbSpecificConfig
|
|
5171
|
-
);
|
|
5172
|
-
}
|
|
5173
|
-
dynamoDBClient;
|
|
5174
|
-
/**
|
|
5175
|
-
* Create an item in the database.
|
|
5176
|
-
* @returns Generated identifier for the created item.
|
|
5177
|
-
*/
|
|
5178
|
-
createItem = async (newItem) => {
|
|
5179
|
-
const {
|
|
5180
|
-
tableName,
|
|
5181
|
-
uniquelyIdentifyingFieldName,
|
|
5182
|
-
generateUniqueIdentifier = () => v4()
|
|
5183
|
-
} = this.config;
|
|
5184
|
-
const newItemId = generateUniqueIdentifier(newItem);
|
|
5185
|
-
const cleanNewItemWithId = {
|
|
5186
|
-
...newItem,
|
|
5187
|
-
[uniquelyIdentifyingFieldName]: newItemId
|
|
5188
|
-
};
|
|
5189
|
-
const command = new PutItemCommand({
|
|
5190
|
-
TableName: tableName,
|
|
5191
|
-
Item: marshall(cleanNewItemWithId)
|
|
5192
|
-
});
|
|
5193
|
-
await this.dynamoDBClient.send(command);
|
|
5194
|
-
return newItemId;
|
|
5195
|
-
};
|
|
5196
|
-
/**
|
|
5197
|
-
* Read an item from the database.
|
|
5198
|
-
* @returns Item payload (partial when selected fields are used).
|
|
5199
|
-
*/
|
|
5200
|
-
readItem = async (uniqueIdentifier, selectedFields) => {
|
|
5201
|
-
const { tableName, uniquelyIdentifyingFieldName } = this.config;
|
|
5202
|
-
const selectedFieldParams = buildSelectedFieldParams(selectedFields);
|
|
5203
|
-
const command = new GetItemCommand({
|
|
5204
|
-
TableName: tableName,
|
|
5205
|
-
Key: marshall({
|
|
5206
|
-
[uniquelyIdentifyingFieldName]: uniqueIdentifier
|
|
5207
|
-
}),
|
|
5208
|
-
...selectedFieldParams
|
|
5209
|
-
});
|
|
5210
|
-
const { Item } = await this.dynamoDBClient.send(command);
|
|
5211
|
-
if (typeof Item === "undefined") {
|
|
5212
|
-
throw new Error("ITEM_NOT_FOUND" /* ITEM_NOT_FOUND */);
|
|
5213
|
-
} else {
|
|
5214
|
-
const cleanItem = unmarshall(Item);
|
|
5215
|
-
return cleanItem;
|
|
5216
|
-
}
|
|
5217
|
-
};
|
|
5218
|
-
/**
|
|
5219
|
-
* Update an item in the database.
|
|
5220
|
-
* @returns True when an item was updated.
|
|
5221
|
-
*/
|
|
5222
|
-
updateItem = async (uniqueIdentifier, updatedItem) => {
|
|
5223
|
-
const { tableName, uniquelyIdentifyingFieldName } = this.config;
|
|
5224
|
-
const {
|
|
5225
|
-
[uniquelyIdentifyingFieldName]: _unusedUniqueIdentifier,
|
|
5226
|
-
...cleanUpdatedItem
|
|
5227
|
-
} = updatedItem;
|
|
5228
|
-
if (typeof uniqueIdentifier !== "undefined") {
|
|
5229
|
-
const command = new UpdateItemCommand({
|
|
5230
|
-
TableName: tableName,
|
|
5231
|
-
Key: marshall({
|
|
5232
|
-
[uniquelyIdentifyingFieldName]: uniqueIdentifier
|
|
5233
|
-
}),
|
|
5234
|
-
ReturnValues: "ALL_NEW",
|
|
5235
|
-
...buildUpdateExpression(
|
|
5236
|
-
cleanUpdatedItem,
|
|
5237
|
-
uniquelyIdentifyingFieldName
|
|
5238
|
-
)
|
|
5239
|
-
});
|
|
5240
|
-
const { Attributes } = await this.dynamoDBClient.send(command);
|
|
5241
|
-
return !!Attributes;
|
|
5242
|
-
} else {
|
|
5243
|
-
throw {
|
|
5244
|
-
message: "MISSING_UNIQUE_IDENTIFIER" /* MISSING_UNIQUE_IDENTIFIER */,
|
|
5245
|
-
uniquelyIdentifyingFieldName
|
|
5246
|
-
};
|
|
5247
|
-
}
|
|
5248
|
-
};
|
|
5249
|
-
/**
|
|
5250
|
-
* Delete an item from the database.
|
|
5251
|
-
* @returns True when an item was deleted.
|
|
5252
|
-
*/
|
|
5253
|
-
deleteItem = async (uniqueIdentifier) => {
|
|
5254
|
-
const { tableName, uniquelyIdentifyingFieldName } = this.config;
|
|
5255
|
-
const command = new DeleteItemCommand({
|
|
5256
|
-
TableName: tableName,
|
|
5257
|
-
Key: marshall({
|
|
5258
|
-
[uniquelyIdentifyingFieldName]: uniqueIdentifier
|
|
5259
|
-
}),
|
|
5260
|
-
ReturnValues: "ALL_OLD"
|
|
5261
|
-
});
|
|
5262
|
-
const { Attributes } = await this.dynamoDBClient.send(command);
|
|
5263
|
-
return !!Attributes;
|
|
5264
|
-
};
|
|
5265
|
-
/**
|
|
5266
|
-
* List items from the database.
|
|
5267
|
-
* @returns List results with items and cursor.
|
|
5268
|
-
*/
|
|
5269
|
-
listItems = async (config, selectedFields) => {
|
|
5270
|
-
const { tableName } = this.config;
|
|
5271
|
-
const {
|
|
5272
|
-
itemsPerPage = 10,
|
|
5273
|
-
cursor,
|
|
5274
|
-
sortFields,
|
|
5275
|
-
criteria: {
|
|
5276
|
-
logicalOperator = "AND" /* AND */,
|
|
5277
|
-
fieldCriteria = []
|
|
5278
|
-
} = {}
|
|
5279
|
-
} = config;
|
|
5280
|
-
const {
|
|
5281
|
-
ProjectionExpression,
|
|
5282
|
-
ExpressionAttributeNames: selectFieldParamsAttributeNames
|
|
5283
|
-
} = buildSelectedFieldParams(selectedFields);
|
|
5284
|
-
const {
|
|
5285
|
-
FilterExpression,
|
|
5286
|
-
ExpressionAttributeNames,
|
|
5287
|
-
ExpressionAttributeValues
|
|
5288
|
-
} = createFilterExpression(fieldCriteria, logicalOperator);
|
|
5289
|
-
const params = {
|
|
5290
|
-
TableName: tableName,
|
|
5291
|
-
Select: selectedFields && selectedFields.length > 0 ? "SPECIFIC_ATTRIBUTES" : "ALL_ATTRIBUTES",
|
|
5292
|
-
...ProjectionExpression ? {
|
|
5293
|
-
ProjectionExpression
|
|
5294
|
-
} : {},
|
|
5295
|
-
...FilterExpression ? {
|
|
5296
|
-
FilterExpression
|
|
5297
|
-
} : {},
|
|
5298
|
-
...FilterExpression ? {
|
|
5299
|
-
ExpressionAttributeNames: {
|
|
5300
|
-
...selectFieldParamsAttributeNames,
|
|
5301
|
-
...ExpressionAttributeNames
|
|
5302
|
-
}
|
|
5303
|
-
} : ProjectionExpression ? {
|
|
5304
|
-
ExpressionAttributeNames: {
|
|
5305
|
-
...selectFieldParamsAttributeNames
|
|
5306
|
-
}
|
|
5307
|
-
} : {},
|
|
5308
|
-
...FilterExpression ? {
|
|
5309
|
-
ExpressionAttributeValues
|
|
5310
|
-
} : {}
|
|
5311
|
-
};
|
|
5312
|
-
let structuredCursor = void 0;
|
|
5313
|
-
if (typeof cursor === "string") {
|
|
5314
|
-
try {
|
|
5315
|
-
structuredCursor = marshall(JSON.parse(cursor));
|
|
5316
|
-
} catch (error) {
|
|
5317
|
-
throw {
|
|
5318
|
-
message: "INVALID_CURSOR" /* INVALID_CURSOR */,
|
|
5319
|
-
cursor
|
|
5320
|
-
};
|
|
5321
|
-
}
|
|
5322
|
-
}
|
|
5323
|
-
const command = new ScanCommand({
|
|
5324
|
-
...params,
|
|
5325
|
-
ExclusiveStartKey: structuredCursor,
|
|
5326
|
-
Limit: itemsPerPage
|
|
5327
|
-
});
|
|
5328
|
-
const { Items = [], LastEvaluatedKey } = await this.dynamoDBClient.send(command);
|
|
5329
|
-
const unmarshalledItems = Items.map((item) => unmarshall(item));
|
|
5330
|
-
const sortedItems = getSortedItems(sortFields, unmarshalledItems);
|
|
5331
|
-
return {
|
|
5332
|
-
items: sortedItems,
|
|
5333
|
-
cursor: LastEvaluatedKey ? JSON.stringify(unmarshall(LastEvaluatedKey)) : void 0
|
|
5334
|
-
};
|
|
5335
|
-
};
|
|
5336
|
-
};
|
|
5337
|
-
var DynamoDBSupportedDataItemDBDriverEntry = {
|
|
5338
|
-
/**
|
|
5339
|
-
* @param config Driver configuration.
|
|
5340
|
-
* @returns DynamoDB-backed driver instance.
|
|
5341
|
-
*/
|
|
5342
|
-
factory: (config) => {
|
|
5343
|
-
return new DynamoDBDataItemDBDriver(config);
|
|
5344
|
-
},
|
|
5345
|
-
/**
|
|
5346
|
-
* @returns Type info pack for the DynamoDB-specific config.
|
|
5347
|
-
*/
|
|
5348
|
-
getDBSpecificConfigTypeInfo: () => {
|
|
5349
|
-
const configTypesPath = Path.join(
|
|
5350
|
-
moduleDirname2,
|
|
5351
|
-
"DynamoDBDataItemDBDriver",
|
|
5352
|
-
"ConfigTypes.ts"
|
|
5353
|
-
);
|
|
5354
|
-
const configTypesTS = FS.readFileSync(configTypesPath, "utf8");
|
|
5355
|
-
const typeInfoMap = getTypeInfoMapFromTypeScript(configTypesTS);
|
|
5356
|
-
return {
|
|
5357
|
-
entryTypeName: "DynamoDBSpecificConfig",
|
|
5358
|
-
typeInfoMap
|
|
5359
|
-
};
|
|
5360
|
-
}
|
|
5361
|
-
};
|
|
5362
|
-
var moduleDirname3 = typeof __dirname === "string" ? __dirname : Path.dirname(fileURLToPath(import.meta.url));
|
|
5363
|
-
var decodeCursor2 = (cursor) => {
|
|
5364
|
-
if (!cursor) {
|
|
5365
|
-
return 0;
|
|
5366
|
-
}
|
|
5367
|
-
try {
|
|
5368
|
-
const parsed = JSON.parse(cursor);
|
|
5369
|
-
const offset = parsed.offset ?? 0;
|
|
5370
|
-
if (!Number.isFinite(offset) || offset < 0) {
|
|
5371
|
-
throw new Error("Invalid cursor offset.");
|
|
5372
|
-
}
|
|
5373
|
-
return offset;
|
|
5374
|
-
} catch (_error) {
|
|
5375
|
-
throw {
|
|
5376
|
-
message: "INVALID_CURSOR" /* INVALID_CURSOR */,
|
|
5377
|
-
cursor
|
|
5378
|
-
};
|
|
5379
|
-
}
|
|
5380
|
-
};
|
|
5381
|
-
var encodeCursor2 = (offset) => JSON.stringify({ offset });
|
|
5382
|
-
var selectFieldsFromItem = (item, selectedFields) => {
|
|
5383
|
-
if (!selectedFields || selectedFields.length === 0) {
|
|
5384
|
-
return { ...item };
|
|
5385
|
-
}
|
|
5386
|
-
return selectedFields.reduce((accumulator, field) => {
|
|
5387
|
-
if (field in item) {
|
|
5388
|
-
accumulator[field] = item[field];
|
|
5389
|
-
}
|
|
5390
|
-
return accumulator;
|
|
5391
|
-
}, {});
|
|
5392
|
-
};
|
|
5393
|
-
var InMemoryDataItemDBDriver = class {
|
|
5470
|
+
var InMemoryDataItemDBDriver = class {
|
|
5394
5471
|
constructor(config) {
|
|
5395
5472
|
this.config = config;
|
|
5396
5473
|
}
|
|
@@ -5405,7 +5482,9 @@ var InMemoryDataItemDBDriver = class {
|
|
|
5405
5482
|
uniquelyIdentifyingFieldName,
|
|
5406
5483
|
generateUniqueIdentifier = () => v4()
|
|
5407
5484
|
} = this.config;
|
|
5408
|
-
const newItemId = generateUniqueIdentifier(
|
|
5485
|
+
const newItemId = generateUniqueIdentifier(
|
|
5486
|
+
newItem
|
|
5487
|
+
);
|
|
5409
5488
|
const cleanNewItemWithId = {
|
|
5410
5489
|
...newItem,
|
|
5411
5490
|
[uniquelyIdentifyingFieldName]: newItemId
|
|
@@ -5477,18 +5556,16 @@ var InMemoryDataItemDBDriver = class {
|
|
|
5477
5556
|
* @returns List results with items and cursor.
|
|
5478
5557
|
*/
|
|
5479
5558
|
listItems = async (config, selectedFields) => {
|
|
5480
|
-
const {
|
|
5481
|
-
itemsPerPage = 10,
|
|
5482
|
-
cursor,
|
|
5483
|
-
sortFields,
|
|
5484
|
-
criteria
|
|
5485
|
-
} = config;
|
|
5559
|
+
const { itemsPerPage = 10, cursor, sortFields, criteria } = config;
|
|
5486
5560
|
const allItems = Array.from(this.items.values());
|
|
5487
5561
|
const filteredItems = criteria ? getFilterTypeInfoDataItemsBySearchCriteria(
|
|
5488
5562
|
criteria,
|
|
5489
5563
|
allItems
|
|
5490
5564
|
) : allItems;
|
|
5491
|
-
const sortedItems = getSortedItems(
|
|
5565
|
+
const sortedItems = getSortedItems(
|
|
5566
|
+
sortFields,
|
|
5567
|
+
filteredItems
|
|
5568
|
+
);
|
|
5492
5569
|
const offset = decodeCursor2(cursor);
|
|
5493
5570
|
const items = sortedItems.slice(offset, offset + itemsPerPage).map((item) => selectFieldsFromItem(item, selectedFields));
|
|
5494
5571
|
const nextOffset = offset + itemsPerPage;
|
|
@@ -5510,16 +5587,9 @@ var InMemorySupportedDataItemDBDriverEntry = {
|
|
|
5510
5587
|
* @returns Type info pack for the in-memory config.
|
|
5511
5588
|
*/
|
|
5512
5589
|
getDBSpecificConfigTypeInfo: () => {
|
|
5513
|
-
const configTypesPath = Path.join(
|
|
5514
|
-
moduleDirname3,
|
|
5515
|
-
"InMemoryDataItemDBDriver",
|
|
5516
|
-
"ConfigTypes.ts"
|
|
5517
|
-
);
|
|
5518
|
-
const configTypesTS = FS.readFileSync(configTypesPath, "utf8");
|
|
5519
|
-
const typeInfoMap = getTypeInfoMapFromTypeScript(configTypesTS);
|
|
5520
5590
|
return {
|
|
5521
5591
|
entryTypeName: "InMemorySpecificConfig",
|
|
5522
|
-
typeInfoMap
|
|
5592
|
+
typeInfoMap: ConfigTypeInfoMap_default3
|
|
5523
5593
|
};
|
|
5524
5594
|
}
|
|
5525
5595
|
};
|
|
@@ -5551,7 +5621,33 @@ var InMemoryItemRelationshipDBDriver = class extends InMemoryDataItemDBDriver {
|
|
|
5551
5621
|
});
|
|
5552
5622
|
}
|
|
5553
5623
|
};
|
|
5554
|
-
|
|
5624
|
+
|
|
5625
|
+
// src/api/ORM/drivers/InMemoryFileItemDBDriver/ConfigTypeInfoMap.json
|
|
5626
|
+
var ConfigTypeInfoMap_default4 = {
|
|
5627
|
+
InMemoryFileSpecificConfig: {
|
|
5628
|
+
fields: {
|
|
5629
|
+
uploadUrlPrefix: {
|
|
5630
|
+
type: "string",
|
|
5631
|
+
array: false,
|
|
5632
|
+
readonly: false,
|
|
5633
|
+
optional: true,
|
|
5634
|
+
tags: {}
|
|
5635
|
+
},
|
|
5636
|
+
downloadUrlPrefix: {
|
|
5637
|
+
type: "string",
|
|
5638
|
+
array: false,
|
|
5639
|
+
readonly: false,
|
|
5640
|
+
optional: true,
|
|
5641
|
+
tags: {}
|
|
5642
|
+
}
|
|
5643
|
+
},
|
|
5644
|
+
tags: {},
|
|
5645
|
+
primaryField: "uploadUrlPrefix"
|
|
5646
|
+
}
|
|
5647
|
+
};
|
|
5648
|
+
|
|
5649
|
+
// src/api/ORM/drivers/InMemoryFileItemDBDriver.ts
|
|
5650
|
+
typeof __dirname === "string" ? __dirname : Path.dirname(fileURLToPath(import.meta.url));
|
|
5555
5651
|
var decodeCursor3 = (cursor) => {
|
|
5556
5652
|
if (!cursor) {
|
|
5557
5653
|
return 0;
|
|
@@ -5607,13 +5703,14 @@ var InMemoryFileItemDBDriver = class {
|
|
|
5607
5703
|
* @returns Generated file id.
|
|
5608
5704
|
*/
|
|
5609
5705
|
createItem = async (item) => {
|
|
5610
|
-
const {
|
|
5611
|
-
generateUniqueIdentifier
|
|
5612
|
-
} = this.config;
|
|
5706
|
+
const { generateUniqueIdentifier } = this.config;
|
|
5613
5707
|
if (!item?.name) {
|
|
5614
5708
|
throw new Error("MISSING_ID" /* MISSING_ID */);
|
|
5615
5709
|
}
|
|
5616
|
-
const fileLocation = {
|
|
5710
|
+
const fileLocation = {
|
|
5711
|
+
name: item.name,
|
|
5712
|
+
directory: item.directory
|
|
5713
|
+
};
|
|
5617
5714
|
const id = typeof generateUniqueIdentifier === "function" ? String(generateUniqueIdentifier(item)) : getFullFileKey({ file: fileLocation });
|
|
5618
5715
|
const mimeType = item.mimeType ?? "application/octet-stream";
|
|
5619
5716
|
const newItem = {
|
|
@@ -5719,7 +5816,10 @@ var InMemoryFileItemDBDriver = class {
|
|
|
5719
5816
|
criteria,
|
|
5720
5817
|
allItems
|
|
5721
5818
|
) : allItems;
|
|
5722
|
-
const sortedItems = getSortedItems(
|
|
5819
|
+
const sortedItems = getSortedItems(
|
|
5820
|
+
sortFields,
|
|
5821
|
+
filteredItems
|
|
5822
|
+
);
|
|
5723
5823
|
const offset = decodeCursor3(cursor);
|
|
5724
5824
|
const slice = sortedItems.slice(offset, offset + itemsPerPage);
|
|
5725
5825
|
const expandedItems = slice.map((item) => {
|
|
@@ -5751,16 +5851,9 @@ var InMemoryFileSupportedDataItemDBDriverEntry = {
|
|
|
5751
5851
|
* @returns Type info pack for the in-memory file config.
|
|
5752
5852
|
*/
|
|
5753
5853
|
getDBSpecificConfigTypeInfo: () => {
|
|
5754
|
-
const configTypesPath = Path.join(
|
|
5755
|
-
moduleDirname4,
|
|
5756
|
-
"InMemoryFileItemDBDriver",
|
|
5757
|
-
"ConfigTypes.ts"
|
|
5758
|
-
);
|
|
5759
|
-
const configTypesTS = FS.readFileSync(configTypesPath, "utf8");
|
|
5760
|
-
const typeInfoMap = getTypeInfoMapFromTypeScript(configTypesTS);
|
|
5761
5854
|
return {
|
|
5762
5855
|
entryTypeName: "InMemoryFileSpecificConfig",
|
|
5763
|
-
typeInfoMap
|
|
5856
|
+
typeInfoMap: ConfigTypeInfoMap_default4
|
|
5764
5857
|
};
|
|
5765
5858
|
}
|
|
5766
5859
|
};
|
|
@@ -5879,6 +5972,343 @@ var SUPPORTED_TYPE_INFO_ORM_DB_DRIVERS = {
|
|
|
5879
5972
|
["S3_FILE_ITEM" /* S3_FILE_ITEM */]: S3SupportedFileItemDBDriverEntry
|
|
5880
5973
|
};
|
|
5881
5974
|
|
|
5975
|
+
// src/common/TypeParsing/Validation.ts
|
|
5976
|
+
var INVALID_CUSTOM_TYPE = "INVALID_CUSTOM_TYPE";
|
|
5977
|
+
var PRIMITIVE_ERROR_MESSAGE_CONSTANTS = {
|
|
5978
|
+
string: "NOT_A_STRING",
|
|
5979
|
+
number: "NOT_A_NUMBER",
|
|
5980
|
+
boolean: "NOT_A_BOOLEAN"
|
|
5981
|
+
};
|
|
5982
|
+
var ERROR_MESSAGE_CONSTANTS = {
|
|
5983
|
+
MISSING: "MISSING",
|
|
5984
|
+
INVALID_OPTION: "INVALID_OPTION",
|
|
5985
|
+
INVALID_FIELD: "INVALID_FIELD",
|
|
5986
|
+
RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED: "RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED",
|
|
5987
|
+
INVALID_TYPE: "INVALID_TYPE",
|
|
5988
|
+
NO_UNION_TYPE_MATCHED: "NO_UNION_TYPE_MATCHED",
|
|
5989
|
+
TYPE_DOES_NOT_EXIST: "TYPE_DOES_NOT_EXIST",
|
|
5990
|
+
INVALID_PATTERN: "INVALID_PATTERN",
|
|
5991
|
+
VALUE_DOES_NOT_MATCH_PATTERN: "VALUE_DOES_NOT_MATCH_PATTERN"
|
|
5992
|
+
};
|
|
5993
|
+
var DENIED_TYPE_OPERATIONS = {
|
|
5994
|
+
CREATE: "DENIED_TYPE_OPERATION_CREATE",
|
|
5995
|
+
READ: "DENIED_TYPE_OPERATION_READ",
|
|
5996
|
+
UPDATE: "DENIED_TYPE_OPERATION_UPDATE",
|
|
5997
|
+
DELETE: "DENIED_TYPE_OPERATION_DELETE"
|
|
5998
|
+
};
|
|
5999
|
+
var validateValueMatchesPattern = (typeName, value, pattern) => {
|
|
6000
|
+
const results = {
|
|
6001
|
+
typeName,
|
|
6002
|
+
valid: true,
|
|
6003
|
+
error: "",
|
|
6004
|
+
errorMap: {}
|
|
6005
|
+
};
|
|
6006
|
+
{
|
|
6007
|
+
try {
|
|
6008
|
+
const regex = new RegExp(pattern);
|
|
6009
|
+
const testResult = typeof value === "string" && regex.test(value);
|
|
6010
|
+
if (!testResult) {
|
|
6011
|
+
results.valid = false;
|
|
6012
|
+
results.error = ERROR_MESSAGE_CONSTANTS.VALUE_DOES_NOT_MATCH_PATTERN;
|
|
6013
|
+
}
|
|
6014
|
+
} catch (e) {
|
|
6015
|
+
results.valid = false;
|
|
6016
|
+
results.error = ERROR_MESSAGE_CONSTANTS.INVALID_PATTERN;
|
|
6017
|
+
}
|
|
6018
|
+
}
|
|
6019
|
+
return results;
|
|
6020
|
+
};
|
|
6021
|
+
var getValidityValue = (existing, pending) => !existing ? false : pending;
|
|
6022
|
+
var TYPE_KEYWORD_VALIDATORS = {
|
|
6023
|
+
string: (value) => typeof value === "string",
|
|
6024
|
+
number: (value) => typeof value === "number",
|
|
6025
|
+
boolean: (value) => typeof value === "boolean"
|
|
6026
|
+
};
|
|
6027
|
+
var hasValue = (value) => value ?? false;
|
|
6028
|
+
var validateKeywordType = (value, type) => {
|
|
6029
|
+
const validator = TYPE_KEYWORD_VALIDATORS[type];
|
|
6030
|
+
let valid = true;
|
|
6031
|
+
if (validator) {
|
|
6032
|
+
valid = validator(value);
|
|
6033
|
+
}
|
|
6034
|
+
return valid;
|
|
6035
|
+
};
|
|
6036
|
+
var validateCustomType = (value, customType, customValidators) => {
|
|
6037
|
+
let valid = true;
|
|
6038
|
+
if (customValidators && customType) {
|
|
6039
|
+
const validator = customValidators[customType];
|
|
6040
|
+
if (validator) {
|
|
6041
|
+
try {
|
|
6042
|
+
valid = validator(value);
|
|
6043
|
+
} catch (e) {
|
|
6044
|
+
valid = false;
|
|
6045
|
+
}
|
|
6046
|
+
}
|
|
6047
|
+
}
|
|
6048
|
+
return valid;
|
|
6049
|
+
};
|
|
6050
|
+
var validateTypeInfoFieldValue = (value, typeInfoField, typeInfoMap, ignoreArray = false, strict = false, customValidators, typeOperation, relationshipValidationType = "STRICT_EXCLUDE" /* STRICT_EXCLUDE */, itemIsPartial) => {
|
|
6051
|
+
const {
|
|
6052
|
+
type,
|
|
6053
|
+
typeReference,
|
|
6054
|
+
array,
|
|
6055
|
+
optional,
|
|
6056
|
+
possibleValues,
|
|
6057
|
+
tags: { customType, constraints: { pattern = void 0 } = {} } = {}
|
|
6058
|
+
} = typeInfoField;
|
|
6059
|
+
const results = {
|
|
6060
|
+
typeName: typeReference ?? type,
|
|
6061
|
+
valid: true,
|
|
6062
|
+
error: "",
|
|
6063
|
+
errorMap: {}
|
|
6064
|
+
};
|
|
6065
|
+
const requiredValueAllowed = !typeReference || relationshipValidationType === "INCLUDE" /* INCLUDE */;
|
|
6066
|
+
if (requiredValueAllowed && !itemIsPartial && !optional && !hasValue(value)) {
|
|
6067
|
+
results.valid = false;
|
|
6068
|
+
results.error = ERROR_MESSAGE_CONSTANTS.MISSING;
|
|
6069
|
+
} else if (array && !ignoreArray) {
|
|
6070
|
+
const {
|
|
6071
|
+
valid: validArray,
|
|
6072
|
+
error: arrayError,
|
|
6073
|
+
errorMap: arrayErrorMap
|
|
6074
|
+
} = validateArrayOfTypeInfoFieldValues(
|
|
6075
|
+
value,
|
|
6076
|
+
typeInfoField,
|
|
6077
|
+
typeInfoMap,
|
|
6078
|
+
strict,
|
|
6079
|
+
customValidators,
|
|
6080
|
+
typeOperation,
|
|
6081
|
+
relationshipValidationType,
|
|
6082
|
+
itemIsPartial
|
|
6083
|
+
);
|
|
6084
|
+
results.valid = getValidityValue(results.valid, validArray);
|
|
6085
|
+
results.error = arrayError;
|
|
6086
|
+
results.errorMap = arrayErrorMap;
|
|
6087
|
+
} else {
|
|
6088
|
+
if (typeReference) {
|
|
6089
|
+
if (relationshipValidationType === "INCLUDE" /* INCLUDE */) {
|
|
6090
|
+
const {
|
|
6091
|
+
valid: validTypeInfo,
|
|
6092
|
+
error: typeInfoError,
|
|
6093
|
+
errorMap: typeInfoErrorMap
|
|
6094
|
+
} = validateTypeInfoValue(
|
|
6095
|
+
value,
|
|
6096
|
+
typeReference,
|
|
6097
|
+
typeInfoMap,
|
|
6098
|
+
strict,
|
|
6099
|
+
customValidators,
|
|
6100
|
+
typeOperation,
|
|
6101
|
+
relationshipValidationType,
|
|
6102
|
+
itemIsPartial
|
|
6103
|
+
);
|
|
6104
|
+
results.valid = getValidityValue(results.valid, validTypeInfo);
|
|
6105
|
+
results.error = typeInfoError;
|
|
6106
|
+
results.errorMap = typeInfoErrorMap;
|
|
6107
|
+
} else if (relationshipValidationType === "STRICT_EXCLUDE" /* STRICT_EXCLUDE */) {
|
|
6108
|
+
const valueSupplied = typeof value !== "undefined";
|
|
6109
|
+
if (valueSupplied) {
|
|
6110
|
+
results.valid = false;
|
|
6111
|
+
results.error = ERROR_MESSAGE_CONSTANTS.RELATIONSHIP_VALUES_ARE_STRICTLY_EXCLUDED;
|
|
6112
|
+
}
|
|
6113
|
+
} else if (relationshipValidationType === "EXCLUDE" /* EXCLUDE */) {
|
|
6114
|
+
results.valid = getValidityValue(results.valid, true);
|
|
6115
|
+
}
|
|
6116
|
+
} else if (possibleValues && !possibleValues.includes(value)) {
|
|
6117
|
+
results.valid = false;
|
|
6118
|
+
results.error = ERROR_MESSAGE_CONSTANTS.INVALID_OPTION;
|
|
6119
|
+
} else {
|
|
6120
|
+
const pendingValid = validateKeywordType(value, type);
|
|
6121
|
+
const customValid = validateCustomType(
|
|
6122
|
+
value,
|
|
6123
|
+
customType,
|
|
6124
|
+
customValidators
|
|
6125
|
+
);
|
|
6126
|
+
results.valid = getValidityValue(results.valid, pendingValid);
|
|
6127
|
+
results.valid = getValidityValue(results.valid, customValid);
|
|
6128
|
+
if (type === "string" && typeof pattern === "string") {
|
|
6129
|
+
const { valid: patternValid, error: patternError } = validateValueMatchesPattern(value, pattern);
|
|
6130
|
+
results.valid = getValidityValue(results.valid, patternValid);
|
|
6131
|
+
results.error = patternError;
|
|
6132
|
+
}
|
|
6133
|
+
if (!customValid) {
|
|
6134
|
+
results.error = INVALID_CUSTOM_TYPE;
|
|
6135
|
+
} else if (!results.valid) {
|
|
6136
|
+
results.error = results.error ? results.error : PRIMITIVE_ERROR_MESSAGE_CONSTANTS[type];
|
|
6137
|
+
}
|
|
6138
|
+
}
|
|
6139
|
+
}
|
|
6140
|
+
return results;
|
|
6141
|
+
};
|
|
6142
|
+
var validateArrayOfTypeInfoFieldValues = (values = [], typeInfoField, typeInfoMap, strict = false, customValidators, typeOperation, relationshipValidationType, itemIsPartial) => {
|
|
6143
|
+
const { type, typeReference } = typeInfoField;
|
|
6144
|
+
const results = {
|
|
6145
|
+
typeName: typeReference ?? type,
|
|
6146
|
+
valid: true,
|
|
6147
|
+
error: "",
|
|
6148
|
+
errorMap: {}
|
|
6149
|
+
};
|
|
6150
|
+
for (let i = 0; i < values.length; i++) {
|
|
6151
|
+
const v = values[i];
|
|
6152
|
+
const {
|
|
6153
|
+
valid: indexValid,
|
|
6154
|
+
error: indexError = "",
|
|
6155
|
+
errorMap: indexErrorMap
|
|
6156
|
+
} = validateTypeInfoFieldValue(
|
|
6157
|
+
v,
|
|
6158
|
+
typeInfoField,
|
|
6159
|
+
typeInfoMap,
|
|
6160
|
+
true,
|
|
6161
|
+
strict,
|
|
6162
|
+
customValidators,
|
|
6163
|
+
typeOperation,
|
|
6164
|
+
relationshipValidationType,
|
|
6165
|
+
itemIsPartial
|
|
6166
|
+
);
|
|
6167
|
+
results.valid = getValidityValue(results.valid, indexValid);
|
|
6168
|
+
results.errorMap[getPathString([i])] = [indexError];
|
|
6169
|
+
for (const er in indexErrorMap) {
|
|
6170
|
+
results.errorMap[getPathString([i, er])] = indexErrorMap[er];
|
|
6171
|
+
}
|
|
6172
|
+
}
|
|
6173
|
+
return results;
|
|
6174
|
+
};
|
|
6175
|
+
var validateTypeInfoFieldOperationAllowed = (fieldName, fieldOperation, typeInfoField) => {
|
|
6176
|
+
const results = {
|
|
6177
|
+
typeName: null,
|
|
6178
|
+
valid: true,
|
|
6179
|
+
error: "",
|
|
6180
|
+
errorMap: {}
|
|
6181
|
+
};
|
|
6182
|
+
if (fieldOperation && typeInfoField) {
|
|
6183
|
+
const {
|
|
6184
|
+
type,
|
|
6185
|
+
typeReference,
|
|
6186
|
+
tags = {}
|
|
6187
|
+
} = typeInfoField || {};
|
|
6188
|
+
const { deniedOperations: { [fieldOperation]: denied = false } = {} } = tags;
|
|
6189
|
+
results.typeName = typeReference ?? type;
|
|
6190
|
+
results.valid = !denied;
|
|
6191
|
+
if (!results.valid) {
|
|
6192
|
+
results.error = DENIED_TYPE_OPERATIONS[fieldOperation];
|
|
6193
|
+
results.errorMap[fieldName] = [results.error];
|
|
6194
|
+
}
|
|
6195
|
+
}
|
|
6196
|
+
return results;
|
|
6197
|
+
};
|
|
6198
|
+
var validateTypeOperationAllowed = (typeName, valueFields, typeOperation, typeInfo) => {
|
|
6199
|
+
const results = {
|
|
6200
|
+
typeName,
|
|
6201
|
+
valid: true,
|
|
6202
|
+
error: "",
|
|
6203
|
+
errorMap: {}
|
|
6204
|
+
};
|
|
6205
|
+
const { fields = {}, tags = {} } = typeInfo;
|
|
6206
|
+
const { deniedOperations: { [typeOperation]: denied = false } = {} } = tags;
|
|
6207
|
+
if (denied) {
|
|
6208
|
+
results.valid = false;
|
|
6209
|
+
results.error = DENIED_TYPE_OPERATIONS[typeOperation];
|
|
6210
|
+
} else {
|
|
6211
|
+
for (const vF of valueFields) {
|
|
6212
|
+
const vFieldInfo = fields[vF];
|
|
6213
|
+
const { valid: vFValid, error: vFError } = validateTypeInfoFieldOperationAllowed(vF, typeOperation, vFieldInfo);
|
|
6214
|
+
results.valid = getValidityValue(results.valid, vFValid);
|
|
6215
|
+
if (!vFValid) {
|
|
6216
|
+
results.errorMap[vF] = [vFError];
|
|
6217
|
+
}
|
|
6218
|
+
}
|
|
6219
|
+
}
|
|
6220
|
+
return results;
|
|
6221
|
+
};
|
|
6222
|
+
var validateTypeInfoValue = (value, typeInfoFullName, typeInfoMap, strict = false, customValidators, typeOperation, relationshipValidationType, itemIsPartial) => {
|
|
6223
|
+
const typeInfo = typeInfoMap[typeInfoFullName];
|
|
6224
|
+
const results = {
|
|
6225
|
+
typeName: typeInfoFullName,
|
|
6226
|
+
valid: !!typeInfo,
|
|
6227
|
+
error: !!typeInfo ? "" : ERROR_MESSAGE_CONSTANTS.TYPE_DOES_NOT_EXIST,
|
|
6228
|
+
errorMap: {}
|
|
6229
|
+
};
|
|
6230
|
+
if (typeInfo) {
|
|
6231
|
+
const { primaryField, fields, unionFieldSets } = typeInfo;
|
|
6232
|
+
if (typeOperation) {
|
|
6233
|
+
const valueFields = typeof value === "object" ? Object.keys(value ?? {}) : [];
|
|
6234
|
+
const {
|
|
6235
|
+
valid: operationValid,
|
|
6236
|
+
error: operationError,
|
|
6237
|
+
errorMap: operationErrorMap
|
|
6238
|
+
} = validateTypeOperationAllowed(
|
|
6239
|
+
typeInfoFullName,
|
|
6240
|
+
valueFields,
|
|
6241
|
+
typeOperation,
|
|
6242
|
+
typeInfo
|
|
6243
|
+
);
|
|
6244
|
+
results.valid = getValidityValue(results.valid, operationValid);
|
|
6245
|
+
results.error = operationError;
|
|
6246
|
+
for (const oE in operationErrorMap) {
|
|
6247
|
+
const existingError = results.errorMap[oE] ?? [];
|
|
6248
|
+
results.errorMap[oE] = existingError ? [...existingError, ...operationErrorMap[oE]] : operationErrorMap[oE];
|
|
6249
|
+
}
|
|
6250
|
+
if (!operationValid && operationError) {
|
|
6251
|
+
results.error = operationError;
|
|
6252
|
+
}
|
|
6253
|
+
}
|
|
6254
|
+
if (unionFieldSets) {
|
|
6255
|
+
const valueFields = Object.keys(value || {});
|
|
6256
|
+
let valid = false;
|
|
6257
|
+
for (const uFS of unionFieldSets) {
|
|
6258
|
+
valid = valueFields.every((vF) => uFS.includes(vF));
|
|
6259
|
+
if (valid) {
|
|
6260
|
+
break;
|
|
6261
|
+
}
|
|
6262
|
+
}
|
|
6263
|
+
if (!valid) {
|
|
6264
|
+
results.valid = false;
|
|
6265
|
+
results.error = ERROR_MESSAGE_CONSTANTS.NO_UNION_TYPE_MATCHED;
|
|
6266
|
+
}
|
|
6267
|
+
} else if (strict) {
|
|
6268
|
+
const knownFields = Object.keys(fields || {});
|
|
6269
|
+
const valueFields = Object.keys(value || {});
|
|
6270
|
+
for (const vF of valueFields) {
|
|
6271
|
+
if (!knownFields.includes(vF)) {
|
|
6272
|
+
results.valid = false;
|
|
6273
|
+
results.errorMap[vF] = [ERROR_MESSAGE_CONSTANTS.INVALID_FIELD];
|
|
6274
|
+
}
|
|
6275
|
+
}
|
|
6276
|
+
}
|
|
6277
|
+
if (fields) {
|
|
6278
|
+
for (const key in fields) {
|
|
6279
|
+
if (typeOperation !== "CREATE" /* CREATE */ || typeof primaryField !== "string" || key !== primaryField) {
|
|
6280
|
+
const typeInfoField = fields[key];
|
|
6281
|
+
const fieldValue = value[key];
|
|
6282
|
+
const {
|
|
6283
|
+
valid: fieldValid,
|
|
6284
|
+
error: fieldError,
|
|
6285
|
+
errorMap: fieldErrorMap
|
|
6286
|
+
} = validateTypeInfoFieldValue(
|
|
6287
|
+
fieldValue,
|
|
6288
|
+
typeInfoField,
|
|
6289
|
+
typeInfoMap,
|
|
6290
|
+
false,
|
|
6291
|
+
strict,
|
|
6292
|
+
customValidators,
|
|
6293
|
+
typeOperation,
|
|
6294
|
+
relationshipValidationType,
|
|
6295
|
+
itemIsPartial
|
|
6296
|
+
);
|
|
6297
|
+
results.valid = getValidityValue(results.valid, fieldValid);
|
|
6298
|
+
results.errorMap[key] = [fieldError];
|
|
6299
|
+
for (const fE in fieldErrorMap) {
|
|
6300
|
+
results.errorMap[getPathString([key, fE])] = fieldErrorMap[fE];
|
|
6301
|
+
}
|
|
6302
|
+
}
|
|
6303
|
+
}
|
|
6304
|
+
}
|
|
6305
|
+
if (!results.valid && !results.error) {
|
|
6306
|
+
results.error = ERROR_MESSAGE_CONSTANTS.INVALID_TYPE;
|
|
6307
|
+
}
|
|
6308
|
+
}
|
|
6309
|
+
return results;
|
|
6310
|
+
};
|
|
6311
|
+
|
|
5882
6312
|
// src/common/SearchValidation.ts
|
|
5883
6313
|
var SEARCH_VALIDATION_ERRORS = {
|
|
5884
6314
|
INVALID_TYPE_INFO: "INVALID_TYPE_INFO",
|