@fgv/ts-res 4.5.0-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/LICENSE +21 -0
- package/README.md +27 -0
- package/dist/ts-res.d.ts +4282 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +79 -0
- package/lib/index.js.map +1 -0
- package/lib/packlets/common/conditions.d.ts +148 -0
- package/lib/packlets/common/conditions.d.ts.map +1 -0
- package/lib/packlets/common/conditions.js +50 -0
- package/lib/packlets/common/conditions.js.map +1 -0
- package/lib/packlets/common/convert.d.ts +111 -0
- package/lib/packlets/common/convert.d.ts.map +1 -0
- package/lib/packlets/common/convert.js +173 -0
- package/lib/packlets/common/convert.js.map +1 -0
- package/lib/packlets/common/helpers/conditions.d.ts +39 -0
- package/lib/packlets/common/helpers/conditions.d.ts.map +1 -0
- package/lib/packlets/common/helpers/conditions.js +105 -0
- package/lib/packlets/common/helpers/conditions.js.map +1 -0
- package/lib/packlets/common/helpers/index.d.ts +3 -0
- package/lib/packlets/common/helpers/index.d.ts.map +1 -0
- package/lib/packlets/common/helpers/index.js +40 -0
- package/lib/packlets/common/helpers/index.js.map +1 -0
- package/lib/packlets/common/helpers/resources.d.ts +34 -0
- package/lib/packlets/common/helpers/resources.d.ts.map +1 -0
- package/lib/packlets/common/helpers/resources.js +81 -0
- package/lib/packlets/common/helpers/resources.js.map +1 -0
- package/lib/packlets/common/index.d.ts +7 -0
- package/lib/packlets/common/index.d.ts.map +1 -0
- package/lib/packlets/common/index.js +69 -0
- package/lib/packlets/common/index.js.map +1 -0
- package/lib/packlets/common/resources.d.ts +41 -0
- package/lib/packlets/common/resources.d.ts.map +1 -0
- package/lib/packlets/common/resources.js +30 -0
- package/lib/packlets/common/resources.js.map +1 -0
- package/lib/packlets/common/validate/conditions.d.ts +248 -0
- package/lib/packlets/common/validate/conditions.d.ts.map +1 -0
- package/lib/packlets/common/validate/conditions.js +436 -0
- package/lib/packlets/common/validate/conditions.js.map +1 -0
- package/lib/packlets/common/validate/index.d.ts +5 -0
- package/lib/packlets/common/validate/index.d.ts.map +1 -0
- package/lib/packlets/common/validate/index.js +65 -0
- package/lib/packlets/common/validate/index.js.map +1 -0
- package/lib/packlets/common/validate/regularExpressions.d.ts +39 -0
- package/lib/packlets/common/validate/regularExpressions.d.ts.map +1 -0
- package/lib/packlets/common/validate/regularExpressions.js +63 -0
- package/lib/packlets/common/validate/regularExpressions.js.map +1 -0
- package/lib/packlets/common/validate/resources.d.ts +97 -0
- package/lib/packlets/common/validate/resources.d.ts.map +1 -0
- package/lib/packlets/common/validate/resources.js +171 -0
- package/lib/packlets/common/validate/resources.js.map +1 -0
- package/lib/packlets/conditions/condition.d.ts +91 -0
- package/lib/packlets/conditions/condition.d.ts.map +1 -0
- package/lib/packlets/conditions/condition.js +146 -0
- package/lib/packlets/conditions/condition.js.map +1 -0
- package/lib/packlets/conditions/conditionCollector.d.ts +54 -0
- package/lib/packlets/conditions/conditionCollector.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionCollector.js +72 -0
- package/lib/packlets/conditions/conditionCollector.js.map +1 -0
- package/lib/packlets/conditions/conditionDecls.d.ts +26 -0
- package/lib/packlets/conditions/conditionDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionDecls.js +24 -0
- package/lib/packlets/conditions/conditionDecls.js.map +1 -0
- package/lib/packlets/conditions/conditionSet.d.ts +99 -0
- package/lib/packlets/conditions/conditionSet.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSet.js +164 -0
- package/lib/packlets/conditions/conditionSet.js.map +1 -0
- package/lib/packlets/conditions/conditionSetCollector.d.ts +65 -0
- package/lib/packlets/conditions/conditionSetCollector.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSetCollector.js +90 -0
- package/lib/packlets/conditions/conditionSetCollector.js.map +1 -0
- package/lib/packlets/conditions/conditionSetDecls.d.ts +18 -0
- package/lib/packlets/conditions/conditionSetDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionSetDecls.js +24 -0
- package/lib/packlets/conditions/conditionSetDecls.js.map +1 -0
- package/lib/packlets/conditions/conditionToken.d.ts +86 -0
- package/lib/packlets/conditions/conditionToken.d.ts.map +1 -0
- package/lib/packlets/conditions/conditionToken.js +150 -0
- package/lib/packlets/conditions/conditionToken.js.map +1 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.d.ts +24 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.js +54 -0
- package/lib/packlets/conditions/convert/conditionSetDecls.js.map +1 -0
- package/lib/packlets/conditions/convert/decls.d.ts +24 -0
- package/lib/packlets/conditions/convert/decls.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/decls.js +111 -0
- package/lib/packlets/conditions/convert/decls.js.map +1 -0
- package/lib/packlets/conditions/convert/index.d.ts +3 -0
- package/lib/packlets/conditions/convert/index.d.ts.map +1 -0
- package/lib/packlets/conditions/convert/index.js +40 -0
- package/lib/packlets/conditions/convert/index.js.map +1 -0
- package/lib/packlets/conditions/index.d.ts +10 -0
- package/lib/packlets/conditions/index.d.ts.map +1 -0
- package/lib/packlets/conditions/index.js +70 -0
- package/lib/packlets/conditions/index.js.map +1 -0
- package/lib/packlets/decisions/abstractDecision.d.ts +39 -0
- package/lib/packlets/decisions/abstractDecision.d.ts.map +1 -0
- package/lib/packlets/decisions/abstractDecision.js +63 -0
- package/lib/packlets/decisions/abstractDecision.js.map +1 -0
- package/lib/packlets/decisions/abstractDecisionCollector.d.ts +59 -0
- package/lib/packlets/decisions/abstractDecisionCollector.d.ts.map +1 -0
- package/lib/packlets/decisions/abstractDecisionCollector.js +92 -0
- package/lib/packlets/decisions/abstractDecisionCollector.js.map +1 -0
- package/lib/packlets/decisions/candidate.d.ts +58 -0
- package/lib/packlets/decisions/candidate.d.ts.map +1 -0
- package/lib/packlets/decisions/candidate.js +80 -0
- package/lib/packlets/decisions/candidate.js.map +1 -0
- package/lib/packlets/decisions/common.d.ts +15 -0
- package/lib/packlets/decisions/common.d.ts.map +1 -0
- package/lib/packlets/decisions/common.js +24 -0
- package/lib/packlets/decisions/common.js.map +1 -0
- package/lib/packlets/decisions/concreteDecision.d.ts +74 -0
- package/lib/packlets/decisions/concreteDecision.d.ts.map +1 -0
- package/lib/packlets/decisions/concreteDecision.js +114 -0
- package/lib/packlets/decisions/concreteDecision.js.map +1 -0
- package/lib/packlets/decisions/decision.d.ts +91 -0
- package/lib/packlets/decisions/decision.d.ts.map +1 -0
- package/lib/packlets/decisions/decision.js +126 -0
- package/lib/packlets/decisions/decision.js.map +1 -0
- package/lib/packlets/decisions/index.d.ts +7 -0
- package/lib/packlets/decisions/index.d.ts.map +1 -0
- package/lib/packlets/decisions/index.js +44 -0
- package/lib/packlets/decisions/index.js.map +1 -0
- package/lib/packlets/import/fsItem.d.ts +99 -0
- package/lib/packlets/import/fsItem.d.ts.map +1 -0
- package/lib/packlets/import/fsItem.js +174 -0
- package/lib/packlets/import/fsItem.js.map +1 -0
- package/lib/packlets/import/importContext.d.ts +85 -0
- package/lib/packlets/import/importContext.d.ts.map +1 -0
- package/lib/packlets/import/importContext.js +94 -0
- package/lib/packlets/import/importContext.js.map +1 -0
- package/lib/packlets/import/importManager.d.ts +93 -0
- package/lib/packlets/import/importManager.d.ts.map +1 -0
- package/lib/packlets/import/importManager.js +133 -0
- package/lib/packlets/import/importManager.js.map +1 -0
- package/lib/packlets/import/importable.d.ts +71 -0
- package/lib/packlets/import/importable.d.ts.map +1 -0
- package/lib/packlets/import/importable.js +35 -0
- package/lib/packlets/import/importable.js.map +1 -0
- package/lib/packlets/import/importers/collectionImporter.d.ts +60 -0
- package/lib/packlets/import/importers/collectionImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/collectionImporter.js +146 -0
- package/lib/packlets/import/importers/collectionImporter.js.map +1 -0
- package/lib/packlets/import/importers/fsItemImporter.d.ts +49 -0
- package/lib/packlets/import/importers/fsItemImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/fsItemImporter.js +120 -0
- package/lib/packlets/import/importers/fsItemImporter.js.map +1 -0
- package/lib/packlets/import/importers/importer.d.ts +31 -0
- package/lib/packlets/import/importers/importer.d.ts.map +1 -0
- package/lib/packlets/import/importers/importer.js +24 -0
- package/lib/packlets/import/importers/importer.js.map +1 -0
- package/lib/packlets/import/importers/index.d.ts +6 -0
- package/lib/packlets/import/importers/index.d.ts.map +1 -0
- package/lib/packlets/import/importers/index.js +43 -0
- package/lib/packlets/import/importers/index.js.map +1 -0
- package/lib/packlets/import/importers/jsonImporter.d.ts +32 -0
- package/lib/packlets/import/importers/jsonImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/jsonImporter.js +140 -0
- package/lib/packlets/import/importers/jsonImporter.js.map +1 -0
- package/lib/packlets/import/importers/pathImporter.d.ts +61 -0
- package/lib/packlets/import/importers/pathImporter.d.ts.map +1 -0
- package/lib/packlets/import/importers/pathImporter.js +87 -0
- package/lib/packlets/import/importers/pathImporter.js.map +1 -0
- package/lib/packlets/import/index.d.ts +7 -0
- package/lib/packlets/import/index.d.ts.map +1 -0
- package/lib/packlets/import/index.js +67 -0
- package/lib/packlets/import/index.js.map +1 -0
- package/lib/packlets/qualifier-types/convert.d.ts +19 -0
- package/lib/packlets/qualifier-types/convert.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/convert.js +45 -0
- package/lib/packlets/qualifier-types/convert.js.map +1 -0
- package/lib/packlets/qualifier-types/index.d.ts +8 -0
- package/lib/packlets/qualifier-types/index.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/index.js +68 -0
- package/lib/packlets/qualifier-types/index.js.map +1 -0
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts +56 -0
- package/lib/packlets/qualifier-types/languageQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/languageQualifierType.js +87 -0
- package/lib/packlets/qualifier-types/languageQualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts +92 -0
- package/lib/packlets/qualifier-types/literalQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/literalQualifierType.js +114 -0
- package/lib/packlets/qualifier-types/literalQualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts +184 -0
- package/lib/packlets/qualifier-types/qualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/qualifierType.js +173 -0
- package/lib/packlets/qualifier-types/qualifierType.js.map +1 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts +40 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js +102 -0
- package/lib/packlets/qualifier-types/qualifierTypeCollector.js.map +1 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts +74 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.d.ts.map +1 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.js +113 -0
- package/lib/packlets/qualifier-types/territoryQualifierType.js.map +1 -0
- package/lib/packlets/qualifiers/convert/decls.d.ts +23 -0
- package/lib/packlets/qualifiers/convert/decls.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/decls.js +71 -0
- package/lib/packlets/qualifiers/convert/decls.js.map +1 -0
- package/lib/packlets/qualifiers/convert/index.d.ts +3 -0
- package/lib/packlets/qualifiers/convert/index.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/index.js +40 -0
- package/lib/packlets/qualifiers/convert/index.js.map +1 -0
- package/lib/packlets/qualifiers/convert/qualifier.d.ts +17 -0
- package/lib/packlets/qualifiers/convert/qualifier.d.ts.map +1 -0
- package/lib/packlets/qualifiers/convert/qualifier.js +43 -0
- package/lib/packlets/qualifiers/convert/qualifier.js.map +1 -0
- package/lib/packlets/qualifiers/index.d.ts +6 -0
- package/lib/packlets/qualifiers/index.d.ts.map +1 -0
- package/lib/packlets/qualifiers/index.js +66 -0
- package/lib/packlets/qualifiers/index.js.map +1 -0
- package/lib/packlets/qualifiers/qualifier.d.ts +68 -0
- package/lib/packlets/qualifiers/qualifier.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifier.js +87 -0
- package/lib/packlets/qualifiers/qualifier.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierCollector.d.ts +90 -0
- package/lib/packlets/qualifiers/qualifierCollector.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierCollector.js +157 -0
- package/lib/packlets/qualifiers/qualifierCollector.js.map +1 -0
- package/lib/packlets/qualifiers/qualifierDecl.d.ts +46 -0
- package/lib/packlets/qualifiers/qualifierDecl.d.ts.map +1 -0
- package/lib/packlets/qualifiers/qualifierDecl.js +24 -0
- package/lib/packlets/qualifiers/qualifierDecl.js.map +1 -0
- package/lib/packlets/resource-json/convert.d.ts +54 -0
- package/lib/packlets/resource-json/convert.d.ts.map +1 -0
- package/lib/packlets/resource-json/convert.js +139 -0
- package/lib/packlets/resource-json/convert.js.map +1 -0
- package/lib/packlets/resource-json/helpers.d.ts +41 -0
- package/lib/packlets/resource-json/helpers.d.ts.map +1 -0
- package/lib/packlets/resource-json/helpers.js +96 -0
- package/lib/packlets/resource-json/helpers.js.map +1 -0
- package/lib/packlets/resource-json/index.d.ts +9 -0
- package/lib/packlets/resource-json/index.d.ts.map +1 -0
- package/lib/packlets/resource-json/index.js +72 -0
- package/lib/packlets/resource-json/index.js.map +1 -0
- package/lib/packlets/resource-json/json.d.ts +182 -0
- package/lib/packlets/resource-json/json.d.ts.map +1 -0
- package/lib/packlets/resource-json/json.js +24 -0
- package/lib/packlets/resource-json/json.js.map +1 -0
- package/lib/packlets/resource-json/normalized.d.ts +123 -0
- package/lib/packlets/resource-json/normalized.d.ts.map +1 -0
- package/lib/packlets/resource-json/normalized.js +24 -0
- package/lib/packlets/resource-json/normalized.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts +39 -0
- package/lib/packlets/resource-json/resourceDeclCollection.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclCollection.js +121 -0
- package/lib/packlets/resource-json/resourceDeclCollection.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts +11 -0
- package/lib/packlets/resource-json/resourceDeclContainer.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclContainer.js +24 -0
- package/lib/packlets/resource-json/resourceDeclContainer.js.map +1 -0
- package/lib/packlets/resource-json/resourceDeclTree.d.ts +39 -0
- package/lib/packlets/resource-json/resourceDeclTree.d.ts.map +1 -0
- package/lib/packlets/resource-json/resourceDeclTree.js +122 -0
- package/lib/packlets/resource-json/resourceDeclTree.js.map +1 -0
- package/lib/packlets/resource-types/index.d.ts +4 -0
- package/lib/packlets/resource-types/index.d.ts.map +1 -0
- package/lib/packlets/resource-types/index.js +41 -0
- package/lib/packlets/resource-types/index.js.map +1 -0
- package/lib/packlets/resource-types/jsonResourceType.d.ts +65 -0
- package/lib/packlets/resource-types/jsonResourceType.d.ts.map +1 -0
- package/lib/packlets/resource-types/jsonResourceType.js +63 -0
- package/lib/packlets/resource-types/jsonResourceType.js.map +1 -0
- package/lib/packlets/resource-types/resourceType.d.ts +87 -0
- package/lib/packlets/resource-types/resourceType.d.ts.map +1 -0
- package/lib/packlets/resource-types/resourceType.js +62 -0
- package/lib/packlets/resource-types/resourceType.js.map +1 -0
- package/lib/packlets/resource-types/resourceTypeCollector.d.ts +30 -0
- package/lib/packlets/resource-types/resourceTypeCollector.d.ts.map +1 -0
- package/lib/packlets/resource-types/resourceTypeCollector.js +65 -0
- package/lib/packlets/resource-types/resourceTypeCollector.js.map +1 -0
- package/lib/packlets/resources/index.d.ts +5 -0
- package/lib/packlets/resources/index.d.ts.map +1 -0
- package/lib/packlets/resources/index.js +42 -0
- package/lib/packlets/resources/index.js.map +1 -0
- package/lib/packlets/resources/resource.d.ts +75 -0
- package/lib/packlets/resources/resource.d.ts.map +1 -0
- package/lib/packlets/resources/resource.js +109 -0
- package/lib/packlets/resources/resource.js.map +1 -0
- package/lib/packlets/resources/resourceBuilder.d.ts +112 -0
- package/lib/packlets/resources/resourceBuilder.d.ts.map +1 -0
- package/lib/packlets/resources/resourceBuilder.js +162 -0
- package/lib/packlets/resources/resourceBuilder.js.map +1 -0
- package/lib/packlets/resources/resourceCandidate.d.ts +102 -0
- package/lib/packlets/resources/resourceCandidate.d.ts.map +1 -0
- package/lib/packlets/resources/resourceCandidate.js +180 -0
- package/lib/packlets/resources/resourceCandidate.js.map +1 -0
- package/lib/packlets/resources/resourceManager.d.ts +104 -0
- package/lib/packlets/resources/resourceManager.d.ts.map +1 -0
- package/lib/packlets/resources/resourceManager.js +193 -0
- package/lib/packlets/resources/resourceManager.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IConditionDecl, IValidatedConditionDecl } from '../conditionDecls';
|
|
2
|
+
import { IReadOnlyQualifierCollector } from '../../qualifiers';
|
|
3
|
+
/**
|
|
4
|
+
* Converter for a {@link Conditions.IConditionDecl | condition declaration}.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare const conditionDecl: import("@fgv/ts-utils").ObjectConverter<IConditionDecl, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Conversion context to uses when converting
|
|
10
|
+
* a {@link Conditions.IValidatedConditionDecl | validated condition declaration}.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export interface IConditionDeclConvertContext {
|
|
14
|
+
readonly qualifiers: IReadOnlyQualifierCollector;
|
|
15
|
+
conditionIndex?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Converter which constructs a {@link Conditions.IValidatedConditionDecl | validated condition declaration}
|
|
19
|
+
* from a {@link Conditions.IConditionDecl | condition declaration}, instantiating qualifiers by name
|
|
20
|
+
* from a supplied {@link Conditions.Convert.IConditionDeclConvertContext | conversion context}.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare const validatedConditionDecl: import("@fgv/ts-utils").Converter<IValidatedConditionDecl, IConditionDeclConvertContext>;
|
|
24
|
+
//# sourceMappingURL=decls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decls.d.ts","sourceRoot":"","sources":["../../../../src/packlets/conditions/convert/decls.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAI/D;;;GAGG;AACH,eAAO,MAAM,aAAa,kEAMxB,CAAC;AAEH;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,UAAU,EAAE,2BAA2B,CAAC;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,0FAqCjC,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.validatedConditionDecl = exports.conditionDecl = void 0;
|
|
58
|
+
const Common = __importStar(require("../../common"));
|
|
59
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
60
|
+
/* eslint-disable @rushstack/typedef-var */
|
|
61
|
+
/**
|
|
62
|
+
* Converter for a {@link Conditions.IConditionDecl | condition declaration}.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
exports.conditionDecl = ts_utils_1.Converters.strictObject({
|
|
66
|
+
qualifierName: ts_utils_1.Converters.string,
|
|
67
|
+
value: ts_utils_1.Converters.string,
|
|
68
|
+
operator: Common.Convert.conditionOperator.optional(),
|
|
69
|
+
priority: ts_utils_1.Converters.number.optional(),
|
|
70
|
+
scoreAsDefault: ts_utils_1.Converters.number.optional()
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* Converter which constructs a {@link Conditions.IValidatedConditionDecl | validated condition declaration}
|
|
74
|
+
* from a {@link Conditions.IConditionDecl | condition declaration}, instantiating qualifiers by name
|
|
75
|
+
* from a supplied {@link Conditions.Convert.IConditionDeclConvertContext | conversion context}.
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
exports.validatedConditionDecl = ts_utils_1.Converters.generic((from, __self, context) => {
|
|
79
|
+
/* c8 ignore next 3 - coverage is having a bad day */
|
|
80
|
+
if (!context) {
|
|
81
|
+
return (0, ts_utils_1.fail)('validatedConditionDecl converter requires a context');
|
|
82
|
+
}
|
|
83
|
+
return exports.conditionDecl.convert(from).onSuccess((decl) => {
|
|
84
|
+
var _a;
|
|
85
|
+
const operator = (_a = decl.operator) !== null && _a !== void 0 ? _a : 'matches';
|
|
86
|
+
return context.qualifiers.validating.get(decl.qualifierName).onSuccess((qualifier) => {
|
|
87
|
+
return (0, ts_utils_1.populateObject)({
|
|
88
|
+
qualifier: () => (0, ts_utils_1.succeed)(qualifier),
|
|
89
|
+
value: () => qualifier.type.validateCondition(decl.value, operator),
|
|
90
|
+
operator: () => (0, ts_utils_1.succeed)(operator),
|
|
91
|
+
priority: () => decl.priority
|
|
92
|
+
? Common.Convert.conditionPriority.convert(decl.priority)
|
|
93
|
+
: (0, ts_utils_1.succeed)(qualifier.defaultPriority),
|
|
94
|
+
scoreAsDefault: () => decl.scoreAsDefault
|
|
95
|
+
? Common.Convert.qualifierMatchScore.convert(decl.scoreAsDefault)
|
|
96
|
+
: (0, ts_utils_1.succeed)(undefined),
|
|
97
|
+
index: () => context.conditionIndex
|
|
98
|
+
? Common.Convert.conditionIndex.convert(context.conditionIndex)
|
|
99
|
+
: (0, ts_utils_1.succeed)(undefined)
|
|
100
|
+
})
|
|
101
|
+
.onSuccess((result) => {
|
|
102
|
+
if (context.conditionIndex !== undefined) {
|
|
103
|
+
context.conditionIndex++;
|
|
104
|
+
}
|
|
105
|
+
return (0, ts_utils_1.succeed)(result);
|
|
106
|
+
})
|
|
107
|
+
.withDetail('success');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=decls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decls.js","sourceRoot":"","sources":["../../../../src/packlets/conditions/convert/decls.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,qDAAuC;AACvC,4CAAkF;AAIlF,2CAA2C;AAE3C;;;GAGG;AACU,QAAA,aAAa,GAAG,qBAAU,CAAC,YAAY,CAAiB;IACnE,aAAa,EAAE,qBAAU,CAAC,MAAM;IAChC,KAAK,EAAE,qBAAU,CAAC,MAAM;IACxB,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,EAAE;IACrD,QAAQ,EAAE,qBAAU,CAAC,MAAM,CAAC,QAAQ,EAAE;IACtC,cAAc,EAAE,qBAAU,CAAC,MAAM,CAAC,QAAQ,EAAE;CAC7C,CAAC,CAAC;AAYH;;;;;GAKG;AACU,QAAA,sBAAsB,GAAG,qBAAU,CAAC,OAAO,CAGtD,CAAC,IAAa,EAAE,MAAM,EAAE,OAAsC,EAAmC,EAAE;IACnG,qDAAqD;IACrD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAA,eAAI,EAAC,qDAAqD,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,qBAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;;QACpD,MAAM,QAAQ,GAAG,MAAA,IAAI,CAAC,QAAQ,mCAAI,SAAS,CAAC;QAC5C,OAAO,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,EAAE;YACnF,OAAO,IAAA,yBAAc,EAA0B;gBAC7C,SAAS,EAAE,GAAG,EAAE,CAAC,IAAA,kBAAO,EAAC,SAAS,CAAC;gBACnC,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC;gBACnE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAA,kBAAO,EAAC,QAAQ,CAAC;gBACjC,QAAQ,EAAE,GAAG,EAAE,CACb,IAAI,CAAC,QAAQ;oBACX,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;oBACzD,CAAC,CAAC,IAAA,kBAAO,EAAC,SAAS,CAAC,eAAe,CAAC;gBACxC,cAAc,EAAE,GAAG,EAAE,CACnB,IAAI,CAAC,cAAc;oBACjB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC;oBACjE,CAAC,CAAC,IAAA,kBAAO,EAAC,SAAS,CAAC;gBACxB,KAAK,EAAE,GAAG,EAAE,CACV,OAAO,CAAC,cAAc;oBACpB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;oBAC/D,CAAC,CAAC,IAAA,kBAAO,EAAC,SAAS,CAAC;aACzB,CAAC;iBACC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;gBACpB,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;oBACzC,OAAO,CAAC,cAAc,EAAE,CAAC;gBAC3B,CAAC;gBACD,OAAO,IAAA,kBAAO,EAAC,MAAM,CAAC,CAAC;YACzB,CAAC,CAAC;iBACD,UAAU,CAAC,SAAS,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Common from '../../common';\nimport { Converters, populateObject, Result, fail, succeed } from '@fgv/ts-utils';\nimport { IConditionDecl, IValidatedConditionDecl } from '../conditionDecls';\nimport { IReadOnlyQualifierCollector } from '../../qualifiers';\n\n/* eslint-disable @rushstack/typedef-var */\n\n/**\n * Converter for a {@link Conditions.IConditionDecl | condition declaration}.\n * @public\n */\nexport const conditionDecl = Converters.strictObject<IConditionDecl>({\n qualifierName: Converters.string,\n value: Converters.string,\n operator: Common.Convert.conditionOperator.optional(),\n priority: Converters.number.optional(),\n scoreAsDefault: Converters.number.optional()\n});\n\n/**\n * Conversion context to uses when converting\n * a {@link Conditions.IValidatedConditionDecl | validated condition declaration}.\n * @public\n */\nexport interface IConditionDeclConvertContext {\n readonly qualifiers: IReadOnlyQualifierCollector;\n conditionIndex?: number;\n}\n\n/**\n * Converter which constructs a {@link Conditions.IValidatedConditionDecl | validated condition declaration}\n * from a {@link Conditions.IConditionDecl | condition declaration}, instantiating qualifiers by name\n * from a supplied {@link Conditions.Convert.IConditionDeclConvertContext | conversion context}.\n * @public\n */\nexport const validatedConditionDecl = Converters.generic<\n IValidatedConditionDecl,\n IConditionDeclConvertContext\n>((from: unknown, __self, context?: IConditionDeclConvertContext): Result<IValidatedConditionDecl> => {\n /* c8 ignore next 3 - coverage is having a bad day */\n if (!context) {\n return fail('validatedConditionDecl converter requires a context');\n }\n return conditionDecl.convert(from).onSuccess((decl) => {\n const operator = decl.operator ?? 'matches';\n return context.qualifiers.validating.get(decl.qualifierName).onSuccess((qualifier) => {\n return populateObject<IValidatedConditionDecl>({\n qualifier: () => succeed(qualifier),\n value: () => qualifier.type.validateCondition(decl.value, operator),\n operator: () => succeed(operator),\n priority: () =>\n decl.priority\n ? Common.Convert.conditionPriority.convert(decl.priority)\n : succeed(qualifier.defaultPriority),\n scoreAsDefault: () =>\n decl.scoreAsDefault\n ? Common.Convert.qualifierMatchScore.convert(decl.scoreAsDefault)\n : succeed(undefined),\n index: () =>\n context.conditionIndex\n ? Common.Convert.conditionIndex.convert(context.conditionIndex)\n : succeed(undefined)\n })\n .onSuccess((result) => {\n if (context.conditionIndex !== undefined) {\n context.conditionIndex++;\n }\n return succeed(result);\n })\n .withDetail('success');\n });\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packlets/conditions/convert/index.ts"],"names":[],"mappings":"AAsBA,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
35
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
__exportStar(require("./decls"), exports);
|
|
39
|
+
__exportStar(require("./conditionSetDecls"), exports);
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/packlets/conditions/convert/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,sDAAoC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './decls';\nexport * from './conditionSetDecls';\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Convert from './convert';
|
|
2
|
+
export * from './condition';
|
|
3
|
+
export * from './conditionCollector';
|
|
4
|
+
export * from './conditionDecls';
|
|
5
|
+
export * from './conditionSet';
|
|
6
|
+
export * from './conditionSetCollector';
|
|
7
|
+
export * from './conditionSetDecls';
|
|
8
|
+
export * from './conditionToken';
|
|
9
|
+
export { Convert };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/conditions/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}) : function(o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
40
|
+
var ownKeys = function(o) {
|
|
41
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
42
|
+
var ar = [];
|
|
43
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
44
|
+
return ar;
|
|
45
|
+
};
|
|
46
|
+
return ownKeys(o);
|
|
47
|
+
};
|
|
48
|
+
return function (mod) {
|
|
49
|
+
if (mod && mod.__esModule) return mod;
|
|
50
|
+
var result = {};
|
|
51
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
52
|
+
__setModuleDefault(result, mod);
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
57
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.Convert = void 0;
|
|
61
|
+
const Convert = __importStar(require("./convert"));
|
|
62
|
+
exports.Convert = Convert;
|
|
63
|
+
__exportStar(require("./condition"), exports);
|
|
64
|
+
__exportStar(require("./conditionCollector"), exports);
|
|
65
|
+
__exportStar(require("./conditionDecls"), exports);
|
|
66
|
+
__exportStar(require("./conditionSet"), exports);
|
|
67
|
+
__exportStar(require("./conditionSetCollector"), exports);
|
|
68
|
+
__exportStar(require("./conditionSetDecls"), exports);
|
|
69
|
+
__exportStar(require("./conditionToken"), exports);
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/conditions/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,mDAAqC;AAU5B,0BAAO;AARhB,8CAA4B;AAC5B,uDAAqC;AACrC,mDAAiC;AACjC,iDAA+B;AAC/B,0DAAwC;AACxC,sDAAoC;AACpC,mDAAiC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Convert from './convert';\n\nexport * from './condition';\nexport * from './conditionCollector';\nexport * from './conditionDecls';\nexport * from './conditionSet';\nexport * from './conditionSetCollector';\nexport * from './conditionSetDecls';\nexport * from './conditionToken';\n\nexport { Convert };\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
import { ConditionSet } from '../conditions';
|
|
3
|
+
import { Decision } from './decision';
|
|
4
|
+
/**
|
|
5
|
+
* Parameters to create an {@link Decisions.AbstractDecision | AbstractDecision}.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface IAbstractDecisionCreateParams {
|
|
9
|
+
conditionSets: ConditionSet[];
|
|
10
|
+
index?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* An abstract decision represents a class of decisions with candidates
|
|
14
|
+
* that differ only in value. It is a {@link Decisions.Decision | IDecision<number>}
|
|
15
|
+
* in which the `number` values are sequentially assigned indexes.
|
|
16
|
+
* This allows us to represent each related {@link Decisions.IDecision | decision} as an
|
|
17
|
+
* {@link Decisions.AbstractDecision | abstract decision} and a matching array containing
|
|
18
|
+
* the corresponding value for each candidate. This representation is highly cacheable.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare class AbstractDecision extends Decision<number> {
|
|
22
|
+
/**
|
|
23
|
+
* Constructor for an {@link Decisions.AbstractDecision | AbstractDecision} object.
|
|
24
|
+
* @param params - {@link Decisions.IAbstractDecisionCreateParams | Parameters}
|
|
25
|
+
* used to create the decision.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
protected constructor(params: IAbstractDecisionCreateParams);
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new {@link Decisions.AbstractDecision | AbstractDecision} object.
|
|
31
|
+
* @param params - {@link Decisions.IAbstractDecisionCreateParams | Parameters}
|
|
32
|
+
* used to create the decision.
|
|
33
|
+
* @returns `Success` with the new decision if successful, or `Failure` with an
|
|
34
|
+
* error message if not.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
static createAbstractDecision(params: IAbstractDecisionCreateParams): Result<AbstractDecision>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=abstractDecision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractDecision.d.ts","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecision.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,MAAM,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ,CAAC,MAAM,CAAC;IACpD;;;;;OAKG;IACH,SAAS,aAAa,MAAM,EAAE,6BAA6B;IAO3D;;;;;;;OAOG;WACW,sBAAsB,CAAC,MAAM,EAAE,6BAA6B,GAAG,MAAM,CAAC,gBAAgB,CAAC;CAGtG"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.AbstractDecision = void 0;
|
|
25
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
26
|
+
const candidate_1 = require("./candidate");
|
|
27
|
+
const decision_1 = require("./decision");
|
|
28
|
+
/**
|
|
29
|
+
* An abstract decision represents a class of decisions with candidates
|
|
30
|
+
* that differ only in value. It is a {@link Decisions.Decision | IDecision<number>}
|
|
31
|
+
* in which the `number` values are sequentially assigned indexes.
|
|
32
|
+
* This allows us to represent each related {@link Decisions.IDecision | decision} as an
|
|
33
|
+
* {@link Decisions.AbstractDecision | abstract decision} and a matching array containing
|
|
34
|
+
* the corresponding value for each candidate. This representation is highly cacheable.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
class AbstractDecision extends decision_1.Decision {
|
|
38
|
+
/**
|
|
39
|
+
* Constructor for an {@link Decisions.AbstractDecision | AbstractDecision} object.
|
|
40
|
+
* @param params - {@link Decisions.IAbstractDecisionCreateParams | Parameters}
|
|
41
|
+
* used to create the decision.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
constructor(params) {
|
|
45
|
+
const candidates = Array.from(params.conditionSets)
|
|
46
|
+
.map((conditionSet, value) => candidate_1.Candidate.createCandidate({ conditionSet, value }).orThrow())
|
|
47
|
+
.sort(candidate_1.Candidate.compare);
|
|
48
|
+
super({ candidates, index: params.index, isAbstract: true });
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new {@link Decisions.AbstractDecision | AbstractDecision} object.
|
|
52
|
+
* @param params - {@link Decisions.IAbstractDecisionCreateParams | Parameters}
|
|
53
|
+
* used to create the decision.
|
|
54
|
+
* @returns `Success` with the new decision if successful, or `Failure` with an
|
|
55
|
+
* error message if not.
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
static createAbstractDecision(params) {
|
|
59
|
+
return (0, ts_utils_1.captureResult)(() => new AbstractDecision(params));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.AbstractDecision = AbstractDecision;
|
|
63
|
+
//# sourceMappingURL=abstractDecision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractDecision.js","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecision.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAsD;AAEtD,2CAAwC;AACxC,yCAAsC;AAWtC;;;;;;;;GAQG;AACH,MAAa,gBAAiB,SAAQ,mBAAgB;IACpD;;;;;OAKG;IACH,YAAsB,MAAqC;QACzD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;aAChD,GAAG,CAAC,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,qBAAS,CAAC,eAAe,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;aAC1F,IAAI,CAAC,qBAAS,CAAC,OAAO,CAAC,CAAC;QAC3B,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,sBAAsB,CAAC,MAAqC;QACxE,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAzBD,4CAyBC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Result } from '@fgv/ts-utils';\nimport { ConditionSet } from '../conditions';\nimport { Candidate } from './candidate';\nimport { Decision } from './decision';\n\n/**\n * Parameters to create an {@link Decisions.AbstractDecision | AbstractDecision}.\n * @public\n */\nexport interface IAbstractDecisionCreateParams {\n conditionSets: ConditionSet[];\n index?: number;\n}\n\n/**\n * An abstract decision represents a class of decisions with candidates\n * that differ only in value. It is a {@link Decisions.Decision | IDecision<number>}\n * in which the `number` values are sequentially assigned indexes.\n * This allows us to represent each related {@link Decisions.IDecision | decision} as an\n * {@link Decisions.AbstractDecision | abstract decision} and a matching array containing\n * the corresponding value for each candidate. This representation is highly cacheable.\n * @public\n */\nexport class AbstractDecision extends Decision<number> {\n /**\n * Constructor for an {@link Decisions.AbstractDecision | AbstractDecision} object.\n * @param params - {@link Decisions.IAbstractDecisionCreateParams | Parameters}\n * used to create the decision.\n * @public\n */\n protected constructor(params: IAbstractDecisionCreateParams) {\n const candidates = Array.from(params.conditionSets)\n .map((conditionSet, value) => Candidate.createCandidate({ conditionSet, value }).orThrow())\n .sort(Candidate.compare);\n super({ candidates, index: params.index, isAbstract: true });\n }\n\n /**\n * Creates a new {@link Decisions.AbstractDecision | AbstractDecision} object.\n * @param params - {@link Decisions.IAbstractDecisionCreateParams | Parameters}\n * used to create the decision.\n * @returns `Success` with the new decision if successful, or `Failure` with an\n * error message if not.\n * @public\n */\n public static createAbstractDecision(params: IAbstractDecisionCreateParams): Result<AbstractDecision> {\n return captureResult(() => new AbstractDecision(params));\n }\n}\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Collections, Result, ValidatingCollector } from '@fgv/ts-utils';
|
|
2
|
+
import { AbstractDecision } from './abstractDecision';
|
|
3
|
+
import { DecisionIndex } from '../common';
|
|
4
|
+
import { ReadOnlyConditionSetCollector } from '../conditions';
|
|
5
|
+
/**
|
|
6
|
+
* Parameters for creating a {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface IAbstractDecisionCollectorCreateParams {
|
|
10
|
+
/**
|
|
11
|
+
* {@link Conditions.ReadOnlyConditionSetCollector | ConditionSetCollector} used to create conditions
|
|
12
|
+
* sets for decisions in this collector.
|
|
13
|
+
*/
|
|
14
|
+
conditionSets: ReadOnlyConditionSetCollector;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A `ValidatingCollector` for {@link Decisions.AbstractDecision | AbstractDecisions}.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare class AbstractDecisionCollector extends ValidatingCollector<AbstractDecision> {
|
|
21
|
+
/**
|
|
22
|
+
* The {@link Conditions.ReadOnlyConditionSetCollector | ConditionSetCollector} used to create conditions
|
|
23
|
+
* sets for decisions in this collector.
|
|
24
|
+
*/
|
|
25
|
+
readonly conditionSets: ReadOnlyConditionSetCollector;
|
|
26
|
+
/**
|
|
27
|
+
* The empty decision (no condition sets) for this collector.
|
|
28
|
+
*/
|
|
29
|
+
get emptyDecision(): AbstractDecision;
|
|
30
|
+
/**
|
|
31
|
+
* The default-only decision (one condition set with no conditions) for this collector.
|
|
32
|
+
*/
|
|
33
|
+
get defaultOnlyDecision(): AbstractDecision;
|
|
34
|
+
/**
|
|
35
|
+
* The index for the empty decision.
|
|
36
|
+
*/
|
|
37
|
+
static readonly EmptyDecisionIndex: DecisionIndex;
|
|
38
|
+
/**
|
|
39
|
+
* The index for the default-only decision.
|
|
40
|
+
*/
|
|
41
|
+
static readonly DefaultOnlyDecisionIndex: DecisionIndex;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new instance of {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.
|
|
44
|
+
*/
|
|
45
|
+
protected constructor(params: IAbstractDecisionCollectorCreateParams);
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new instance of {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.
|
|
48
|
+
* @returns `Success` with the new instance, or `Failure` with an error if the instance could not be created.
|
|
49
|
+
*/
|
|
50
|
+
static create(params: IAbstractDecisionCollectorCreateParams): Result<AbstractDecisionCollector>;
|
|
51
|
+
private _toAbstractDecision;
|
|
52
|
+
private _isConditionSetArray;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A read-only {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export type ReadOnlyAbstractDecisionCollector = Collections.IReadOnlyValidatingCollector<AbstractDecision>;
|
|
59
|
+
//# sourceMappingURL=abstractDecisionCollector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractDecisionCollector.d.ts","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecisionCollector.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,WAAW,EAAE,MAAM,EAAiB,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAA4B,aAAa,EAAyB,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAgB,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAE5E;;;GAGG;AACH,MAAM,WAAW,sCAAsC;IACrD;;;OAGG;IACH,aAAa,EAAE,6BAA6B,CAAC;CAC9C;AAED;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;IAClF;;;OAGG;IACH,SAAgB,aAAa,EAAE,6BAA6B,CAAC;IAE7D;;OAEG;IACH,IAAW,aAAa,IAAI,gBAAgB,CAE3C;IAED;;OAEG;IACH,IAAW,mBAAmB,IAAI,gBAAgB,CAEjD;IAED;;OAEG;IACH,gBAAuB,kBAAkB,EAAE,aAAa,CAAyC;IAEjG;;OAEG;IACH,gBAAuB,wBAAwB,EAAE,aAAa,CAAyC;IAEvG;;OAEG;IACH,SAAS,aAAa,MAAM,EAAE,sCAAsC;IAapE;;;OAGG;WACW,MAAM,CAAC,MAAM,EAAE,sCAAsC,GAAG,MAAM,CAAC,yBAAyB,CAAC;IAIvG,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,oBAAoB;CAG7B;AAED;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,WAAW,CAAC,4BAA4B,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.AbstractDecisionCollector = void 0;
|
|
25
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
26
|
+
const abstractDecision_1 = require("./abstractDecision");
|
|
27
|
+
const common_1 = require("../common");
|
|
28
|
+
const conditions_1 = require("../conditions");
|
|
29
|
+
/**
|
|
30
|
+
* A `ValidatingCollector` for {@link Decisions.AbstractDecision | AbstractDecisions}.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
class AbstractDecisionCollector extends ts_utils_1.ValidatingCollector {
|
|
34
|
+
/**
|
|
35
|
+
* The empty decision (no condition sets) for this collector.
|
|
36
|
+
*/
|
|
37
|
+
get emptyDecision() {
|
|
38
|
+
return this.getAt(AbstractDecisionCollector.EmptyDecisionIndex).orThrow();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The default-only decision (one condition set with no conditions) for this collector.
|
|
42
|
+
*/
|
|
43
|
+
get defaultOnlyDecision() {
|
|
44
|
+
return this.getAt(AbstractDecisionCollector.DefaultOnlyDecisionIndex).orThrow();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new instance of {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.
|
|
48
|
+
*/
|
|
49
|
+
constructor(params) {
|
|
50
|
+
super({
|
|
51
|
+
converters: new ts_utils_1.Collections.KeyValueConverters({
|
|
52
|
+
key: common_1.Convert.decisionKey,
|
|
53
|
+
value: (from) => this._toAbstractDecision(from)
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
this.conditionSets = params.conditionSets;
|
|
57
|
+
this.add(abstractDecision_1.AbstractDecision.createAbstractDecision({ conditionSets: [] }).orThrow()).orThrow();
|
|
58
|
+
const cs = this.conditionSets.validating.get('').orThrow();
|
|
59
|
+
this.add(abstractDecision_1.AbstractDecision.createAbstractDecision({ conditionSets: [cs] }).orThrow()).orThrow();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates a new instance of {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.
|
|
63
|
+
* @returns `Success` with the new instance, or `Failure` with an error if the instance could not be created.
|
|
64
|
+
*/
|
|
65
|
+
static create(params) {
|
|
66
|
+
return (0, ts_utils_1.captureResult)(() => new AbstractDecisionCollector(params));
|
|
67
|
+
}
|
|
68
|
+
_toAbstractDecision(from) {
|
|
69
|
+
if (from instanceof abstractDecision_1.AbstractDecision) {
|
|
70
|
+
return (0, ts_utils_1.succeed)(from);
|
|
71
|
+
}
|
|
72
|
+
if (this._isConditionSetArray(from)) {
|
|
73
|
+
return abstractDecision_1.AbstractDecision.createAbstractDecision({
|
|
74
|
+
conditionSets: from
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return (0, ts_utils_1.fail)('invalid value: not an abstract decision or condition sets');
|
|
78
|
+
}
|
|
79
|
+
_isConditionSetArray(from) {
|
|
80
|
+
return Array.isArray(from) && from.every((e) => e instanceof conditions_1.ConditionSet);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.AbstractDecisionCollector = AbstractDecisionCollector;
|
|
84
|
+
/**
|
|
85
|
+
* The index for the empty decision.
|
|
86
|
+
*/
|
|
87
|
+
AbstractDecisionCollector.EmptyDecisionIndex = common_1.Validate.toDecisionIndex(0).orThrow();
|
|
88
|
+
/**
|
|
89
|
+
* The index for the default-only decision.
|
|
90
|
+
*/
|
|
91
|
+
AbstractDecisionCollector.DefaultOnlyDecisionIndex = common_1.Validate.toDecisionIndex(1).orThrow();
|
|
92
|
+
//# sourceMappingURL=abstractDecisionCollector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractDecisionCollector.js","sourceRoot":"","sources":["../../../src/packlets/decisions/abstractDecisionCollector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAuG;AACvG,yDAAsD;AACtD,sCAA2F;AAC3F,8CAA4E;AAc5E;;;GAGG;AACH,MAAa,yBAA0B,SAAQ,8BAAqC;IAOlF;;OAEG;IACH,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,CAAC,OAAO,EAAE,CAAC;IAC5E,CAAC;IAED;;OAEG;IACH,IAAW,mBAAmB;QAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,yBAAyB,CAAC,wBAAwB,CAAC,CAAC,OAAO,EAAE,CAAC;IAClF,CAAC;IAYD;;OAEG;IACH,YAAsB,MAA8C;QAClE,KAAK,CAAC;YACJ,UAAU,EAAE,IAAI,sBAAW,CAAC,kBAAkB,CAAgC;gBAC5E,GAAG,EAAE,gBAAa,CAAC,WAAW;gBAC9B,KAAK,EAAE,CAAC,IAAa,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;aACzD,CAAC;SACH,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;QAC1C,IAAI,CAAC,GAAG,CAAC,mCAAgB,CAAC,sBAAsB,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAC7F,MAAM,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAC3D,IAAI,CAAC,GAAG,CAAC,mCAAgB,CAAC,sBAAsB,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACjG,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,MAA8C;QACjE,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC;IACpE,CAAC;IAEO,mBAAmB,CAAC,IAAa;QACvC,IAAI,IAAI,YAAY,mCAAgB,EAAE,CAAC;YACrC,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC;YACpC,OAAO,mCAAgB,CAAC,sBAAsB,CAAC;gBAC7C,aAAa,EAAE,IAAI;aACpB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,2DAA2D,CAAC,CAAC;IAC3E,CAAC;IAEO,oBAAoB,CAAC,IAAa;QACxC,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,yBAAY,CAAC,CAAC;IAC7E,CAAC;;AArEH,8DAsEC;AAjDC;;GAEG;AACoB,4CAAkB,GAAkB,iBAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AAEjG;;GAEG;AACoB,kDAAwB,GAAkB,iBAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { captureResult, Collections, Result, fail, succeed, ValidatingCollector } from '@fgv/ts-utils';\nimport { AbstractDecision } from './abstractDecision';\nimport { Convert as CommonConvert, DecisionIndex, DecisionKey, Validate } from '../common';\nimport { ConditionSet, ReadOnlyConditionSetCollector } from '../conditions';\n\n/**\n * Parameters for creating a {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n * @public\n */\nexport interface IAbstractDecisionCollectorCreateParams {\n /**\n * {@link Conditions.ReadOnlyConditionSetCollector | ConditionSetCollector} used to create conditions\n * sets for decisions in this collector.\n */\n conditionSets: ReadOnlyConditionSetCollector;\n}\n\n/**\n * A `ValidatingCollector` for {@link Decisions.AbstractDecision | AbstractDecisions}.\n * @public\n */\nexport class AbstractDecisionCollector extends ValidatingCollector<AbstractDecision> {\n /**\n * The {@link Conditions.ReadOnlyConditionSetCollector | ConditionSetCollector} used to create conditions\n * sets for decisions in this collector.\n */\n public readonly conditionSets: ReadOnlyConditionSetCollector;\n\n /**\n * The empty decision (no condition sets) for this collector.\n */\n public get emptyDecision(): AbstractDecision {\n return this.getAt(AbstractDecisionCollector.EmptyDecisionIndex).orThrow();\n }\n\n /**\n * The default-only decision (one condition set with no conditions) for this collector.\n */\n public get defaultOnlyDecision(): AbstractDecision {\n return this.getAt(AbstractDecisionCollector.DefaultOnlyDecisionIndex).orThrow();\n }\n\n /**\n * The index for the empty decision.\n */\n public static readonly EmptyDecisionIndex: DecisionIndex = Validate.toDecisionIndex(0).orThrow();\n\n /**\n * The index for the default-only decision.\n */\n public static readonly DefaultOnlyDecisionIndex: DecisionIndex = Validate.toDecisionIndex(1).orThrow();\n\n /**\n * Creates a new instance of {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n */\n protected constructor(params: IAbstractDecisionCollectorCreateParams) {\n super({\n converters: new Collections.KeyValueConverters<DecisionKey, AbstractDecision>({\n key: CommonConvert.decisionKey,\n value: (from: unknown) => this._toAbstractDecision(from)\n })\n });\n this.conditionSets = params.conditionSets;\n this.add(AbstractDecision.createAbstractDecision({ conditionSets: [] }).orThrow()).orThrow();\n const cs = this.conditionSets.validating.get('').orThrow();\n this.add(AbstractDecision.createAbstractDecision({ conditionSets: [cs] }).orThrow()).orThrow();\n }\n\n /**\n * Creates a new instance of {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n * @returns `Success` with the new instance, or `Failure` with an error if the instance could not be created.\n */\n public static create(params: IAbstractDecisionCollectorCreateParams): Result<AbstractDecisionCollector> {\n return captureResult(() => new AbstractDecisionCollector(params));\n }\n\n private _toAbstractDecision(from: unknown): Result<AbstractDecision> {\n if (from instanceof AbstractDecision) {\n return succeed(from);\n }\n if (this._isConditionSetArray(from)) {\n return AbstractDecision.createAbstractDecision({\n conditionSets: from\n });\n }\n return fail('invalid value: not an abstract decision or condition sets');\n }\n\n private _isConditionSetArray(from: unknown): from is ConditionSet[] {\n return Array.isArray(from) && from.every((e) => e instanceof ConditionSet);\n }\n}\n\n/**\n * A read-only {@link Decisions.AbstractDecisionCollector | AbstractDecisionCollector}.\n * @public\n */\nexport type ReadOnlyAbstractDecisionCollector = Collections.IReadOnlyValidatingCollector<AbstractDecision>;\n"]}
|