@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
package/.releaserc
ADDED
package/README.md
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
# Voltra
|
|
2
2
|
|
|
3
|
-

|
|
22
4
|
|
|
23
5
|
## Usage
|
|
24
6
|
|
|
@@ -40,7 +22,7 @@ features like chainable stacks and comprehensive parameter support. Its intuitiv
|
|
|
40
22
|
databases, storage, authentication, and functions through easy-to-use packs. Furthermore, Voltra enhances development
|
|
41
23
|
workflows with advanced state management, and a smart, lightweight routing system for React
|
|
42
24
|
front-end apps.</td>
|
|
43
|
-
<td><img src="https://docs.voltra.app/images/
|
|
25
|
+
<td><img src="https://docs.voltra.app/images/Robo%20Power.png" style="width: 200em;" /></td>
|
|
44
26
|
</tr>
|
|
45
27
|
</tbody>
|
|
46
28
|
</table>
|
|
@@ -49,38 +31,9 @@ front-end apps.</td>
|
|
|
49
31
|
|
|
50
32
|
| API | App | IaC |
|
|
51
33
|
|-----------------------------------------------------------------------------|-----------------------------------------------|---------------------------------------------------------------|
|
|
52
|
-
| RPC |
|
|
34
|
+
| RPC | Form Generation: TypeScript Type Driven | Chainable Stacks |
|
|
35
|
+
| CORS | Easy Layout | Full Parameter Support: Groups/Labels/Types/etc... |
|
|
53
36
|
| Auth: Public/Secured/Role Based | State Management | Packs: Easy to add Database/Storage/Auth/Functions/etc... |
|
|
54
37
|
| Routing: Nesting/Handlers/Injected Handlers | Routing: Param Handlers/Parallel Routes/Hooks | Utilities: Patching Stacks/Constants/Standard Includes/etc... |
|
|
55
38
|
| ORM: TypeScript Type Driven Auto-generated Data Contexts with Relationships | | Typed Build Spec Creation |
|
|
56
39
|
| | | Typed Resource Parameters |
|
|
57
|
-
|
|
58
|
-
## Releasing
|
|
59
|
-
|
|
60
|
-
Voltra publishes npm packages from GitHub Releases. The release tag is used verbatim
|
|
61
|
-
as the npm package version, so it must be valid SemVer without a leading `v`.
|
|
62
|
-
|
|
63
|
-
### Stable releases
|
|
64
|
-
|
|
65
|
-
Use tags like:
|
|
66
|
-
|
|
67
|
-
```
|
|
68
|
-
3.0.0
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Pre-releases (alpha, beta, rc)
|
|
72
|
-
|
|
73
|
-
Use tags like:
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
3.0.0-alpha.0
|
|
77
|
-
3.0.0-beta.1
|
|
78
|
-
3.0.0-rc.1
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
When the GitHub Release is marked as a prerelease, the npm publish step uses the
|
|
82
|
-
`next` dist-tag instead of `latest`. Consumers can install prereleases with:
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npm install @resistdesign/voltra@next
|
|
86
|
-
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Criteria } from "../SearchCriteriaTypes";
|
|
2
|
+
import { DataContext, DataContextMap, DataContextOperationOptions } from "../DataContextService";
|
|
3
|
+
export declare const reduceCriteria: (criteria: Criteria) => Criteria;
|
|
4
|
+
export declare const flattenCriterionGroups: (criteria: Criteria | undefined) => Criteria[];
|
|
5
|
+
export declare const criteriaListHasRelatedField: <ItemType extends Record<any, any>, UniquelyIdentifyingFieldName extends keyof ItemType>(criteriaList: Criteria[], dataContext: DataContext<ItemType, UniquelyIdentifyingFieldName>) => boolean;
|
|
6
|
+
export declare const criteriaListHasDisallowedFieldForOperation: <ItemType extends Record<any, any>, UniquelyIdentifyingFieldName extends keyof ItemType>(criteriaList: Criteria[], operation: DataContextOperationOptions, dataContext: DataContext<ItemType, UniquelyIdentifyingFieldName>) => boolean;
|
|
7
|
+
export declare const criteriaListHasInvalidFieldOrValueType: <DCM extends DataContextMap, ContextName extends keyof DCM>(criteriaList: Criteria[], contextName: ContextName, dataContextMap: DCM) => boolean;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.criteriaListHasInvalidFieldOrValueType = exports.criteriaListHasDisallowedFieldForOperation = exports.criteriaListHasRelatedField = exports.flattenCriterionGroups = exports.reduceCriteria = void 0;
|
|
4
|
+
const SearchCriteriaTypes_1 = require("../SearchCriteriaTypes");
|
|
5
|
+
const DataContextService_1 = require("../DataContextService");
|
|
6
|
+
const CRITERIA_REDUCER_MAP = {
|
|
7
|
+
[SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION]: (criteria) => criteria,
|
|
8
|
+
[SearchCriteriaTypes_1.SearchCriterionTypes.NESTED_CRITERION]: (criteria) => {
|
|
9
|
+
const { value } = criteria;
|
|
10
|
+
return Object.assign(Object.assign({}, criteria), { value: (0, exports.reduceCriteria)(value) });
|
|
11
|
+
},
|
|
12
|
+
[SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION_GROUP]: (criteria) => {
|
|
13
|
+
const { logicalGroupingType, criteria: groupCriteria = [] } = criteria;
|
|
14
|
+
const newGroupCriteria = groupCriteria.map(exports.reduceCriteria);
|
|
15
|
+
const allAreBoolean = newGroupCriteria.every(({ type }) => type === SearchCriteriaTypes_1.SearchCriterionTypes.BOOLEAN_CRITERION);
|
|
16
|
+
if (allAreBoolean) {
|
|
17
|
+
const boolList = newGroupCriteria.map(({ value }) => value);
|
|
18
|
+
if (logicalGroupingType === SearchCriteriaTypes_1.SearchCriterionLogicalGroupingTypes.OR) {
|
|
19
|
+
return {
|
|
20
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.BOOLEAN_CRITERION,
|
|
21
|
+
value: boolList.some((bool) => bool),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (logicalGroupingType === SearchCriteriaTypes_1.SearchCriterionLogicalGroupingTypes.AND) {
|
|
25
|
+
return {
|
|
26
|
+
type: SearchCriteriaTypes_1.SearchCriterionTypes.BOOLEAN_CRITERION,
|
|
27
|
+
value: boolList.every((bool) => bool),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const nGC of newGroupCriteria) {
|
|
32
|
+
const { type: nGCType } = nGC;
|
|
33
|
+
if (nGCType === SearchCriteriaTypes_1.SearchCriterionTypes.BOOLEAN_CRITERION) {
|
|
34
|
+
const { value: nGCValue } = nGC;
|
|
35
|
+
if (logicalGroupingType === SearchCriteriaTypes_1.SearchCriterionLogicalGroupingTypes.OR &&
|
|
36
|
+
nGCValue) {
|
|
37
|
+
return nGC;
|
|
38
|
+
}
|
|
39
|
+
if (logicalGroupingType === SearchCriteriaTypes_1.SearchCriterionLogicalGroupingTypes.AND &&
|
|
40
|
+
!nGCValue) {
|
|
41
|
+
return nGC;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return Object.assign(Object.assign({}, criteria), { criteria: newGroupCriteria });
|
|
46
|
+
},
|
|
47
|
+
[SearchCriteriaTypes_1.SearchCriterionTypes.BOOLEAN_CRITERION]: (criteria) => criteria,
|
|
48
|
+
};
|
|
49
|
+
const reduceCriteria = (criteria) => {
|
|
50
|
+
const { type } = criteria;
|
|
51
|
+
const criteriaReducer = CRITERIA_REDUCER_MAP[type];
|
|
52
|
+
return criteriaReducer(criteria);
|
|
53
|
+
};
|
|
54
|
+
exports.reduceCriteria = reduceCriteria;
|
|
55
|
+
const flattenCriterionGroups = (criteria) => {
|
|
56
|
+
if (!criteria) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const { type } = criteria;
|
|
61
|
+
if (type === SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION_GROUP) {
|
|
62
|
+
const { criteria: criteriaList = [] } = criteria;
|
|
63
|
+
let flattenedCriteriaList = [];
|
|
64
|
+
for (const criterion of criteriaList) {
|
|
65
|
+
if (criterion.type === SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION_GROUP) {
|
|
66
|
+
flattenedCriteriaList = [...(0, exports.flattenCriterionGroups)(criterion)];
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
flattenedCriteriaList = [...flattenedCriteriaList, criterion];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return flattenedCriteriaList;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return [criteria];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
exports.flattenCriterionGroups = flattenCriterionGroups;
|
|
80
|
+
const criteriaListHasRelatedField = (criteriaList, dataContext) => {
|
|
81
|
+
const { fields } = dataContext;
|
|
82
|
+
for (const criterion of criteriaList) {
|
|
83
|
+
const { type } = criterion;
|
|
84
|
+
if (type === SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION ||
|
|
85
|
+
type === SearchCriteriaTypes_1.SearchCriterionTypes.NESTED_CRITERION) {
|
|
86
|
+
const { field } = criterion;
|
|
87
|
+
const { isContext = false, embedded = false } = fields[field] || {};
|
|
88
|
+
const isRelatedField = isContext && !embedded;
|
|
89
|
+
if (isRelatedField) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
};
|
|
96
|
+
exports.criteriaListHasRelatedField = criteriaListHasRelatedField;
|
|
97
|
+
const criteriaListHasDisallowedFieldForOperation = (criteriaList, operation, dataContext) => {
|
|
98
|
+
const { fields } = dataContext;
|
|
99
|
+
for (const criterion of criteriaList) {
|
|
100
|
+
const { type } = criterion;
|
|
101
|
+
if (type === SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION ||
|
|
102
|
+
type === SearchCriteriaTypes_1.SearchCriterionTypes.NESTED_CRITERION) {
|
|
103
|
+
const { field } = criterion;
|
|
104
|
+
const { allowedOperations = [] } = fields[field] || {};
|
|
105
|
+
const isDisallowedField = !(0, DataContextService_1.dataContextOperationIsAllowed)(operation, allowedOperations);
|
|
106
|
+
if (isDisallowedField) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
};
|
|
113
|
+
exports.criteriaListHasDisallowedFieldForOperation = criteriaListHasDisallowedFieldForOperation;
|
|
114
|
+
const criteriaListHasInvalidFieldOrValueType = (criteriaList, contextName, dataContextMap) => {
|
|
115
|
+
const { uniquelyIdentifyingFieldName, fields = {} } = dataContextMap[contextName];
|
|
116
|
+
const dataContextList = Object.keys(dataContextMap);
|
|
117
|
+
const fieldList = Object.keys(fields);
|
|
118
|
+
for (const criterion of criteriaList) {
|
|
119
|
+
const { type } = criterion;
|
|
120
|
+
if (type === SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION ||
|
|
121
|
+
type === SearchCriteriaTypes_1.SearchCriterionTypes.NESTED_CRITERION) {
|
|
122
|
+
const { field, value } = criterion;
|
|
123
|
+
if (!fieldList.includes(field)) {
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const { typeName } = fields[field];
|
|
128
|
+
if (dataContextList.includes(typeName)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
else if (typeof value !== typeName) {
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
};
|
|
139
|
+
exports.criteriaListHasInvalidFieldOrValueType = criteriaListHasInvalidFieldOrValueType;
|
|
140
|
+
// TODO: Make these functions return a list of issues.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Criteria, Criterion, SearchCriterionLogicalGroupingTypes } from "../SearchCriteriaTypes";
|
|
2
|
+
export type CriterionTranslator<ReturnType> = (criterion: Criterion, fieldOrderPath: number[], fieldNamePath: string[]) => ReturnType;
|
|
3
|
+
export type CriterionGroupTranslator<ReturnType> = (translatedCriterionList: any[], relationshipType: SearchCriterionLogicalGroupingTypes, fieldOrderPath: number[], fieldNamePath: string[]) => ReturnType;
|
|
4
|
+
export declare const processCriteria: <TranslatedCriterion, TranslatedCriterionGroup>(criteria: Criteria, criterionTranslator: CriterionTranslator<TranslatedCriterion>, criterionGroupTranslator: CriterionGroupTranslator<TranslatedCriterionGroup>, pathDelimiter?: string, parentOrderPath?: number[], parentPath?: string[], fieldIndex?: number) => TranslatedCriterion | TranslatedCriterionGroup;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processCriteria = void 0;
|
|
4
|
+
const SearchCriteriaTypes_1 = require("../SearchCriteriaTypes");
|
|
5
|
+
const processCriteria = (criteria, criterionTranslator, criterionGroupTranslator, pathDelimiter = ".", parentOrderPath = [], parentPath = [], fieldIndex = 0) => {
|
|
6
|
+
const { type } = criteria;
|
|
7
|
+
const orderPath = [...parentOrderPath, fieldIndex];
|
|
8
|
+
if (type === SearchCriteriaTypes_1.SearchCriterionTypes.CRITERION) {
|
|
9
|
+
const { field } = criteria;
|
|
10
|
+
const path = [...parentPath, field];
|
|
11
|
+
return criterionTranslator(Object.assign({}, criteria), orderPath, path);
|
|
12
|
+
}
|
|
13
|
+
else if (type === SearchCriteriaTypes_1.SearchCriterionTypes.NESTED_CRITERION) {
|
|
14
|
+
const { field, value } = criteria;
|
|
15
|
+
const path = [...parentPath, field];
|
|
16
|
+
return (0, exports.processCriteria)(value, criterionTranslator, criterionGroupTranslator, pathDelimiter, orderPath, path, 0);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const { logicalGroupingType, criteria: criteriaList = [] } = criteria;
|
|
20
|
+
return criterionGroupTranslator(criteriaList.map((criterion, subFieldIndex) => (0, exports.processCriteria)(criterion, criterionTranslator, criterionGroupTranslator, pathDelimiter, orderPath, parentPath, subFieldIndex)), logicalGroupingType, orderPath, parentPath);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.processCriteria = processCriteria;
|
|
@@ -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("./CriteriaUtils"), exports);
|
|
18
|
+
__exportStar(require("./CriterionDriverResolutionTools"), exports);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { AsyncReturnValue, DBServiceItemDriver, ListItemResults, ListItemsConfig } from "./ServiceTypes/DBServiceTypes";
|
|
2
|
+
import { TypeStructureUnionType } from "../../common/TypeParsing";
|
|
3
|
+
export declare const DataContextServiceErrorTypes: {
|
|
4
|
+
OPERATION_NOT_ALLOWED: string;
|
|
5
|
+
RELATED_ITEM_SEARCH_NOT_ALLOWED: string;
|
|
6
|
+
OPERATION_NOT_ALLOWED_FOR_FIELD: string;
|
|
7
|
+
INVALID_CRITERION: string;
|
|
8
|
+
};
|
|
9
|
+
export type DataContextOperationOptions = "CREATE" | "READ" | "UPDATE" | "DELETE" | "LIST";
|
|
10
|
+
export declare const DataContextOperations: Record<DataContextOperationOptions, DataContextOperationOptions>;
|
|
11
|
+
export declare const dataContextOperationIsAllowed: (operation: DataContextOperationOptions, allowedOperations?: DataContextOperationOptions[]) => boolean;
|
|
12
|
+
export declare const getDataContextOperationNotAllowed: (operation: DataContextOperationOptions) => Error;
|
|
13
|
+
export type DataContextField = {
|
|
14
|
+
typeName: string;
|
|
15
|
+
isContext?: boolean;
|
|
16
|
+
isMultiple?: boolean;
|
|
17
|
+
allowedOperations?: DataContextOperationOptions[];
|
|
18
|
+
valueOptions?: TypeStructureUnionType[];
|
|
19
|
+
embedded?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type DataContext<ItemType extends Record<any, any>, UniquelyIdentifyingFieldName extends keyof ItemType> = {
|
|
22
|
+
itemTypeName: string;
|
|
23
|
+
resolvedType?: string;
|
|
24
|
+
uniquelyIdentifyingFieldName: UniquelyIdentifyingFieldName;
|
|
25
|
+
allowedOperations?: DataContextOperationOptions[];
|
|
26
|
+
valueOptions?: TypeStructureUnionType[];
|
|
27
|
+
fields: Partial<Record<keyof ItemType, DataContextField>>;
|
|
28
|
+
};
|
|
29
|
+
export type DataContextItemType<DC> = DC extends DataContext<infer T, any> ? T : never;
|
|
30
|
+
export type DataContextUniquelyIdentifyingFieldName<DC> = DC extends DataContext<any, infer T> ? T : never;
|
|
31
|
+
export type DataContextUniquelyIdentifyingFieldType<DC> = DataContextItemType<DC>[DataContextUniquelyIdentifyingFieldName<DC>];
|
|
32
|
+
export type NewItemType<ItemType extends Record<any, any>, UniquelyIdentifyingFieldName extends keyof ItemType> = ItemType | Omit<ItemType, UniquelyIdentifyingFieldName>;
|
|
33
|
+
export type DataContextMap = Record<string, DataContext<any, any>>;
|
|
34
|
+
export type DataContextOperationProvider<T extends Record<Lowercase<DataContextOperationOptions>, (...args: any[]) => AsyncReturnValue<any>>> = T;
|
|
35
|
+
export type DataContextCreateOrUpdateOperation<DCM extends DataContextMap> = <ContextName extends keyof DCM, UpdateFlag extends boolean>(contextName: ContextName, item: UpdateFlag extends true ? DataContextItemType<DCM[ContextName]> : NewItemType<DataContextItemType<DCM[ContextName]>, DataContextUniquelyIdentifyingFieldName<DCM[ContextName]>>, update?: UpdateFlag) => AsyncReturnValue<DataContextItemType<DCM[ContextName]>>;
|
|
36
|
+
/**
|
|
37
|
+
* An advanced OMR service that can handle relationships between data contexts.
|
|
38
|
+
* */
|
|
39
|
+
export type DataContextService<DCM extends DataContextMap> = DataContextOperationProvider<{
|
|
40
|
+
create: <ContextName extends keyof DCM>(contextName: ContextName, item: NewItemType<DataContextItemType<DCM[ContextName]>, DataContextUniquelyIdentifyingFieldName<DCM[ContextName]>>) => AsyncReturnValue<DataContextItemType<DCM[ContextName]>>;
|
|
41
|
+
read: <ContextName extends keyof DCM>(contextName: ContextName, itemId: DataContextUniquelyIdentifyingFieldType<DCM>) => AsyncReturnValue<DataContextItemType<DCM[ContextName]>>;
|
|
42
|
+
update: <ContextName extends keyof DCM>(contextName: ContextName, item: DataContextItemType<DCM[ContextName]>) => AsyncReturnValue<DataContextItemType<DCM[ContextName]>>;
|
|
43
|
+
delete: <ContextName extends keyof DCM>(contextName: ContextName, itemId: DataContextUniquelyIdentifyingFieldType<DCM>) => AsyncReturnValue<DataContextItemType<DCM[ContextName]>>;
|
|
44
|
+
list: <ContextName extends keyof DCM>(contextName: ContextName, config: ListItemsConfig) => AsyncReturnValue<ListItemResults<DataContextItemType<DCM[ContextName]>>>;
|
|
45
|
+
}>;
|
|
46
|
+
export type DataContextRelationship<FromDataContext extends DataContext<any, any>, ToDataContext extends DataContext<any, any>> = {
|
|
47
|
+
id: string;
|
|
48
|
+
fromContext: FromDataContext["itemTypeName"];
|
|
49
|
+
fromField: keyof DataContextItemType<FromDataContext>;
|
|
50
|
+
fromUniqueIdentifier: DataContextUniquelyIdentifyingFieldName<FromDataContext>;
|
|
51
|
+
toContext: ToDataContext["itemTypeName"];
|
|
52
|
+
toUniqueIdentifier: DataContextUniquelyIdentifyingFieldName<ToDataContext>;
|
|
53
|
+
};
|
|
54
|
+
export type GetDataContextServiceConfig<DCM extends DataContextMap> = {
|
|
55
|
+
dataContextMap: DCM;
|
|
56
|
+
itemDriverMap: Record<keyof DCM, DBServiceItemDriver<DataContextItemType<DCM[keyof DCM]>, DataContextUniquelyIdentifyingFieldType<DCM[keyof DCM]>>>;
|
|
57
|
+
relationshipItemDriver?: DBServiceItemDriver<DataContextRelationship<DataContextItemType<DCM[keyof DCM]>, DataContextItemType<DCM[keyof DCM]>>, "id">;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Configure and instantiate a {@link DataContextService}.
|
|
61
|
+
* */
|
|
62
|
+
export declare const getDataContextService: <DCM extends DataContextMap>(config: GetDataContextServiceConfig<DCM>) => {
|
|
63
|
+
create: <ContextName extends keyof DCM>(contextName: ContextName, item: NewItemType<DataContextItemType<DCM[ContextName]>, DataContextUniquelyIdentifyingFieldName<DCM[ContextName]>>) => AsyncReturnValue<DataContextItemType<DCM[ContextName]>>;
|
|
64
|
+
read: <ContextName_1 extends keyof DCM>(contextName: ContextName_1, itemId: DataContextUniquelyIdentifyingFieldType<DCM>) => AsyncReturnValue<DataContextItemType<DCM[ContextName_1]>>;
|
|
65
|
+
update: <ContextName_2 extends keyof DCM>(contextName: ContextName_2, item: DataContextItemType<DCM[ContextName_2]>) => AsyncReturnValue<DataContextItemType<DCM[ContextName_2]>>;
|
|
66
|
+
delete: <ContextName_3 extends keyof DCM>(contextName: ContextName_3, itemId: DataContextUniquelyIdentifyingFieldType<DCM>) => AsyncReturnValue<DataContextItemType<DCM[ContextName_3]>>;
|
|
67
|
+
list: <ContextName_4 extends keyof DCM>(contextName: ContextName_4, config: ListItemsConfig) => AsyncReturnValue<ListItemResults<DataContextItemType<DCM[ContextName_4]>>>;
|
|
68
|
+
};
|