@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,49 @@
|
|
|
1
|
+
import { DetailedResult, Result } from '@fgv/ts-utils';
|
|
2
|
+
import { ResourceManager } from '../../resources';
|
|
3
|
+
import { IImportable } from '../importable';
|
|
4
|
+
import { IImporter, ImporterResultDetail } from './importer';
|
|
5
|
+
import { IReadOnlyQualifierCollector } from '../../qualifiers';
|
|
6
|
+
import { FsItem, FsItemResultDetail } from '../fsItem';
|
|
7
|
+
/**
|
|
8
|
+
* Parameters for creating a {@link Import.Importers.FsItemImporter | FsItemImporter}.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export interface IFsItemImporterCreateParams {
|
|
12
|
+
qualifiers: IReadOnlyQualifierCollector;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* {@link Import.Importers.IImporter | Importer} implementation which imports resources from a `FileTree`.
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare class FsItemImporter implements IImporter {
|
|
19
|
+
/**
|
|
20
|
+
* The {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector} to use for this importer.
|
|
21
|
+
*/
|
|
22
|
+
readonly qualifiers: IReadOnlyQualifierCollector;
|
|
23
|
+
/**
|
|
24
|
+
* The types of {@link Import.IImportable | importables} that this importer can handle.
|
|
25
|
+
*/
|
|
26
|
+
readonly types: ReadonlyArray<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Protected constructor for the {@link Import.Importers.FsItemImporter | FsItemImporter}.
|
|
29
|
+
* @param params - Parameters for creating the {@link Import.Importers.FsItemImporter | FsItemImporter}.
|
|
30
|
+
*/
|
|
31
|
+
protected constructor(params: IFsItemImporterCreateParams);
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new {@link Import.Importers.FsItemImporter | FsItemImporter}.
|
|
34
|
+
* @param params - Parameters for creating the {@link Import.Importers.FsItemImporter | FsItemImporter}.
|
|
35
|
+
* @returns `Success` with the new `FsItemImporter` if successful, `Failure` with an error message if not.
|
|
36
|
+
*/
|
|
37
|
+
static create(params: IFsItemImporterCreateParams): Result<FsItemImporter>;
|
|
38
|
+
/**
|
|
39
|
+
* {@inheritdoc Import.Importers.IImporter.import}
|
|
40
|
+
*/
|
|
41
|
+
import(item: IImportable, __manager: ResourceManager): DetailedResult<IImportable[], ImporterResultDetail>;
|
|
42
|
+
/**
|
|
43
|
+
* Gets an {@link Import.FsItem | FsItem} from an {@link Import.IImportable | importable}.
|
|
44
|
+
* @param item - The importable to convert.
|
|
45
|
+
* @returns `Success` containing the `FsItem` if successful, `Failure` with an error message if not.
|
|
46
|
+
*/
|
|
47
|
+
protected _getFileTreeItemFromImportable(item: IImportable): DetailedResult<FsItem, FsItemResultDetail>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=fsItemImporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsItemImporter.d.ts","sourceRoot":"","sources":["../../../../src/packlets/import/importers/fsItemImporter.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,cAAc,EAEd,MAAM,EAIP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAA+B,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,2BAA2B,CAAC;CACzC;AAED;;;GAGG;AACH,qBAAa,cAAe,YAAW,SAAS;IAC9C;;OAEG;IACH,SAAgB,UAAU,EAAE,2BAA2B,CAAC;IAExD;;OAEG;IACH,SAAgB,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAc;IAE1D;;;OAGG;IACH,SAAS,aAAa,MAAM,EAAE,2BAA2B;IAIzD;;;;OAIG;WACW,MAAM,CAAC,MAAM,EAAE,2BAA2B,GAAG,MAAM,CAAC,cAAc,CAAC;IAIjF;;OAEG;IACI,MAAM,CACX,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,eAAe,GACzB,cAAc,CAAC,WAAW,EAAE,EAAE,oBAAoB,CAAC;IAuDtD;;;;OAIG;IACH,SAAS,CAAC,8BAA8B,CAAC,IAAI,EAAE,WAAW,GAAG,cAAc,CAAC,MAAM,EAAE,kBAAkB,CAAC;CASxG"}
|
|
@@ -0,0 +1,120 @@
|
|
|
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.FsItemImporter = void 0;
|
|
25
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
26
|
+
const ts_json_base_1 = require("@fgv/ts-json-base");
|
|
27
|
+
const fsItem_1 = require("../fsItem");
|
|
28
|
+
/**
|
|
29
|
+
* {@link Import.Importers.IImporter | Importer} implementation which imports resources from a `FileTree`.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
class FsItemImporter {
|
|
33
|
+
/**
|
|
34
|
+
* Protected constructor for the {@link Import.Importers.FsItemImporter | FsItemImporter}.
|
|
35
|
+
* @param params - Parameters for creating the {@link Import.Importers.FsItemImporter | FsItemImporter}.
|
|
36
|
+
*/
|
|
37
|
+
constructor(params) {
|
|
38
|
+
/**
|
|
39
|
+
* The types of {@link Import.IImportable | importables} that this importer can handle.
|
|
40
|
+
*/
|
|
41
|
+
this.types = ['fsItem'];
|
|
42
|
+
this.qualifiers = params.qualifiers;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new {@link Import.Importers.FsItemImporter | FsItemImporter}.
|
|
46
|
+
* @param params - Parameters for creating the {@link Import.Importers.FsItemImporter | FsItemImporter}.
|
|
47
|
+
* @returns `Success` with the new `FsItemImporter` if successful, `Failure` with an error message if not.
|
|
48
|
+
*/
|
|
49
|
+
static create(params) {
|
|
50
|
+
return (0, ts_utils_1.captureResult)(() => new FsItemImporter(params));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* {@inheritdoc Import.Importers.IImporter.import}
|
|
54
|
+
*/
|
|
55
|
+
import(item, __manager) {
|
|
56
|
+
const { value: fsItem, message: getTreeMessage, detail: getTreeDetail } = this._getFileTreeItemFromImportable(item);
|
|
57
|
+
if (getTreeMessage !== undefined) {
|
|
58
|
+
return (0, ts_utils_1.failWithDetail)(getTreeMessage, getTreeDetail === 'skipped' ? 'skipped' : 'failed');
|
|
59
|
+
}
|
|
60
|
+
const { value: context, message: getContextMessage } = fsItem.getContext().onSuccess((fsItemContext) => {
|
|
61
|
+
return item.context ? item.context.extend(fsItemContext) : (0, ts_utils_1.succeed)(fsItemContext);
|
|
62
|
+
});
|
|
63
|
+
/* c8 ignore next 3 - defense in depth nearly impossible to reproduce */
|
|
64
|
+
if (getContextMessage) {
|
|
65
|
+
return (0, ts_utils_1.failWithDetail)(getContextMessage, 'failed');
|
|
66
|
+
}
|
|
67
|
+
if (fsItem.item.type === 'directory') {
|
|
68
|
+
return fsItem.item
|
|
69
|
+
.getChildren()
|
|
70
|
+
.onSuccess((children) => {
|
|
71
|
+
const errors = new ts_utils_1.MessageAggregator();
|
|
72
|
+
const items = [];
|
|
73
|
+
for (const child of children) {
|
|
74
|
+
const { value: item, message, detail } = fsItem_1.FsItem.createForItem(child, this.qualifiers);
|
|
75
|
+
if (item) {
|
|
76
|
+
items.push({ type: 'fsItem', item, context });
|
|
77
|
+
}
|
|
78
|
+
else if (detail !== 'skipped') {
|
|
79
|
+
errors.addMessage(message);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return errors.returnOrReport((0, ts_utils_1.succeed)(items));
|
|
83
|
+
})
|
|
84
|
+
.withDetail('failed', 'processed');
|
|
85
|
+
}
|
|
86
|
+
else if (fsItem.item.type === 'file') {
|
|
87
|
+
if (fsItem.item.extension === '.json') {
|
|
88
|
+
return fsItem.item
|
|
89
|
+
.getContents(ts_json_base_1.Converters.jsonValue)
|
|
90
|
+
.onSuccess((json) => {
|
|
91
|
+
const jsonItem = {
|
|
92
|
+
type: 'json',
|
|
93
|
+
json,
|
|
94
|
+
context
|
|
95
|
+
};
|
|
96
|
+
return (0, ts_utils_1.succeed)([jsonItem]);
|
|
97
|
+
})
|
|
98
|
+
.withDetail('failed', 'processed');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/* c8 ignore next 2 - defense in depth near impossible to reproduce */
|
|
102
|
+
return (0, ts_utils_1.succeedWithDetail)([], 'skipped');
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Gets an {@link Import.FsItem | FsItem} from an {@link Import.IImportable | importable}.
|
|
106
|
+
* @param item - The importable to convert.
|
|
107
|
+
* @returns `Success` containing the `FsItem` if successful, `Failure` with an error message if not.
|
|
108
|
+
*/
|
|
109
|
+
_getFileTreeItemFromImportable(item) {
|
|
110
|
+
if (item.type === 'fsItem') {
|
|
111
|
+
if ('item' in item && item.item instanceof fsItem_1.FsItem) {
|
|
112
|
+
return (0, ts_utils_1.succeedWithDetail)(item.item, 'succeeded');
|
|
113
|
+
}
|
|
114
|
+
return (0, ts_utils_1.failWithDetail)(`malformed fsItem importable does not contain a valid item`, 'failed');
|
|
115
|
+
}
|
|
116
|
+
return (0, ts_utils_1.failWithDetail)(`${item.type}: invalid importable type for an FsItemImporter`, 'skipped');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.FsItemImporter = FsItemImporter;
|
|
120
|
+
//# sourceMappingURL=fsItemImporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsItemImporter.js","sourceRoot":"","sources":["../../../../src/packlets/import/importers/fsItemImporter.ts"],"names":[],"mappings":"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","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 {\n captureResult,\n DetailedResult,\n failWithDetail,\n Result,\n succeed,\n succeedWithDetail,\n MessageAggregator\n} from '@fgv/ts-utils';\nimport { Converters as JsonConverters } from '@fgv/ts-json-base';\nimport { ResourceManager } from '../../resources';\nimport { IImportable, IImportableJson, Importable } from '../importable';\nimport { IImporter, ImporterResultDetail } from './importer';\nimport { IReadOnlyQualifierCollector } from '../../qualifiers';\nimport { FsItem, FsItemResultDetail } from '../fsItem';\n\n/**\n * Parameters for creating a {@link Import.Importers.FsItemImporter | FsItemImporter}.\n * @public\n */\nexport interface IFsItemImporterCreateParams {\n qualifiers: IReadOnlyQualifierCollector;\n}\n\n/**\n * {@link Import.Importers.IImporter | Importer} implementation which imports resources from a `FileTree`.\n * @public\n */\nexport class FsItemImporter implements IImporter {\n /**\n * The {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector} to use for this importer.\n */\n public readonly qualifiers: IReadOnlyQualifierCollector;\n\n /**\n * The types of {@link Import.IImportable | importables} that this importer can handle.\n */\n public readonly types: ReadonlyArray<string> = ['fsItem'];\n\n /**\n * Protected constructor for the {@link Import.Importers.FsItemImporter | FsItemImporter}.\n * @param params - Parameters for creating the {@link Import.Importers.FsItemImporter | FsItemImporter}.\n */\n protected constructor(params: IFsItemImporterCreateParams) {\n this.qualifiers = params.qualifiers;\n }\n\n /**\n * Creates a new {@link Import.Importers.FsItemImporter | FsItemImporter}.\n * @param params - Parameters for creating the {@link Import.Importers.FsItemImporter | FsItemImporter}.\n * @returns `Success` with the new `FsItemImporter` if successful, `Failure` with an error message if not.\n */\n public static create(params: IFsItemImporterCreateParams): Result<FsItemImporter> {\n return captureResult(() => new FsItemImporter(params));\n }\n\n /**\n * {@inheritdoc Import.Importers.IImporter.import}\n */\n public import(\n item: IImportable,\n __manager: ResourceManager\n ): DetailedResult<IImportable[], ImporterResultDetail> {\n const {\n value: fsItem,\n message: getTreeMessage,\n detail: getTreeDetail\n } = this._getFileTreeItemFromImportable(item);\n if (getTreeMessage !== undefined) {\n return failWithDetail(getTreeMessage, getTreeDetail === 'skipped' ? 'skipped' : 'failed');\n }\n\n const { value: context, message: getContextMessage } = fsItem.getContext().onSuccess((fsItemContext) => {\n return item.context ? item.context.extend(fsItemContext) : succeed(fsItemContext);\n });\n\n /* c8 ignore next 3 - defense in depth nearly impossible to reproduce */\n if (getContextMessage) {\n return failWithDetail(getContextMessage, 'failed');\n }\n\n if (fsItem.item.type === 'directory') {\n return fsItem.item\n .getChildren()\n .onSuccess((children) => {\n const errors = new MessageAggregator();\n const items: Importable[] = [];\n for (const child of children) {\n const { value: item, message, detail } = FsItem.createForItem(child, this.qualifiers);\n if (item) {\n items.push({ type: 'fsItem', item, context });\n } else if (detail !== 'skipped') {\n errors.addMessage(message);\n }\n }\n return errors.returnOrReport(succeed(items));\n })\n .withDetail('failed', 'processed');\n } else if (fsItem.item.type === 'file') {\n if (fsItem.item.extension === '.json') {\n return fsItem.item\n .getContents(JsonConverters.jsonValue)\n .onSuccess((json) => {\n const jsonItem: IImportableJson = {\n type: 'json',\n json,\n context\n };\n return succeed([jsonItem]);\n })\n .withDetail('failed', 'processed');\n }\n }\n /* c8 ignore next 2 - defense in depth near impossible to reproduce */\n return succeedWithDetail([], 'skipped');\n }\n\n /**\n * Gets an {@link Import.FsItem | FsItem} from an {@link Import.IImportable | importable}.\n * @param item - The importable to convert.\n * @returns `Success` containing the `FsItem` if successful, `Failure` with an error message if not.\n */\n protected _getFileTreeItemFromImportable(item: IImportable): DetailedResult<FsItem, FsItemResultDetail> {\n if (item.type === 'fsItem') {\n if ('item' in item && item.item instanceof FsItem) {\n return succeedWithDetail(item.item, 'succeeded');\n }\n return failWithDetail(`malformed fsItem importable does not contain a valid item`, 'failed');\n }\n return failWithDetail(`${item.type}: invalid importable type for an FsItemImporter`, 'skipped');\n }\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DetailedResult } from '@fgv/ts-utils';
|
|
2
|
+
import { IImportable } from '../importable';
|
|
3
|
+
import { ResourceManager } from '../../resources';
|
|
4
|
+
/**
|
|
5
|
+
* Possible results of an import operation.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export type ImporterResultDetail = 'consumed' | 'processed' | 'skipped' | 'failed';
|
|
9
|
+
/**
|
|
10
|
+
* Generic interface for an importer than accepts a typed
|
|
11
|
+
* {@link Import.IImportable | importable} item, extracts any resources
|
|
12
|
+
* or candidates from it, and returns an optional list of
|
|
13
|
+
* additional importable items derived from the original.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface IImporter {
|
|
17
|
+
/**
|
|
18
|
+
* The types of {@link Import.Importable | importable} items that this importer can process.
|
|
19
|
+
*/
|
|
20
|
+
readonly types: ReadonlyArray<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Imports an item, extracting any resources or candidates from it and returns an optional
|
|
23
|
+
* list of additional importable items derived from it.
|
|
24
|
+
* @param item - The {@link Import.IImportable | importable} item to import.
|
|
25
|
+
* @param manager - The {@link Resources.ResourceManager | resource manager} to use for the import.
|
|
26
|
+
* @returns `Success` with a list of additional importable items derived from the original, or
|
|
27
|
+
* `Failure` with an error message and a {@link Import.Importers.ImporterResultDetail | result detail}.
|
|
28
|
+
*/
|
|
29
|
+
import(item: IImportable, manager: ResourceManager): DetailedResult<IImportable[], ImporterResultDetail>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=importer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../../../../src/packlets/import/importers/importer.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEnF;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAEtC;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,GAAG,cAAc,CAAC,WAAW,EAAE,EAAE,oBAAoB,CAAC,CAAC;CAC1G"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
//# sourceMappingURL=importer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importer.js","sourceRoot":"","sources":["../../../../src/packlets/import/importers/importer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","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 { DetailedResult } from '@fgv/ts-utils';\nimport { IImportable } from '../importable';\nimport { ResourceManager } from '../../resources';\n\n/**\n * Possible results of an import operation.\n * @public\n */\nexport type ImporterResultDetail = 'consumed' | 'processed' | 'skipped' | 'failed';\n\n/**\n * Generic interface for an importer than accepts a typed\n * {@link Import.IImportable | importable} item, extracts any resources\n * or candidates from it, and returns an optional list of\n * additional importable items derived from the original.\n * @public\n */\nexport interface IImporter {\n /**\n * The types of {@link Import.Importable | importable} items that this importer can process.\n */\n readonly types: ReadonlyArray<string>;\n\n /**\n * Imports an item, extracting any resources or candidates from it and returns an optional\n * list of additional importable items derived from it.\n * @param item - The {@link Import.IImportable | importable} item to import.\n * @param manager - The {@link Resources.ResourceManager | resource manager} to use for the import.\n * @returns `Success` with a list of additional importable items derived from the original, or\n * `Failure` with an error message and a {@link Import.Importers.ImporterResultDetail | result detail}.\n */\n import(item: IImportable, manager: ResourceManager): DetailedResult<IImportable[], ImporterResultDetail>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/packlets/import/importers/index.ts"],"names":[],"mappings":"AAsBA,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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("./importer"), exports);
|
|
39
|
+
__exportStar(require("./collectionImporter"), exports);
|
|
40
|
+
__exportStar(require("./fsItemImporter"), exports);
|
|
41
|
+
__exportStar(require("./jsonImporter"), exports);
|
|
42
|
+
__exportStar(require("./pathImporter"), exports);
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/packlets/import/importers/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,uDAAqC;AACrC,mDAAiC;AACjC,iDAA+B;AAC/B,iDAA+B","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 './importer';\nexport * from './collectionImporter';\nexport * from './fsItemImporter';\nexport * from './jsonImporter';\nexport * from './pathImporter';\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DetailedResult, Result } from '@fgv/ts-utils';
|
|
2
|
+
import { IImporter, ImporterResultDetail } from './importer';
|
|
3
|
+
import { ResourceManager } from '../../resources';
|
|
4
|
+
import { IImportable } from '../importable';
|
|
5
|
+
/**
|
|
6
|
+
* {@link Import.Importers.IImporter | Importer} implementation which imports resources from a JSON object.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare class JsonImporter implements IImporter {
|
|
10
|
+
/**
|
|
11
|
+
* {@inheritdoc Import.Importers.IImporter.types}
|
|
12
|
+
*/
|
|
13
|
+
readonly types: ReadonlyArray<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Protected {@link Import.Importers.JsonImporter | JsonImporter} constructor for derived classes.
|
|
16
|
+
*/
|
|
17
|
+
protected constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new {@link Import.Importers.JsonImporter | JsonImporter} instance.
|
|
20
|
+
* @returns `Success` with the new {@link Import.Importers.JsonImporter | JsonImporter} if successful,
|
|
21
|
+
* `Failure` otherwise.
|
|
22
|
+
*/
|
|
23
|
+
static create(): Result<JsonImporter>;
|
|
24
|
+
/**
|
|
25
|
+
* {@inheritdoc Import.Importers.IImporter.import}
|
|
26
|
+
*/
|
|
27
|
+
import(item: IImportable, manager: ResourceManager): DetailedResult<IImportable[], ImporterResultDetail>;
|
|
28
|
+
private _tryImportResourceCollection;
|
|
29
|
+
private _tryImportResourceTree;
|
|
30
|
+
private _tryImportResource;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=jsonImporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonImporter.d.ts","sourceRoot":"","sources":["../../../../src/packlets/import/importers/jsonImporter.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAiB,cAAc,EAAkB,MAAM,EAAW,MAAM,eAAe,CAAC;AAE/F,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAA6C,MAAM,eAAe,CAAC;AAGvF;;;GAGG;AACH,qBAAa,YAAa,YAAW,SAAS;IAC5C;;OAEG;IACH,SAAgB,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAY;IAExD;;OAEG;IACH,SAAS;IAET;;;;OAIG;WACW,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC;IAI5C;;OAEG;IACI,MAAM,CACX,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,eAAe,GACvB,cAAc,CAAC,WAAW,EAAE,EAAE,oBAAoB,CAAC;IAWtD,OAAO,CAAC,4BAA4B;IAepC,OAAO,CAAC,sBAAsB;IAa9B,OAAO,CAAC,kBAAkB;CAkB3B"}
|
|
@@ -0,0 +1,140 @@
|
|
|
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.JsonImporter = void 0;
|
|
58
|
+
const ts_utils_1 = require("@fgv/ts-utils");
|
|
59
|
+
const ts_json_base_1 = require("@fgv/ts-json-base");
|
|
60
|
+
const importable_1 = require("../importable");
|
|
61
|
+
const ResourceJson = __importStar(require("../../resource-json"));
|
|
62
|
+
/**
|
|
63
|
+
* {@link Import.Importers.IImporter | Importer} implementation which imports resources from a JSON object.
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
class JsonImporter {
|
|
67
|
+
/**
|
|
68
|
+
* Protected {@link Import.Importers.JsonImporter | JsonImporter} constructor for derived classes.
|
|
69
|
+
*/
|
|
70
|
+
constructor() {
|
|
71
|
+
/**
|
|
72
|
+
* {@inheritdoc Import.Importers.IImporter.types}
|
|
73
|
+
*/
|
|
74
|
+
this.types = ['json'];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Creates a new {@link Import.Importers.JsonImporter | JsonImporter} instance.
|
|
78
|
+
* @returns `Success` with the new {@link Import.Importers.JsonImporter | JsonImporter} if successful,
|
|
79
|
+
* `Failure` otherwise.
|
|
80
|
+
*/
|
|
81
|
+
static create() {
|
|
82
|
+
return (0, ts_utils_1.captureResult)(() => new JsonImporter());
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* {@inheritdoc Import.Importers.IImporter.import}
|
|
86
|
+
*/
|
|
87
|
+
import(item, manager) {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
if (!(0, importable_1.isImportable)(item) || item.type !== 'json') {
|
|
90
|
+
/* c8 ignore next 1 - defense in depth */
|
|
91
|
+
const name = (_b = (_a = item.context) === null || _a === void 0 ? void 0 : _a.baseId) !== null && _b !== void 0 ? _b : 'unknown';
|
|
92
|
+
return (0, ts_utils_1.failWithDetail)(`${name}: not a valid JSON importable (${item.type})`, 'skipped');
|
|
93
|
+
}
|
|
94
|
+
return this._tryImportResourceCollection(item)
|
|
95
|
+
.onFailure(() => this._tryImportResourceTree(item))
|
|
96
|
+
.onFailure(() => this._tryImportResource(item, manager));
|
|
97
|
+
}
|
|
98
|
+
_tryImportResourceCollection(item) {
|
|
99
|
+
return ResourceJson.ResourceDeclCollection.create(item.json)
|
|
100
|
+
.onSuccess((collection) => {
|
|
101
|
+
const importable = {
|
|
102
|
+
type: 'resourceCollection',
|
|
103
|
+
collection,
|
|
104
|
+
context: item.context
|
|
105
|
+
};
|
|
106
|
+
return (0, ts_utils_1.succeed)([importable]);
|
|
107
|
+
})
|
|
108
|
+
.withDetail('skipped', 'consumed');
|
|
109
|
+
}
|
|
110
|
+
_tryImportResourceTree(item) {
|
|
111
|
+
return ResourceJson.ResourceDeclTree.create(item.json)
|
|
112
|
+
.onSuccess((tree) => {
|
|
113
|
+
const importable = {
|
|
114
|
+
type: 'resourceTree',
|
|
115
|
+
tree,
|
|
116
|
+
context: item.context
|
|
117
|
+
};
|
|
118
|
+
return (0, ts_utils_1.succeed)([importable]);
|
|
119
|
+
})
|
|
120
|
+
.withDetail('skipped', 'consumed');
|
|
121
|
+
}
|
|
122
|
+
_tryImportResource(item, manager) {
|
|
123
|
+
return ts_json_base_1.Converters.jsonObject
|
|
124
|
+
.convert(item.json)
|
|
125
|
+
.onSuccess((json) => {
|
|
126
|
+
var _a, _b, _c;
|
|
127
|
+
/* c8 ignore next 2 - defense in depth */
|
|
128
|
+
const id = (_b = (_a = item.context) === null || _a === void 0 ? void 0 : _a.baseId) !== null && _b !== void 0 ? _b : '';
|
|
129
|
+
const conditions = (_c = item.context) === null || _c === void 0 ? void 0 : _c.conditions;
|
|
130
|
+
const candidate = { id, conditions, json };
|
|
131
|
+
return manager.addLooseCandidate(candidate);
|
|
132
|
+
})
|
|
133
|
+
.onSuccess(() => {
|
|
134
|
+
return (0, ts_utils_1.succeed)([]);
|
|
135
|
+
})
|
|
136
|
+
.withDetail('failed', 'consumed');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.JsonImporter = JsonImporter;
|
|
140
|
+
//# sourceMappingURL=jsonImporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonImporter.js","sourceRoot":"","sources":["../../../../src/packlets/import/importers/jsonImporter.ts"],"names":[],"mappings":"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","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, DetailedResult, failWithDetail, Result, succeed } from '@fgv/ts-utils';\nimport { Converters as JsonConverters } from '@fgv/ts-json-base';\nimport { IImporter, ImporterResultDetail } from './importer';\nimport { ResourceManager } from '../../resources';\nimport { IImportable, IImportableJson, Importable, isImportable } from '../importable';\nimport * as ResourceJson from '../../resource-json';\n\n/**\n * {@link Import.Importers.IImporter | Importer} implementation which imports resources from a JSON object.\n * @public\n */\nexport class JsonImporter implements IImporter {\n /**\n * {@inheritdoc Import.Importers.IImporter.types}\n */\n public readonly types: ReadonlyArray<string> = ['json'];\n\n /**\n * Protected {@link Import.Importers.JsonImporter | JsonImporter} constructor for derived classes.\n */\n protected constructor() {}\n\n /**\n * Creates a new {@link Import.Importers.JsonImporter | JsonImporter} instance.\n * @returns `Success` with the new {@link Import.Importers.JsonImporter | JsonImporter} if successful,\n * `Failure` otherwise.\n */\n public static create(): Result<JsonImporter> {\n return captureResult(() => new JsonImporter());\n }\n\n /**\n * {@inheritdoc Import.Importers.IImporter.import}\n */\n public import(\n item: IImportable,\n manager: ResourceManager\n ): DetailedResult<IImportable[], ImporterResultDetail> {\n if (!isImportable(item) || item.type !== 'json') {\n /* c8 ignore next 1 - defense in depth */\n const name = item.context?.baseId ?? 'unknown';\n return failWithDetail(`${name}: not a valid JSON importable (${item.type})`, 'skipped');\n }\n return this._tryImportResourceCollection(item)\n .onFailure(() => this._tryImportResourceTree(item))\n .onFailure(() => this._tryImportResource(item, manager));\n }\n\n private _tryImportResourceCollection(\n item: IImportableJson\n ): DetailedResult<IImportable[], ImporterResultDetail> {\n return ResourceJson.ResourceDeclCollection.create(item.json)\n .onSuccess((collection) => {\n const importable: Importable = {\n type: 'resourceCollection',\n collection,\n context: item.context\n };\n return succeed([importable]);\n })\n .withDetail('skipped', 'consumed');\n }\n\n private _tryImportResourceTree(item: IImportableJson): DetailedResult<IImportable[], ImporterResultDetail> {\n return ResourceJson.ResourceDeclTree.create(item.json)\n .onSuccess((tree) => {\n const importable: Importable = {\n type: 'resourceTree',\n tree,\n context: item.context\n };\n return succeed([importable]);\n })\n .withDetail('skipped', 'consumed');\n }\n\n private _tryImportResource(\n item: IImportableJson,\n manager: ResourceManager\n ): DetailedResult<IImportable[], ImporterResultDetail> {\n return JsonConverters.jsonObject\n .convert(item.json)\n .onSuccess((json) => {\n /* c8 ignore next 2 - defense in depth */\n const id = item.context?.baseId ?? '';\n const conditions = item.context?.conditions;\n const candidate: ResourceJson.Json.ILooseResourceCandidateDecl = { id, conditions, json };\n return manager.addLooseCandidate(candidate);\n })\n .onSuccess(() => {\n return succeed([]);\n })\n .withDetail('failed', 'consumed');\n }\n}\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { DetailedResult, Result, FileTree } from '@fgv/ts-utils';
|
|
2
|
+
import { ResourceManager } from '../../resources';
|
|
3
|
+
import { IImportable } from '../importable';
|
|
4
|
+
import { IImporter, ImporterResultDetail } from './importer';
|
|
5
|
+
import { IReadOnlyQualifierCollector } from '../../qualifiers';
|
|
6
|
+
import { FsItem, FsItemResultDetail } from '../fsItem';
|
|
7
|
+
/**
|
|
8
|
+
* Parameters for creating a {@link Import.Importers.PathImporter | PathImporter}.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export interface IPathImporterCreateParams {
|
|
12
|
+
qualifiers: IReadOnlyQualifierCollector;
|
|
13
|
+
tree?: FileTree.FileTree;
|
|
14
|
+
ignoreFileTypes?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* {@link Import.Importers.IImporter | Importer} implementation which imports resources from a `FileTree`
|
|
18
|
+
* given a path.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare class PathImporter implements IImporter {
|
|
22
|
+
/**
|
|
23
|
+
* The {@link Qualifiers.IReadOnlyQualifierCollector | qualifier collector} to use for this importer.
|
|
24
|
+
*/
|
|
25
|
+
readonly qualifiers: IReadOnlyQualifierCollector;
|
|
26
|
+
/**
|
|
27
|
+
* The `FileTree` from which resources will be imported.
|
|
28
|
+
*/
|
|
29
|
+
readonly tree: FileTree.FileTree;
|
|
30
|
+
/**
|
|
31
|
+
* The types of {@link Import.IImportable | importables} that this importer can handle.
|
|
32
|
+
*/
|
|
33
|
+
readonly types: ReadonlyArray<string>;
|
|
34
|
+
/**
|
|
35
|
+
* The types of files to ignore when importing. Any file not ignored is converted
|
|
36
|
+
* to an {@link Import.IImportableFsItem | IImportableFsItem}.
|
|
37
|
+
*/
|
|
38
|
+
readonly ignoreFileTypes: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Protected constructor for the {@link Import.Importers.PathImporter | PathImporter}.
|
|
41
|
+
* @param params - Parameters for creating the {@link Import.Importers.PathImporter | PathImporter}.
|
|
42
|
+
*/
|
|
43
|
+
protected constructor(params: IPathImporterCreateParams);
|
|
44
|
+
/**
|
|
45
|
+
* Creates a new {@link Import.Importers.PathImporter | PathImporter}.
|
|
46
|
+
* @param params - Parameters for creating the {@link Import.Importers.PathImporter | dirPathImporter}.
|
|
47
|
+
* @returns `Success` with the new `PathImporter` if successful, `Failure` with an error message if not.
|
|
48
|
+
*/
|
|
49
|
+
static create(params: IPathImporterCreateParams): Result<PathImporter>;
|
|
50
|
+
/**
|
|
51
|
+
* {@inheritdoc Import.Importers.IImporter.import}
|
|
52
|
+
*/
|
|
53
|
+
import(item: IImportable, __manager: ResourceManager): DetailedResult<IImportable[], ImporterResultDetail>;
|
|
54
|
+
/**
|
|
55
|
+
* Gets an {@link Import.FsItem | FsItem} from an {@link Import.IImportable | importable}.
|
|
56
|
+
* @param item - The importable to convert.
|
|
57
|
+
* @returns `Success` containing the `FsItem` if successful, `Failure` with an error message if not.
|
|
58
|
+
*/
|
|
59
|
+
protected _getFileTreeItemFromImportable(item: IImportable): DetailedResult<FsItem, FsItemResultDetail>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=pathImporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathImporter.d.ts","sourceRoot":"","sources":["../../../../src/packlets/import/importers/pathImporter.ts"],"names":[],"mappings":"AAsBA,OAAO,EAEL,cAAc,EAEd,MAAM,EAEN,QAAQ,EACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,2BAA2B,CAAC;IACxC,IAAI,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;;;GAIG;AACH,qBAAa,YAAa,YAAW,SAAS;IAC5C;;OAEG;IACH,SAAgB,UAAU,EAAE,2BAA2B,CAAC;IAExD;;OAEG;IACH,SAAgB,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAExC;;OAEG;IACH,SAAgB,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAY;IAExD;;;OAGG;IACH,SAAgB,eAAe,EAAE,MAAM,EAAE,CAAC;IAE1C;;;OAGG;IACH,SAAS,aAAa,MAAM,EAAE,yBAAyB;IAMvD;;;;OAIG;WACW,MAAM,CAAC,MAAM,EAAE,yBAAyB,GAAG,MAAM,CAAC,YAAY,CAAC;IAI7E;;OAEG;IACI,MAAM,CACX,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,eAAe,GACzB,cAAc,CAAC,WAAW,EAAE,EAAE,oBAAoB,CAAC;IAqBtD;;;;OAIG;IACH,SAAS,CAAC,8BAA8B,CAAC,IAAI,EAAE,WAAW,GAAG,cAAc,CAAC,MAAM,EAAE,kBAAkB,CAAC;CASxG"}
|