@resistdesign/voltra 3.0.0-alpha.3 → 3.0.0-alpha.4
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 +75 -0
- package/SearchTypes-DjN6YQzE.d.ts +577 -0
- package/Types-C7XjUjoF.d.ts +240 -0
- package/Validation-CFP59oIP.d.ts +226 -0
- package/api/index.d.ts +6 -0
- package/api/index.js +7968 -0
- package/app/index.d.ts +5 -0
- package/app/index.js +810 -0
- package/common/Testing/CLI.js +432 -0
- package/common/index.d.ts +4 -0
- package/common/index.js +1760 -0
- package/iac/index.d.ts +2 -0
- package/iac/index.js +1661 -0
- package/iac/packs/index.d.ts +1 -0
- package/iac/packs/index.js +1620 -0
- package/index-BkFZlfit.d.ts +112 -0
- package/index-C3-iD9Mh.d.ts +690 -0
- package/index-DZ2BB4iX.d.ts +5357 -0
- package/{src/iac/types/IaCTypes.d.ts → index-DcvJOZ_c.d.ts} +1018 -23
- package/index-IokxSNxm.d.ts +745 -0
- package/index.d.ts +13 -0
- package/index.js +10973 -0
- package/package.json +40 -41
- package/src/api/DataAccessControl.d.ts +0 -85
- package/src/api/DataAccessControl.js +0 -159
- package/src/api/ORM/DACUtils.d.ts +0 -60
- package/src/api/ORM/DACUtils.js +0 -197
- package/src/api/ORM/ListItemUtils.d.ts +0 -7
- package/src/api/ORM/ListItemUtils.js +0 -22
- package/src/api/ORM/ORMRouteMap.d.ts +0 -19
- package/src/api/ORM/ORMRouteMap.js +0 -82
- package/src/api/ORM/TypeInfoORMService.d.ts +0 -103
- package/src/api/ORM/TypeInfoORMService.js +0 -581
- package/src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.d.ts +0 -63
- package/src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.js +0 -2
- package/src/api/ORM/drivers/DynamoDBDataItemDBDriver.d.ts +0 -36
- package/src/api/ORM/drivers/DynamoDBDataItemDBDriver.js +0 -282
- package/src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.d.ts +0 -90
- package/src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.js +0 -2
- package/src/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.d.ts +0 -45
- package/src/api/ORM/drivers/S3FileItemDBDriver/S3FileDriver.js +0 -127
- package/src/api/ORM/drivers/S3FileItemDBDriver.d.ts +0 -44
- package/src/api/ORM/drivers/S3FileItemDBDriver.js +0 -182
- package/src/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.d.ts +0 -12
- package/src/api/ORM/drivers/common/SupportedTypeInfoORMDBDrivers.js +0 -20
- package/src/api/ORM/drivers/common/Types.d.ts +0 -77
- package/src/api/ORM/drivers/common/Types.js +0 -14
- package/src/api/ORM/drivers/common/index.d.ts +0 -2
- package/src/api/ORM/drivers/common/index.js +0 -18
- package/src/api/ORM/drivers/index.d.ts +0 -3
- package/src/api/ORM/drivers/index.js +0 -19
- package/src/api/ORM/index.d.ts +0 -4
- package/src/api/ORM/index.js +0 -43
- package/src/api/Router/AWS.d.ts +0 -26
- package/src/api/Router/AWS.js +0 -76
- package/src/api/Router/Auth.d.ts +0 -2
- package/src/api/Router/Auth.js +0 -9
- package/src/api/Router/CORS.d.ts +0 -6
- package/src/api/Router/CORS.js +0 -27
- package/src/api/Router/Types.d.ts +0 -71
- package/src/api/Router/Types.js +0 -2
- package/src/api/Router/index.d.ts +0 -18
- package/src/api/Router/index.js +0 -145
- package/src/api/index.d.ts +0 -3
- package/src/api/index.js +0 -39
- package/src/app/index.d.ts +0 -1
- package/src/app/index.js +0 -37
- package/src/app/utils/ApplicationState.d.ts +0 -52
- package/src/app/utils/ApplicationState.js +0 -86
- package/src/app/utils/ApplicationStateLoader.d.ts +0 -46
- package/src/app/utils/ApplicationStateLoader.js +0 -57
- package/src/app/utils/Controller.d.ts +0 -4
- package/src/app/utils/Controller.js +0 -47
- package/src/app/utils/Debug.d.ts +0 -4
- package/src/app/utils/Debug.js +0 -30
- package/src/app/utils/EasyLayout.d.ts +0 -49
- package/src/app/utils/EasyLayout.js +0 -122
- package/src/app/utils/Route.d.ts +0 -28
- package/src/app/utils/Route.js +0 -102
- package/src/app/utils/Service.d.ts +0 -12
- package/src/app/utils/Service.js +0 -34
- package/src/app/utils/TypeInfoORMAPIUtils.d.ts +0 -20
- package/src/app/utils/TypeInfoORMAPIUtils.js +0 -62
- package/src/app/utils/TypeInfoORMClient.d.ts +0 -24
- package/src/app/utils/TypeInfoORMClient.js +0 -69
- package/src/app/utils/index.d.ts +0 -8
- package/src/app/utils/index.js +0 -24
- package/src/common/CommandLine/collectRequiredEnvironmentVariables.d.ts +0 -1
- package/src/common/CommandLine/collectRequiredEnvironmentVariables.js +0 -16
- package/src/common/HelperTypes.d.ts +0 -3
- package/src/common/HelperTypes.js +0 -2
- package/src/common/IdGeneration/getSimpleId.d.ts +0 -4
- package/src/common/IdGeneration/getSimpleId.js +0 -16
- package/src/common/IdGeneration/index.d.ts +0 -1
- package/src/common/IdGeneration/index.js +0 -17
- package/src/common/ItemRelationshipInfoTypes.d.ts +0 -46
- package/src/common/ItemRelationshipInfoTypes.js +0 -20
- package/src/common/ItemRelationships/ItemRelationshipValidation.d.ts +0 -10
- package/src/common/ItemRelationships/ItemRelationshipValidation.js +0 -43
- package/src/common/ItemRelationships/index.d.ts +0 -1
- package/src/common/ItemRelationships/index.js +0 -17
- package/src/common/Logging/Utils.d.ts +0 -10
- package/src/common/Logging/Utils.js +0 -33
- package/src/common/Logging/index.d.ts +0 -1
- package/src/common/Logging/index.js +0 -17
- package/src/common/Routing.d.ts +0 -25
- package/src/common/Routing.js +0 -102
- package/src/common/SearchTypes.d.ts +0 -98
- package/src/common/SearchTypes.js +0 -39
- package/src/common/SearchUtils.d.ts +0 -22
- package/src/common/SearchUtils.js +0 -134
- package/src/common/SearchValidation.d.ts +0 -17
- package/src/common/SearchValidation.js +0 -90
- package/src/common/Storyboarding/Types.d.ts +0 -25
- package/src/common/Storyboarding/Types.js +0 -2
- package/src/common/StringTransformers.d.ts +0 -17
- package/src/common/StringTransformers.js +0 -36
- package/src/common/Testing/CLI.d.ts +0 -2
- package/src/common/Testing/CLI.js +0 -56
- package/src/common/Testing/Types.d.ts +0 -117
- package/src/common/Testing/Types.js +0 -19
- package/src/common/Testing/Utils.d.ts +0 -48
- package/src/common/Testing/Utils.js +0 -334
- package/src/common/Testing/index.d.ts +0 -2
- package/src/common/Testing/index.js +0 -18
- package/src/common/TypeInfoDataItemUtils.d.ts +0 -10
- package/src/common/TypeInfoDataItemUtils.js +0 -55
- package/src/common/TypeInfoORM/Types.d.ts +0 -76
- package/src/common/TypeInfoORM/Types.js +0 -55
- package/src/common/TypeInfoORM/index.d.ts +0 -1
- package/src/common/TypeInfoORM/index.js +0 -17
- package/src/common/TypeParsing/Constants.d.ts +0 -1
- package/src/common/TypeParsing/Constants.js +0 -4
- package/src/common/TypeParsing/ParsingUtils/Constants.d.ts +0 -5
- package/src/common/TypeParsing/ParsingUtils/Constants.js +0 -8
- package/src/common/TypeParsing/ParsingUtils/checkType.d.ts +0 -8
- package/src/common/TypeParsing/ParsingUtils/checkType.js +0 -46
- package/src/common/TypeParsing/ParsingUtils/checkUnionType.d.ts +0 -6
- package/src/common/TypeParsing/ParsingUtils/checkUnionType.js +0 -15
- package/src/common/TypeParsing/ParsingUtils/extractCommentTags.d.ts +0 -2
- package/src/common/TypeParsing/ParsingUtils/extractCommentTags.js +0 -105
- package/src/common/TypeParsing/ParsingUtils/extractLiteralValues.d.ts +0 -6
- package/src/common/TypeParsing/ParsingUtils/extractLiteralValues.js +0 -42
- package/src/common/TypeParsing/ParsingUtils/extractTypeDetails.d.ts +0 -8
- package/src/common/TypeParsing/ParsingUtils/extractTypeDetails.js +0 -14
- package/src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.d.ts +0 -5
- package/src/common/TypeParsing/ParsingUtils/getPrimaryFieldForTypeInfo.js +0 -27
- package/src/common/TypeParsing/ParsingUtils/getTypeInfo.d.ts +0 -3
- package/src/common/TypeParsing/ParsingUtils/getTypeInfo.js +0 -27
- package/src/common/TypeParsing/ParsingUtils/getTypeInfoField.d.ts +0 -3
- package/src/common/TypeParsing/ParsingUtils/getTypeInfoField.js +0 -44
- package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.d.ts +0 -4
- package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromAliasType.js +0 -28
- package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.d.ts +0 -4
- package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromFieldFilter.js +0 -105
- package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.d.ts +0 -4
- package/src/common/TypeParsing/ParsingUtils/getTypeInfoFromTypeAlias.js +0 -20
- package/src/common/TypeParsing/ParsingUtils/getTypeKeyword.d.ts +0 -3
- package/src/common/TypeParsing/ParsingUtils/getTypeKeyword.js +0 -17
- package/src/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.d.ts +0 -4
- package/src/common/TypeParsing/ParsingUtils/getUnionOrIntersectionTypeInfo.js +0 -49
- package/src/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.d.ts +0 -2
- package/src/common/TypeParsing/ParsingUtils/getUnionOrLiteralStringValues.js +0 -24
- package/src/common/TypeParsing/TypeInfo.d.ts +0 -142
- package/src/common/TypeParsing/TypeInfo.js +0 -13
- package/src/common/TypeParsing/TypeMapping.d.ts +0 -9
- package/src/common/TypeParsing/TypeMapping.js +0 -32
- package/src/common/TypeParsing/TypeParsing.d.ts +0 -5
- package/src/common/TypeParsing/TypeParsing.js +0 -39
- package/src/common/TypeParsing/Utils.d.ts +0 -21
- package/src/common/TypeParsing/Utils.js +0 -94
- package/src/common/TypeParsing/Validation.d.ts +0 -92
- package/src/common/TypeParsing/Validation.js +0 -340
- package/src/common/TypeParsing/index.d.ts +0 -5
- package/src/common/TypeParsing/index.js +0 -44
- package/src/common/index.d.ts +0 -11
- package/src/common/index.js +0 -47
- package/src/iac/SimpleCFT.d.ts +0 -48
- package/src/iac/SimpleCFT.js +0 -82
- package/src/iac/index.d.ts +0 -9
- package/src/iac/index.js +0 -48
- package/src/iac/packs/auth/user-management.d.ts +0 -14
- package/src/iac/packs/auth/user-management.js +0 -302
- package/src/iac/packs/auth.d.ts +0 -19
- package/src/iac/packs/auth.js +0 -47
- package/src/iac/packs/build/utils.d.ts +0 -100
- package/src/iac/packs/build/utils.js +0 -23
- package/src/iac/packs/build.d.ts +0 -29
- package/src/iac/packs/build.js +0 -217
- package/src/iac/packs/cdn.d.ts +0 -12
- package/src/iac/packs/cdn.js +0 -126
- package/src/iac/packs/cloud-function.d.ts +0 -17
- package/src/iac/packs/cloud-function.js +0 -69
- package/src/iac/packs/database.d.ts +0 -29
- package/src/iac/packs/database.js +0 -27
- package/src/iac/packs/dns.d.ts +0 -13
- package/src/iac/packs/dns.js +0 -26
- package/src/iac/packs/file-storage.d.ts +0 -14
- package/src/iac/packs/file-storage.js +0 -71
- package/src/iac/packs/gateway.d.ts +0 -27
- package/src/iac/packs/gateway.js +0 -342
- package/src/iac/packs/index.d.ts +0 -11
- package/src/iac/packs/index.js +0 -27
- package/src/iac/packs/repo.d.ts +0 -10
- package/src/iac/packs/repo.js +0 -34
- package/src/iac/packs/ssl-certificate.d.ts +0 -10
- package/src/iac/packs/ssl-certificate.js +0 -36
- package/src/iac/types/CloudFormationResourceSpecification.d.ts +0 -2
- package/src/iac/types/Constants.d.ts +0 -9
- package/src/iac/types/Constants.js +0 -20
- package/src/iac/types/IaCTypes.js +0 -14
- package/src/iac/types/Renderers.d.ts +0 -12
- package/src/iac/types/Renderers.js +0 -112
- package/src/iac/types/Types.d.ts +0 -37
- package/src/iac/types/Types.js +0 -2
- package/src/iac/types/Utils.d.ts +0 -2
- package/src/iac/types/Utils.js +0 -60
- package/src/iac/types/generate.d.ts +0 -1
- package/src/iac/types/generate.js +0 -31
- package/src/iac/utils/index.d.ts +0 -36
- package/src/iac/utils/index.js +0 -105
- package/src/iac/utils/patch-utils.d.ts +0 -15
- package/src/iac/utils/patch-utils.js +0 -62
- package/src/index.d.ts +0 -178
- package/src/index.js +0 -214
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.S3SupportedFileItemDBDriverEntry = exports.S3FileItemDBDriver = void 0;
|
|
7
|
-
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
8
|
-
const S3FileDriver_1 = require("./S3FileItemDBDriver/S3FileDriver");
|
|
9
|
-
const SearchUtils_1 = require("../../../common/SearchUtils");
|
|
10
|
-
const Types_1 = require("./common/Types");
|
|
11
|
-
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const fs_1 = __importDefault(require("fs"));
|
|
13
|
-
const TypeParsing_1 = require("../../../common/TypeParsing");
|
|
14
|
-
/**
|
|
15
|
-
* Use S3 as a {@link DataItemDBDriver} for {@link BaseFileItem}s.
|
|
16
|
-
* */
|
|
17
|
-
class S3FileItemDBDriver {
|
|
18
|
-
config;
|
|
19
|
-
specificConfig;
|
|
20
|
-
s3;
|
|
21
|
-
s3FileDriver;
|
|
22
|
-
constructor(config) {
|
|
23
|
-
this.config = config;
|
|
24
|
-
const { dbSpecificConfig } = config;
|
|
25
|
-
const { s3Config, bucketName, urlExpirationInSeconds } = dbSpecificConfig;
|
|
26
|
-
this.specificConfig = dbSpecificConfig;
|
|
27
|
-
this.s3 = new client_s3_1.S3(s3Config);
|
|
28
|
-
this.s3FileDriver = new S3FileDriver_1.S3FileDriver({
|
|
29
|
-
s3Config: s3Config,
|
|
30
|
-
bucketName,
|
|
31
|
-
urlExpirationInSeconds,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create a new @{@link BaseFileItem}.
|
|
36
|
-
* */
|
|
37
|
-
createItem = async (item) => {
|
|
38
|
-
const { tableName } = this.config;
|
|
39
|
-
const { bucketName } = this.specificConfig;
|
|
40
|
-
await this.s3.send(new client_s3_1.PutObjectCommand({
|
|
41
|
-
Bucket: bucketName,
|
|
42
|
-
Key: (0, S3FileDriver_1.getFullFileKey)({
|
|
43
|
-
file: item,
|
|
44
|
-
// SECURITY: `baseDirectory` is only used internally here, and not as part of the `id`.
|
|
45
|
-
baseDirectory: tableName,
|
|
46
|
-
}),
|
|
47
|
-
Body: "",
|
|
48
|
-
}));
|
|
49
|
-
return (0, S3FileDriver_1.getFullFileKey)({
|
|
50
|
-
file: item,
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Read a @{@link BaseFileItem} by its id.
|
|
55
|
-
* */
|
|
56
|
-
readItem = async (id, selectFields) => {
|
|
57
|
-
const { tableName } = this.config;
|
|
58
|
-
const { bucketName } = this.specificConfig;
|
|
59
|
-
if (typeof id === "undefined") {
|
|
60
|
-
throw new Error(Types_1.DATA_ITEM_DB_DRIVER_ERRORS.MISSING_ID);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const itemLoc = (0, S3FileDriver_1.getBaseFileLocationInfo)(id);
|
|
64
|
-
const { ContentType = "", ContentLength = 0, LastModified, Metadata: {} = {}, } = await this.s3.send(new client_s3_1.HeadObjectCommand({
|
|
65
|
-
Bucket: bucketName,
|
|
66
|
-
Key: (0, S3FileDriver_1.getFullFileKey)({
|
|
67
|
-
file: itemLoc,
|
|
68
|
-
baseDirectory: tableName,
|
|
69
|
-
}),
|
|
70
|
-
}));
|
|
71
|
-
const item = {
|
|
72
|
-
...itemLoc,
|
|
73
|
-
id,
|
|
74
|
-
updatedOn: LastModified?.getTime() || 0,
|
|
75
|
-
mimeType: ContentType,
|
|
76
|
-
sizeInBytes: ContentLength,
|
|
77
|
-
isDirectory: ContentType === "application/x-directory",
|
|
78
|
-
uploadUrl: selectFields && selectFields.includes("uploadUrl")
|
|
79
|
-
? await this.s3FileDriver.getFileUploadUrl(itemLoc, tableName)
|
|
80
|
-
: undefined,
|
|
81
|
-
downloadUrl: selectFields && selectFields.includes("downloadUrl")
|
|
82
|
-
? await this.s3FileDriver.getFileDownloadUrl(itemLoc, tableName)
|
|
83
|
-
: undefined,
|
|
84
|
-
};
|
|
85
|
-
return item;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
/**
|
|
89
|
-
* Update a @{@link BaseFileItem}.
|
|
90
|
-
* */
|
|
91
|
-
updateItem = async (uniqueIdentifier, item) => {
|
|
92
|
-
const { directory, name } = item;
|
|
93
|
-
const { tableName } = this.config;
|
|
94
|
-
const { bucketName } = this.specificConfig;
|
|
95
|
-
const oldItemLoc = (0, S3FileDriver_1.getBaseFileLocationInfo)(uniqueIdentifier);
|
|
96
|
-
const { name: oldName, directory: oldDirectory } = oldItemLoc;
|
|
97
|
-
if (name && (name !== oldName || directory !== oldDirectory)) {
|
|
98
|
-
await this.s3.send(new client_s3_1.CopyObjectCommand({
|
|
99
|
-
Bucket: bucketName,
|
|
100
|
-
Key: (0, S3FileDriver_1.getFullFileKey)({
|
|
101
|
-
file: {
|
|
102
|
-
directory,
|
|
103
|
-
name,
|
|
104
|
-
},
|
|
105
|
-
baseDirectory: tableName,
|
|
106
|
-
}),
|
|
107
|
-
CopySource: (0, S3FileDriver_1.getFullFileKey)({
|
|
108
|
-
file: oldItemLoc,
|
|
109
|
-
baseDirectory: tableName,
|
|
110
|
-
}),
|
|
111
|
-
}));
|
|
112
|
-
await this.s3FileDriver.deleteFile(oldItemLoc, tableName);
|
|
113
|
-
}
|
|
114
|
-
await this.readItem(uniqueIdentifier);
|
|
115
|
-
return true;
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Delete a @{@link BaseFileItem} by its id.
|
|
119
|
-
*/
|
|
120
|
-
deleteItem = async (id) => {
|
|
121
|
-
const { tableName } = this.config;
|
|
122
|
-
if (typeof id === "undefined") {
|
|
123
|
-
throw new Error(Types_1.DATA_ITEM_DB_DRIVER_ERRORS.MISSING_ID);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
await this.readItem(id);
|
|
127
|
-
await this.s3FileDriver.deleteFile((0, S3FileDriver_1.getBaseFileLocationInfo)(id), tableName);
|
|
128
|
-
}
|
|
129
|
-
return true;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* List @{@link BaseFileItem}s by a given criteria.
|
|
133
|
-
*/
|
|
134
|
-
listItems = async (config, selectFields) => {
|
|
135
|
-
const { tableName } = this.config;
|
|
136
|
-
const { itemsPerPage = Infinity, cursor, sortFields = [], criteria, } = config;
|
|
137
|
-
const { files: baseFileList = [], cursor: newCursor } = await this.s3FileDriver.listFiles(undefined, tableName, itemsPerPage, cursor);
|
|
138
|
-
const currentFileItems = baseFileList.map((bF) => ({
|
|
139
|
-
id: (0, S3FileDriver_1.getFullFileKey)({
|
|
140
|
-
file: bF,
|
|
141
|
-
}),
|
|
142
|
-
...bF,
|
|
143
|
-
}));
|
|
144
|
-
const filteredFiles = criteria
|
|
145
|
-
? (0, SearchUtils_1.getFilterTypeInfoDataItemsBySearchCriteria)(criteria, currentFileItems)
|
|
146
|
-
: currentFileItems;
|
|
147
|
-
const expandedFiles = [];
|
|
148
|
-
for (const fF of filteredFiles) {
|
|
149
|
-
expandedFiles.push({
|
|
150
|
-
...fF,
|
|
151
|
-
uploadUrl: selectFields?.includes("uploadUrl")
|
|
152
|
-
? await this.s3FileDriver.getFileUploadUrl(fF, tableName)
|
|
153
|
-
: undefined,
|
|
154
|
-
downloadUrl: selectFields?.includes("downloadUrl")
|
|
155
|
-
? await this.s3FileDriver.getFileDownloadUrl(fF, tableName)
|
|
156
|
-
: undefined,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
return {
|
|
160
|
-
items: (0, SearchUtils_1.getSortedItems)(sortFields, expandedFiles),
|
|
161
|
-
cursor: newCursor,
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
exports.S3FileItemDBDriver = S3FileItemDBDriver;
|
|
166
|
-
/**
|
|
167
|
-
* The supported DB driver entry for the S3 File {@link DataItemDBDriver}.
|
|
168
|
-
* */
|
|
169
|
-
exports.S3SupportedFileItemDBDriverEntry = {
|
|
170
|
-
factory: (config) => {
|
|
171
|
-
return new S3FileItemDBDriver(config);
|
|
172
|
-
},
|
|
173
|
-
getDBSpecificConfigTypeInfo: () => {
|
|
174
|
-
const configTypesPath = path_1.default.join(__dirname, "S3DataItemDBDriver", "ConfigTypes.ts");
|
|
175
|
-
const configTypesTS = fs_1.default.readFileSync(configTypesPath, "utf8");
|
|
176
|
-
const typeInfoMap = (0, TypeParsing_1.getTypeInfoMapFromTypeScript)(configTypesTS);
|
|
177
|
-
return {
|
|
178
|
-
entryTypeName: "S3SpecificConfig",
|
|
179
|
-
typeInfoMap,
|
|
180
|
-
};
|
|
181
|
-
},
|
|
182
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { SupportedDataItemDBDriverEntry } from "./Types";
|
|
2
|
-
/**
|
|
3
|
-
* The supported Type Info ORM DB driver names.
|
|
4
|
-
* */
|
|
5
|
-
export declare enum SupportedTypeInfoORMDBDriverNames {
|
|
6
|
-
DYNAMO_DB_DATA_ITEM = "DYNAMO_DB_DATA_ITEM",
|
|
7
|
-
S3_FILE_ITEM = "S3_FILE_ITEM"
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* A map of supported Type Info ORM DB drivers by name.
|
|
11
|
-
* */
|
|
12
|
-
export declare const SUPPORTED_TYPE_INFO_ORM_DB_DRIVERS: Record<SupportedTypeInfoORMDBDriverNames, SupportedDataItemDBDriverEntry>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SUPPORTED_TYPE_INFO_ORM_DB_DRIVERS = exports.SupportedTypeInfoORMDBDriverNames = void 0;
|
|
4
|
-
const DynamoDBDataItemDBDriver_1 = require("../DynamoDBDataItemDBDriver");
|
|
5
|
-
const S3FileItemDBDriver_1 = require("../S3FileItemDBDriver");
|
|
6
|
-
/**
|
|
7
|
-
* The supported Type Info ORM DB driver names.
|
|
8
|
-
* */
|
|
9
|
-
var SupportedTypeInfoORMDBDriverNames;
|
|
10
|
-
(function (SupportedTypeInfoORMDBDriverNames) {
|
|
11
|
-
SupportedTypeInfoORMDBDriverNames["DYNAMO_DB_DATA_ITEM"] = "DYNAMO_DB_DATA_ITEM";
|
|
12
|
-
SupportedTypeInfoORMDBDriverNames["S3_FILE_ITEM"] = "S3_FILE_ITEM";
|
|
13
|
-
})(SupportedTypeInfoORMDBDriverNames || (exports.SupportedTypeInfoORMDBDriverNames = SupportedTypeInfoORMDBDriverNames = {}));
|
|
14
|
-
/**
|
|
15
|
-
* A map of supported Type Info ORM DB drivers by name.
|
|
16
|
-
* */
|
|
17
|
-
exports.SUPPORTED_TYPE_INFO_ORM_DB_DRIVERS = {
|
|
18
|
-
[SupportedTypeInfoORMDBDriverNames.DYNAMO_DB_DATA_ITEM]: DynamoDBDataItemDBDriver_1.DynamoDBSupportedDataItemDBDriverEntry,
|
|
19
|
-
[SupportedTypeInfoORMDBDriverNames.S3_FILE_ITEM]: S3FileItemDBDriver_1.S3SupportedFileItemDBDriverEntry,
|
|
20
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { TypeInfoDataItem, TypeInfoPack } from "../../../../common/TypeParsing/TypeInfo";
|
|
2
|
-
import { ItemRelationshipInfo, ItemRelationshipInfoIdentifyingKeys } from "../../../../common/ItemRelationshipInfoTypes";
|
|
3
|
-
import { ListItemsConfig, ListItemsResults } from "../../../../common/SearchTypes";
|
|
4
|
-
/**
|
|
5
|
-
* The errors that can be thrown by a {@link DataItemDBDriver}.
|
|
6
|
-
* */
|
|
7
|
-
export declare enum DATA_ITEM_DB_DRIVER_ERRORS {
|
|
8
|
-
MISSING_ID = "MISSING_ID",
|
|
9
|
-
INVALID_CURSOR = "INVALID_CURSOR",
|
|
10
|
-
ITEM_NOT_FOUND = "ITEM_NOT_FOUND",
|
|
11
|
-
MISSING_UNIQUE_IDENTIFIER = "MISSING_UNIQUE_IDENTIFIER",
|
|
12
|
-
SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED = "SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED"
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The generic type for a database driver configuration.
|
|
16
|
-
* */
|
|
17
|
-
export type DataItemDBDriverConfig<ItemType extends TypeInfoDataItem, UniquelyIdentifyingFieldName extends keyof ItemType> = {
|
|
18
|
-
tableName: string;
|
|
19
|
-
uniquelyIdentifyingFieldName: UniquelyIdentifyingFieldName;
|
|
20
|
-
generateUniqueIdentifier?: (targetItem: ItemType) => string;
|
|
21
|
-
dbSpecificConfig?: Record<string, any>;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* The API for a database driver.
|
|
25
|
-
* */
|
|
26
|
-
export type DataItemDBDriver<ItemType extends TypeInfoDataItem, UniquelyIdentifyingFieldName extends keyof ItemType> = {
|
|
27
|
-
createItem: (newItem: Partial<Omit<ItemType, UniquelyIdentifyingFieldName>>) => Promise<ItemType[UniquelyIdentifyingFieldName]>;
|
|
28
|
-
readItem: (uniqueIdentifier: ItemType[UniquelyIdentifyingFieldName], selectedFields?: (keyof ItemType)[]) => Promise<Partial<ItemType>>;
|
|
29
|
-
updateItem: (uniqueIdentifier: ItemType[UniquelyIdentifyingFieldName], updatedItem: Partial<ItemType>) => Promise<boolean>;
|
|
30
|
-
deleteItem: (uniqueIdentifier: ItemType[UniquelyIdentifyingFieldName]) => Promise<boolean>;
|
|
31
|
-
listItems: (config: ListItemsConfig, selectedFields?: (keyof ItemType)[]) => Promise<ListItemsResults<Partial<ItemType>>>;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* An entry for a supported database driver.
|
|
35
|
-
* */
|
|
36
|
-
export type SupportedDataItemDBDriverEntry = {
|
|
37
|
-
factory: <ItemType extends Record<any, any>, UniquelyIdentifyingFieldName extends keyof ItemType>(config: DataItemDBDriverConfig<ItemType, UniquelyIdentifyingFieldName>) => DataItemDBDriver<ItemType, UniquelyIdentifyingFieldName>;
|
|
38
|
-
getDBSpecificConfigTypeInfo: () => TypeInfoPack;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* The API for a database driver that handles item relationships.
|
|
42
|
-
* */
|
|
43
|
-
export type ItemRelationshipDBDriver = DataItemDBDriver<ItemRelationshipInfo, ItemRelationshipInfoIdentifyingKeys.id>;
|
|
44
|
-
/**
|
|
45
|
-
* The location information for a file.
|
|
46
|
-
* */
|
|
47
|
-
export type BaseFileLocationInfo = {
|
|
48
|
-
directory?: string;
|
|
49
|
-
name: string;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* The most integral information about a file.
|
|
53
|
-
* */
|
|
54
|
-
export type BaseFile = BaseFileLocationInfo & {
|
|
55
|
-
updatedOn: number;
|
|
56
|
-
mimeType: string;
|
|
57
|
-
sizeInBytes: number;
|
|
58
|
-
isDirectory?: boolean;
|
|
59
|
-
uploadUrl?: string;
|
|
60
|
-
downloadUrl?: string;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* The result returned when listing files.
|
|
64
|
-
* */
|
|
65
|
-
export type ListFilesResult = {
|
|
66
|
-
cursor?: string;
|
|
67
|
-
files: BaseFile[];
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* An API for a cloud file service driver.
|
|
71
|
-
* */
|
|
72
|
-
export type CloudFileServiceDriver = {
|
|
73
|
-
getFileUploadUrl: (file: BaseFileLocationInfo, baseDirectory?: string) => Promise<string>;
|
|
74
|
-
getFileDownloadUrl: (file: BaseFileLocationInfo, baseDirectory?: string) => Promise<string>;
|
|
75
|
-
deleteFile: (file: BaseFileLocationInfo, baseDirectory?: string) => Promise<void>;
|
|
76
|
-
listFiles: (path?: string, baseDirectory?: string, maxNumberOfFiles?: number, cursor?: string) => Promise<ListFilesResult>;
|
|
77
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DATA_ITEM_DB_DRIVER_ERRORS = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The errors that can be thrown by a {@link DataItemDBDriver}.
|
|
6
|
-
* */
|
|
7
|
-
var DATA_ITEM_DB_DRIVER_ERRORS;
|
|
8
|
-
(function (DATA_ITEM_DB_DRIVER_ERRORS) {
|
|
9
|
-
DATA_ITEM_DB_DRIVER_ERRORS["MISSING_ID"] = "MISSING_ID";
|
|
10
|
-
DATA_ITEM_DB_DRIVER_ERRORS["INVALID_CURSOR"] = "INVALID_CURSOR";
|
|
11
|
-
DATA_ITEM_DB_DRIVER_ERRORS["ITEM_NOT_FOUND"] = "ITEM_NOT_FOUND";
|
|
12
|
-
DATA_ITEM_DB_DRIVER_ERRORS["MISSING_UNIQUE_IDENTIFIER"] = "MISSING_UNIQUE_IDENTIFIER";
|
|
13
|
-
DATA_ITEM_DB_DRIVER_ERRORS["SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED"] = "SEARCH_COMPARISON_OPERATOR_NOT_SUPPORTED";
|
|
14
|
-
})(DATA_ITEM_DB_DRIVER_ERRORS || (exports.DATA_ITEM_DB_DRIVER_ERRORS = DATA_ITEM_DB_DRIVER_ERRORS = {}));
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Types"), exports);
|
|
18
|
-
__exportStar(require("./SupportedTypeInfoORMDBDrivers"), exports);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./S3FileItemDBDriver"), exports);
|
|
18
|
-
__exportStar(require("./DynamoDBDataItemDBDriver"), exports);
|
|
19
|
-
__exportStar(require("./common"), exports);
|
package/src/api/ORM/index.d.ts
DELETED
package/src/api/ORM/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Drivers = void 0;
|
|
40
|
-
exports.Drivers = __importStar(require("./drivers"));
|
|
41
|
-
__exportStar(require("./TypeInfoORMService"), exports);
|
|
42
|
-
__exportStar(require("./DACUtils"), exports);
|
|
43
|
-
__exportStar(require("./ORMRouteMap"), exports);
|
package/src/api/Router/AWS.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { AuthInfo, CloudFunctionEventTransformer } from "./Types";
|
|
2
|
-
/**
|
|
3
|
-
* AWS specific utilities for processing routing and normalizing Cloud Function events.
|
|
4
|
-
* */
|
|
5
|
-
export declare namespace AWS {
|
|
6
|
-
/**
|
|
7
|
-
* An AWS specific Cloud Function event.
|
|
8
|
-
* */
|
|
9
|
-
interface IAWSCloudFunctionEvent {
|
|
10
|
-
requestContext?: Record<any, any>;
|
|
11
|
-
httpMethod?: string;
|
|
12
|
-
headers?: Record<string, string>;
|
|
13
|
-
multiValueHeaders?: Record<string, string[]>;
|
|
14
|
-
path?: string;
|
|
15
|
-
body?: string;
|
|
16
|
-
}
|
|
17
|
-
const getPathFromEvent: (event: IAWSCloudFunctionEvent) => string;
|
|
18
|
-
const getBodyFromEvent: (event: IAWSCloudFunctionEvent) => any;
|
|
19
|
-
const getHeadersFromEvent: (event: IAWSCloudFunctionEvent) => Record<string, string[]>;
|
|
20
|
-
const getMethodFromEvent: (event: IAWSCloudFunctionEvent) => string;
|
|
21
|
-
const getAuthInfo: (event: IAWSCloudFunctionEvent) => AuthInfo;
|
|
22
|
-
/**
|
|
23
|
-
* Parse out the Auth, CORS, Headers, Method and Body from an AWS Cloud Function event.
|
|
24
|
-
* */
|
|
25
|
-
const normalizeCloudFunctionEvent: CloudFunctionEventTransformer;
|
|
26
|
-
}
|
package/src/api/Router/AWS.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AWS = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* AWS specific utilities for processing routing and normalizing Cloud Function events.
|
|
6
|
-
* */
|
|
7
|
-
var AWS;
|
|
8
|
-
(function (AWS) {
|
|
9
|
-
AWS.getPathFromEvent = (event) => {
|
|
10
|
-
const { path = "" } = event;
|
|
11
|
-
return path;
|
|
12
|
-
};
|
|
13
|
-
AWS.getBodyFromEvent = (event) => {
|
|
14
|
-
const { body = "" } = event;
|
|
15
|
-
try {
|
|
16
|
-
const bodyValue = JSON.parse(body);
|
|
17
|
-
return bodyValue;
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
AWS.getHeadersFromEvent = (event) => {
|
|
24
|
-
const { headers = {}, multiValueHeaders = {} } = event;
|
|
25
|
-
const mergedHeaders = {
|
|
26
|
-
...headers,
|
|
27
|
-
...multiValueHeaders,
|
|
28
|
-
};
|
|
29
|
-
const normalizedHeaders = Object.keys(mergedHeaders).reduce((acc, key) => {
|
|
30
|
-
const value = mergedHeaders[key];
|
|
31
|
-
const normalizedKey = key.toLowerCase();
|
|
32
|
-
const normalizedValue = Array.isArray(value) ? value : [value];
|
|
33
|
-
return {
|
|
34
|
-
...acc,
|
|
35
|
-
[normalizedKey]: normalizedValue,
|
|
36
|
-
};
|
|
37
|
-
}, {});
|
|
38
|
-
return normalizedHeaders;
|
|
39
|
-
};
|
|
40
|
-
AWS.getMethodFromEvent = (event) => {
|
|
41
|
-
const { httpMethod = "" } = event;
|
|
42
|
-
return httpMethod;
|
|
43
|
-
};
|
|
44
|
-
AWS.getAuthInfo = (event) => {
|
|
45
|
-
const { requestContext: { authorizer: { claims: { sub: userId = undefined, "cognito:groups": roles = [], } = {}, } = {}, } = {}, } = event;
|
|
46
|
-
const cleanRoles = Array.isArray(roles)
|
|
47
|
-
? roles
|
|
48
|
-
: typeof roles === "string"
|
|
49
|
-
? roles
|
|
50
|
-
.split(",")
|
|
51
|
-
.map((x) => x.trim())
|
|
52
|
-
.filter((x) => !!x)
|
|
53
|
-
: [];
|
|
54
|
-
return {
|
|
55
|
-
userId,
|
|
56
|
-
roles: cleanRoles,
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Parse out the Auth, CORS, Headers, Method and Body from an AWS Cloud Function event.
|
|
61
|
-
* */
|
|
62
|
-
AWS.normalizeCloudFunctionEvent = (event) => {
|
|
63
|
-
const authInfo = AWS.getAuthInfo(event);
|
|
64
|
-
const headers = AWS.getHeadersFromEvent(event);
|
|
65
|
-
const method = AWS.getMethodFromEvent(event);
|
|
66
|
-
const path = AWS.getPathFromEvent(event);
|
|
67
|
-
const body = AWS.getBodyFromEvent(event);
|
|
68
|
-
return {
|
|
69
|
-
authInfo,
|
|
70
|
-
headers,
|
|
71
|
-
method,
|
|
72
|
-
path,
|
|
73
|
-
body,
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
})(AWS || (exports.AWS = AWS = {}));
|
package/src/api/Router/Auth.d.ts
DELETED
package/src/api/Router/Auth.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRouteIsAuthorized = void 0;
|
|
4
|
-
const getRouteIsAuthorized = (authInfo, authConfig) => {
|
|
5
|
-
const { userId, roles = [] } = authInfo;
|
|
6
|
-
const { public: routeIsPublic = false, anyAuthorized, allowedRoles = [] } = authConfig;
|
|
7
|
-
return routeIsPublic || (anyAuthorized && !!userId) || !!allowedRoles.find((role) => roles.includes(role));
|
|
8
|
-
};
|
|
9
|
-
exports.getRouteIsAuthorized = getRouteIsAuthorized;
|
package/src/api/Router/CORS.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CORSPatter } from "./Types";
|
|
2
|
-
export declare const originMatchesString: (origin?: string, str?: string) => boolean;
|
|
3
|
-
export declare const originMatchesRegExp: (origin?: string, regExp?: RegExp) => boolean;
|
|
4
|
-
export declare const originMatches: (origin?: string, corsPattern?: CORSPatter) => boolean;
|
|
5
|
-
export declare const getAllowedCORSOrigin: (origin?: string, corsPatterns?: CORSPatter[]) => string;
|
|
6
|
-
export declare const getHeadersWithCORS: (origin?: string, corsPatterns?: CORSPatter[]) => Record<string, string>;
|
package/src/api/Router/CORS.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHeadersWithCORS = exports.getAllowedCORSOrigin = exports.originMatches = exports.originMatchesRegExp = exports.originMatchesString = void 0;
|
|
4
|
-
const originMatchesString = (origin = "", str = "") => str === origin;
|
|
5
|
-
exports.originMatchesString = originMatchesString;
|
|
6
|
-
const originMatchesRegExp = (origin = "", regExp = /^$/) => !!regExp.test(origin);
|
|
7
|
-
exports.originMatchesRegExp = originMatchesRegExp;
|
|
8
|
-
const originMatches = (origin = "", corsPattern = "") => {
|
|
9
|
-
if (typeof corsPattern === "string") {
|
|
10
|
-
return (0, exports.originMatchesString)(origin, corsPattern);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
return (0, exports.originMatchesRegExp)(origin, corsPattern);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
exports.originMatches = originMatches;
|
|
17
|
-
const getAllowedCORSOrigin = (origin = "", corsPatterns = []) => !!corsPatterns.find((cP) => (0, exports.originMatches)(origin, cP)) ? origin : "";
|
|
18
|
-
exports.getAllowedCORSOrigin = getAllowedCORSOrigin;
|
|
19
|
-
const getHeadersWithCORS = (origin = "", corsPatterns = []) => {
|
|
20
|
-
return {
|
|
21
|
-
"Access-Control-Allow-Origin": (0, exports.getAllowedCORSOrigin)(origin, corsPatterns),
|
|
22
|
-
"Access-Control-Allow-Credentials": "true",
|
|
23
|
-
"Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept, Authorization",
|
|
24
|
-
"Access-Control-Allow-Methods": "OPTIONS, HEAD, GET, POST, PUT, PATCH, DELETE",
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
exports.getHeadersWithCORS = getHeadersWithCORS;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A pattern for a CORS origin.
|
|
3
|
-
* */
|
|
4
|
-
export type CORSPatter = string | RegExp;
|
|
5
|
-
/**
|
|
6
|
-
* User authentication information.
|
|
7
|
-
* Typically, from Cognito.
|
|
8
|
-
* */
|
|
9
|
-
export type AuthInfo = {
|
|
10
|
-
userId?: string;
|
|
11
|
-
roles?: string[];
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* The normalized event data that is passed to the route handler.
|
|
15
|
-
* */
|
|
16
|
-
export type NormalizedCloudFunctionEventData = {
|
|
17
|
-
authInfo: AuthInfo;
|
|
18
|
-
headers: Record<string, string[]>;
|
|
19
|
-
method: string;
|
|
20
|
-
path: string;
|
|
21
|
-
body: any;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* The response information that sent back to the requester.
|
|
25
|
-
* */
|
|
26
|
-
export type CloudFunctionResponse = {
|
|
27
|
-
statusCode: number;
|
|
28
|
-
headers: Record<string, string>;
|
|
29
|
-
body: string;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* A function that handles an RPC request to a route.
|
|
33
|
-
* */
|
|
34
|
-
export type RouteHandler = (...args: any[]) => any | Promise<any>;
|
|
35
|
-
/**
|
|
36
|
-
* A factory for creating a route handler with context injected.
|
|
37
|
-
* */
|
|
38
|
-
export type RouteHandlerFactory = (eventData: NormalizedCloudFunctionEventData) => RouteHandler;
|
|
39
|
-
/**
|
|
40
|
-
* A configuration to specify the authentication required to access a route.
|
|
41
|
-
* */
|
|
42
|
-
export type RouteAuthConfig = {
|
|
43
|
-
public?: boolean;
|
|
44
|
-
anyAuthorized?: boolean;
|
|
45
|
-
allowedRoles?: string[];
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* A configuration used to define how an RPC request to a specific path is handled.
|
|
49
|
-
* */
|
|
50
|
-
export type Route = {
|
|
51
|
-
path: string;
|
|
52
|
-
authConfig?: RouteAuthConfig;
|
|
53
|
-
} & ({
|
|
54
|
-
handlerFactory: RouteHandlerFactory;
|
|
55
|
-
handler?: never;
|
|
56
|
-
} | {
|
|
57
|
-
handlerFactory?: never;
|
|
58
|
-
handler: RouteHandler;
|
|
59
|
-
});
|
|
60
|
-
/**
|
|
61
|
-
* A collection of {@link Route} objects, indexed by their path.
|
|
62
|
-
* */
|
|
63
|
-
export type RouteMap = Record<string, Route>;
|
|
64
|
-
/**
|
|
65
|
-
* A function that transforms an event into a normalized event data object.
|
|
66
|
-
* */
|
|
67
|
-
export type CloudFunctionEventTransformer = (event: any) => NormalizedCloudFunctionEventData;
|
|
68
|
-
/**
|
|
69
|
-
* A function that routes an event to a route handler based on a {@link RouteMap}.
|
|
70
|
-
* */
|
|
71
|
-
export type CloudFunctionEventRouter = (event: any, eventTransformer: CloudFunctionEventTransformer, routeMap: RouteMap, allowedOrigins: CORSPatter[], errorShouldBeExposedToClient?: (error: unknown) => boolean, debug?: boolean) => Promise<CloudFunctionResponse>;
|
package/src/api/Router/Types.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CloudFunctionEventRouter, Route, RouteMap } from "./Types";
|
|
2
|
-
export * from "./AWS";
|
|
3
|
-
/**
|
|
4
|
-
* A utility function to add a route to a route map by path.
|
|
5
|
-
* */
|
|
6
|
-
export declare const addRouteToRouteMap: (routeMap: RouteMap, route: Route, basePath?: string) => RouteMap;
|
|
7
|
-
/**
|
|
8
|
-
* Add multiple routes to a {@link RouteMap} by path.
|
|
9
|
-
* */
|
|
10
|
-
export declare const addRoutesToRouteMap: (routeMap: RouteMap, routes: Route[], basePath?: string) => RouteMap;
|
|
11
|
-
/**
|
|
12
|
-
* Apply one {@link RouteMap} to another.
|
|
13
|
-
* */
|
|
14
|
-
export declare const addRouteMapToRouteMap: (routeMap: RouteMap, routeMapToAdd: RouteMap, basePath?: string) => RouteMap;
|
|
15
|
-
/**
|
|
16
|
-
* A Cloud Function event router.
|
|
17
|
-
* */
|
|
18
|
-
export declare const handleCloudFunctionEvent: CloudFunctionEventRouter;
|