@resistdesign/voltra 0.0.0-alpha.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.releaserc +3 -0
- package/README.md +4 -51
- package/api/ORM/CriteriaUtils/CriteriaUtils.d.ts +7 -0
- package/api/ORM/CriteriaUtils/CriteriaUtils.js +140 -0
- package/api/ORM/CriteriaUtils/CriterionDriverResolutionTools.d.ts +4 -0
- package/api/ORM/CriteriaUtils/CriterionDriverResolutionTools.js +23 -0
- package/api/ORM/CriteriaUtils/index.d.ts +2 -0
- package/api/ORM/CriteriaUtils/index.js +18 -0
- package/api/ORM/DataContextService.d.ts +68 -0
- package/api/ORM/DataContextService.js +352 -0
- package/api/ORM/SearchCriteriaTypes.d.ts +83 -0
- package/api/ORM/SearchCriteriaTypes.js +47 -0
- package/api/ORM/ServiceTypes/DBServiceTypes.d.ts +30 -0
- package/api/ORM/ServiceTypes/FileServiceTypes.d.ts +25 -0
- package/api/ORM/ServiceTypes/index.d.ts +2 -0
- package/api/ORM/ServiceTypes/index.js +18 -0
- package/api/ORM/TypeStructureUtils.d.ts +17 -0
- package/api/ORM/TypeStructureUtils.js +120 -0
- package/api/ORM/drivers/db/DynamoDBServiceItem.d.ts +19 -0
- package/api/ORM/drivers/db/DynamoDBServiceItem.js +206 -0
- package/api/ORM/drivers/db/S3DBServiceItem.d.ts +17 -0
- package/api/ORM/drivers/db/S3DBServiceItem.js +118 -0
- package/api/ORM/drivers/db/index.d.ts +2 -0
- package/{src/api/ORM/drivers/common → api/ORM/drivers/db}/index.js +2 -2
- package/api/ORM/drivers/file/S3.d.ts +15 -0
- package/api/ORM/drivers/file/S3.js +97 -0
- package/api/ORM/drivers/file/index.d.ts +1 -0
- package/{src/common/TypeInfoORM → api/ORM/drivers/file}/index.js +1 -1
- package/api/ORM/drivers/index.d.ts +2 -0
- package/{src/common/ItemRelationships → api/ORM/drivers}/index.js +2 -1
- package/api/ORM/index.d.ts +6 -0
- package/api/ORM/index.js +32 -0
- package/{src/api → api}/Router/AWS.js +2 -8
- package/{src/api → api}/Router/CORS.d.ts +1 -1
- package/{src/api → api}/Router/CORS.js +10 -10
- package/{src/api → api}/Router/Types.d.ts +1 -1
- package/{src/api → api}/Router/index.js +18 -22
- package/api/index.d.ts +2 -0
- package/{src/api → api}/index.js +8 -19
- package/app/components/BaseForm.d.ts +9 -0
- package/app/components/BaseForm.js +37 -0
- package/app/components/FormGen/Application.d.ts +10 -0
- package/app/components/FormGen/Application.js +58 -0
- package/app/components/FormGen/Display.d.ts +13 -0
- package/app/components/FormGen/Display.js +69 -0
- package/app/components/FormGen/Editor.d.ts +12 -0
- package/app/components/FormGen/Editor.js +46 -0
- package/app/components/FormGen/Form.d.ts +5 -0
- package/app/components/FormGen/Form.js +25 -0
- package/app/components/FormGen/HelperTypes.d.ts +41 -0
- package/app/components/FormGen/HelperTypes.js +27 -0
- package/app/components/FormGen/IdUtils.d.ts +3 -0
- package/app/components/FormGen/IdUtils.js +22 -0
- package/app/components/FormGen/Input.d.ts +13 -0
- package/app/components/FormGen/Input.js +82 -0
- package/app/components/FormGen/Layout.d.ts +20 -0
- package/app/components/FormGen/Layout.js +107 -0
- package/app/components/FormGen/List.d.ts +12 -0
- package/app/components/FormGen/List.js +134 -0
- package/app/components/FormGen/Navigation.d.ts +27 -0
- package/app/components/FormGen/Navigation.js +82 -0
- package/app/components/FormGen/Storage/LocalJSON.d.ts +8 -0
- package/app/components/FormGen/Storage/LocalJSON.js +35 -0
- package/app/components/FormGen/Storage/index.d.ts +1 -0
- package/{src/common/Logging → app/components/FormGen/Storage}/index.js +1 -1
- package/app/components/FormGen/TypeStructureComponent.d.ts +20 -0
- package/app/components/FormGen/TypeStructureComponent.js +223 -0
- package/app/components/FormGen/ValueProcessing/HashMatrix.d.ts +50 -0
- package/app/components/FormGen/ValueProcessing/HashMatrix.js +268 -0
- package/app/components/FormGen/ValueProcessing/index.d.ts +1 -0
- package/{src/common/IdGeneration → app/components/FormGen/ValueProcessing}/index.js +1 -1
- package/app/components/FormGen/index.d.ts +13 -0
- package/app/components/FormGen/index.js +42 -0
- package/app/components/MaterialSymbol.d.ts +8 -0
- package/app/components/MaterialSymbol.js +22 -0
- package/app/components/Tabs.d.ts +9 -0
- package/app/components/Tabs.js +26 -0
- package/app/components/index.d.ts +4 -0
- package/{src/api/ORM → app/components}/index.js +12 -22
- package/app/index.d.ts +2 -0
- package/{src/app → app}/index.js +9 -18
- package/{src/app → app}/utils/ApplicationState.d.ts +1 -1
- package/{src/app → app}/utils/ApplicationState.js +3 -9
- package/{src/app → app}/utils/ApplicationStateLoader.js +13 -4
- package/{src/app → app}/utils/Controller.js +1 -4
- package/{src/app → app}/utils/Debug.d.ts +0 -3
- package/{src/app → app}/utils/Debug.js +1 -4
- package/{src/app → app}/utils/EasyLayout.d.ts +1 -1
- package/{src/app → app}/utils/EasyLayout.js +2 -5
- package/{src/app → app}/utils/Route.d.ts +1 -1
- package/{src/app → app}/utils/Route.js +4 -8
- package/{src/app → app}/utils/Service.js +14 -5
- package/{src/app → app}/utils/index.d.ts +0 -1
- package/{src/app → app}/utils/index.js +0 -1
- package/common/Routing.d.ts +20 -0
- package/{src/common → common}/Routing.js +10 -32
- package/common/TypeParsing/TypeParsing.d.ts +5 -0
- package/common/TypeParsing/TypeParsing.js +283 -0
- package/common/TypeParsing/TypeUtils.d.ts +86 -0
- package/common/TypeParsing/TypeUtils.js +281 -0
- package/common/TypeParsing/index.d.ts +2 -0
- package/{src/common/Testing → common/TypeParsing}/index.js +2 -2
- package/common/index.d.ts +2 -0
- package/common/index.js +28 -0
- package/{src/iac → iac}/SimpleCFT.d.ts +1 -21
- package/iac/SimpleCFT.js +67 -0
- package/{src/iac → iac}/index.js +7 -17
- package/iac/packs/abstract/user-management/UserPoolAliasTargetCustomResourceCode.d.ts +2 -0
- package/iac/packs/abstract/user-management/UserPoolAliasTargetCustomResourceCode.js +86 -0
- package/{src/iac/packs/auth → iac/packs/abstract}/user-management.js +88 -16
- package/{src/iac → iac}/packs/auth.js +1 -1
- package/{src/iac → iac}/packs/build/utils.d.ts +1 -1
- package/{src/iac → iac}/packs/build.d.ts +2 -7
- package/{src/iac → iac}/packs/cloud-function.d.ts +1 -2
- package/{src/iac → iac}/packs/cloud-function.js +1 -1
- package/iac/packs/database.d.ts +10 -0
- package/{src/iac → iac}/packs/database.js +1 -2
- package/iac/packs/dns.d.ts +11 -0
- package/iac/packs/dns.js +60 -0
- package/{src/iac → iac}/packs/gateway.d.ts +1 -2
- package/{src/iac → iac}/packs/gateway.js +8 -20
- package/{src/iac → iac}/types/CloudFormationResourceSpecification.d.ts +1 -1
- package/iac/types/CloudFormationResourceSpecification.js +196438 -0
- package/{src/iac → iac}/types/Renderers.js +1 -1
- package/{src/iac → iac}/types/Utils.js +2 -7
- package/{src/iac → iac}/types/generate.js +15 -5
- package/{src/iac → iac}/utils/index.d.ts +1 -4
- package/{src/iac → iac}/utils/index.js +10 -27
- package/{src/iac → iac}/utils/patch-utils.js +2 -8
- package/{src/index.d.ts → index.d.ts} +5 -5
- package/{src/index.js → index.js} +12 -22
- package/package.json +11 -69
- 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.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/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/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/index.d.ts +0 -3
- package/src/app/index.d.ts +0 -1
- 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/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/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/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/Routing.d.ts +0 -25
- 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/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/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/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.js +0 -82
- package/src/iac/packs/database.d.ts +0 -29
- package/src/iac/packs/dns.d.ts +0 -13
- package/src/iac/packs/dns.js +0 -26
- package/src/iac/types/IaCTypes.d.ts +0 -234994
- package/src/iac/types/IaCTypes.js +0 -14
- package/src/iac/types/Types.js +0 -2
- /package/{src/api/ORM/drivers/DynamoDBDataItemDBDriver/ConfigTypes.js → api/ORM/ServiceTypes/DBServiceTypes.js} +0 -0
- /package/{src/api/ORM/drivers/S3FileItemDBDriver/ConfigTypes.js → api/ORM/ServiceTypes/FileServiceTypes.js} +0 -0
- /package/{src/api → api}/Router/AWS.d.ts +0 -0
- /package/{src/api → api}/Router/Auth.d.ts +0 -0
- /package/{src/api → api}/Router/Auth.js +0 -0
- /package/{src/api → api}/Router/Types.js +0 -0
- /package/{src/api → api}/Router/index.d.ts +0 -0
- /package/{src/app → app}/utils/ApplicationStateLoader.d.ts +0 -0
- /package/{src/app → app}/utils/Controller.d.ts +0 -0
- /package/{src/app → app}/utils/Service.d.ts +0 -0
- /package/{src/iac → iac}/index.d.ts +0 -0
- /package/{src/iac/packs/auth → iac/packs/abstract}/user-management.d.ts +0 -0
- /package/{src/iac → iac}/packs/auth.d.ts +0 -0
- /package/{src/iac → iac}/packs/build/utils.js +0 -0
- /package/{src/iac → iac}/packs/build.js +0 -0
- /package/{src/iac → iac}/packs/cdn.d.ts +0 -0
- /package/{src/iac → iac}/packs/cdn.js +0 -0
- /package/{src/iac → iac}/packs/file-storage.d.ts +0 -0
- /package/{src/iac → iac}/packs/file-storage.js +0 -0
- /package/{src/iac → iac}/packs/index.d.ts +0 -0
- /package/{src/iac → iac}/packs/index.js +0 -0
- /package/{src/iac → iac}/packs/repo.d.ts +0 -0
- /package/{src/iac → iac}/packs/repo.js +0 -0
- /package/{src/iac → iac}/packs/ssl-certificate.d.ts +0 -0
- /package/{src/iac → iac}/packs/ssl-certificate.js +0 -0
- /package/{src/iac → iac}/types/Constants.d.ts +0 -0
- /package/{src/iac → iac}/types/Constants.js +0 -0
- /package/{src/iac → iac}/types/Renderers.d.ts +0 -0
- /package/{src/iac → iac}/types/Types.d.ts +0 -0
- /package/{src/common/Storyboarding → iac/types}/Types.js +0 -0
- /package/{src/iac → iac}/types/Utils.d.ts +0 -0
- /package/{src/iac → iac}/types/generate.d.ts +0 -0
- /package/{src/iac → iac}/utils/patch-utils.d.ts +0 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.getDataContextService = exports.getDataContextOperationNotAllowed = exports.dataContextOperationIsAllowed = exports.DataContextOperations = exports.DataContextServiceErrorTypes = void 0;
|
|
24
|
+
const SearchCriteriaTypes_1 = require("./SearchCriteriaTypes");
|
|
25
|
+
const CriteriaUtils_1 = require("./CriteriaUtils/CriteriaUtils");
|
|
26
|
+
exports.DataContextServiceErrorTypes = {
|
|
27
|
+
OPERATION_NOT_ALLOWED: "OPERATION_NOT_ALLOWED",
|
|
28
|
+
RELATED_ITEM_SEARCH_NOT_ALLOWED: "RELATED_ITEM_SEARCH_NOT_ALLOWED",
|
|
29
|
+
OPERATION_NOT_ALLOWED_FOR_FIELD: "OPERATION_NOT_ALLOWED_FOR_FIELD",
|
|
30
|
+
INVALID_CRITERION: "INVALID_CRITERION",
|
|
31
|
+
};
|
|
32
|
+
exports.DataContextOperations = {
|
|
33
|
+
CREATE: "CREATE",
|
|
34
|
+
READ: "READ",
|
|
35
|
+
UPDATE: "UPDATE",
|
|
36
|
+
DELETE: "DELETE",
|
|
37
|
+
LIST: "LIST",
|
|
38
|
+
};
|
|
39
|
+
const dataContextOperationIsAllowed = (operation, allowedOperations = []) => allowedOperations.includes(operation);
|
|
40
|
+
exports.dataContextOperationIsAllowed = dataContextOperationIsAllowed;
|
|
41
|
+
const getDataContextOperationNotAllowed = (operation) => new Error(`${exports.DataContextServiceErrorTypes.OPERATION_NOT_ALLOWED}: ${operation}`);
|
|
42
|
+
exports.getDataContextOperationNotAllowed = getDataContextOperationNotAllowed;
|
|
43
|
+
/**
|
|
44
|
+
* Configure and instantiate a {@link DataContextService}.
|
|
45
|
+
* */
|
|
46
|
+
const getDataContextService = (config) => {
|
|
47
|
+
const { dataContextMap, itemDriverMap, relationshipItemDriver } = config;
|
|
48
|
+
const createOrUpdate = (contextName, item, update) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
const serviceOperation = update === true
|
|
50
|
+
? exports.DataContextOperations.UPDATE
|
|
51
|
+
: exports.DataContextOperations.CREATE;
|
|
52
|
+
const { allowedOperations = [], fields: dataContextFields = {}, uniquelyIdentifyingFieldName, } = dataContextMap[contextName];
|
|
53
|
+
// Check allowed operations for the context.
|
|
54
|
+
if ((0, exports.dataContextOperationIsAllowed)(serviceOperation, allowedOperations)) {
|
|
55
|
+
const itemDriver = itemDriverMap[contextName];
|
|
56
|
+
const newItem = {};
|
|
57
|
+
const relatedIdMap = {};
|
|
58
|
+
for (const f in dataContextFields) {
|
|
59
|
+
const { isContext = false, isMultiple = false, embedded = false, typeName, allowedOperations: allowedFieldOperations = [], } = dataContextFields[f] || {};
|
|
60
|
+
// Check allowed operations for the field.
|
|
61
|
+
if (f !== uniquelyIdentifyingFieldName &&
|
|
62
|
+
(0, exports.dataContextOperationIsAllowed)(serviceOperation, allowedFieldOperations)) {
|
|
63
|
+
if (!isContext || embedded) {
|
|
64
|
+
// Only create based on non-relational fields in the data context.
|
|
65
|
+
newItem[f] =
|
|
66
|
+
item[f];
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// Normalize to an array.
|
|
70
|
+
const baseValue = item[f];
|
|
71
|
+
const arrayValue = isMultiple
|
|
72
|
+
? [...(baseValue instanceof Array ? baseValue : [])]
|
|
73
|
+
: [baseValue];
|
|
74
|
+
const { uniquelyIdentifyingFieldName: uniquelyIdentifyingFieldNameForItem, } = dataContextMap[typeName];
|
|
75
|
+
for (const relatedItem of arrayValue) {
|
|
76
|
+
if (!!relatedItem) {
|
|
77
|
+
const isExistingItem = !!relatedItem[uniquelyIdentifyingFieldNameForItem];
|
|
78
|
+
const relatedIdListForField = relatedIdMap[f] || [];
|
|
79
|
+
let targetIdentifier = relatedItem[uniquelyIdentifyingFieldNameForItem];
|
|
80
|
+
if (!isExistingItem) {
|
|
81
|
+
// Create item.
|
|
82
|
+
const { [uniquelyIdentifyingFieldNameForItem]: newIdentifier, } = yield service.create(typeName, relatedItem);
|
|
83
|
+
// Set targetIdentifier to the newly created item's identifier.
|
|
84
|
+
targetIdentifier = newIdentifier;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// Update item.
|
|
88
|
+
yield service.update(typeName, relatedItem);
|
|
89
|
+
}
|
|
90
|
+
// Add the related item's identifier to the relatedIdMap.
|
|
91
|
+
relatedIdMap[f] = [
|
|
92
|
+
...relatedIdListForField,
|
|
93
|
+
targetIdentifier,
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const { [uniquelyIdentifyingFieldName]: newItemIdentifier } = yield itemDriver.createItem(newItem);
|
|
101
|
+
if (relationshipItemDriver) {
|
|
102
|
+
// Create relationships for fields in the data context.
|
|
103
|
+
for (const f in relatedIdMap) {
|
|
104
|
+
const relatedIdListForField = relatedIdMap[f] || [];
|
|
105
|
+
const { typeName } = dataContextFields[f] || {};
|
|
106
|
+
const { uniquelyIdentifyingFieldName: uniquelyIdentifyingFieldNameForItem, } = dataContextMap[typeName];
|
|
107
|
+
// Remove omitted relationships on update.
|
|
108
|
+
if (update) {
|
|
109
|
+
const { [uniquelyIdentifyingFieldName]: updatingItemIdentifier } = item;
|
|
110
|
+
const { items: allExistingRelationships } = yield relationshipItemDriver.listItems({
|
|
111
|
+
itemsPerPage: Infinity,
|
|
112
|
+
criteria: {
|
|
113
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION_GROUP,
|
|
114
|
+
logicalGroupingType: SearchCriteriaTypes_1.SearchCriterionLogicalGroupingTypes.AND,
|
|
115
|
+
criteria: [
|
|
116
|
+
{
|
|
117
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION,
|
|
118
|
+
field: "fromContext",
|
|
119
|
+
operator: SearchCriteriaTypes_1.SearchOperatorTypes.EQUAL,
|
|
120
|
+
value: contextName,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION,
|
|
124
|
+
field: "fromField",
|
|
125
|
+
operator: SearchCriteriaTypes_1.SearchOperatorTypes.EQUAL,
|
|
126
|
+
value: f,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION,
|
|
130
|
+
field: "fromUniqueIdentifier",
|
|
131
|
+
operator: SearchCriteriaTypes_1.SearchOperatorTypes.EQUAL,
|
|
132
|
+
value: updatingItemIdentifier,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION,
|
|
136
|
+
field: "toContext",
|
|
137
|
+
operator: SearchCriteriaTypes_1.SearchOperatorTypes.EQUAL,
|
|
138
|
+
value: typeName,
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
const allExistingRelationshipIds = allExistingRelationships.map(({ toUniqueIdentifier }) => toUniqueIdentifier);
|
|
144
|
+
const allExistingRelationshipsIdsMap = allExistingRelationships.reduce((acc, { id, toUniqueIdentifier }) => (Object.assign(Object.assign({}, acc), { [toUniqueIdentifier]: id })), {});
|
|
145
|
+
// Create relationships that are in the updating item but not in the existing item.
|
|
146
|
+
for (const relatedId of relatedIdListForField) {
|
|
147
|
+
if (!allExistingRelationshipIds.includes(relatedId)) {
|
|
148
|
+
yield relationshipItemDriver.createItem({
|
|
149
|
+
fromContext: contextName,
|
|
150
|
+
fromField: f,
|
|
151
|
+
fromUniqueIdentifier: updatingItemIdentifier,
|
|
152
|
+
toContext: typeName,
|
|
153
|
+
toUniqueIdentifier: uniquelyIdentifyingFieldNameForItem,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Remove relationships that are not in the updating item.
|
|
158
|
+
for (const existingRelatedId of allExistingRelationshipIds) {
|
|
159
|
+
if (!relatedIdListForField.includes(existingRelatedId)) {
|
|
160
|
+
yield relationshipItemDriver.deleteItem(allExistingRelationshipsIdsMap[existingRelatedId]);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
for (const relatedId of relatedIdListForField) {
|
|
166
|
+
yield relationshipItemDriver.createItem({
|
|
167
|
+
fromContext: contextName,
|
|
168
|
+
fromField: f,
|
|
169
|
+
fromUniqueIdentifier: newItemIdentifier,
|
|
170
|
+
toContext: typeName,
|
|
171
|
+
toUniqueIdentifier: uniquelyIdentifyingFieldNameForItem,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// Make sure READ is allowed, if not just return the given item.
|
|
178
|
+
if ((0, exports.dataContextOperationIsAllowed)(exports.DataContextOperations.READ, allowedOperations)) {
|
|
179
|
+
// Read and return the new item.
|
|
180
|
+
return service.read(contextName, newItemIdentifier);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
return Object.assign(Object.assign({}, newItem), { [uniquelyIdentifyingFieldName]: newItemIdentifier });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
throw (0, exports.getDataContextOperationNotAllowed)(serviceOperation);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const readItem = (contextName, itemId, serviceOperation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
191
|
+
const { allowedOperations = [], fields: dataContextFields = {}, uniquelyIdentifyingFieldName, } = dataContextMap[contextName];
|
|
192
|
+
// Check allowed operations for the context.
|
|
193
|
+
if ((0, exports.dataContextOperationIsAllowed)(serviceOperation, allowedOperations)) {
|
|
194
|
+
const itemDriver = itemDriverMap[contextName];
|
|
195
|
+
const newItem = {};
|
|
196
|
+
let readableFields = [uniquelyIdentifyingFieldName];
|
|
197
|
+
for (const f in dataContextFields) {
|
|
198
|
+
const { isContext = false, isMultiple = false, embedded = false, typeName, allowedOperations: allowedFieldOperations = [], } = dataContextFields[f] || {};
|
|
199
|
+
if (f !== uniquelyIdentifyingFieldName &&
|
|
200
|
+
(0, exports.dataContextOperationIsAllowed)(serviceOperation, allowedFieldOperations)) {
|
|
201
|
+
if (!isContext || embedded) {
|
|
202
|
+
readableFields = [...readableFields, f];
|
|
203
|
+
}
|
|
204
|
+
else if (relationshipItemDriver) {
|
|
205
|
+
const { items: relatedItemInfoList = [] } = yield relationshipItemDriver.listItems({
|
|
206
|
+
itemsPerPage: Infinity,
|
|
207
|
+
criteria: {
|
|
208
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION_GROUP,
|
|
209
|
+
logicalGroupingType: SearchCriteriaTypes_1.SearchCriterionLogicalGroupingTypes.AND,
|
|
210
|
+
criteria: [
|
|
211
|
+
{
|
|
212
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION,
|
|
213
|
+
field: "fromContext",
|
|
214
|
+
operator: SearchCriteriaTypes_1.SearchOperatorTypes.EQUAL,
|
|
215
|
+
value: contextName,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION,
|
|
219
|
+
field: "fromField",
|
|
220
|
+
operator: SearchCriteriaTypes_1.SearchOperatorTypes.EQUAL,
|
|
221
|
+
value: f,
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION,
|
|
225
|
+
field: "fromUniqueIdentifier",
|
|
226
|
+
operator: SearchCriteriaTypes_1.SearchOperatorTypes.EQUAL,
|
|
227
|
+
value: itemId,
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION,
|
|
231
|
+
field: "toContext",
|
|
232
|
+
operator: SearchCriteriaTypes_1.SearchOperatorTypes.EQUAL,
|
|
233
|
+
value: typeName,
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
const relatedItemIdList = relatedItemInfoList.map(({ toUniqueIdentifier }) => toUniqueIdentifier);
|
|
239
|
+
let newRelationalValue;
|
|
240
|
+
if (isMultiple) {
|
|
241
|
+
newRelationalValue = [];
|
|
242
|
+
for (const relatedItemId of relatedItemIdList) {
|
|
243
|
+
const relatedItem = yield service.read(typeName, relatedItemId);
|
|
244
|
+
newRelationalValue.push(relatedItem);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
const lastRelatedItemId = relatedItemIdList[relatedItemIdList.length - 1];
|
|
249
|
+
newRelationalValue = yield service.read(typeName, lastRelatedItemId);
|
|
250
|
+
}
|
|
251
|
+
newItem[f] = newRelationalValue;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// Read the item from the item driver.
|
|
256
|
+
const itemFromDriver = yield itemDriver.readItem(itemId);
|
|
257
|
+
const cleanItemFromDriver = readableFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: itemFromDriver[field] })), {});
|
|
258
|
+
return Object.assign(Object.assign({}, newItem), cleanItemFromDriver);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
throw (0, exports.getDataContextOperationNotAllowed)(serviceOperation);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
const service = {
|
|
265
|
+
create: (contextName, item) => __awaiter(void 0, void 0, void 0, function* () { return createOrUpdate(contextName, item); }),
|
|
266
|
+
read: (contextName, itemId) => __awaiter(void 0, void 0, void 0, function* () { return readItem(contextName, itemId, exports.DataContextOperations.READ); }),
|
|
267
|
+
update: (contextName, item) => __awaiter(void 0, void 0, void 0, function* () { return createOrUpdate(contextName, item, true); }),
|
|
268
|
+
delete: (contextName, itemId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
269
|
+
const { allowedOperations = [], uniquelyIdentifyingFieldName } = dataContextMap[contextName];
|
|
270
|
+
let returnItem;
|
|
271
|
+
if ((0, exports.dataContextOperationIsAllowed)(exports.DataContextOperations.READ, allowedOperations)) {
|
|
272
|
+
returnItem = yield service.read(contextName, itemId);
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
returnItem = {
|
|
276
|
+
[uniquelyIdentifyingFieldName]: itemId,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
// Check allowed operations for the context.
|
|
280
|
+
if ((0, exports.dataContextOperationIsAllowed)(exports.DataContextOperations.DELETE, allowedOperations)) {
|
|
281
|
+
// Delete item.
|
|
282
|
+
const itemDriver = itemDriverMap[contextName];
|
|
283
|
+
yield itemDriver.deleteItem(itemId);
|
|
284
|
+
if (relationshipItemDriver) {
|
|
285
|
+
// Delete relationships.
|
|
286
|
+
const allRelationships = yield relationshipItemDriver.listItems({
|
|
287
|
+
itemsPerPage: Infinity,
|
|
288
|
+
criteria: {
|
|
289
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION_GROUP,
|
|
290
|
+
logicalGroupingType: SearchCriteriaTypes_1.SearchCriterionLogicalGroupingTypes.OR,
|
|
291
|
+
criteria: [
|
|
292
|
+
{
|
|
293
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION,
|
|
294
|
+
field: "fromContext",
|
|
295
|
+
operator: SearchCriteriaTypes_1.SearchOperatorTypes.EQUAL,
|
|
296
|
+
value: contextName,
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION,
|
|
300
|
+
field: "fromUniqueIdentifier",
|
|
301
|
+
operator: SearchCriteriaTypes_1.SearchOperatorTypes.EQUAL,
|
|
302
|
+
value: itemId,
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
for (const { id } of allRelationships.items) {
|
|
308
|
+
yield relationshipItemDriver.deleteItem(id);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return returnItem;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
throw (0, exports.getDataContextOperationNotAllowed)(exports.DataContextOperations.DELETE);
|
|
315
|
+
}
|
|
316
|
+
}),
|
|
317
|
+
list: (contextName, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
318
|
+
const dataContext = dataContextMap[contextName];
|
|
319
|
+
const { allowedOperations = [], uniquelyIdentifyingFieldName } = dataContext;
|
|
320
|
+
if ((0, exports.dataContextOperationIsAllowed)(exports.DataContextOperations.LIST, allowedOperations)) {
|
|
321
|
+
const { itemsPerPage = 10, cursor, criteria } = config;
|
|
322
|
+
const { type: criteriaType } = criteria || {};
|
|
323
|
+
const itemDriver = itemDriverMap[contextName];
|
|
324
|
+
const reducedCriteria = criteria ? (0, CriteriaUtils_1.reduceCriteria)(criteria) : undefined;
|
|
325
|
+
const criteriaList = (0, CriteriaUtils_1.flattenCriterionGroups)(criteria);
|
|
326
|
+
if ((0, CriteriaUtils_1.criteriaListHasRelatedField)(criteriaList, dataContext)) {
|
|
327
|
+
throw new Error(exports.DataContextServiceErrorTypes.RELATED_ITEM_SEARCH_NOT_ALLOWED);
|
|
328
|
+
}
|
|
329
|
+
else if ((0, CriteriaUtils_1.criteriaListHasDisallowedFieldForOperation)(criteriaList, exports.DataContextOperations.LIST, dataContext)) {
|
|
330
|
+
throw new Error(exports.DataContextServiceErrorTypes.OPERATION_NOT_ALLOWED_FOR_FIELD);
|
|
331
|
+
}
|
|
332
|
+
else if ((0, CriteriaUtils_1.criteriaListHasInvalidFieldOrValueType)(criteriaList, contextName, dataContextMap)) {
|
|
333
|
+
throw new Error(exports.DataContextServiceErrorTypes.INVALID_CRITERION);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
const _a = yield itemDriver.listItems({
|
|
337
|
+
itemsPerPage,
|
|
338
|
+
cursor,
|
|
339
|
+
criteria: reducedCriteria,
|
|
340
|
+
}), { items = [] } = _a, otherListItemResultProperties = __rest(_a, ["items"]);
|
|
341
|
+
const readItemList = yield Promise.all(items.map(({ [uniquelyIdentifyingFieldName]: id }) => service.read(contextName, id)));
|
|
342
|
+
return Object.assign({ items: readItemList }, otherListItemResultProperties);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
throw (0, exports.getDataContextOperationNotAllowed)(exports.DataContextOperations.LIST);
|
|
347
|
+
}
|
|
348
|
+
}),
|
|
349
|
+
};
|
|
350
|
+
return service;
|
|
351
|
+
};
|
|
352
|
+
exports.getDataContextService = getDataContextService;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The possible types of criteria for a search or report query.
|
|
3
|
+
* */
|
|
4
|
+
export declare enum SearchCriterionTypes {
|
|
5
|
+
CRITERION = "CRITERION",
|
|
6
|
+
NESTED_CRITERION = "NESTED_CRITERION",
|
|
7
|
+
CRITERION_GROUP = "CRITERION_GROUP",
|
|
8
|
+
BOOLEAN_CRITERION = "BOOLEAN_CRITERION"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The possible logical groupings for a set of criteria.
|
|
12
|
+
* */
|
|
13
|
+
export declare enum SearchCriterionLogicalGroupingTypes {
|
|
14
|
+
AND = "AND",
|
|
15
|
+
OR = "OR"
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The possible operators for a search criterion.
|
|
19
|
+
* */
|
|
20
|
+
export declare enum SearchOperatorTypes {
|
|
21
|
+
EQUAL = "EQUAL",
|
|
22
|
+
NOT_EQUAL = "NOT_EQUAL",
|
|
23
|
+
GREATER_THAN = "GREATER_THAN",
|
|
24
|
+
GREATER_THAN_OR_EQUAL = "GREATER_THAN_OR_EQUAL",
|
|
25
|
+
LESS_THAN = "LESS_THAN",
|
|
26
|
+
LESS_THAN_OR_EQUAL = "LESS_THAN_OR_EQUAL",
|
|
27
|
+
IN = "IN",
|
|
28
|
+
NOT_IN = "NOT_IN",
|
|
29
|
+
CONTAINS = "CONTAINS",
|
|
30
|
+
NOT_CONTAINS = "NOT_CONTAINS",
|
|
31
|
+
STARTS_WITH = "STARTS_WITH",
|
|
32
|
+
ENDS_WITH = "ENDS_WITH",
|
|
33
|
+
IS_NULL = "IS_NULL",
|
|
34
|
+
IS_NOT_NULL = "IS_NOT_NULL",
|
|
35
|
+
IS_EMPTY = "IS_EMPTY",
|
|
36
|
+
IS_NOT_EMPTY = "IS_NOT_EMPTY",
|
|
37
|
+
BETWEEN = "BETWEEN",
|
|
38
|
+
NOT_BETWEEN = "NOT_BETWEEN",
|
|
39
|
+
EXISTS = "EXISTS",
|
|
40
|
+
NOT_EXISTS = "NOT_EXISTS"
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A generic type specifier for a criterion.
|
|
44
|
+
* */
|
|
45
|
+
export type CriterionTypeSpecifier<SpecificType extends SearchCriterionTypes> = {
|
|
46
|
+
type: SpecificType;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* A boolean criterion. (`true` or `false`)
|
|
50
|
+
* */
|
|
51
|
+
export type BooleanCriterion = CriterionTypeSpecifier<SearchCriterionTypes.BOOLEAN_CRITERION> & {
|
|
52
|
+
value: boolean;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* A nested criterion path.
|
|
56
|
+
* */
|
|
57
|
+
export type CriterionPath = CriterionTypeSpecifier<SearchCriterionTypes.NESTED_CRITERION> & {
|
|
58
|
+
field: string;
|
|
59
|
+
value: Criteria;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* A single criterion for a search or report query.
|
|
63
|
+
* */
|
|
64
|
+
export type Criterion = CriterionTypeSpecifier<SearchCriterionTypes.CRITERION> & {
|
|
65
|
+
field: string;
|
|
66
|
+
operator: SearchOperatorTypes;
|
|
67
|
+
value: any;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Either a criterion or a nested criterion path.
|
|
71
|
+
* */
|
|
72
|
+
export type CriterionVariation = CriterionPath | Criterion;
|
|
73
|
+
/**
|
|
74
|
+
* An AND or OR grouping of criteria.
|
|
75
|
+
* */
|
|
76
|
+
export type CriterionGroup = CriterionTypeSpecifier<SearchCriterionTypes.CRITERION_GROUP> & {
|
|
77
|
+
logicalGroupingType: SearchCriterionLogicalGroupingTypes;
|
|
78
|
+
criteria: Criteria[];
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* A universal type to describe the criteria for a search or report query.
|
|
82
|
+
* */
|
|
83
|
+
export type Criteria = CriterionVariation | CriterionGroup | BooleanCriterion;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchOperatorTypes = exports.SearchCriterionLogicalGroupingTypes = exports.SearchCriterionTypes = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The possible types of criteria for a search or report query.
|
|
6
|
+
* */
|
|
7
|
+
var SearchCriterionTypes;
|
|
8
|
+
(function (SearchCriterionTypes) {
|
|
9
|
+
SearchCriterionTypes["CRITERION"] = "CRITERION";
|
|
10
|
+
SearchCriterionTypes["NESTED_CRITERION"] = "NESTED_CRITERION";
|
|
11
|
+
SearchCriterionTypes["CRITERION_GROUP"] = "CRITERION_GROUP";
|
|
12
|
+
SearchCriterionTypes["BOOLEAN_CRITERION"] = "BOOLEAN_CRITERION";
|
|
13
|
+
})(SearchCriterionTypes || (exports.SearchCriterionTypes = SearchCriterionTypes = {}));
|
|
14
|
+
/**
|
|
15
|
+
* The possible logical groupings for a set of criteria.
|
|
16
|
+
* */
|
|
17
|
+
var SearchCriterionLogicalGroupingTypes;
|
|
18
|
+
(function (SearchCriterionLogicalGroupingTypes) {
|
|
19
|
+
SearchCriterionLogicalGroupingTypes["AND"] = "AND";
|
|
20
|
+
SearchCriterionLogicalGroupingTypes["OR"] = "OR";
|
|
21
|
+
})(SearchCriterionLogicalGroupingTypes || (exports.SearchCriterionLogicalGroupingTypes = SearchCriterionLogicalGroupingTypes = {}));
|
|
22
|
+
/**
|
|
23
|
+
* The possible operators for a search criterion.
|
|
24
|
+
* */
|
|
25
|
+
var SearchOperatorTypes;
|
|
26
|
+
(function (SearchOperatorTypes) {
|
|
27
|
+
SearchOperatorTypes["EQUAL"] = "EQUAL";
|
|
28
|
+
SearchOperatorTypes["NOT_EQUAL"] = "NOT_EQUAL";
|
|
29
|
+
SearchOperatorTypes["GREATER_THAN"] = "GREATER_THAN";
|
|
30
|
+
SearchOperatorTypes["GREATER_THAN_OR_EQUAL"] = "GREATER_THAN_OR_EQUAL";
|
|
31
|
+
SearchOperatorTypes["LESS_THAN"] = "LESS_THAN";
|
|
32
|
+
SearchOperatorTypes["LESS_THAN_OR_EQUAL"] = "LESS_THAN_OR_EQUAL";
|
|
33
|
+
SearchOperatorTypes["IN"] = "IN";
|
|
34
|
+
SearchOperatorTypes["NOT_IN"] = "NOT_IN";
|
|
35
|
+
SearchOperatorTypes["CONTAINS"] = "CONTAINS";
|
|
36
|
+
SearchOperatorTypes["NOT_CONTAINS"] = "NOT_CONTAINS";
|
|
37
|
+
SearchOperatorTypes["STARTS_WITH"] = "STARTS_WITH";
|
|
38
|
+
SearchOperatorTypes["ENDS_WITH"] = "ENDS_WITH";
|
|
39
|
+
SearchOperatorTypes["IS_NULL"] = "IS_NULL";
|
|
40
|
+
SearchOperatorTypes["IS_NOT_NULL"] = "IS_NOT_NULL";
|
|
41
|
+
SearchOperatorTypes["IS_EMPTY"] = "IS_EMPTY";
|
|
42
|
+
SearchOperatorTypes["IS_NOT_EMPTY"] = "IS_NOT_EMPTY";
|
|
43
|
+
SearchOperatorTypes["BETWEEN"] = "BETWEEN";
|
|
44
|
+
SearchOperatorTypes["NOT_BETWEEN"] = "NOT_BETWEEN";
|
|
45
|
+
SearchOperatorTypes["EXISTS"] = "EXISTS";
|
|
46
|
+
SearchOperatorTypes["NOT_EXISTS"] = "NOT_EXISTS";
|
|
47
|
+
})(SearchOperatorTypes || (exports.SearchOperatorTypes = SearchOperatorTypes = {}));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Criteria } from "../SearchCriteriaTypes";
|
|
2
|
+
export type AsyncReturnValue<T> = Promise<T> | T;
|
|
3
|
+
export type ListItemResults<ItemType extends Record<any, any>> = {
|
|
4
|
+
cursor?: string;
|
|
5
|
+
items: ItemType[];
|
|
6
|
+
};
|
|
7
|
+
export type SortField = {
|
|
8
|
+
field?: string;
|
|
9
|
+
reverse?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type ListItemsConfig = {
|
|
12
|
+
itemsPerPage?: number;
|
|
13
|
+
cursor?: string;
|
|
14
|
+
criteria?: Criteria;
|
|
15
|
+
sortFields?: SortField[];
|
|
16
|
+
};
|
|
17
|
+
export type PartialItemTypeWithUniquelyIdentifyingFieldName<ItemType extends Record<any, any>, UniquelyIdentifyingFieldName extends keyof ItemType> = Partial<ItemType> & Pick<ItemType, UniquelyIdentifyingFieldName>;
|
|
18
|
+
export type BooleanOrUndefined = boolean | undefined;
|
|
19
|
+
export type PartialOrFullItemType<PatchType extends BooleanOrUndefined, ItemType extends Record<any, any>, UniquelyIdentifyingFieldName extends keyof ItemType> = PatchType extends true ? PartialItemTypeWithUniquelyIdentifyingFieldName<ItemType, UniquelyIdentifyingFieldName> : ItemType;
|
|
20
|
+
export type UpdateItemOperation<ItemType extends Record<any, any>, UniquelyIdentifyingFieldName extends keyof ItemType> = (updatedItem: PartialOrFullItemType<typeof patch, ItemType, UniquelyIdentifyingFieldName>, patch?: BooleanOrUndefined) => AsyncReturnValue<ItemType>;
|
|
21
|
+
/**
|
|
22
|
+
* A driver for a database service.
|
|
23
|
+
* */
|
|
24
|
+
export type DBServiceItemDriver<ItemType extends Record<any, any>, UniquelyIdentifyingFieldName extends keyof ItemType> = {
|
|
25
|
+
createItem: (newItem: Partial<Omit<ItemType, UniquelyIdentifyingFieldName>>) => AsyncReturnValue<ItemType>;
|
|
26
|
+
readItem: (uniqueIdentifier: ItemType[UniquelyIdentifyingFieldName]) => AsyncReturnValue<ItemType>;
|
|
27
|
+
updateItem: UpdateItemOperation<ItemType, UniquelyIdentifyingFieldName>;
|
|
28
|
+
deleteItem: (uniqueIdentifier: ItemType[UniquelyIdentifyingFieldName]) => AsyncReturnValue<ItemType>;
|
|
29
|
+
listItems: (config: ListItemsConfig) => AsyncReturnValue<ListItemResults<ItemType>>;
|
|
30
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type BaseFileLocationInfo = {
|
|
2
|
+
directory?: string;
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
export type BaseFile = BaseFileLocationInfo & {
|
|
6
|
+
updatedOn: number;
|
|
7
|
+
mimeType: string;
|
|
8
|
+
sizeInBytes: number;
|
|
9
|
+
isDirectory?: boolean;
|
|
10
|
+
uploadUrl?: string;
|
|
11
|
+
downloadUrl?: string;
|
|
12
|
+
};
|
|
13
|
+
export type ListFilesResult = {
|
|
14
|
+
files: BaseFile[];
|
|
15
|
+
cursor?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A driver for the file service.
|
|
19
|
+
* */
|
|
20
|
+
export type FileServiceDriver = {
|
|
21
|
+
getFileUploadUrl: (file: BaseFileLocationInfo, baseDirectory?: string) => Promise<string>;
|
|
22
|
+
getFileDownloadUrl: (file: BaseFileLocationInfo, baseDirectory?: string) => Promise<string>;
|
|
23
|
+
deleteFile: (file: BaseFileLocationInfo, baseDirectory?: string) => Promise<void>;
|
|
24
|
+
listFiles: (path?: string, baseDirectory?: string, maxNumberOfFiles?: number, cursor?: string) => Promise<ListFilesResult>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./DBServiceTypes"), exports);
|
|
18
|
+
__exportStar(require("./FileServiceTypes"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DataContext, DataContextField, DataContextMap } from "./DataContextService";
|
|
2
|
+
import { TypeStructure, TypeStructureMap, TypeStructureTagMap } from "../../common/TypeParsing";
|
|
3
|
+
export declare const DataContextFieldTagNames: {
|
|
4
|
+
uniquelyIdentifyingFieldName: string;
|
|
5
|
+
allowedOperations: string;
|
|
6
|
+
virtual: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const getCleanedTagStringValue: (tagValue: any) => string | undefined;
|
|
9
|
+
export declare const typeStructureToDataContextField: (typeStructure: TypeStructure) => DataContextField;
|
|
10
|
+
export declare const mergeDataContextTagMaps: (tagMapA: TypeStructureTagMap, tagMapB: TypeStructureTagMap) => TypeStructureTagMap;
|
|
11
|
+
export declare const typeStructureToDataContext: (typeStructure: TypeStructure, typeStructureMap: TypeStructureMap, defaultUniquelyIdentifyingFieldName?: string, cache?: DataContextMap) => DataContext<any, any>;
|
|
12
|
+
export declare const DEFAULT_UNIQUELY_IDENTIFYING_FIELD_NAME = "id";
|
|
13
|
+
/**
|
|
14
|
+
* Create a {@link DataContextMap} from a {@link TypeStructureMap} generated from TypeScript types.
|
|
15
|
+
* Types tagged as `@virtual` will not be included in the resulting {@link DataContextMap}.
|
|
16
|
+
* */
|
|
17
|
+
export declare const typeStructureMapToDataContextMap: (typeStructureMap: TypeStructureMap, useDefaultUniquelyIdentifyingFieldName?: boolean) => DataContextMap;
|