@webiny/stdlib 0.0.1
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 +60 -0
- package/dist/LICENSE +21 -0
- package/dist/README.md +60 -0
- package/dist/browser/features/LocalStorageCache/LocalStorageCache.d.ts +26 -0
- package/dist/browser/features/LocalStorageCache/LocalStorageCache.d.ts.map +1 -0
- package/dist/browser/features/LocalStorageCache/LocalStorageCache.js +159 -0
- package/dist/browser/features/LocalStorageCache/LocalStorageCache.js.map +1 -0
- package/dist/browser/features/LocalStorageCache/errors.d.ts +26 -0
- package/dist/browser/features/LocalStorageCache/errors.d.ts.map +1 -0
- package/dist/browser/features/LocalStorageCache/errors.js +23 -0
- package/dist/browser/features/LocalStorageCache/errors.js.map +1 -0
- package/dist/browser/features/LocalStorageCache/feature.d.ts +6 -0
- package/dist/browser/features/LocalStorageCache/feature.d.ts.map +1 -0
- package/dist/browser/features/LocalStorageCache/feature.js +10 -0
- package/dist/browser/features/LocalStorageCache/feature.js.map +1 -0
- package/dist/browser/features/LocalStorageCache/index.d.ts +4 -0
- package/dist/browser/features/LocalStorageCache/index.d.ts.map +1 -0
- package/dist/browser/features/LocalStorageCache/index.js +4 -0
- package/dist/browser/features/LocalStorageCache/index.js.map +1 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/common/core/BaseError.d.ts +13 -0
- package/dist/common/core/BaseError.d.ts.map +1 -0
- package/dist/common/core/BaseError.js +8 -0
- package/dist/common/core/BaseError.js.map +1 -0
- package/dist/common/core/Result.d.ts +103 -0
- package/dist/common/core/Result.d.ts.map +1 -0
- package/dist/common/core/Result.js +127 -0
- package/dist/common/core/Result.js.map +1 -0
- package/dist/common/core/ResultAsync.d.ts +17 -0
- package/dist/common/core/ResultAsync.d.ts.map +1 -0
- package/dist/common/core/ResultAsync.js +62 -0
- package/dist/common/core/ResultAsync.js.map +1 -0
- package/dist/common/core/createAbstraction.d.ts +4 -0
- package/dist/common/core/createAbstraction.d.ts.map +1 -0
- package/dist/common/core/createAbstraction.js +5 -0
- package/dist/common/core/createAbstraction.js.map +1 -0
- package/dist/common/core/createFeature.d.ts +10 -0
- package/dist/common/core/createFeature.d.ts.map +1 -0
- package/dist/common/core/createFeature.js +9 -0
- package/dist/common/core/createFeature.js.map +1 -0
- package/dist/common/core/index.d.ts +7 -0
- package/dist/common/core/index.d.ts.map +1 -0
- package/dist/common/core/index.js +6 -0
- package/dist/common/core/index.js.map +1 -0
- package/dist/common/features/Cache/AsyncMemoryCache.d.ts +23 -0
- package/dist/common/features/Cache/AsyncMemoryCache.d.ts.map +1 -0
- package/dist/common/features/Cache/AsyncMemoryCache.js +90 -0
- package/dist/common/features/Cache/AsyncMemoryCache.js.map +1 -0
- package/dist/common/features/Cache/AsyncMemoryCacheFeature.d.ts +6 -0
- package/dist/common/features/Cache/AsyncMemoryCacheFeature.d.ts.map +1 -0
- package/dist/common/features/Cache/AsyncMemoryCacheFeature.js +10 -0
- package/dist/common/features/Cache/AsyncMemoryCacheFeature.js.map +1 -0
- package/dist/common/features/Cache/MemoryCache.d.ts +23 -0
- package/dist/common/features/Cache/MemoryCache.d.ts.map +1 -0
- package/dist/common/features/Cache/MemoryCache.js +75 -0
- package/dist/common/features/Cache/MemoryCache.js.map +1 -0
- package/dist/common/features/Cache/MemoryCacheFeature.d.ts +6 -0
- package/dist/common/features/Cache/MemoryCacheFeature.d.ts.map +1 -0
- package/dist/common/features/Cache/MemoryCacheFeature.js +10 -0
- package/dist/common/features/Cache/MemoryCacheFeature.js.map +1 -0
- package/dist/common/features/Cache/abstractions/AsyncCache.d.ts +39 -0
- package/dist/common/features/Cache/abstractions/AsyncCache.d.ts.map +1 -0
- package/dist/common/features/Cache/abstractions/AsyncCache.js +3 -0
- package/dist/common/features/Cache/abstractions/AsyncCache.js.map +1 -0
- package/dist/common/features/Cache/abstractions/Cache.d.ts +39 -0
- package/dist/common/features/Cache/abstractions/Cache.d.ts.map +1 -0
- package/dist/common/features/Cache/abstractions/Cache.js +3 -0
- package/dist/common/features/Cache/abstractions/Cache.js.map +1 -0
- package/dist/common/features/Cache/abstractions/CacheError.d.ts +5 -0
- package/dist/common/features/Cache/abstractions/CacheError.d.ts.map +1 -0
- package/dist/common/features/Cache/abstractions/CacheError.js +5 -0
- package/dist/common/features/Cache/abstractions/CacheError.js.map +1 -0
- package/dist/common/features/Cache/abstractions/index.d.ts +4 -0
- package/dist/common/features/Cache/abstractions/index.d.ts.map +1 -0
- package/dist/common/features/Cache/abstractions/index.js +4 -0
- package/dist/common/features/Cache/abstractions/index.js.map +1 -0
- package/dist/common/features/Cache/index.d.ts +8 -0
- package/dist/common/features/Cache/index.d.ts.map +1 -0
- package/dist/common/features/Cache/index.js +6 -0
- package/dist/common/features/Cache/index.js.map +1 -0
- package/dist/common/features/Logger/ConsoleLogger.d.ts +28 -0
- package/dist/common/features/Logger/ConsoleLogger.d.ts.map +1 -0
- package/dist/common/features/Logger/ConsoleLogger.js +84 -0
- package/dist/common/features/Logger/ConsoleLogger.js.map +1 -0
- package/dist/common/features/Logger/abstractions/ConsoleLoggerConfig.d.ts +27 -0
- package/dist/common/features/Logger/abstractions/ConsoleLoggerConfig.d.ts.map +1 -0
- package/dist/common/features/Logger/abstractions/ConsoleLoggerConfig.js +3 -0
- package/dist/common/features/Logger/abstractions/ConsoleLoggerConfig.js.map +1 -0
- package/dist/common/features/Logger/abstractions/Logger.d.ts +20 -0
- package/dist/common/features/Logger/abstractions/Logger.d.ts.map +1 -0
- package/dist/common/features/Logger/abstractions/Logger.js +3 -0
- package/dist/common/features/Logger/abstractions/Logger.js.map +1 -0
- package/dist/common/features/Logger/abstractions/index.d.ts +3 -0
- package/dist/common/features/Logger/abstractions/index.d.ts.map +1 -0
- package/dist/common/features/Logger/abstractions/index.js +3 -0
- package/dist/common/features/Logger/abstractions/index.js.map +1 -0
- package/dist/common/features/Logger/feature.d.ts +9 -0
- package/dist/common/features/Logger/feature.d.ts.map +1 -0
- package/dist/common/features/Logger/feature.js +13 -0
- package/dist/common/features/Logger/feature.js.map +1 -0
- package/dist/common/features/Logger/index.d.ts +5 -0
- package/dist/common/features/Logger/index.d.ts.map +1 -0
- package/dist/common/features/Logger/index.js +5 -0
- package/dist/common/features/Logger/index.js.map +1 -0
- package/dist/common/index.d.ts +11 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +9 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/utils/boolean.d.ts +7 -0
- package/dist/common/utils/boolean.d.ts.map +1 -0
- package/dist/common/utils/boolean.js +22 -0
- package/dist/common/utils/boolean.js.map +1 -0
- package/dist/common/utils/dotProp.d.ts +23 -0
- package/dist/common/utils/dotProp.d.ts.map +1 -0
- package/dist/common/utils/dotProp.js +45 -0
- package/dist/common/utils/dotProp.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/node/features/DirectoryTool/DirectoryTool.d.ts +24 -0
- package/dist/node/features/DirectoryTool/DirectoryTool.d.ts.map +1 -0
- package/dist/node/features/DirectoryTool/DirectoryTool.js +83 -0
- package/dist/node/features/DirectoryTool/DirectoryTool.js.map +1 -0
- package/dist/node/features/DirectoryTool/abstractions/DirectoryTool.d.ts +32 -0
- package/dist/node/features/DirectoryTool/abstractions/DirectoryTool.d.ts.map +1 -0
- package/dist/node/features/DirectoryTool/abstractions/DirectoryTool.js +3 -0
- package/dist/node/features/DirectoryTool/abstractions/DirectoryTool.js.map +1 -0
- package/dist/node/features/DirectoryTool/abstractions/index.d.ts +2 -0
- package/dist/node/features/DirectoryTool/abstractions/index.d.ts.map +1 -0
- package/dist/node/features/DirectoryTool/abstractions/index.js +2 -0
- package/dist/node/features/DirectoryTool/abstractions/index.js.map +1 -0
- package/dist/node/features/DirectoryTool/feature.d.ts +5 -0
- package/dist/node/features/DirectoryTool/feature.d.ts.map +1 -0
- package/dist/node/features/DirectoryTool/feature.js +9 -0
- package/dist/node/features/DirectoryTool/feature.js.map +1 -0
- package/dist/node/features/DirectoryTool/index.d.ts +4 -0
- package/dist/node/features/DirectoryTool/index.d.ts.map +1 -0
- package/dist/node/features/DirectoryTool/index.js +4 -0
- package/dist/node/features/DirectoryTool/index.js.map +1 -0
- package/dist/node/features/FileTool/FileTool.d.ts +26 -0
- package/dist/node/features/FileTool/FileTool.d.ts.map +1 -0
- package/dist/node/features/FileTool/FileTool.js +71 -0
- package/dist/node/features/FileTool/FileTool.js.map +1 -0
- package/dist/node/features/FileTool/abstractions/FileTool.d.ts +15 -0
- package/dist/node/features/FileTool/abstractions/FileTool.d.ts.map +1 -0
- package/dist/node/features/FileTool/abstractions/FileTool.js +3 -0
- package/dist/node/features/FileTool/abstractions/FileTool.js.map +1 -0
- package/dist/node/features/FileTool/abstractions/index.d.ts +2 -0
- package/dist/node/features/FileTool/abstractions/index.d.ts.map +1 -0
- package/dist/node/features/FileTool/abstractions/index.js +2 -0
- package/dist/node/features/FileTool/abstractions/index.js.map +1 -0
- package/dist/node/features/FileTool/feature.d.ts +5 -0
- package/dist/node/features/FileTool/feature.d.ts.map +1 -0
- package/dist/node/features/FileTool/feature.js +9 -0
- package/dist/node/features/FileTool/feature.js.map +1 -0
- package/dist/node/features/FileTool/index.d.ts +4 -0
- package/dist/node/features/FileTool/index.d.ts.map +1 -0
- package/dist/node/features/FileTool/index.js +4 -0
- package/dist/node/features/FileTool/index.js.map +1 -0
- package/dist/node/features/JsonFileTool/JsonFileTool.d.ts +19 -0
- package/dist/node/features/JsonFileTool/JsonFileTool.d.ts.map +1 -0
- package/dist/node/features/JsonFileTool/JsonFileTool.js +43 -0
- package/dist/node/features/JsonFileTool/JsonFileTool.js.map +1 -0
- package/dist/node/features/JsonFileTool/abstractions/JsonFileTool.d.ts +17 -0
- package/dist/node/features/JsonFileTool/abstractions/JsonFileTool.d.ts.map +1 -0
- package/dist/node/features/JsonFileTool/abstractions/JsonFileTool.js +3 -0
- package/dist/node/features/JsonFileTool/abstractions/JsonFileTool.js.map +1 -0
- package/dist/node/features/JsonFileTool/abstractions/index.d.ts +2 -0
- package/dist/node/features/JsonFileTool/abstractions/index.d.ts.map +1 -0
- package/dist/node/features/JsonFileTool/abstractions/index.js +2 -0
- package/dist/node/features/JsonFileTool/abstractions/index.js.map +1 -0
- package/dist/node/features/JsonFileTool/feature.d.ts +5 -0
- package/dist/node/features/JsonFileTool/feature.d.ts.map +1 -0
- package/dist/node/features/JsonFileTool/feature.js +9 -0
- package/dist/node/features/JsonFileTool/feature.js.map +1 -0
- package/dist/node/features/JsonFileTool/index.d.ts +4 -0
- package/dist/node/features/JsonFileTool/index.d.ts.map +1 -0
- package/dist/node/features/JsonFileTool/index.js +4 -0
- package/dist/node/features/JsonFileTool/index.js.map +1 -0
- package/dist/node/features/NdJsonReaderTool/LineAccumulator.d.ts +13 -0
- package/dist/node/features/NdJsonReaderTool/LineAccumulator.d.ts.map +1 -0
- package/dist/node/features/NdJsonReaderTool/LineAccumulator.js +68 -0
- package/dist/node/features/NdJsonReaderTool/LineAccumulator.js.map +1 -0
- package/dist/node/features/NdJsonReaderTool/NdJsonReaderTool.d.ts +22 -0
- package/dist/node/features/NdJsonReaderTool/NdJsonReaderTool.d.ts.map +1 -0
- package/dist/node/features/NdJsonReaderTool/NdJsonReaderTool.js +73 -0
- package/dist/node/features/NdJsonReaderTool/NdJsonReaderTool.js.map +1 -0
- package/dist/node/features/NdJsonReaderTool/abstractions/NdJsonReaderTool.d.ts +41 -0
- package/dist/node/features/NdJsonReaderTool/abstractions/NdJsonReaderTool.d.ts.map +1 -0
- package/dist/node/features/NdJsonReaderTool/abstractions/NdJsonReaderTool.js +3 -0
- package/dist/node/features/NdJsonReaderTool/abstractions/NdJsonReaderTool.js.map +1 -0
- package/dist/node/features/NdJsonReaderTool/abstractions/index.d.ts +2 -0
- package/dist/node/features/NdJsonReaderTool/abstractions/index.d.ts.map +1 -0
- package/dist/node/features/NdJsonReaderTool/abstractions/index.js +2 -0
- package/dist/node/features/NdJsonReaderTool/abstractions/index.js.map +1 -0
- package/dist/node/features/NdJsonReaderTool/feature.d.ts +5 -0
- package/dist/node/features/NdJsonReaderTool/feature.d.ts.map +1 -0
- package/dist/node/features/NdJsonReaderTool/feature.js +9 -0
- package/dist/node/features/NdJsonReaderTool/feature.js.map +1 -0
- package/dist/node/features/NdJsonReaderTool/index.d.ts +4 -0
- package/dist/node/features/NdJsonReaderTool/index.d.ts.map +1 -0
- package/dist/node/features/NdJsonReaderTool/index.js +4 -0
- package/dist/node/features/NdJsonReaderTool/index.js.map +1 -0
- package/dist/node/features/PackageJsonFileTool/PackageJsonFile.d.ts +67 -0
- package/dist/node/features/PackageJsonFileTool/PackageJsonFile.d.ts.map +1 -0
- package/dist/node/features/PackageJsonFileTool/PackageJsonFile.js +91 -0
- package/dist/node/features/PackageJsonFileTool/PackageJsonFile.js.map +1 -0
- package/dist/node/features/PackageJsonFileTool/PackageJsonFileTool.d.ts +23 -0
- package/dist/node/features/PackageJsonFileTool/PackageJsonFileTool.d.ts.map +1 -0
- package/dist/node/features/PackageJsonFileTool/PackageJsonFileTool.js +75 -0
- package/dist/node/features/PackageJsonFileTool/PackageJsonFileTool.js.map +1 -0
- package/dist/node/features/PackageJsonFileTool/abstractions/PackageJsonFileTool.d.ts +40 -0
- package/dist/node/features/PackageJsonFileTool/abstractions/PackageJsonFileTool.d.ts.map +1 -0
- package/dist/node/features/PackageJsonFileTool/abstractions/PackageJsonFileTool.js +3 -0
- package/dist/node/features/PackageJsonFileTool/abstractions/PackageJsonFileTool.js.map +1 -0
- package/dist/node/features/PackageJsonFileTool/abstractions/index.d.ts +2 -0
- package/dist/node/features/PackageJsonFileTool/abstractions/index.d.ts.map +1 -0
- package/dist/node/features/PackageJsonFileTool/abstractions/index.js +2 -0
- package/dist/node/features/PackageJsonFileTool/abstractions/index.js.map +1 -0
- package/dist/node/features/PackageJsonFileTool/feature.d.ts +5 -0
- package/dist/node/features/PackageJsonFileTool/feature.d.ts.map +1 -0
- package/dist/node/features/PackageJsonFileTool/feature.js +9 -0
- package/dist/node/features/PackageJsonFileTool/feature.js.map +1 -0
- package/dist/node/features/PackageJsonFileTool/index.d.ts +5 -0
- package/dist/node/features/PackageJsonFileTool/index.d.ts.map +1 -0
- package/dist/node/features/PackageJsonFileTool/index.js +5 -0
- package/dist/node/features/PackageJsonFileTool/index.js.map +1 -0
- package/dist/node/features/PathTool/PathTool.d.ts +14 -0
- package/dist/node/features/PathTool/PathTool.d.ts.map +1 -0
- package/dist/node/features/PathTool/PathTool.js +38 -0
- package/dist/node/features/PathTool/PathTool.js.map +1 -0
- package/dist/node/features/PathTool/abstractions/PathTool.d.ts +23 -0
- package/dist/node/features/PathTool/abstractions/PathTool.d.ts.map +1 -0
- package/dist/node/features/PathTool/abstractions/PathTool.js +3 -0
- package/dist/node/features/PathTool/abstractions/PathTool.js.map +1 -0
- package/dist/node/features/PathTool/abstractions/index.d.ts +2 -0
- package/dist/node/features/PathTool/abstractions/index.d.ts.map +1 -0
- package/dist/node/features/PathTool/abstractions/index.js +2 -0
- package/dist/node/features/PathTool/abstractions/index.js.map +1 -0
- package/dist/node/features/PathTool/errors.d.ts +12 -0
- package/dist/node/features/PathTool/errors.d.ts.map +1 -0
- package/dist/node/features/PathTool/errors.js +9 -0
- package/dist/node/features/PathTool/errors.js.map +1 -0
- package/dist/node/features/PathTool/feature.d.ts +5 -0
- package/dist/node/features/PathTool/feature.d.ts.map +1 -0
- package/dist/node/features/PathTool/feature.js +9 -0
- package/dist/node/features/PathTool/feature.js.map +1 -0
- package/dist/node/features/PathTool/index.d.ts +5 -0
- package/dist/node/features/PathTool/index.d.ts.map +1 -0
- package/dist/node/features/PathTool/index.js +5 -0
- package/dist/node/features/PathTool/index.js.map +1 -0
- package/dist/node/features/PinoLogger/PinoLogger.d.ts +27 -0
- package/dist/node/features/PinoLogger/PinoLogger.d.ts.map +1 -0
- package/dist/node/features/PinoLogger/PinoLogger.js +152 -0
- package/dist/node/features/PinoLogger/PinoLogger.js.map +1 -0
- package/dist/node/features/PinoLogger/abstractions/PinoLoggerConfig.d.ts +24 -0
- package/dist/node/features/PinoLogger/abstractions/PinoLoggerConfig.d.ts.map +1 -0
- package/dist/node/features/PinoLogger/abstractions/PinoLoggerConfig.js +3 -0
- package/dist/node/features/PinoLogger/abstractions/PinoLoggerConfig.js.map +1 -0
- package/dist/node/features/PinoLogger/abstractions/index.d.ts +2 -0
- package/dist/node/features/PinoLogger/abstractions/index.d.ts.map +1 -0
- package/dist/node/features/PinoLogger/abstractions/index.js +2 -0
- package/dist/node/features/PinoLogger/abstractions/index.js.map +1 -0
- package/dist/node/features/PinoLogger/feature.d.ts +9 -0
- package/dist/node/features/PinoLogger/feature.d.ts.map +1 -0
- package/dist/node/features/PinoLogger/feature.js +13 -0
- package/dist/node/features/PinoLogger/feature.js.map +1 -0
- package/dist/node/features/PinoLogger/index.d.ts +4 -0
- package/dist/node/features/PinoLogger/index.d.ts.map +1 -0
- package/dist/node/features/PinoLogger/index.js +4 -0
- package/dist/node/features/PinoLogger/index.js.map +1 -0
- package/dist/node/features/ReadStreamFactory/ReadStreamFactory.d.ts +11 -0
- package/dist/node/features/ReadStreamFactory/ReadStreamFactory.d.ts.map +1 -0
- package/dist/node/features/ReadStreamFactory/ReadStreamFactory.js +27 -0
- package/dist/node/features/ReadStreamFactory/ReadStreamFactory.js.map +1 -0
- package/dist/node/features/ReadStreamFactory/abstractions/ReadStreamFactory.d.ts +21 -0
- package/dist/node/features/ReadStreamFactory/abstractions/ReadStreamFactory.d.ts.map +1 -0
- package/dist/node/features/ReadStreamFactory/abstractions/ReadStreamFactory.js +3 -0
- package/dist/node/features/ReadStreamFactory/abstractions/ReadStreamFactory.js.map +1 -0
- package/dist/node/features/ReadStreamFactory/abstractions/index.d.ts +2 -0
- package/dist/node/features/ReadStreamFactory/abstractions/index.d.ts.map +1 -0
- package/dist/node/features/ReadStreamFactory/abstractions/index.js +2 -0
- package/dist/node/features/ReadStreamFactory/abstractions/index.js.map +1 -0
- package/dist/node/features/ReadStreamFactory/feature.d.ts +5 -0
- package/dist/node/features/ReadStreamFactory/feature.d.ts.map +1 -0
- package/dist/node/features/ReadStreamFactory/feature.js +9 -0
- package/dist/node/features/ReadStreamFactory/feature.js.map +1 -0
- package/dist/node/features/ReadStreamFactory/index.d.ts +4 -0
- package/dist/node/features/ReadStreamFactory/index.d.ts.map +1 -0
- package/dist/node/features/ReadStreamFactory/index.js +4 -0
- package/dist/node/features/ReadStreamFactory/index.js.map +1 -0
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +9 -0
- package/dist/node/index.js.map +1 -0
- package/dist/package.json +58 -0
- package/package.json +61 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Logger } from "../../../common/index.js";
|
|
2
|
+
export declare class LineAccumulator {
|
|
3
|
+
private readonly logger;
|
|
4
|
+
private pending;
|
|
5
|
+
constructor(logger: Logger.Interface);
|
|
6
|
+
feed(line: string): Record<string, unknown> | null;
|
|
7
|
+
/**
|
|
8
|
+
* Attempt a final parse of any buffered lines. Returns the record on success,
|
|
9
|
+
* logs a warning and returns null on failure.
|
|
10
|
+
*/
|
|
11
|
+
flush(): Record<string, unknown> | null;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=LineAccumulator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LineAccumulator.d.ts","sourceRoot":"","sources":["../../../../src/node/features/NdJsonReaderTool/LineAccumulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,qBAAa,eAAe;IAGL,OAAO,CAAC,QAAQ,CAAC,MAAM;IAF1C,OAAO,CAAC,OAAO,CAAgB;IAE/B,YAAoC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAI;IAEzD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CA8CxD;IAED;;;OAGG;IACI,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAc7C;CACJ"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Logger } from "../../../common/index.js";
|
|
2
|
+
export class LineAccumulator {
|
|
3
|
+
logger;
|
|
4
|
+
pending = [];
|
|
5
|
+
constructor(logger) {
|
|
6
|
+
this.logger = logger;
|
|
7
|
+
}
|
|
8
|
+
feed(line) {
|
|
9
|
+
if (this.pending.length === 0) {
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(line);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
this.logger.debug("Failed to parse line, accumulating");
|
|
15
|
+
this.pending.push(line);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const record = JSON.parse([...this.pending, line].join("\n"));
|
|
21
|
+
this.pending = [];
|
|
22
|
+
this.logger.debug("Newline-joined accumulation parsed successfully");
|
|
23
|
+
return record;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// try next strategy
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const record = JSON.parse([...this.pending, line].join(""));
|
|
30
|
+
this.pending = [];
|
|
31
|
+
this.logger.debug("Empty-string-joined accumulation parsed successfully");
|
|
32
|
+
return record;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// try next strategy
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const record = JSON.parse(line);
|
|
39
|
+
this.logger.warn(`Discarding ${this.pending.length} accumulated line(s) that could not form valid JSON`);
|
|
40
|
+
this.pending = [];
|
|
41
|
+
return record;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
this.logger.debug(`All strategies failed, continuing to accumulate (${this.pending.length + 1} lines pending)`);
|
|
45
|
+
this.pending.push(line);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Attempt a final parse of any buffered lines. Returns the record on success,
|
|
51
|
+
* logs a warning and returns null on failure.
|
|
52
|
+
*/
|
|
53
|
+
flush() {
|
|
54
|
+
if (this.pending.length === 0) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const combined = this.pending.join("\n");
|
|
58
|
+
this.pending = [];
|
|
59
|
+
try {
|
|
60
|
+
return JSON.parse(combined);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
this.logger.warn(`Discarding ${combined.split("\n").length} unfinished accumulated line(s) at end of input`);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=LineAccumulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LineAccumulator.js","sourceRoot":"","sources":["../../../../src/node/features/NdJsonReaderTool/LineAccumulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,OAAO,eAAe;IAGY,MAAM;IAFlC,OAAO,GAAa,EAAE,CAAC;IAE/B,YAAoC,MAAwB;sBAAxB,MAAM;IAAqB,CAAC;IAEzD,IAAI,CAAC,IAAY;QACpB,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;YACvD,CAAC;YAAC,MAAM,CAAC;gBACL,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;gBACxD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACxB,OAAO,IAAI,CAAC;YAChB,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CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC;YACD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAA4B,CAAC;QAC3D,CAAC;QAAC,MAAM,CAAC;YACL,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ,cAAc,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,iDAAiD,CAC7F,CAAC;YACF,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Readable } from "node:stream";
|
|
2
|
+
import { Logger } from "../../../common/index.js";
|
|
3
|
+
import { NdJsonReaderTool as NdJsonReaderToolAbstraction, type NdJsonRow, type NdJsonReaderOptions } from "./abstractions/NdJsonReaderTool.js";
|
|
4
|
+
import { ReadStreamFactory } from "../ReadStreamFactory/abstractions/ReadStreamFactory.js";
|
|
5
|
+
declare class NdJsonReaderToolImpl implements NdJsonReaderToolAbstraction.Interface {
|
|
6
|
+
private readonly logger;
|
|
7
|
+
private readonly readStreamFactory;
|
|
8
|
+
constructor(logger: Logger.Interface, readStreamFactory: ReadStreamFactory.Interface);
|
|
9
|
+
parseFile(path: string, options?: NdJsonReaderOptions): AsyncGenerator<NdJsonRow>;
|
|
10
|
+
parseStream(stream: Readable, options?: NdJsonReaderOptions): AsyncGenerator<NdJsonRow>;
|
|
11
|
+
parseLines(lines: Iterable<string>, options?: NdJsonReaderOptions): Generator<NdJsonRow>;
|
|
12
|
+
}
|
|
13
|
+
export declare const NdJsonReaderTool: typeof NdJsonReaderToolImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions/NdJsonReaderTool.js").INdJsonReaderTool>;
|
|
15
|
+
};
|
|
16
|
+
export interface CreateNdJsonReaderToolParams {
|
|
17
|
+
logger?: Logger.Interface;
|
|
18
|
+
readStreamFactory?: ReadStreamFactory.Interface;
|
|
19
|
+
}
|
|
20
|
+
export declare function createNdJsonReaderTool(params?: CreateNdJsonReaderToolParams): NdJsonReaderToolAbstraction.Interface;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=NdJsonReaderTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NdJsonReaderTool.d.ts","sourceRoot":"","sources":["../../../../src/node/features/NdJsonReaderTool/NdJsonReaderTool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAiB,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACH,gBAAgB,IAAI,2BAA2B,EAC/C,KAAK,SAAS,EACd,KAAK,mBAAmB,EAC3B,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAG3F,cAAM,oBAAqB,YAAW,2BAA2B,CAAC,SAAS;IAEnE,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAFtC,YACqB,MAAM,EAAE,MAAM,CAAC,SAAS,EACxB,iBAAiB,EAAE,iBAAiB,CAAC,SAAS,EAC/D;IAEU,SAAS,CACnB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,mBAAmB,GAC9B,cAAc,CAAC,SAAS,CAAC,CAG3B;IAEa,WAAW,CACrB,MAAM,EAAE,QAAQ,EAChB,OAAO,CAAC,EAAE,mBAAmB,GAC9B,cAAc,CAAC,SAAS,CAAC,CAwB3B;IAEO,UAAU,CACd,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EACvB,OAAO,CAAC,EAAE,mBAAmB,GAC9B,SAAS,CAAC,SAAS,CAAC,CAuBtB;CACJ;AAED,eAAO,MAAM,gBAAgB;;CAG3B,CAAC;AAEH,MAAM,WAAW,4BAA4B;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC;IAC1B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC;CACnD;AAED,wBAAgB,sBAAsB,CAClC,MAAM,CAAC,EAAE,4BAA4B,GACtC,2BAA2B,CAAC,SAAS,CAIvC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createInterface } from "node:readline";
|
|
2
|
+
import { Logger, ConsoleLogger } from "../../../common/index.js";
|
|
3
|
+
import { NdJsonReaderTool as NdJsonReaderToolAbstraction } from "./abstractions/NdJsonReaderTool.js";
|
|
4
|
+
import { LineAccumulator } from "./LineAccumulator.js";
|
|
5
|
+
import { ReadStreamFactory } from "../ReadStreamFactory/abstractions/ReadStreamFactory.js";
|
|
6
|
+
import { createReadStreamFactory } from "../ReadStreamFactory/ReadStreamFactory.js";
|
|
7
|
+
class NdJsonReaderToolImpl {
|
|
8
|
+
logger;
|
|
9
|
+
readStreamFactory;
|
|
10
|
+
constructor(logger, readStreamFactory) {
|
|
11
|
+
this.logger = logger;
|
|
12
|
+
this.readStreamFactory = readStreamFactory;
|
|
13
|
+
}
|
|
14
|
+
async *parseFile(path, options) {
|
|
15
|
+
await using rs = this.readStreamFactory.create(path);
|
|
16
|
+
yield* this.parseStream(rs.getStream(), options);
|
|
17
|
+
}
|
|
18
|
+
async *parseStream(stream, options) {
|
|
19
|
+
const rl = createInterface({ input: stream, crlfDelay: Infinity });
|
|
20
|
+
const accumulator = new LineAccumulator(this.logger);
|
|
21
|
+
const fromLine = options?.fromLine ?? 1;
|
|
22
|
+
let lineNumber = 0;
|
|
23
|
+
for await (const line of rl) {
|
|
24
|
+
lineNumber++;
|
|
25
|
+
if (lineNumber < fromLine) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (line.trim().length === 0) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const record = accumulator.feed(line);
|
|
32
|
+
if (record !== null) {
|
|
33
|
+
yield { data: record, line: lineNumber };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const flushed = accumulator.flush();
|
|
37
|
+
if (flushed !== null) {
|
|
38
|
+
yield { data: flushed, line: lineNumber };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
*parseLines(lines, options) {
|
|
42
|
+
const accumulator = new LineAccumulator(this.logger);
|
|
43
|
+
const fromLine = options?.fromLine ?? 1;
|
|
44
|
+
let lineNumber = 0;
|
|
45
|
+
for (const line of lines) {
|
|
46
|
+
lineNumber++;
|
|
47
|
+
if (lineNumber < fromLine) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (line.trim().length === 0) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const record = accumulator.feed(line);
|
|
54
|
+
if (record !== null) {
|
|
55
|
+
yield { data: record, line: lineNumber };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const flushed = accumulator.flush();
|
|
59
|
+
if (flushed !== null) {
|
|
60
|
+
yield { data: flushed, line: lineNumber };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export const NdJsonReaderTool = NdJsonReaderToolAbstraction.createImplementation({
|
|
65
|
+
implementation: NdJsonReaderToolImpl,
|
|
66
|
+
dependencies: [Logger, ReadStreamFactory]
|
|
67
|
+
});
|
|
68
|
+
export function createNdJsonReaderTool(params) {
|
|
69
|
+
const logger = params?.logger ?? new ConsoleLogger();
|
|
70
|
+
const readStreamFactory = params?.readStreamFactory ?? createReadStreamFactory();
|
|
71
|
+
return new NdJsonReaderToolImpl(logger, readStreamFactory);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=NdJsonReaderTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NdJsonReaderTool.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C;QACpC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACnB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAC9C,CAAC;IACL,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC,oBAAoB,CAAC;IAC7E,cAAc,EAAE,oBAAoB;IACpC,YAAY,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC;CAC5C,CAAC,CAAC;AAOH,MAAM,UAAU,sBAAsB,CAClC,MAAqC;IAErC,MAAM,MAAM,GAAG,MAAM,EAAE,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;IACrD,MAAM,iBAAiB,GAAG,MAAM,EAAE,iBAAiB,IAAI,uBAAuB,EAAE,CAAC;IACjF,OAAO,IAAI,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Readable } from "node:stream";
|
|
2
|
+
export interface NdJsonRow {
|
|
3
|
+
/** The parsed JSON record. */
|
|
4
|
+
data: Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* 1-based physical line number where this record was completed.
|
|
7
|
+
* Pass `line + 1` as `fromLine` to resume reading after this record.
|
|
8
|
+
*/
|
|
9
|
+
line: number;
|
|
10
|
+
}
|
|
11
|
+
export interface NdJsonReaderOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Skip all physical lines before this 1-based line number.
|
|
14
|
+
* Use the `line` value from the last yielded row plus one to resume a previous run.
|
|
15
|
+
*/
|
|
16
|
+
fromLine?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface INdJsonReaderTool {
|
|
19
|
+
/**
|
|
20
|
+
* Yield parsed records from an NDJSON file.
|
|
21
|
+
* Handles multi-line JSON values via line accumulation.
|
|
22
|
+
*/
|
|
23
|
+
parseFile(path: string, options?: NdJsonReaderOptions): AsyncGenerator<NdJsonRow>;
|
|
24
|
+
/**
|
|
25
|
+
* Yield parsed records from a Readable stream of NDJSON data.
|
|
26
|
+
* Handles multi-line JSON values via line accumulation.
|
|
27
|
+
*/
|
|
28
|
+
parseStream(stream: Readable, options?: NdJsonReaderOptions): AsyncGenerator<NdJsonRow>;
|
|
29
|
+
/**
|
|
30
|
+
* Yield parsed records from an iterable of NDJSON lines.
|
|
31
|
+
* Synchronous; useful for in-memory parsing and testing.
|
|
32
|
+
*/
|
|
33
|
+
parseLines(lines: Iterable<string>, options?: NdJsonReaderOptions): Generator<NdJsonRow>;
|
|
34
|
+
}
|
|
35
|
+
export declare const NdJsonReaderTool: import("@webiny/di").Abstraction<INdJsonReaderTool>;
|
|
36
|
+
export declare namespace NdJsonReaderTool {
|
|
37
|
+
type Interface = INdJsonReaderTool;
|
|
38
|
+
type Row = NdJsonRow;
|
|
39
|
+
type Options = NdJsonReaderOptions;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=NdJsonReaderTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NdJsonReaderTool.d.ts","sourceRoot":"","sources":["../../../../../src/node/features/NdJsonReaderTool/abstractions/NdJsonReaderTool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,SAAS;IACtB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAC9B;;;OAGG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAElF;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAExF;;;OAGG;IACH,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;CAC5F;AAED,eAAO,MAAM,gBAAgB,qDAAgE,CAAC;AAE9F,yBAAiB,gBAAgB,CAAC;IAC9B,KAAY,SAAS,GAAG,iBAAiB,CAAC;IAC1C,KAAY,GAAG,GAAG,SAAS,CAAC;IAC5B,KAAY,OAAO,GAAG,mBAAmB,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NdJsonReaderTool.js","sourceRoot":"","sources":["../../../../../src/node/features/NdJsonReaderTool/abstractions/NdJsonReaderTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAyCtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAoB,uBAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/node/features/NdJsonReaderTool/abstractions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,SAAS,EAAE,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/node/features/NdJsonReaderTool/abstractions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA4C,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../../../src/node/features/NdJsonReaderTool/feature.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB;;;CAKlC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createFeature } from "../../../common/index.js";
|
|
2
|
+
import { NdJsonReaderTool } from "./NdJsonReaderTool.js";
|
|
3
|
+
export const NdJsonReaderToolFeature = createFeature({
|
|
4
|
+
name: "Node/NdJsonReaderToolFeature",
|
|
5
|
+
register(container) {
|
|
6
|
+
container.register(NdJsonReaderTool).inSingletonScope();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature.js","sourceRoot":"","sources":["../../../../src/node/features/NdJsonReaderTool/feature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAC;IACjD,IAAI,EAAE,8BAA8B;IACpC,QAAQ,CAAC,SAAS;QACd,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC5D,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { NdJsonReaderTool, type NdJsonRow, type NdJsonReaderOptions } from "./abstractions/index.js";
|
|
2
|
+
export { NdJsonReaderToolFeature } from "./feature.js";
|
|
3
|
+
export { createNdJsonReaderTool, type CreateNdJsonReaderToolParams } from "./NdJsonReaderTool.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/features/NdJsonReaderTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,mBAAmB,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,KAAK,4BAA4B,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/node/features/NdJsonReaderTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAGnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAqC,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { PackageJson } from "type-fest";
|
|
2
|
+
export interface IPackageJsonFile {
|
|
3
|
+
/** Absolute path to the file on disk. */
|
|
4
|
+
readonly path: string;
|
|
5
|
+
/** The underlying parsed data. Mutated in place by the setter methods. */
|
|
6
|
+
readonly raw: PackageJson;
|
|
7
|
+
/** Returns a shallow copy of `dependencies`, or `{}` if absent. */
|
|
8
|
+
getDependencies(): Record<string, string>;
|
|
9
|
+
/** Returns the version string for `name`, or null if absent. */
|
|
10
|
+
getDependency(name: string): string | null;
|
|
11
|
+
setDependency(name: string, version: string): void;
|
|
12
|
+
removeDependency(name: string): void;
|
|
13
|
+
/** Returns a shallow copy of `devDependencies`, or `{}` if absent. */
|
|
14
|
+
getDevDependencies(): Record<string, string>;
|
|
15
|
+
getDevDependency(name: string): string | null;
|
|
16
|
+
setDevDependency(name: string, version: string): void;
|
|
17
|
+
removeDevDependency(name: string): void;
|
|
18
|
+
/** Returns a shallow copy of `peerDependencies`, or `{}` if absent. */
|
|
19
|
+
getPeerDependencies(): Record<string, string>;
|
|
20
|
+
getPeerDependency(name: string): string | null;
|
|
21
|
+
setPeerDependency(name: string, version: string): void;
|
|
22
|
+
removePeerDependency(name: string): void;
|
|
23
|
+
/** Returns a shallow copy of `resolutions` (Yarn), or `{}` if absent. */
|
|
24
|
+
getResolutions(): Record<string, string>;
|
|
25
|
+
getResolution(name: string): string | null;
|
|
26
|
+
setResolution(name: string, version: string): void;
|
|
27
|
+
removeResolution(name: string): void;
|
|
28
|
+
/** Returns `version`, or null if absent. */
|
|
29
|
+
getVersion(): string | null;
|
|
30
|
+
/** Returns the value at `key`, or null if absent. */
|
|
31
|
+
get(key: string): unknown;
|
|
32
|
+
/** Sets an arbitrary top-level field. */
|
|
33
|
+
set(key: string, value: unknown): void;
|
|
34
|
+
}
|
|
35
|
+
export declare class PackageJsonFile implements IPackageJsonFile {
|
|
36
|
+
readonly path: string;
|
|
37
|
+
readonly raw: PackageJson;
|
|
38
|
+
constructor(path: string, raw: PackageJson);
|
|
39
|
+
private section;
|
|
40
|
+
private ensureSection;
|
|
41
|
+
private getEntry;
|
|
42
|
+
private setEntry;
|
|
43
|
+
private removeEntry;
|
|
44
|
+
getDependencies(): Record<string, string>;
|
|
45
|
+
getDependency(name: string): string | null;
|
|
46
|
+
setDependency(name: string, version: string): void;
|
|
47
|
+
removeDependency(name: string): void;
|
|
48
|
+
getDevDependencies(): Record<string, string>;
|
|
49
|
+
getDevDependency(name: string): string | null;
|
|
50
|
+
setDevDependency(name: string, version: string): void;
|
|
51
|
+
removeDevDependency(name: string): void;
|
|
52
|
+
getPeerDependencies(): Record<string, string>;
|
|
53
|
+
getPeerDependency(name: string): string | null;
|
|
54
|
+
setPeerDependency(name: string, version: string): void;
|
|
55
|
+
removePeerDependency(name: string): void;
|
|
56
|
+
getResolutions(): Record<string, string>;
|
|
57
|
+
getResolution(name: string): string | null;
|
|
58
|
+
setResolution(name: string, version: string): void;
|
|
59
|
+
removeResolution(name: string): void;
|
|
60
|
+
getVersion(): string | null;
|
|
61
|
+
get(key: string): unknown;
|
|
62
|
+
set(key: string, value: unknown): void;
|
|
63
|
+
}
|
|
64
|
+
export declare namespace PackageJsonFile {
|
|
65
|
+
type Interface = IPackageJsonFile;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=PackageJsonFile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3D;IAEM,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE7C;IAIM,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEnD;IAEM,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEpD;IAEM,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAE5D;IAEM,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE9C;IAIM,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE9C;IAEM,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEhD;IAEM,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAExD;IAEM,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE1C;IAIM,UAAU,IAAI,MAAM,GAAG,IAAI,CAEjC;IAEM,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE/B;IAEM,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAE5C;CACJ;AAED,yBAAiB,eAAe,CAAC;IAC7B,KAAY,SAAS,GAAG,gBAAgB,CAAC;CAC5C"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export class PackageJsonFile {
|
|
2
|
+
path;
|
|
3
|
+
raw;
|
|
4
|
+
constructor(path, raw) {
|
|
5
|
+
this.path = path;
|
|
6
|
+
this.raw = raw;
|
|
7
|
+
}
|
|
8
|
+
// ── dependency helpers ─────────────────────────────────────────────────
|
|
9
|
+
section(key) {
|
|
10
|
+
return (this.raw[key] ?? {});
|
|
11
|
+
}
|
|
12
|
+
ensureSection(key) {
|
|
13
|
+
const data = this.raw;
|
|
14
|
+
if (!data[key]) {
|
|
15
|
+
data[key] = {};
|
|
16
|
+
}
|
|
17
|
+
return data[key];
|
|
18
|
+
}
|
|
19
|
+
getEntry(key, name) {
|
|
20
|
+
return this.section(key)[name] ?? null;
|
|
21
|
+
}
|
|
22
|
+
setEntry(key, name, version) {
|
|
23
|
+
this.ensureSection(key)[name] = version;
|
|
24
|
+
}
|
|
25
|
+
removeEntry(key, name) {
|
|
26
|
+
delete this.section(key)[name];
|
|
27
|
+
}
|
|
28
|
+
// ── dependencies ──────────────────────────────────────────────────────
|
|
29
|
+
getDependencies() {
|
|
30
|
+
return { ...this.section("dependencies") };
|
|
31
|
+
}
|
|
32
|
+
getDependency(name) {
|
|
33
|
+
return this.getEntry("dependencies", name);
|
|
34
|
+
}
|
|
35
|
+
setDependency(name, version) {
|
|
36
|
+
this.setEntry("dependencies", name, version);
|
|
37
|
+
}
|
|
38
|
+
removeDependency(name) {
|
|
39
|
+
this.removeEntry("dependencies", name);
|
|
40
|
+
}
|
|
41
|
+
// ── devDependencies ───────────────────────────────────────────────────
|
|
42
|
+
getDevDependencies() {
|
|
43
|
+
return { ...this.section("devDependencies") };
|
|
44
|
+
}
|
|
45
|
+
getDevDependency(name) {
|
|
46
|
+
return this.getEntry("devDependencies", name);
|
|
47
|
+
}
|
|
48
|
+
setDevDependency(name, version) {
|
|
49
|
+
this.setEntry("devDependencies", name, version);
|
|
50
|
+
}
|
|
51
|
+
removeDevDependency(name) {
|
|
52
|
+
this.removeEntry("devDependencies", name);
|
|
53
|
+
}
|
|
54
|
+
// ── peerDependencies ──────────────────────────────────────────────────
|
|
55
|
+
getPeerDependencies() {
|
|
56
|
+
return { ...this.section("peerDependencies") };
|
|
57
|
+
}
|
|
58
|
+
getPeerDependency(name) {
|
|
59
|
+
return this.getEntry("peerDependencies", name);
|
|
60
|
+
}
|
|
61
|
+
setPeerDependency(name, version) {
|
|
62
|
+
this.setEntry("peerDependencies", name, version);
|
|
63
|
+
}
|
|
64
|
+
removePeerDependency(name) {
|
|
65
|
+
this.removeEntry("peerDependencies", name);
|
|
66
|
+
}
|
|
67
|
+
// ── resolutions ───────────────────────────────────────────────────────
|
|
68
|
+
getResolutions() {
|
|
69
|
+
return { ...this.section("resolutions") };
|
|
70
|
+
}
|
|
71
|
+
getResolution(name) {
|
|
72
|
+
return this.getEntry("resolutions", name);
|
|
73
|
+
}
|
|
74
|
+
setResolution(name, version) {
|
|
75
|
+
this.setEntry("resolutions", name, version);
|
|
76
|
+
}
|
|
77
|
+
removeResolution(name) {
|
|
78
|
+
this.removeEntry("resolutions", name);
|
|
79
|
+
}
|
|
80
|
+
// ── misc ──────────────────────────────────────────────────────────────
|
|
81
|
+
getVersion() {
|
|
82
|
+
return this.raw.version ?? null;
|
|
83
|
+
}
|
|
84
|
+
get(key) {
|
|
85
|
+
return this.raw[key] ?? null;
|
|
86
|
+
}
|
|
87
|
+
set(key, value) {
|
|
88
|
+
this.raw[key] = value;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=PackageJsonFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PackageJsonFile.js","sourceRoot":"","sources":["../../../../src/node/features/PackageJsonFileTool/PackageJsonFile.ts"],"names":[],"mappings":"AA6CA,MAAM,OAAO,eAAe;IAEJ,IAAI;IACJ,GAAG;IAFvB,YACoB,IAAY,EACZ,GAAgB;oBADhB,IAAI;mBACJ,GAAG;IACpB,CAAC;IAEJ,0EAA0E;IAElE,OAAO,CAAC,GAAe;QAC3B,OAAO,CAAE,IAAI,CAAC,GAA+B,CAAC,GAAG,CAAC,IAAI,EAAE,CAA2B,CAAC;IACxF,CAAC;IAEO,aAAa,CAAC,GAAe;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,GAA8B,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAA2B,CAAC;IAC/C,CAA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GAAG,KAAK,CAAC;IACvD,CAAC;CACJ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PackageJson } from "type-fest";
|
|
2
|
+
import { PackageJsonFileTool as PackageJsonFileToolAbstraction } from "./abstractions/PackageJsonFileTool.js";
|
|
3
|
+
import { PackageJsonFile } from "./PackageJsonFile.js";
|
|
4
|
+
import { FileTool } from "../FileTool/abstractions/FileTool.js";
|
|
5
|
+
declare class PackageJsonFileToolImpl implements PackageJsonFileToolAbstraction.Interface {
|
|
6
|
+
private readonly fileTool;
|
|
7
|
+
constructor(fileTool: FileTool.Interface);
|
|
8
|
+
read(path: string): PackageJsonFile.Interface | null;
|
|
9
|
+
readOrThrow(path: string): PackageJsonFile.Interface;
|
|
10
|
+
write(path: string, data: PackageJson): void;
|
|
11
|
+
write(file: PackageJsonFile.Interface): void;
|
|
12
|
+
writeOrThrow(path: string, data: PackageJson): void;
|
|
13
|
+
writeOrThrow(file: PackageJsonFile.Interface): void;
|
|
14
|
+
}
|
|
15
|
+
export declare const PackageJsonFileTool: typeof PackageJsonFileToolImpl & {
|
|
16
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions/PackageJsonFileTool.js").IPackageJsonFileTool>;
|
|
17
|
+
};
|
|
18
|
+
export interface CreatePackageJsonFileToolParams {
|
|
19
|
+
fileTool?: FileTool.Interface;
|
|
20
|
+
}
|
|
21
|
+
export declare function createPackageJsonFileTool(params?: CreatePackageJsonFileToolParams): PackageJsonFileToolAbstraction.Interface;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=PackageJsonFileTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PackageJsonFileTool.d.ts","sourceRoot":"","sources":["../../../../src/node/features/PackageJsonFileTool/PackageJsonFileTool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,mBAAmB,IAAI,8BAA8B,EAAE,MAAM,uCAAuC,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAgChE,cAAM,uBAAwB,YAAW,8BAA8B,CAAC,SAAS;IAC1D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAA5C,YAAoC,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAI;IAE7D,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC,SAAS,GAAG,IAAI,CAO1D;IAEM,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC,SAAS,CAI1D;IAEM,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7C,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,GAAG,IAAI,CAAC;IAS7C,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACpD,YAAY,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,GAAG,IAAI,CAAC;CAQ9D;AAED,eAAO,MAAM,mBAAmB;;CAG9B,CAAC;AAEH,MAAM,WAAW,+BAA+B;IAC5C,QAAQ,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;CACjC;AAED,wBAAgB,yBAAyB,CACrC,MAAM,CAAC,EAAE,+BAA+B,GACzC,8BAA8B,CAAC,SAAS,CAG1C"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { PackageJsonFileTool as PackageJsonFileToolAbstraction } from "./abstractions/PackageJsonFileTool.js";
|
|
3
|
+
import { PackageJsonFile } from "./PackageJsonFile.js";
|
|
4
|
+
import { FileTool } from "../FileTool/abstractions/FileTool.js";
|
|
5
|
+
import { createFileTool } from "../FileTool/FileTool.js";
|
|
6
|
+
const dependencyRecord = z.record(z.string(), z.string()).optional();
|
|
7
|
+
/** Validates well-known root-level fields; unknown fields pass through unchanged. */
|
|
8
|
+
const packageJsonSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
name: z.string().optional(),
|
|
11
|
+
version: z.string().optional(),
|
|
12
|
+
description: z.string().optional(),
|
|
13
|
+
license: z.string().optional(),
|
|
14
|
+
private: z.boolean().optional(),
|
|
15
|
+
type: z.enum(["module", "commonjs"]).optional(),
|
|
16
|
+
main: z.string().optional(),
|
|
17
|
+
module: z.string().optional(),
|
|
18
|
+
types: z.string().optional(),
|
|
19
|
+
typings: z.string().optional(),
|
|
20
|
+
files: z.array(z.string()).optional(),
|
|
21
|
+
keywords: z.array(z.string()).optional(),
|
|
22
|
+
scripts: z.record(z.string(), z.string()).optional(),
|
|
23
|
+
dependencies: dependencyRecord,
|
|
24
|
+
devDependencies: dependencyRecord,
|
|
25
|
+
peerDependencies: dependencyRecord,
|
|
26
|
+
optionalDependencies: dependencyRecord
|
|
27
|
+
})
|
|
28
|
+
.passthrough();
|
|
29
|
+
function serialize(data) {
|
|
30
|
+
return JSON.stringify(data, null, 2);
|
|
31
|
+
}
|
|
32
|
+
class PackageJsonFileToolImpl {
|
|
33
|
+
fileTool;
|
|
34
|
+
constructor(fileTool) {
|
|
35
|
+
this.fileTool = fileTool;
|
|
36
|
+
}
|
|
37
|
+
read(path) {
|
|
38
|
+
const content = this.fileTool.readFile(path);
|
|
39
|
+
if (content === null) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const raw = packageJsonSchema.parse(JSON.parse(content));
|
|
43
|
+
return new PackageJsonFile(path, raw);
|
|
44
|
+
}
|
|
45
|
+
readOrThrow(path) {
|
|
46
|
+
const content = this.fileTool.readFileOrThrow(path);
|
|
47
|
+
const raw = packageJsonSchema.parse(JSON.parse(content));
|
|
48
|
+
return new PackageJsonFile(path, raw);
|
|
49
|
+
}
|
|
50
|
+
write(pathOrFile, data) {
|
|
51
|
+
if (typeof pathOrFile === "string") {
|
|
52
|
+
this.fileTool.writeFile(pathOrFile, serialize(data));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.fileTool.writeFile(pathOrFile.path, serialize(pathOrFile.raw));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
writeOrThrow(pathOrFile, data) {
|
|
59
|
+
if (typeof pathOrFile === "string") {
|
|
60
|
+
this.fileTool.writeFileOrThrow(pathOrFile, serialize(data));
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.fileTool.writeFileOrThrow(pathOrFile.path, serialize(pathOrFile.raw));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export const PackageJsonFileTool = PackageJsonFileToolAbstraction.createImplementation({
|
|
68
|
+
implementation: PackageJsonFileToolImpl,
|
|
69
|
+
dependencies: [FileTool]
|
|
70
|
+
});
|
|
71
|
+
export function createPackageJsonFileTool(params) {
|
|
72
|
+
const fileTool = params?.fileTool ?? createFileTool();
|
|
73
|
+
return new PackageJsonFileToolImpl(fileTool);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=PackageJsonFileTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PackageJsonFileTool.js","sourceRoot":"","sources":["../../../../src/node/features/PackageJsonFileTool/PackageJsonFileTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,mBAAmB,IAAI,8BAA8B,EAAE,MAAM,uCAAuC,CAAC;AAC9G,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,C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