@fgv/ts-res-ui-components 5.0.0-10
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/.rush/temp/03c8b056281d9db0a97d8a6e25eea798a160d393.tar.log +271 -0
- package/.rush/temp/chunked-rush-logs/ts-res-ui-components.build.chunks.jsonl +9 -0
- package/.rush/temp/operation/build/all.log +9 -0
- package/.rush/temp/operation/build/log-chunks.jsonl +9 -0
- package/.rush/temp/operation/build/state.json +3 -0
- package/.rush/temp/shrinkwrap-deps.json +1111 -0
- package/README.md +18 -0
- package/REFACTORING_PLAN.md +171 -0
- package/config/jest.config.json +16 -0
- package/config/jest.setup.js +64 -0
- package/config/rig.json +16 -0
- package/lib/components/common/QualifierContextControl.d.ts +14 -0
- package/lib/components/common/QualifierContextControl.d.ts.map +1 -0
- package/lib/components/common/QualifierContextControl.js +78 -0
- package/lib/components/common/QualifierContextControl.js.map +1 -0
- package/lib/components/common/ResourceListView.d.ts +11 -0
- package/lib/components/common/ResourceListView.d.ts.map +1 -0
- package/lib/components/common/ResourceListView.js +20 -0
- package/lib/components/common/ResourceListView.js.map +1 -0
- package/lib/components/common/ResourceTreeView.d.ts +12 -0
- package/lib/components/common/ResourceTreeView.d.ts.map +1 -0
- package/lib/components/common/ResourceTreeView.js +162 -0
- package/lib/components/common/ResourceTreeView.js.map +1 -0
- package/lib/components/forms/HierarchyEditor.d.ts +10 -0
- package/lib/components/forms/HierarchyEditor.d.ts.map +1 -0
- package/lib/components/forms/HierarchyEditor.js +106 -0
- package/lib/components/forms/HierarchyEditor.js.map +1 -0
- package/lib/components/forms/QualifierEditForm.d.ts +11 -0
- package/lib/components/forms/QualifierEditForm.d.ts.map +1 -0
- package/lib/components/forms/QualifierEditForm.js +181 -0
- package/lib/components/forms/QualifierEditForm.js.map +1 -0
- package/lib/components/forms/QualifierTypeEditForm.d.ts +10 -0
- package/lib/components/forms/QualifierTypeEditForm.d.ts.map +1 -0
- package/lib/components/forms/QualifierTypeEditForm.js +172 -0
- package/lib/components/forms/QualifierTypeEditForm.js.map +1 -0
- package/lib/components/forms/ResourceTypeEditForm.d.ts +10 -0
- package/lib/components/forms/ResourceTypeEditForm.d.ts.map +1 -0
- package/lib/components/forms/ResourceTypeEditForm.js +188 -0
- package/lib/components/forms/ResourceTypeEditForm.js.map +1 -0
- package/lib/components/forms/index.d.ts +9 -0
- package/lib/components/forms/index.d.ts.map +1 -0
- package/lib/components/forms/index.js +5 -0
- package/lib/components/forms/index.js.map +1 -0
- package/lib/components/orchestrator/ResourceOrchestrator.d.ts +14 -0
- package/lib/components/orchestrator/ResourceOrchestrator.d.ts.map +1 -0
- package/lib/components/orchestrator/ResourceOrchestrator.js +278 -0
- package/lib/components/orchestrator/ResourceOrchestrator.js.map +1 -0
- package/lib/components/views/CompiledView/index.d.ts +5 -0
- package/lib/components/views/CompiledView/index.d.ts.map +1 -0
- package/lib/components/views/CompiledView/index.js +595 -0
- package/lib/components/views/CompiledView/index.js.map +1 -0
- package/lib/components/views/ConfigurationView/index.d.ts +5 -0
- package/lib/components/views/ConfigurationView/index.d.ts.map +1 -0
- package/lib/components/views/ConfigurationView/index.js +363 -0
- package/lib/components/views/ConfigurationView/index.js.map +1 -0
- package/lib/components/views/FilterView/index.d.ts +5 -0
- package/lib/components/views/FilterView/index.d.ts.map +1 -0
- package/lib/components/views/FilterView/index.js +463 -0
- package/lib/components/views/FilterView/index.js.map +1 -0
- package/lib/components/views/ImportView/index.d.ts +5 -0
- package/lib/components/views/ImportView/index.d.ts.map +1 -0
- package/lib/components/views/ImportView/index.js +514 -0
- package/lib/components/views/ImportView/index.js.map +1 -0
- package/lib/components/views/ResolutionView/EditableJsonView.d.ts +21 -0
- package/lib/components/views/ResolutionView/EditableJsonView.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/EditableJsonView.js +109 -0
- package/lib/components/views/ResolutionView/EditableJsonView.js.map +1 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.d.ts +19 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.js +82 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.js.map +1 -0
- package/lib/components/views/ResolutionView/index.d.ts +5 -0
- package/lib/components/views/ResolutionView/index.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/index.js +255 -0
- package/lib/components/views/ResolutionView/index.js.map +1 -0
- package/lib/components/views/SourceView/index.d.ts +5 -0
- package/lib/components/views/SourceView/index.d.ts.map +1 -0
- package/lib/components/views/SourceView/index.js +316 -0
- package/lib/components/views/SourceView/index.js.map +1 -0
- package/lib/components/views/ZipLoaderView/index.d.ts +5 -0
- package/lib/components/views/ZipLoaderView/index.d.ts.map +1 -0
- package/lib/components/views/ZipLoaderView/index.js +313 -0
- package/lib/components/views/ZipLoaderView/index.js.map +1 -0
- package/lib/hooks/useConfigurationState.d.ts +46 -0
- package/lib/hooks/useConfigurationState.d.ts.map +1 -0
- package/lib/hooks/useConfigurationState.js +239 -0
- package/lib/hooks/useConfigurationState.js.map +1 -0
- package/lib/hooks/useFilterState.d.ts +7 -0
- package/lib/hooks/useFilterState.d.ts.map +1 -0
- package/lib/hooks/useFilterState.js +80 -0
- package/lib/hooks/useFilterState.js.map +1 -0
- package/lib/hooks/useResolutionState.d.ts +8 -0
- package/lib/hooks/useResolutionState.d.ts.map +1 -0
- package/lib/hooks/useResolutionState.js +253 -0
- package/lib/hooks/useResolutionState.js.map +1 -0
- package/lib/hooks/useResourceData.d.ts +19 -0
- package/lib/hooks/useResourceData.d.ts.map +1 -0
- package/lib/hooks/useResourceData.js +368 -0
- package/lib/hooks/useResourceData.js.map +1 -0
- package/lib/hooks/useViewState.d.ts +10 -0
- package/lib/hooks/useViewState.d.ts.map +1 -0
- package/lib/hooks/useViewState.js +29 -0
- package/lib/hooks/useViewState.js.map +1 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +34 -0
- package/lib/index.js.map +1 -0
- package/lib/test/helpers/testDataLoader.d.ts +37 -0
- package/lib/test/helpers/testDataLoader.d.ts.map +1 -0
- package/lib/test/helpers/testDataLoader.js +171 -0
- package/lib/test/helpers/testDataLoader.js.map +1 -0
- package/lib/test/unit/utils/configurationUtils.test.d.ts +2 -0
- package/lib/test/unit/utils/configurationUtils.test.d.ts.map +1 -0
- package/lib/test/unit/utils/configurationUtils.test.js +497 -0
- package/lib/test/unit/utils/configurationUtils.test.js.map +1 -0
- package/lib/test/unit/utils/fileProcessing.test.d.ts +2 -0
- package/lib/test/unit/utils/fileProcessing.test.d.ts.map +1 -0
- package/lib/test/unit/utils/fileProcessing.test.js +321 -0
- package/lib/test/unit/utils/fileProcessing.test.js.map +1 -0
- package/lib/test/unit/utils/filterResources.test.d.ts +2 -0
- package/lib/test/unit/utils/filterResources.test.d.ts.map +1 -0
- package/lib/test/unit/utils/filterResources.test.js +403 -0
- package/lib/test/unit/utils/filterResources.test.js.map +1 -0
- package/lib/test/unit/utils/resolutionEditing.test.d.ts +2 -0
- package/lib/test/unit/utils/resolutionEditing.test.d.ts.map +1 -0
- package/lib/test/unit/utils/resolutionEditing.test.js +439 -0
- package/lib/test/unit/utils/resolutionEditing.test.js.map +1 -0
- package/lib/test/unit/utils/resolutionUtils.test.d.ts +2 -0
- package/lib/test/unit/utils/resolutionUtils.test.d.ts.map +1 -0
- package/lib/test/unit/utils/resolutionUtils.test.js +397 -0
- package/lib/test/unit/utils/resolutionUtils.test.js.map +1 -0
- package/lib/test/unit/utils/tsResIntegration.test.d.ts +2 -0
- package/lib/test/unit/utils/tsResIntegration.test.d.ts.map +1 -0
- package/lib/test/unit/utils/tsResIntegration.test.js +376 -0
- package/lib/test/unit/utils/tsResIntegration.test.js.map +1 -0
- package/lib/types/index.d.ts +251 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +2 -0
- package/lib/types/index.js.map +1 -0
- package/lib/utils/configurationUtils.d.ts +74 -0
- package/lib/utils/configurationUtils.d.ts.map +1 -0
- package/lib/utils/configurationUtils.js +359 -0
- package/lib/utils/configurationUtils.js.map +1 -0
- package/lib/utils/fileProcessing.d.ts +18 -0
- package/lib/utils/fileProcessing.d.ts.map +1 -0
- package/lib/utils/fileProcessing.js +142 -0
- package/lib/utils/fileProcessing.js.map +1 -0
- package/lib/utils/filterResources.d.ts +38 -0
- package/lib/utils/filterResources.d.ts.map +1 -0
- package/lib/utils/filterResources.js +153 -0
- package/lib/utils/filterResources.js.map +1 -0
- package/lib/utils/resolutionEditing.d.ts +58 -0
- package/lib/utils/resolutionEditing.d.ts.map +1 -0
- package/lib/utils/resolutionEditing.js +246 -0
- package/lib/utils/resolutionEditing.js.map +1 -0
- package/lib/utils/resolutionUtils.d.ts +28 -0
- package/lib/utils/resolutionUtils.d.ts.map +1 -0
- package/lib/utils/resolutionUtils.js +216 -0
- package/lib/utils/resolutionUtils.js.map +1 -0
- package/lib/utils/tsResIntegration.d.ts +71 -0
- package/lib/utils/tsResIntegration.d.ts.map +1 -0
- package/lib/utils/tsResIntegration.js +294 -0
- package/lib/utils/tsResIntegration.js.map +1 -0
- package/lib/utils/zipLoader/browserZipLoader.d.ts +48 -0
- package/lib/utils/zipLoader/browserZipLoader.d.ts.map +1 -0
- package/lib/utils/zipLoader/browserZipLoader.js +247 -0
- package/lib/utils/zipLoader/browserZipLoader.js.map +1 -0
- package/lib/utils/zipLoader/index.d.ts +8 -0
- package/lib/utils/zipLoader/index.d.ts.map +1 -0
- package/lib/utils/zipLoader/index.js +13 -0
- package/lib/utils/zipLoader/index.js.map +1 -0
- package/lib/utils/zipLoader/nodeZipBuilder.d.ts +55 -0
- package/lib/utils/zipLoader/nodeZipBuilder.d.ts.map +1 -0
- package/lib/utils/zipLoader/nodeZipBuilder.js +98 -0
- package/lib/utils/zipLoader/nodeZipBuilder.js.map +1 -0
- package/lib/utils/zipLoader/types.d.ts +139 -0
- package/lib/utils/zipLoader/types.d.ts.map +1 -0
- package/lib/utils/zipLoader/types.js +2 -0
- package/lib/utils/zipLoader/types.js.map +1 -0
- package/lib/utils/zipLoader/zipUtils.d.ts +53 -0
- package/lib/utils/zipLoader/zipUtils.d.ts.map +1 -0
- package/lib/utils/zipLoader/zipUtils.js +229 -0
- package/lib/utils/zipLoader/zipUtils.js.map +1 -0
- package/package.json +69 -0
- package/rush-logs/ts-res-ui-components.build.cache.log +3 -0
- package/rush-logs/ts-res-ui-components.build.log +9 -0
- package/src/components/common/QualifierContextControl.tsx +151 -0
- package/src/components/common/ResourceListView.tsx +63 -0
- package/src/components/common/ResourceTreeView.tsx +271 -0
- package/src/components/forms/HierarchyEditor.tsx +204 -0
- package/src/components/forms/QualifierEditForm.tsx +355 -0
- package/src/components/forms/QualifierTypeEditForm.tsx +347 -0
- package/src/components/forms/ResourceTypeEditForm.tsx +331 -0
- package/src/components/forms/index.ts +11 -0
- package/src/components/orchestrator/ResourceOrchestrator.tsx +372 -0
- package/src/components/views/CompiledView/index.tsx +922 -0
- package/src/components/views/ConfigurationView/index.tsx +800 -0
- package/src/components/views/FilterView/index.tsx +825 -0
- package/src/components/views/ImportView/index.tsx +717 -0
- package/src/components/views/ResolutionView/EditableJsonView.tsx +214 -0
- package/src/components/views/ResolutionView/ResolutionEditControls.tsx +170 -0
- package/src/components/views/ResolutionView/index.tsx +591 -0
- package/src/components/views/SourceView/index.tsx +536 -0
- package/src/components/views/ZipLoaderView/index.tsx +485 -0
- package/src/hooks/useConfigurationState.ts +374 -0
- package/src/hooks/useFilterState.ts +97 -0
- package/src/hooks/useResolutionState.ts +355 -0
- package/src/hooks/useResourceData.ts +467 -0
- package/src/hooks/useViewState.ts +44 -0
- package/src/index.ts +45 -0
- package/src/test/helpers/testDataLoader.ts +195 -0
- package/src/test/unit/utils/configurationUtils.test.ts +630 -0
- package/src/test/unit/utils/fileProcessing.test.ts +391 -0
- package/src/test/unit/utils/filterResources.test.ts +574 -0
- package/src/test/unit/utils/resolutionEditing.test.ts +556 -0
- package/src/test/unit/utils/resolutionUtils.test.ts +521 -0
- package/src/test/unit/utils/tsResIntegration.test.ts +433 -0
- package/src/types/index.ts +322 -0
- package/src/utils/configurationUtils.ts +424 -0
- package/src/utils/fileProcessing.ts +160 -0
- package/src/utils/filterResources.ts +206 -0
- package/src/utils/resolutionEditing.ts +319 -0
- package/src/utils/resolutionUtils.ts +289 -0
- package/src/utils/tsResIntegration.ts +440 -0
- package/src/utils/zipLoader/browserZipLoader.ts +319 -0
- package/src/utils/zipLoader/index.ts +26 -0
- package/src/utils/zipLoader/nodeZipBuilder.ts +153 -0
- package/src/utils/zipLoader/types.ts +175 -0
- package/src/utils/zipLoader/zipUtils.ts +266 -0
- package/temp/build/typescript/ts_gZid87Hu.json +1 -0
- package/tsconfig.json +15 -0
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,cAAc,SAAS,CAAC;AAExB,eAAe;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,sBAAsB;AACtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAEtF,eAAe;AACf,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E,2BAA2B;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAEtF,eAAe;AACf,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,mBAAmB;AACnB,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,OAAO,EACL,mCAAmC,EACnC,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAEjB,MAAM,yBAAyB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC","sourcesContent":["// Export types\nexport * from './types';\n\n// Export views\nexport { ImportView } from './components/views/ImportView';\nexport { SourceView } from './components/views/SourceView';\nexport { FilterView } from './components/views/FilterView';\nexport { CompiledView } from './components/views/CompiledView';\nexport { ResolutionView } from './components/views/ResolutionView';\nexport { ZipLoaderView } from './components/views/ZipLoaderView';\nexport { ConfigurationView } from './components/views/ConfigurationView';\n\n// Export orchestrator\nexport { ResourceOrchestrator } from './components/orchestrator/ResourceOrchestrator';\n\n// Export forms\nexport { QualifierTypeEditForm } from './components/forms/QualifierTypeEditForm';\nexport { QualifierEditForm } from './components/forms/QualifierEditForm';\nexport { ResourceTypeEditForm } from './components/forms/ResourceTypeEditForm';\n\n// Export common components\nexport { ResourceTreeView } from './components/common/ResourceTreeView';\nexport { ResourceListView } from './components/common/ResourceListView';\nexport { QualifierContextControl } from './components/common/QualifierContextControl';\n\n// Export hooks\nexport { useResourceData } from './hooks/useResourceData';\nexport { useFilterState } from './hooks/useFilterState';\nexport { useViewState } from './hooks/useViewState';\nexport { useResolutionState } from './hooks/useResolutionState';\nexport { useConfigurationState } from './hooks/useConfigurationState';\n\n// Export utilities\nexport * from './utils/tsResIntegration';\nexport * from './utils/fileProcessing';\nexport {\n createFilteredResourceManagerSimple,\n analyzeFilteredResources,\n hasFilterValues,\n getFilterSummary,\n type FilterOptions\n} from './utils/filterResources';\nexport * from './utils/resolutionUtils';\nexport * from './utils/zipLoader';\nexport * from './utils/configurationUtils';\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
import { Config } from '@fgv/ts-res';
|
|
3
|
+
/**
|
|
4
|
+
* Generate a unique temp folder name with timestamp and random suffix
|
|
5
|
+
*/
|
|
6
|
+
export declare function createUniqueTempPath(prefix?: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Load a test configuration file from the existing test data
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadTestConfiguration(testSet: 'default' | 'custom-config' | 'extended-example', filename?: string): Result<Config.Model.ISystemConfiguration>;
|
|
11
|
+
/**
|
|
12
|
+
* Load test resource files from a test set
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadTestResources(testSet: 'default' | 'custom-config' | 'extended-example'): Result<Array<{
|
|
15
|
+
path: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}>>;
|
|
18
|
+
/**
|
|
19
|
+
* Write test data to a temp file
|
|
20
|
+
*/
|
|
21
|
+
export declare function writeTempFile(tempDir: string, filename: string, content: string): Result<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Write test data structure to temp directory
|
|
24
|
+
*/
|
|
25
|
+
export declare function writeTempResourceFiles(tempDir: string, files: Array<{
|
|
26
|
+
path: string;
|
|
27
|
+
content: string;
|
|
28
|
+
}>): Result<string[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Load a test bundle file as buffer or text
|
|
31
|
+
*/
|
|
32
|
+
export declare function loadTestBundleFile(filename?: string, asBuffer?: boolean): Result<Buffer | string>;
|
|
33
|
+
/**
|
|
34
|
+
* Clean up temp directory (optional - temp folder is git-ignored)
|
|
35
|
+
*/
|
|
36
|
+
export declare function cleanupTempPath(tempPath: string): void;
|
|
37
|
+
//# sourceMappingURL=testDataLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testDataLoader.d.ts","sourceRoot":"","sources":["../../../src/test/helpers/testDataLoader.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,GAAE,MAAe,GAAG,MAAM,CAUpE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,GAAG,eAAe,GAAG,kBAAkB,EACzD,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAoB3C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,GAAG,eAAe,GAAG,kBAAkB,GACxD,MAAM,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAgClD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAehG;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9C,MAAM,CAAC,MAAM,EAAE,CAAC,CAgBlB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,GAAE,MAAwC,EAClD,QAAQ,GAAE,OAAe,GACxB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,CAczB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAStD"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
23
|
+
import { join, dirname } from 'path';
|
|
24
|
+
import { succeed, fail } from '@fgv/ts-utils';
|
|
25
|
+
/**
|
|
26
|
+
* Base path for test fixtures - using existing test data in monorepo
|
|
27
|
+
*/
|
|
28
|
+
const PROJECT_ROOT = dirname(dirname(dirname(__dirname)));
|
|
29
|
+
const FIXTURES_PATH = join(PROJECT_ROOT, '../../data/test/ts-res');
|
|
30
|
+
const TEMP_PATH = join(PROJECT_ROOT, 'temp');
|
|
31
|
+
/**
|
|
32
|
+
* Generate a unique temp folder name with timestamp and random suffix
|
|
33
|
+
*/
|
|
34
|
+
export function createUniqueTempPath(prefix = 'test') {
|
|
35
|
+
const timestamp = Date.now();
|
|
36
|
+
const random = Math.random().toString(36).substring(2, 8);
|
|
37
|
+
const uniqueName = `${prefix}-${timestamp}-${random}`;
|
|
38
|
+
const tempPath = join(TEMP_PATH, uniqueName);
|
|
39
|
+
// Create the temp directory
|
|
40
|
+
mkdirSync(tempPath, { recursive: true });
|
|
41
|
+
return tempPath;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Load a test configuration file from the existing test data
|
|
45
|
+
*/
|
|
46
|
+
export function loadTestConfiguration(testSet, filename) {
|
|
47
|
+
try {
|
|
48
|
+
let configPath;
|
|
49
|
+
if (testSet === 'default') {
|
|
50
|
+
configPath = join(FIXTURES_PATH, 'default', filename || 'default-config.json');
|
|
51
|
+
}
|
|
52
|
+
else if (testSet === 'custom-config') {
|
|
53
|
+
configPath = join(FIXTURES_PATH, 'custom-config', filename || 'resources-config.json');
|
|
54
|
+
}
|
|
55
|
+
else if (testSet === 'extended-example') {
|
|
56
|
+
configPath = join(FIXTURES_PATH, 'extended-example', filename || 'configuration.json');
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return fail(`Unknown test set: ${testSet}`);
|
|
60
|
+
}
|
|
61
|
+
const configData = readFileSync(configPath, 'utf8');
|
|
62
|
+
const config = JSON.parse(configData);
|
|
63
|
+
return succeed(config);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return fail(`Failed to load test configuration from ${testSet}/${filename}: ${error}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Load test resource files from a test set
|
|
71
|
+
*/
|
|
72
|
+
export function loadTestResources(testSet) {
|
|
73
|
+
try {
|
|
74
|
+
const resourcesPath = join(FIXTURES_PATH, testSet, 'resources');
|
|
75
|
+
const fs = require('fs');
|
|
76
|
+
if (!existsSync(resourcesPath)) {
|
|
77
|
+
return fail(`Test resource directory for ${testSet} does not exist`);
|
|
78
|
+
}
|
|
79
|
+
const files = [];
|
|
80
|
+
function readDirectory(dir, basePath = '') {
|
|
81
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
82
|
+
for (const entry of entries) {
|
|
83
|
+
const fullPath = join(dir, entry.name);
|
|
84
|
+
const relativePath = join(basePath, entry.name);
|
|
85
|
+
if (entry.isDirectory()) {
|
|
86
|
+
readDirectory(fullPath, relativePath);
|
|
87
|
+
}
|
|
88
|
+
else if (entry.isFile() && entry.name.endsWith('.json')) {
|
|
89
|
+
const content = readFileSync(fullPath, 'utf8');
|
|
90
|
+
files.push({ path: relativePath, content });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
readDirectory(resourcesPath);
|
|
95
|
+
return succeed(files);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return fail(`Failed to load test resources from ${testSet}: ${error}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Write test data to a temp file
|
|
103
|
+
*/
|
|
104
|
+
export function writeTempFile(tempDir, filename, content) {
|
|
105
|
+
try {
|
|
106
|
+
const filePath = join(tempDir, filename);
|
|
107
|
+
const fileDir = dirname(filePath);
|
|
108
|
+
// Ensure directory exists
|
|
109
|
+
if (!existsSync(fileDir)) {
|
|
110
|
+
mkdirSync(fileDir, { recursive: true });
|
|
111
|
+
}
|
|
112
|
+
writeFileSync(filePath, content, 'utf8');
|
|
113
|
+
return succeed(filePath);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
return fail(`Failed to write temp file ${filename}: ${error}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Write test data structure to temp directory
|
|
121
|
+
*/
|
|
122
|
+
export function writeTempResourceFiles(tempDir, files) {
|
|
123
|
+
try {
|
|
124
|
+
const writtenPaths = [];
|
|
125
|
+
for (const file of files) {
|
|
126
|
+
const result = writeTempFile(tempDir, file.path, file.content);
|
|
127
|
+
if (result.isFailure()) {
|
|
128
|
+
return fail(`Failed to write resource file ${file.path}: ${result.message}`);
|
|
129
|
+
}
|
|
130
|
+
writtenPaths.push(result.value);
|
|
131
|
+
}
|
|
132
|
+
return succeed(writtenPaths);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
return fail(`Failed to write temp resource files: ${error}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Load a test bundle file as buffer or text
|
|
140
|
+
*/
|
|
141
|
+
export function loadTestBundleFile(filename = 'extended.resource-bundle.json', asBuffer = false) {
|
|
142
|
+
try {
|
|
143
|
+
const bundlePath = join(FIXTURES_PATH, filename);
|
|
144
|
+
if (asBuffer) {
|
|
145
|
+
const buffer = readFileSync(bundlePath);
|
|
146
|
+
return succeed(buffer);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const text = readFileSync(bundlePath, 'utf8');
|
|
150
|
+
return succeed(text);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
return fail(`Failed to load test bundle file ${filename}: ${error}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Clean up temp directory (optional - temp folder is git-ignored)
|
|
159
|
+
*/
|
|
160
|
+
export function cleanupTempPath(tempPath) {
|
|
161
|
+
try {
|
|
162
|
+
const fs = require('fs');
|
|
163
|
+
if (existsSync(tempPath)) {
|
|
164
|
+
fs.rmSync(tempPath, { recursive: true, force: true });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
console.warn(`Warning: Failed to cleanup temp path ${tempPath}:`, error);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=testDataLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testDataLoader.js","sourceRoot":"","sources":["../../../src/test/helpers/testDataLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAU,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGtD;;GAEG;AACH,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1D,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAAC;AACnE,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAiB,MAAM;IAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,GAAG,MAAM,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;IACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAE7C,4BAA4B;IAC5B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kBAAkB,CAChC,WAAmB,+BAA+B,EAClD,WAAoB,KAAK;IAEzB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAEjD,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;YACxC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,CAAC,mCAAmC,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzB,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,wCAAwC,QAAQ,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3E,CAAC;AACH,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 { readFileSync, writeFileSync, mkdirSync, existsSync } from 'fs';\nimport { join, dirname } from 'path';\nimport { Result, succeed, fail } from '@fgv/ts-utils';\nimport { Config } from '@fgv/ts-res';\n\n/**\n * Base path for test fixtures - using existing test data in monorepo\n */\nconst PROJECT_ROOT = dirname(dirname(dirname(__dirname)));\nconst FIXTURES_PATH = join(PROJECT_ROOT, '../../data/test/ts-res');\nconst TEMP_PATH = join(PROJECT_ROOT, 'temp');\n\n/**\n * Generate a unique temp folder name with timestamp and random suffix\n */\nexport function createUniqueTempPath(prefix: string = 'test'): string {\n const timestamp = Date.now();\n const random = Math.random().toString(36).substring(2, 8);\n const uniqueName = `${prefix}-${timestamp}-${random}`;\n const tempPath = join(TEMP_PATH, uniqueName);\n\n // Create the temp directory\n mkdirSync(tempPath, { recursive: true });\n\n return tempPath;\n}\n\n/**\n * Load a test configuration file from the existing test data\n */\nexport function loadTestConfiguration(\n testSet: 'default' | 'custom-config' | 'extended-example',\n filename?: string\n): Result<Config.Model.ISystemConfiguration> {\n try {\n let configPath: string;\n\n if (testSet === 'default') {\n configPath = join(FIXTURES_PATH, 'default', filename || 'default-config.json');\n } else if (testSet === 'custom-config') {\n configPath = join(FIXTURES_PATH, 'custom-config', filename || 'resources-config.json');\n } else if (testSet === 'extended-example') {\n configPath = join(FIXTURES_PATH, 'extended-example', filename || 'configuration.json');\n } else {\n return fail(`Unknown test set: ${testSet}`);\n }\n\n const configData = readFileSync(configPath, 'utf8');\n const config = JSON.parse(configData) as Config.Model.ISystemConfiguration;\n return succeed(config);\n } catch (error) {\n return fail(`Failed to load test configuration from ${testSet}/${filename}: ${error}`);\n }\n}\n\n/**\n * Load test resource files from a test set\n */\nexport function loadTestResources(\n testSet: 'default' | 'custom-config' | 'extended-example'\n): Result<Array<{ path: string; content: string }>> {\n try {\n const resourcesPath = join(FIXTURES_PATH, testSet, 'resources');\n const fs = require('fs');\n\n if (!existsSync(resourcesPath)) {\n return fail(`Test resource directory for ${testSet} does not exist`);\n }\n\n const files: Array<{ path: string; content: string }> = [];\n\n function readDirectory(dir: string, basePath: string = '') {\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = join(dir, entry.name);\n const relativePath = join(basePath, entry.name);\n\n if (entry.isDirectory()) {\n readDirectory(fullPath, relativePath);\n } else if (entry.isFile() && entry.name.endsWith('.json')) {\n const content = readFileSync(fullPath, 'utf8');\n files.push({ path: relativePath, content });\n }\n }\n }\n\n readDirectory(resourcesPath);\n return succeed(files);\n } catch (error) {\n return fail(`Failed to load test resources from ${testSet}: ${error}`);\n }\n}\n\n/**\n * Write test data to a temp file\n */\nexport function writeTempFile(tempDir: string, filename: string, content: string): Result<string> {\n try {\n const filePath = join(tempDir, filename);\n const fileDir = dirname(filePath);\n\n // Ensure directory exists\n if (!existsSync(fileDir)) {\n mkdirSync(fileDir, { recursive: true });\n }\n\n writeFileSync(filePath, content, 'utf8');\n return succeed(filePath);\n } catch (error) {\n return fail(`Failed to write temp file ${filename}: ${error}`);\n }\n}\n\n/**\n * Write test data structure to temp directory\n */\nexport function writeTempResourceFiles(\n tempDir: string,\n files: Array<{ path: string; content: string }>\n): Result<string[]> {\n try {\n const writtenPaths: string[] = [];\n\n for (const file of files) {\n const result = writeTempFile(tempDir, file.path, file.content);\n if (result.isFailure()) {\n return fail(`Failed to write resource file ${file.path}: ${result.message}`);\n }\n writtenPaths.push(result.value);\n }\n\n return succeed(writtenPaths);\n } catch (error) {\n return fail(`Failed to write temp resource files: ${error}`);\n }\n}\n\n/**\n * Load a test bundle file as buffer or text\n */\nexport function loadTestBundleFile(\n filename: string = 'extended.resource-bundle.json',\n asBuffer: boolean = false\n): Result<Buffer | string> {\n try {\n const bundlePath = join(FIXTURES_PATH, filename);\n\n if (asBuffer) {\n const buffer = readFileSync(bundlePath);\n return succeed(buffer);\n } else {\n const text = readFileSync(bundlePath, 'utf8');\n return succeed(text);\n }\n } catch (error) {\n return fail(`Failed to load test bundle file ${filename}: ${error}`);\n }\n}\n\n/**\n * Clean up temp directory (optional - temp folder is git-ignored)\n */\nexport function cleanupTempPath(tempPath: string): void {\n try {\n const fs = require('fs');\n if (existsSync(tempPath)) {\n fs.rmSync(tempPath, { recursive: true, force: true });\n }\n } catch (error) {\n console.warn(`Warning: Failed to cleanup temp path ${tempPath}:`, error);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configurationUtils.test.d.ts","sourceRoot":"","sources":["../../../../src/test/unit/utils/configurationUtils.test.ts"],"names":[],"mappings":"AAsBA,OAAO,oBAAoB,CAAC"}
|