@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,54 @@
|
|
|
1
|
+
import { Converter } from '@fgv/ts-utils';
|
|
2
|
+
import * as Json from './json';
|
|
3
|
+
import * as Normalized from './normalized';
|
|
4
|
+
/**
|
|
5
|
+
* `Converter` for a normalized {@link ResourceJson.Json.ILooseConditionDecl | loose condition declaration}.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare const looseConditionDecl: Converter<Json.ILooseConditionDecl>;
|
|
9
|
+
/**
|
|
10
|
+
* `Converter` for a normalized {@link ResourceJson.Json.IChildConditionDecl | child condition declaration}.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const childConditionDecl: Converter<Json.IChildConditionDecl>;
|
|
14
|
+
/**
|
|
15
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.ConditionSetDecl | condition set declaration}.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare const conditionSetDecl: Converter<Normalized.ConditionSetDecl>;
|
|
19
|
+
/**
|
|
20
|
+
* `Converter` for a normalized {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declaration}.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare const looseResourceCandidateDecl: Converter<Normalized.ILooseResourceCandidateDecl>;
|
|
24
|
+
/**
|
|
25
|
+
* `Converter` for a normalized {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare const childResourceCandidateDecl: Converter<Normalized.IChildResourceCandidateDecl>;
|
|
29
|
+
/**
|
|
30
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.ILooseResourceDecl | loose resource declaration}.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export declare const looseResourceDecl: Converter<Normalized.ILooseResourceDecl>;
|
|
34
|
+
/**
|
|
35
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.IChildResourceDecl | child resource declaration}.
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare const childResourceDecl: Converter<Normalized.IChildResourceDecl>;
|
|
39
|
+
/**
|
|
40
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.IResourceTreeChildNodeDecl | resource tree child node declaration}.
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export declare const resourceTreeChildNodeDecl: Converter<Normalized.IResourceTreeChildNodeDecl>;
|
|
44
|
+
/**
|
|
45
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.IResourceTreeRootDecl | resource tree root declaration}.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export declare const resourceTreeRootDecl: Converter<Normalized.IResourceTreeRootDecl>;
|
|
49
|
+
/**
|
|
50
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.IResourceCollectionDecl | resource collection declaration}.
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
export declare const resourceCollectionDecl: Converter<Normalized.IResourceCollectionDecl>;
|
|
54
|
+
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../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, 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.resourceCollectionDecl = exports.resourceTreeRootDecl = exports.resourceTreeChildNodeDecl = exports.childResourceDecl = exports.looseResourceDecl = exports.childResourceCandidateDecl = exports.looseResourceCandidateDecl = exports.conditionSetDecl = exports.childConditionDecl = exports.looseConditionDecl = void 0;
|
|
25
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
26
|
+
const common_1 = require("../common");
|
|
27
|
+
const ts_json_base_1 = require("@fgv/ts-json-base");
|
|
28
|
+
/**
|
|
29
|
+
* `Converter` for a normalized {@link ResourceJson.Json.ILooseConditionDecl | loose condition declaration}.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
exports.looseConditionDecl = ts_utils_1.Converters.strictObject({
|
|
33
|
+
qualifierName: common_1.Convert.qualifierName,
|
|
34
|
+
value: ts_utils_1.Converters.string,
|
|
35
|
+
operator: common_1.Convert.conditionOperator.optional(),
|
|
36
|
+
priority: common_1.Convert.conditionPriority.optional(),
|
|
37
|
+
scoreAsDefault: ts_utils_1.Converters.number.optional()
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* `Converter` for a normalized {@link ResourceJson.Json.IChildConditionDecl | child condition declaration}.
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
exports.childConditionDecl = ts_utils_1.Converters.strictObject({
|
|
44
|
+
value: ts_utils_1.Converters.string,
|
|
45
|
+
operator: common_1.Convert.conditionOperator.optional(),
|
|
46
|
+
priority: common_1.Convert.conditionPriority.optional(),
|
|
47
|
+
scoreAsDefault: ts_utils_1.Converters.number.optional()
|
|
48
|
+
});
|
|
49
|
+
function _isConditionSetRecord(from) {
|
|
50
|
+
return (0, ts_json_base_1.isJsonObject)(from);
|
|
51
|
+
}
|
|
52
|
+
const conditionSetDeclFromArray = ts_utils_1.Converters.arrayOf(exports.looseConditionDecl);
|
|
53
|
+
const conditionSetDeclFromRecord = ts_utils_1.Converters.generic((from, self, context) => {
|
|
54
|
+
/* c8 ignore next 3 - this is tested but coverage is confused */
|
|
55
|
+
if (!_isConditionSetRecord(from)) {
|
|
56
|
+
return (0, ts_utils_1.fail)('Expected an object');
|
|
57
|
+
}
|
|
58
|
+
return (0, ts_utils_1.mapResults)(Array.from(Object.entries(from)).map(([qualifierName, value]) => {
|
|
59
|
+
const toConvert = typeof value === 'string' ? { qualifierName, value } : Object.assign({ qualifierName }, value);
|
|
60
|
+
return exports.looseConditionDecl.convert(toConvert, context);
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.ConditionSetDecl | condition set declaration}.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
exports.conditionSetDecl = ts_utils_1.Converters.oneOf([conditionSetDeclFromArray, conditionSetDeclFromRecord]);
|
|
68
|
+
/**
|
|
69
|
+
* `Converter` for a normalized {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declaration}.
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
exports.looseResourceCandidateDecl = ts_utils_1.Converters.strictObject({
|
|
73
|
+
id: common_1.Convert.resourceId,
|
|
74
|
+
json: ts_json_base_1.Converters.jsonObject,
|
|
75
|
+
conditions: exports.conditionSetDecl.optional(),
|
|
76
|
+
mergeMethod: common_1.Convert.resourceValueMergeMethod.optional(),
|
|
77
|
+
isPartial: ts_utils_1.Converters.boolean.optional(),
|
|
78
|
+
resourceTypeName: common_1.Convert.resourceTypeName.optional()
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* `Converter` for a normalized {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}.
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
exports.childResourceCandidateDecl = ts_utils_1.Converters.strictObject({
|
|
85
|
+
json: ts_json_base_1.Converters.jsonObject,
|
|
86
|
+
conditions: exports.conditionSetDecl.optional(),
|
|
87
|
+
isPartial: ts_utils_1.Converters.boolean.optional(),
|
|
88
|
+
mergeMethod: common_1.Convert.resourceValueMergeMethod.optional()
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.ILooseResourceDecl | loose resource declaration}.
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
exports.looseResourceDecl = ts_utils_1.Converters.strictObject({
|
|
95
|
+
id: common_1.Convert.resourceId,
|
|
96
|
+
resourceTypeName: common_1.Convert.resourceTypeName,
|
|
97
|
+
candidates: ts_utils_1.Converters.arrayOf(exports.childResourceCandidateDecl).optional()
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.IChildResourceDecl | child resource declaration}.
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
exports.childResourceDecl = ts_utils_1.Converters.strictObject({
|
|
104
|
+
resourceTypeName: common_1.Convert.resourceTypeName,
|
|
105
|
+
candidates: ts_utils_1.Converters.arrayOf(exports.childResourceCandidateDecl).optional()
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.IResourceTreeChildNodeDecl | resource tree child node declaration}.
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
exports.resourceTreeChildNodeDecl = ts_utils_1.Converters.generic((from, self, context) => {
|
|
112
|
+
return ts_utils_1.Converters.strictObject({
|
|
113
|
+
resources: ts_utils_1.Converters.recordOf(exports.childResourceDecl).optional(),
|
|
114
|
+
children: ts_utils_1.Converters.recordOf(self).optional()
|
|
115
|
+
}).convert(from, context);
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.IResourceTreeRootDecl | resource tree root declaration}.
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
exports.resourceTreeRootDecl = ts_utils_1.Converters.strictObject({
|
|
122
|
+
baseName: common_1.Convert.resourceId.optional(),
|
|
123
|
+
resources: ts_utils_1.Converters.recordOf(exports.childResourceDecl).optional(),
|
|
124
|
+
children: ts_utils_1.Converters.recordOf(exports.resourceTreeChildNodeDecl).optional()
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* `Converter` for a normalized {@link ResourceJson.Normalized.IResourceCollectionDecl | resource collection declaration}.
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
exports.resourceCollectionDecl = ts_utils_1.Converters.generic((from, self, context) => {
|
|
131
|
+
return ts_utils_1.Converters.strictObject({
|
|
132
|
+
baseName: common_1.Convert.resourceId.optional(),
|
|
133
|
+
baseConditions: exports.conditionSetDecl.optional(),
|
|
134
|
+
candidates: ts_utils_1.Converters.arrayOf(exports.looseResourceCandidateDecl).optional(),
|
|
135
|
+
resources: ts_utils_1.Converters.arrayOf(exports.looseResourceDecl).optional(),
|
|
136
|
+
collections: ts_utils_1.Converters.arrayOf(self).optional()
|
|
137
|
+
}).convert(from, context);
|
|
138
|
+
});
|
|
139
|
+
//# sourceMappingURL=convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../src/packlets/resource-json/convert.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAgF;AAChF,sCAAqD;AACrD,oDAA+E;AAI/E;;;GAGG;AACU,QAAA,kBAAkB,GAC7B,qBAAU,CAAC,YAAY,CAA2B;IAChD,aAAa,EAAE,gBAAa,CAAC,aAAa;IAC1C,KAAK,EAAE,qBAAU,CAAC,MAAM;IACxB,QAAQ,EAAE,gBAAa,CAAC,iBAAiB,CAAC,QAAQ,EAAE;IACpD,QAAQ,EAAE,gBAAa,CAAC,iBAAiB,CAAC,QAAQ,EAAE;IACpD,cAAc,EAAE,qBAAU,CAAC,MAAM,CAAC,QAAQ,EAAE;CAC7C,CAAC,CAAC;AAEL;;;GAGG;AACU,QAAA,kBAAkB,GAC7B,qBAAU,CAAC,YAAY,CAA2B;IAChD,KAAK,EAAE,qBAAU,CAAC,MAAM;IACxB,QAAQ,EAAE,gBAAa,CAAC,iBAAiB,CAAC,QAAQ,EAAE;IACpD,QAAQ,EAAE,gBAAa,CAAC,iBAAiB,CAAC,QAAQ,EAAE;IACpD,cAAc,EAAE,qBAAU,CAAC,MAAM,CAAC,QAAQ,EAAE;CAC7C,CAAC,CAAC;AAEL,SAAS,qBAAqB,CAAC,IAAa;IAC1C,OAAO,IAAA,2BAAY,EAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,yBAAyB,GAC7B,qBAAU,CAAC,OAAO,C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AAE,qBAAU,CAAC,QAAQ,CAAC,yBAAiB,CAAC,CAAC,QAAQ,EAAE;IAC5D,QAAQ,EAAE,qBAAU,CAAC,QAAQ,CAAC,iCAAyB,CAAC,CAAC,QAAQ,EAAE;CACpE,CAAC,CAAC;AAEL;;;GAGG;AACU,QAAA,sBAAsB,GAAkD,qBAAU,CAAC,OAAO,CAIrG,CACE,IAAa,EACb,IAA4D,EAC5D,OAAiB,EAC2B,EAAE;IAC9C,OAAO,qBAAU,CAAC,YAAY,CAAqC;QACjE,QAAQ,EAAE,gBAAa,CAAC,UAAU,CAAC,QAAQ,EAAE;QAC7C,cAAc,EAAE,wBAAgB,CAAC,QAAQ,EAAE;QAC3C,UAAU,EAAE,qBAAU,CAAC,OAAO,CAAC,kCAA0B,CAAC,CAAC,QAAQ,EAAE;QACrE,SAAS,EAAE,qBAAU,CAAC,OAAO,CAAC,yBAAiB,CAAC,CAAC,QAAQ,EAAE;QAC3D,WAAW,EAAE,qBAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;KACjD,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC,CACF,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 { Converter, Converters, mapResults, Result, fail } from '@fgv/ts-utils';\nimport { Convert as CommonConvert } from '../common';\nimport { isJsonObject, Converters as JsonConverters } from '@fgv/ts-json-base';\nimport * as Json from './json';\nimport * as Normalized from './normalized';\n\n/**\n * `Converter` for a normalized {@link ResourceJson.Json.ILooseConditionDecl | loose condition declaration}.\n * @public\n */\nexport const looseConditionDecl: Converter<Json.ILooseConditionDecl> =\n Converters.strictObject<Json.ILooseConditionDecl>({\n qualifierName: CommonConvert.qualifierName,\n value: Converters.string,\n operator: CommonConvert.conditionOperator.optional(),\n priority: CommonConvert.conditionPriority.optional(),\n scoreAsDefault: Converters.number.optional()\n });\n\n/**\n * `Converter` for a normalized {@link ResourceJson.Json.IChildConditionDecl | child condition declaration}.\n * @public\n */\nexport const childConditionDecl: Converter<Json.IChildConditionDecl> =\n Converters.strictObject<Json.IChildConditionDecl>({\n value: Converters.string,\n operator: CommonConvert.conditionOperator.optional(),\n priority: CommonConvert.conditionPriority.optional(),\n scoreAsDefault: Converters.number.optional()\n });\n\nfunction _isConditionSetRecord(from: unknown): from is Record<string, string | Json.IChildConditionDecl> {\n return isJsonObject(from);\n}\n\nconst conditionSetDeclFromArray: Converter<Normalized.ConditionSetDecl> =\n Converters.arrayOf(looseConditionDecl);\nconst conditionSetDeclFromRecord: Converter<Normalized.ConditionSetDecl> = Converters.generic<\n Normalized.ConditionSetDecl,\n unknown\n>(\n (\n from: unknown,\n self: Converter<Normalized.ConditionSetDecl, unknown>,\n context?: unknown\n ): Result<Normalized.ConditionSetDecl> => {\n /* c8 ignore next 3 - this is tested but coverage is confused */\n if (!_isConditionSetRecord(from)) {\n return fail('Expected an object');\n }\n return mapResults(\n Array.from(Object.entries(from)).map(([qualifierName, value]) => {\n const toConvert: Json.ILooseConditionDecl =\n typeof value === 'string' ? { qualifierName, value } : { qualifierName, ...value };\n return looseConditionDecl.convert(toConvert, context);\n })\n );\n }\n);\n\n/**\n * `Converter` for a normalized {@link ResourceJson.Normalized.ConditionSetDecl | condition set declaration}.\n * @public\n */\nexport const conditionSetDecl: Converter<Normalized.ConditionSetDecl> =\n Converters.oneOf<Normalized.ConditionSetDecl>([conditionSetDeclFromArray, conditionSetDeclFromRecord]);\n\n/**\n * `Converter` for a normalized {@link ResourceJson.Json.ILooseResourceCandidateDecl | loose resource candidate declaration}.\n * @public\n */\nexport const looseResourceCandidateDecl: Converter<Normalized.ILooseResourceCandidateDecl> =\n Converters.strictObject<Normalized.ILooseResourceCandidateDecl>({\n id: CommonConvert.resourceId,\n json: JsonConverters.jsonObject,\n conditions: conditionSetDecl.optional(),\n mergeMethod: CommonConvert.resourceValueMergeMethod.optional(),\n isPartial: Converters.boolean.optional(),\n resourceTypeName: CommonConvert.resourceTypeName.optional()\n });\n\n/**\n * `Converter` for a normalized {@link ResourceJson.Json.IChildResourceCandidateDecl | child resource candidate declaration}.\n * @public\n */\nexport const childResourceCandidateDecl: Converter<Normalized.IChildResourceCandidateDecl> =\n Converters.strictObject<Normalized.IChildResourceCandidateDecl>({\n json: JsonConverters.jsonObject,\n conditions: conditionSetDecl.optional(),\n isPartial: Converters.boolean.optional(),\n mergeMethod: CommonConvert.resourceValueMergeMethod.optional()\n });\n\n/**\n * `Converter` for a normalized {@link ResourceJson.Normalized.ILooseResourceDecl | loose resource declaration}.\n * @public\n */\nexport const looseResourceDecl: Converter<Normalized.ILooseResourceDecl> =\n Converters.strictObject<Normalized.ILooseResourceDecl>({\n id: CommonConvert.resourceId,\n resourceTypeName: CommonConvert.resourceTypeName,\n candidates: Converters.arrayOf(childResourceCandidateDecl).optional()\n });\n\n/**\n * `Converter` for a normalized {@link ResourceJson.Normalized.IChildResourceDecl | child resource declaration}.\n * @public\n */\nexport const childResourceDecl: Converter<Normalized.IChildResourceDecl> =\n Converters.strictObject<Normalized.IChildResourceDecl>({\n resourceTypeName: CommonConvert.resourceTypeName,\n candidates: Converters.arrayOf(childResourceCandidateDecl).optional()\n });\n\n/**\n * `Converter` for a normalized {@link ResourceJson.Normalized.IResourceTreeChildNodeDecl | resource tree child node declaration}.\n * @public\n */\nexport const resourceTreeChildNodeDecl: Converter<Normalized.IResourceTreeChildNodeDecl> = Converters.generic<\n Normalized.IResourceTreeChildNodeDecl,\n unknown\n>(\n (\n from: unknown,\n self: Converter<Normalized.IResourceTreeChildNodeDecl, unknown>,\n context?: unknown\n ): Result<Normalized.IResourceTreeChildNodeDecl> => {\n return Converters.strictObject<Normalized.IResourceTreeChildNodeDecl>({\n resources: Converters.recordOf(childResourceDecl).optional(),\n children: Converters.recordOf(self).optional()\n }).convert(from, context);\n }\n);\n\n/**\n * `Converter` for a normalized {@link ResourceJson.Normalized.IResourceTreeRootDecl | resource tree root declaration}.\n * @public\n */\nexport const resourceTreeRootDecl: Converter<Normalized.IResourceTreeRootDecl> =\n Converters.strictObject<Normalized.IResourceTreeRootDecl>({\n baseName: CommonConvert.resourceId.optional(),\n resources: Converters.recordOf(childResourceDecl).optional(),\n children: Converters.recordOf(resourceTreeChildNodeDecl).optional()\n });\n\n/**\n * `Converter` for a normalized {@link ResourceJson.Normalized.IResourceCollectionDecl | resource collection declaration}.\n * @public\n */\nexport const resourceCollectionDecl: Converter<Normalized.IResourceCollectionDecl> = Converters.generic<\n Normalized.IResourceCollectionDecl,\n unknown\n>(\n (\n from: unknown,\n self: Converter<Normalized.IResourceCollectionDecl, unknown>,\n context?: unknown\n ): Result<Normalized.IResourceCollectionDecl> => {\n return Converters.strictObject<Normalized.IResourceCollectionDecl>({\n baseName: CommonConvert.resourceId.optional(),\n baseConditions: conditionSetDecl.optional(),\n candidates: Converters.arrayOf(looseResourceCandidateDecl).optional(),\n resources: Converters.arrayOf(looseResourceDecl).optional(),\n collections: Converters.arrayOf(self).optional()\n }).convert(from, context);\n }\n);\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
import * as Normalized from './normalized';
|
|
3
|
+
import * as Json from './json';
|
|
4
|
+
import * as Conditions from '../conditions';
|
|
5
|
+
/**
|
|
6
|
+
* Helper method to merge a loose candidate with a base name and conditions.
|
|
7
|
+
* @param candidate - The candidate to merge.
|
|
8
|
+
* @param baseName - The base name to merge with the candidate.
|
|
9
|
+
* @param baseConditions - The base conditions to merge with the candidate.
|
|
10
|
+
* @returns `Success` with the merged candidate if successful, otherwise `Failure`.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare function mergeLooseCandidate(candidate: Normalized.ILooseResourceCandidateDecl, baseName?: string, baseConditions?: ReadonlyArray<Json.ILooseConditionDecl | Conditions.IConditionDecl>): Result<Normalized.ILooseResourceCandidateDecl>;
|
|
14
|
+
/**
|
|
15
|
+
* Helper method to merge a child candidate with base conditions.
|
|
16
|
+
* @param candidate - The candidate to merge.
|
|
17
|
+
* @param baseConditions - The base conditions to merge with the candidate.
|
|
18
|
+
* @returns `Success` with the merged candidate if successful, otherwise `Failure`.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function mergeChildCandidate(candidate: Normalized.IChildResourceCandidateDecl, baseConditions?: ReadonlyArray<Json.ILooseConditionDecl | Conditions.IConditionDecl>): Result<Normalized.IChildResourceCandidateDecl>;
|
|
22
|
+
/**
|
|
23
|
+
* Helper method to merge a loose resource with a base name and conditions.
|
|
24
|
+
* @param resource - The resource to merge.
|
|
25
|
+
* @param baseName - The base name to merge with the resource.
|
|
26
|
+
* @param baseConditions - The base conditions to merge with the resource.
|
|
27
|
+
* @returns `Success` with the merged resource if successful, otherwise `Failure`.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare function mergeLooseResource(resource: Normalized.ILooseResourceDecl, baseName?: string, baseConditions?: ReadonlyArray<Json.ILooseConditionDecl | Conditions.IConditionDecl>): Result<Normalized.ILooseResourceDecl>;
|
|
31
|
+
/**
|
|
32
|
+
* Helper method to merge a child resource with a parent name and conditions.
|
|
33
|
+
* @param resource - The resource to merge.
|
|
34
|
+
* @param name - The name of the resource.
|
|
35
|
+
* @param parentName - The name of the parent resource.
|
|
36
|
+
* @param parentConditions - The conditions of the parent resource.
|
|
37
|
+
* @returns `Success` with the merged resource if successful, otherwise `Failure`.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare function mergeChildResource(resource: Normalized.IChildResourceDecl, name: string, parentName?: string, parentConditions?: ReadonlyArray<Json.ILooseConditionDecl | Conditions.IConditionDecl>): Result<Normalized.ILooseResourceDecl>;
|
|
41
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-json/helpers.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAc,MAAM,EAAW,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAE5C;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,UAAU,CAAC,2BAA2B,EACjD,QAAQ,CAAC,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,mBAAmB,GAAG,UAAU,CAAC,cAAc,CAAC,GACnF,MAAM,CAAC,UAAU,CAAC,2BAA2B,CAAC,CAMhD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,UAAU,CAAC,2BAA2B,EACjD,cAAc,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,mBAAmB,GAAG,UAAU,CAAC,cAAc,CAAC,GACnF,MAAM,CAAC,UAAU,CAAC,2BAA2B,CAAC,CAIhD;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,UAAU,CAAC,kBAAkB,EACvC,QAAQ,CAAC,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,mBAAmB,GAAG,UAAU,CAAC,cAAc,CAAC,GACnF,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,CASvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,UAAU,CAAC,kBAAkB,EACvC,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,EACnB,gBAAgB,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,mBAAmB,GAAG,UAAU,CAAC,cAAc,CAAC,GACrF,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,CASvC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
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.mergeLooseCandidate = mergeLooseCandidate;
|
|
25
|
+
exports.mergeChildCandidate = mergeChildCandidate;
|
|
26
|
+
exports.mergeLooseResource = mergeLooseResource;
|
|
27
|
+
exports.mergeChildResource = mergeChildResource;
|
|
28
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
29
|
+
const common_1 = require("../common");
|
|
30
|
+
/**
|
|
31
|
+
* Helper method to merge a loose candidate with a base name and conditions.
|
|
32
|
+
* @param candidate - The candidate to merge.
|
|
33
|
+
* @param baseName - The base name to merge with the candidate.
|
|
34
|
+
* @param baseConditions - The base conditions to merge with the candidate.
|
|
35
|
+
* @returns `Success` with the merged candidate if successful, otherwise `Failure`.
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
function mergeLooseCandidate(candidate, baseName, baseConditions) {
|
|
39
|
+
return common_1.Helpers.joinResourceIds(baseName, candidate.id).onSuccess((id) => {
|
|
40
|
+
var _a;
|
|
41
|
+
/* c8 ignore next 1 - defense in depth */
|
|
42
|
+
const conditions = [...(baseConditions !== null && baseConditions !== void 0 ? baseConditions : []), ...((_a = candidate.conditions) !== null && _a !== void 0 ? _a : [])];
|
|
43
|
+
return (0, ts_utils_1.succeed)(Object.assign(Object.assign({}, candidate), { id, conditions }));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Helper method to merge a child candidate with base conditions.
|
|
48
|
+
* @param candidate - The candidate to merge.
|
|
49
|
+
* @param baseConditions - The base conditions to merge with the candidate.
|
|
50
|
+
* @returns `Success` with the merged candidate if successful, otherwise `Failure`.
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
function mergeChildCandidate(candidate, baseConditions) {
|
|
54
|
+
var _a;
|
|
55
|
+
/* c8 ignore next 1 - defense in depth */
|
|
56
|
+
const conditions = [...(baseConditions !== null && baseConditions !== void 0 ? baseConditions : []), ...((_a = candidate.conditions) !== null && _a !== void 0 ? _a : [])];
|
|
57
|
+
return (0, ts_utils_1.succeed)(Object.assign(Object.assign({}, candidate), { conditions }));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Helper method to merge a loose resource with a base name and conditions.
|
|
61
|
+
* @param resource - The resource to merge.
|
|
62
|
+
* @param baseName - The base name to merge with the resource.
|
|
63
|
+
* @param baseConditions - The base conditions to merge with the resource.
|
|
64
|
+
* @returns `Success` with the merged resource if successful, otherwise `Failure`.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
function mergeLooseResource(resource, baseName, baseConditions) {
|
|
68
|
+
return common_1.Helpers.joinResourceIds(baseName, resource.id).onSuccess((id) => {
|
|
69
|
+
var _a;
|
|
70
|
+
return (0, ts_utils_1.mapResults)(
|
|
71
|
+
/* c8 ignore next 1 - defense in depth */
|
|
72
|
+
((_a = resource.candidates) !== null && _a !== void 0 ? _a : []).map((candidate) => mergeChildCandidate(candidate, baseConditions))).onSuccess((candidates) => {
|
|
73
|
+
return (0, ts_utils_1.succeed)(Object.assign(Object.assign({}, resource), { id, candidates }));
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Helper method to merge a child resource with a parent name and conditions.
|
|
79
|
+
* @param resource - The resource to merge.
|
|
80
|
+
* @param name - The name of the resource.
|
|
81
|
+
* @param parentName - The name of the parent resource.
|
|
82
|
+
* @param parentConditions - The conditions of the parent resource.
|
|
83
|
+
* @returns `Success` with the merged resource if successful, otherwise `Failure`.
|
|
84
|
+
* @public
|
|
85
|
+
*/
|
|
86
|
+
function mergeChildResource(resource, name, parentName, parentConditions) {
|
|
87
|
+
return common_1.Helpers.joinResourceIds(parentName, name).onSuccess((id) => {
|
|
88
|
+
var _a;
|
|
89
|
+
return (0, ts_utils_1.mapResults)(
|
|
90
|
+
/* c8 ignore next 1 - defense in depth */
|
|
91
|
+
((_a = resource.candidates) !== null && _a !== void 0 ? _a : []).map((candidate) => mergeChildCandidate(candidate, parentConditions))).onSuccess((candidates) => {
|
|
92
|
+
return (0, ts_utils_1.succeed)(Object.assign(Object.assign({}, resource), { id, candidates }));
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/packlets/resource-json/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAgBH,kDAUC;AASD,kDAOC;AAUD,gDAaC;AAWD,gDAcC;AAxFD,4CAA4D;AAG5D,sCAAqD;AAGrD;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CACjC,SAAiD,EACjD,QAAiB,EACjB,cAAoF;IAEpF,OAAO,gBAAa,CAAC,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE;;QAC5E,yCAAyC;QACzC,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,EAAE,CAAC,EAAE,GAAG,CAAC,MAAA,SAAS,CAAC,UAAU,mCAAI,EAAE,CAAC,CAAC,CAAC;QAChF,OAAO,IAAA,kBAAO,kCAAM,SAAS,KAAE,EAAE,EAAE,UAAU,IAAG,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,SA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,CACjG,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,EAAE;YACzB,OAAO,IAAA,kBAAO,kCAAM,QAAQ,KAAE,EAAE,EAAE,UAAU,IAAG,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,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 { mapResults, Result, succeed } from '@fgv/ts-utils';\nimport * as Normalized from './normalized';\nimport * as Json from './json';\nimport { Helpers as CommonHelpers } from '../common';\nimport * as Conditions from '../conditions';\n\n/**\n * Helper method to merge a loose candidate with a base name and conditions.\n * @param candidate - The candidate to merge.\n * @param baseName - The base name to merge with the candidate.\n * @param baseConditions - The base conditions to merge with the candidate.\n * @returns `Success` with the merged candidate if successful, otherwise `Failure`.\n * @public\n */\nexport function mergeLooseCandidate(\n candidate: Normalized.ILooseResourceCandidateDecl,\n baseName?: string,\n baseConditions?: ReadonlyArray<Json.ILooseConditionDecl | Conditions.IConditionDecl>\n): Result<Normalized.ILooseResourceCandidateDecl> {\n return CommonHelpers.joinResourceIds(baseName, candidate.id).onSuccess((id) => {\n /* c8 ignore next 1 - defense in depth */\n const conditions = [...(baseConditions ?? []), ...(candidate.conditions ?? [])];\n return succeed({ ...candidate, id, conditions });\n });\n}\n\n/**\n * Helper method to merge a child candidate with base conditions.\n * @param candidate - The candidate to merge.\n * @param baseConditions - The base conditions to merge with the candidate.\n * @returns `Success` with the merged candidate if successful, otherwise `Failure`.\n * @public\n */\nexport function mergeChildCandidate(\n candidate: Normalized.IChildResourceCandidateDecl,\n baseConditions?: ReadonlyArray<Json.ILooseConditionDecl | Conditions.IConditionDecl>\n): Result<Normalized.IChildResourceCandidateDecl> {\n /* c8 ignore next 1 - defense in depth */\n const conditions = [...(baseConditions ?? []), ...(candidate.conditions ?? [])];\n return succeed({ ...candidate, conditions });\n}\n\n/**\n * Helper method to merge a loose resource with a base name and conditions.\n * @param resource - The resource to merge.\n * @param baseName - The base name to merge with the resource.\n * @param baseConditions - The base conditions to merge with the resource.\n * @returns `Success` with the merged resource if successful, otherwise `Failure`.\n * @public\n */\nexport function mergeLooseResource(\n resource: Normalized.ILooseResourceDecl,\n baseName?: string,\n baseConditions?: ReadonlyArray<Json.ILooseConditionDecl | Conditions.IConditionDecl>\n): Result<Normalized.ILooseResourceDecl> {\n return CommonHelpers.joinResourceIds(baseName, resource.id).onSuccess((id) => {\n return mapResults(\n /* c8 ignore next 1 - defense in depth */\n (resource.candidates ?? []).map((candidate) => mergeChildCandidate(candidate, baseConditions))\n ).onSuccess((candidates) => {\n return succeed({ ...resource, id, candidates });\n });\n });\n}\n\n/**\n * Helper method to merge a child resource with a parent name and conditions.\n * @param resource - The resource to merge.\n * @param name - The name of the resource.\n * @param parentName - The name of the parent resource.\n * @param parentConditions - The conditions of the parent resource.\n * @returns `Success` with the merged resource if successful, otherwise `Failure`.\n * @public\n */\nexport function mergeChildResource(\n resource: Normalized.IChildResourceDecl,\n name: string,\n parentName?: string,\n parentConditions?: ReadonlyArray<Json.ILooseConditionDecl | Conditions.IConditionDecl>\n): Result<Normalized.ILooseResourceDecl> {\n return CommonHelpers.joinResourceIds(parentName, name).onSuccess((id) => {\n return mapResults(\n /* c8 ignore next 1 - defense in depth */\n (resource.candidates ?? []).map((candidate) => mergeChildCandidate(candidate, parentConditions))\n ).onSuccess((candidates) => {\n return succeed({ ...resource, id, candidates });\n });\n });\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as Convert from './convert';
|
|
2
|
+
import * as Helpers from './helpers';
|
|
3
|
+
import * as Json from './json';
|
|
4
|
+
import * as Normalized from './normalized';
|
|
5
|
+
export { Convert, Helpers, Json, Normalized };
|
|
6
|
+
export * from './resourceDeclContainer';
|
|
7
|
+
export * from './resourceDeclCollection';
|
|
8
|
+
export * from './resourceDeclTree';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/resource-json/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAE9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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.Normalized = exports.Json = exports.Helpers = exports.Convert = void 0;
|
|
61
|
+
const Convert = __importStar(require("./convert"));
|
|
62
|
+
exports.Convert = Convert;
|
|
63
|
+
const Helpers = __importStar(require("./helpers"));
|
|
64
|
+
exports.Helpers = Helpers;
|
|
65
|
+
const Json = __importStar(require("./json"));
|
|
66
|
+
exports.Json = Json;
|
|
67
|
+
const Normalized = __importStar(require("./normalized"));
|
|
68
|
+
exports.Normalized = Normalized;
|
|
69
|
+
__exportStar(require("./resourceDeclContainer"), exports);
|
|
70
|
+
__exportStar(require("./resourceDeclCollection"), exports);
|
|
71
|
+
__exportStar(require("./resourceDeclTree"), exports);
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/resource-json/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,mDAAqC;AAK5B,0BAAO;AAJhB,mDAAqC;AAInB,0BAAO;AAHzB,6CAA+B;AAGJ,oBAAI;AAF/B,yDAA2C;AAEV,gCAAU;AAE3C,0DAAwC;AACxC,2DAAyC;AACzC,qDAAmC","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';\nimport * as Helpers from './helpers';\nimport * as Json from './json';\nimport * as Normalized from './normalized';\n\nexport { Convert, Helpers, Json, Normalized };\n\nexport * from './resourceDeclContainer';\nexport * from './resourceDeclCollection';\nexport * from './resourceDeclTree';\n"]}
|