@breadstone-infrastructure/prisma-seeds 0.0.231
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/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +284 -0
- package/ai/AISeedGenerator.d.ts +127 -0
- package/ai/AISeedGenerator.d.ts.map +1 -0
- package/ai/AISeedGenerator.js +438 -0
- package/ai/AISeedGenerator.js.map +1 -0
- package/ai/AISeedTypes.d.ts +138 -0
- package/ai/AISeedTypes.d.ts.map +1 -0
- package/ai/AISeedTypes.js +3 -0
- package/ai/AISeedTypes.js.map +1 -0
- package/ai/PrismaModelAnalyzer.d.ts +36 -0
- package/ai/PrismaModelAnalyzer.d.ts.map +1 -0
- package/ai/PrismaModelAnalyzer.js +110 -0
- package/ai/PrismaModelAnalyzer.js.map +1 -0
- package/ai/PrismaTypeSchemaGenerator.d.ts +38 -0
- package/ai/PrismaTypeSchemaGenerator.d.ts.map +1 -0
- package/ai/PrismaTypeSchemaGenerator.js +71 -0
- package/ai/PrismaTypeSchemaGenerator.js.map +1 -0
- package/ai/createAISeeder.d.ts +11 -0
- package/ai/createAISeeder.d.ts.map +1 -0
- package/ai/createAISeeder.js +72 -0
- package/ai/createAISeeder.js.map +1 -0
- package/ai/index.d.ts +6 -0
- package/ai/index.d.ts.map +1 -0
- package/ai/index.js +5 -0
- package/ai/index.js.map +1 -0
- package/assets/AssetManager.d.ts +213 -0
- package/assets/AssetManager.d.ts.map +1 -0
- package/assets/AssetManager.js +460 -0
- package/assets/AssetManager.js.map +1 -0
- package/assets/IImageTransformOptions.d.ts +42 -0
- package/assets/IImageTransformOptions.d.ts.map +1 -0
- package/assets/IImageTransformOptions.js +22 -0
- package/assets/IImageTransformOptions.js.map +1 -0
- package/assets/adapters/BlobAdapterFactory.d.ts +21 -0
- package/assets/adapters/BlobAdapterFactory.d.ts.map +1 -0
- package/assets/adapters/BlobAdapterFactory.js +3 -0
- package/assets/adapters/BlobAdapterFactory.js.map +1 -0
- package/assets/adapters/CloudflareR2BlobAdapter.d.ts +97 -0
- package/assets/adapters/CloudflareR2BlobAdapter.d.ts.map +1 -0
- package/assets/adapters/CloudflareR2BlobAdapter.js +265 -0
- package/assets/adapters/CloudflareR2BlobAdapter.js.map +1 -0
- package/assets/adapters/EmptyBlobAdapter.d.ts +42 -0
- package/assets/adapters/EmptyBlobAdapter.d.ts.map +1 -0
- package/assets/adapters/EmptyBlobAdapter.js +65 -0
- package/assets/adapters/EmptyBlobAdapter.js.map +1 -0
- package/assets/adapters/LocalFileAdapter.d.ts +34 -0
- package/assets/adapters/LocalFileAdapter.d.ts.map +1 -0
- package/assets/adapters/LocalFileAdapter.js +74 -0
- package/assets/adapters/LocalFileAdapter.js.map +1 -0
- package/assets/adapters/VercelBlobAdapter.d.ts +73 -0
- package/assets/adapters/VercelBlobAdapter.d.ts.map +1 -0
- package/assets/adapters/VercelBlobAdapter.js +168 -0
- package/assets/adapters/VercelBlobAdapter.js.map +1 -0
- package/assets/adapters/abstracts/BlobAdapterBase.d.ts +62 -0
- package/assets/adapters/abstracts/BlobAdapterBase.d.ts.map +1 -0
- package/assets/adapters/abstracts/BlobAdapterBase.js +58 -0
- package/assets/adapters/abstracts/BlobAdapterBase.js.map +1 -0
- package/assets/adapters/abstracts/HttpBlobAdapterBase.d.ts +43 -0
- package/assets/adapters/abstracts/HttpBlobAdapterBase.d.ts.map +1 -0
- package/assets/adapters/abstracts/HttpBlobAdapterBase.js +88 -0
- package/assets/adapters/abstracts/HttpBlobAdapterBase.js.map +1 -0
- package/assets/adapters/createBlobAdapter.d.ts +47 -0
- package/assets/adapters/createBlobAdapter.d.ts.map +1 -0
- package/assets/adapters/createBlobAdapter.js +63 -0
- package/assets/adapters/createBlobAdapter.js.map +1 -0
- package/assets/adapters/index.d.ts +11 -0
- package/assets/adapters/index.d.ts.map +1 -0
- package/assets/adapters/index.js +7 -0
- package/assets/adapters/index.js.map +1 -0
- package/assets/adapters/interfaces/IBlobAdapter.d.ts +41 -0
- package/assets/adapters/interfaces/IBlobAdapter.d.ts.map +1 -0
- package/assets/adapters/interfaces/IBlobAdapter.js +3 -0
- package/assets/adapters/interfaces/IBlobAdapter.js.map +1 -0
- package/assets/adapters/interfaces/IBlobAdapterConfig.d.ts +16 -0
- package/assets/adapters/interfaces/IBlobAdapterConfig.d.ts.map +1 -0
- package/assets/adapters/interfaces/IBlobAdapterConfig.js +2 -0
- package/assets/adapters/interfaces/IBlobAdapterConfig.js.map +1 -0
- package/assets/adapters/interfaces/IBlobUploadResult.d.ts +24 -0
- package/assets/adapters/interfaces/IBlobUploadResult.d.ts.map +1 -0
- package/assets/adapters/interfaces/IBlobUploadResult.js +2 -0
- package/assets/adapters/interfaces/IBlobUploadResult.js.map +1 -0
- package/base/BaseSeeder.d.ts +21 -0
- package/base/BaseSeeder.d.ts.map +1 -0
- package/base/BaseSeeder.js +45 -0
- package/base/BaseSeeder.js.map +1 -0
- package/base/functionalSeeder.d.ts +31 -0
- package/base/functionalSeeder.d.ts.map +1 -0
- package/base/functionalSeeder.js +33 -0
- package/base/functionalSeeder.js.map +1 -0
- package/cli/Cli.d.ts +2 -0
- package/cli/Cli.d.ts.map +1 -0
- package/cli/Cli.js +32 -0
- package/cli/Cli.js.map +1 -0
- package/cli/CliArgs.d.ts +2 -0
- package/cli/CliArgs.d.ts.map +1 -0
- package/cli/CliArgs.js +133 -0
- package/cli/CliArgs.js.map +1 -0
- package/cli/CliArgsConfig.d.ts +2 -0
- package/cli/CliArgsConfig.d.ts.map +1 -0
- package/cli/CliArgsConfig.js +15 -0
- package/cli/CliArgsConfig.js.map +1 -0
- package/cli/CliRun.d.ts +2 -0
- package/cli/CliRun.d.ts.map +1 -0
- package/cli/CliRun.js +34 -0
- package/cli/CliRun.js.map +1 -0
- package/cli/commands/SeedCommand.d.ts +2 -0
- package/cli/commands/SeedCommand.d.ts.map +1 -0
- package/cli/commands/SeedCommand.js +73 -0
- package/cli/commands/SeedCommand.js.map +1 -0
- package/cli/commands/SeedCommandArgsConfig.d.ts +2 -0
- package/cli/commands/SeedCommandArgsConfig.d.ts.map +1 -0
- package/cli/commands/SeedCommandArgsConfig.js +31 -0
- package/cli/commands/SeedCommandArgsConfig.js.map +1 -0
- package/cli/seed.d.ts +2 -0
- package/cli/seed.d.ts.map +1 -0
- package/cli/seed.js +42 -0
- package/cli/seed.js.map +1 -0
- package/config/IAssetConfig.d.ts +36 -0
- package/config/IAssetConfig.d.ts.map +1 -0
- package/config/IAssetConfig.js +3 -0
- package/config/IAssetConfig.js.map +1 -0
- package/config/IComposedSeedConfig.d.ts +32 -0
- package/config/IComposedSeedConfig.d.ts.map +1 -0
- package/config/IComposedSeedConfig.js +3 -0
- package/config/IComposedSeedConfig.js.map +1 -0
- package/config/ISeedConfig.d.ts +75 -0
- package/config/ISeedConfig.d.ts.map +1 -0
- package/config/ISeedConfig.js +3 -0
- package/config/ISeedConfig.js.map +1 -0
- package/config/ISeedContext.d.ts +92 -0
- package/config/ISeedContext.d.ts.map +1 -0
- package/config/ISeedContext.js +3 -0
- package/config/ISeedContext.js.map +1 -0
- package/config/ISeedDefinition.d.ts +38 -0
- package/config/ISeedDefinition.d.ts.map +1 -0
- package/config/ISeedDefinition.js +3 -0
- package/config/ISeedDefinition.js.map +1 -0
- package/config/ISeedFactory.d.ts +15 -0
- package/config/ISeedFactory.d.ts.map +1 -0
- package/config/ISeedFactory.js +3 -0
- package/config/ISeedFactory.js.map +1 -0
- package/config/ISeedOptions.d.ts +44 -0
- package/config/ISeedOptions.d.ts.map +1 -0
- package/config/ISeedOptions.js +2 -0
- package/config/ISeedOptions.js.map +1 -0
- package/config/ISeedResult.d.ts +44 -0
- package/config/ISeedResult.d.ts.map +1 -0
- package/config/ISeedResult.js +2 -0
- package/config/ISeedResult.js.map +1 -0
- package/config/ISeeder.d.ts +37 -0
- package/config/ISeeder.d.ts.map +1 -0
- package/config/ISeeder.js +3 -0
- package/config/ISeeder.js.map +1 -0
- package/config/createAdapter.d.ts +13 -0
- package/config/createAdapter.d.ts.map +1 -0
- package/config/createAdapter.js +16 -0
- package/config/createAdapter.js.map +1 -0
- package/config/createSeed.d.ts +6 -0
- package/config/createSeed.d.ts.map +1 -0
- package/config/createSeed.js +16 -0
- package/config/createSeed.js.map +1 -0
- package/config/defineConfig.d.ts +27 -0
- package/config/defineConfig.d.ts.map +1 -0
- package/config/defineConfig.js +35 -0
- package/config/defineConfig.js.map +1 -0
- package/discovery/SeedConfigDiscovery.d.ts +16 -0
- package/discovery/SeedConfigDiscovery.d.ts.map +1 -0
- package/discovery/SeedConfigDiscovery.js +137 -0
- package/discovery/SeedConfigDiscovery.js.map +1 -0
- package/index.d.ts +32 -0
- package/index.d.ts.map +1 -0
- package/index.js +32 -0
- package/index.js.map +1 -0
- package/json/JsonReferenceResolver.d.ts +23 -0
- package/json/JsonReferenceResolver.d.ts.map +1 -0
- package/json/JsonReferenceResolver.js +99 -0
- package/json/JsonReferenceResolver.js.map +1 -0
- package/json/JsonSchemaValidator.d.ts +23 -0
- package/json/JsonSchemaValidator.d.ts.map +1 -0
- package/json/JsonSchemaValidator.js +98 -0
- package/json/JsonSchemaValidator.js.map +1 -0
- package/json/JsonSeedLoader.d.ts +33 -0
- package/json/JsonSeedLoader.d.ts.map +1 -0
- package/json/JsonSeedLoader.js +176 -0
- package/json/JsonSeedLoader.js.map +1 -0
- package/json/JsonSeedTypes.d.ts +204 -0
- package/json/JsonSeedTypes.d.ts.map +1 -0
- package/json/JsonSeedTypes.js +3 -0
- package/json/JsonSeedTypes.js.map +1 -0
- package/json/createJsonSeeder.d.ts +13 -0
- package/json/createJsonSeeder.d.ts.map +1 -0
- package/json/createJsonSeeder.js +240 -0
- package/json/createJsonSeeder.js.map +1 -0
- package/json/index.d.ts +6 -0
- package/json/index.d.ts.map +1 -0
- package/json/index.js +7 -0
- package/json/index.js.map +1 -0
- package/logging/ISeedLogger.d.ts +55 -0
- package/logging/ISeedLogger.d.ts.map +1 -0
- package/logging/ISeedLogger.js +3 -0
- package/logging/ISeedLogger.js.map +1 -0
- package/logging/LogLevel.d.ts +30 -0
- package/logging/LogLevel.d.ts.map +1 -0
- package/logging/LogLevel.js +37 -0
- package/logging/LogLevel.js.map +1 -0
- package/logging/SeedLogger.d.ts +24 -0
- package/logging/SeedLogger.d.ts.map +1 -0
- package/logging/SeedLogger.js +94 -0
- package/logging/SeedLogger.js.map +1 -0
- package/orchestration/SeedOrchestrator.d.ts +30 -0
- package/orchestration/SeedOrchestrator.d.ts.map +1 -0
- package/orchestration/SeedOrchestrator.js +262 -0
- package/orchestration/SeedOrchestrator.js.map +1 -0
- package/package.json +27 -0
- package/resolvers/EntityResolver.d.ts +43 -0
- package/resolvers/EntityResolver.d.ts.map +1 -0
- package/resolvers/EntityResolver.js +95 -0
- package/resolvers/EntityResolver.js.map +1 -0
- package/utils/AssetReferenceResolver.d.ts +49 -0
- package/utils/AssetReferenceResolver.d.ts.map +1 -0
- package/utils/AssetReferenceResolver.js +62 -0
- package/utils/AssetReferenceResolver.js.map +1 -0
- package/utils/EntityLookupCache.d.ts +47 -0
- package/utils/EntityLookupCache.d.ts.map +1 -0
- package/utils/EntityLookupCache.js +64 -0
- package/utils/EntityLookupCache.js.map +1 -0
- package/utils/ISeedRandom.d.ts +70 -0
- package/utils/ISeedRandom.d.ts.map +1 -0
- package/utils/ISeedRandom.js +3 -0
- package/utils/ISeedRandom.js.map +1 -0
- package/utils/LocalizationToolkit.d.ts +125 -0
- package/utils/LocalizationToolkit.d.ts.map +1 -0
- package/utils/LocalizationToolkit.js +131 -0
- package/utils/LocalizationToolkit.js.map +1 -0
- package/utils/SeededRandom.d.ts +15 -0
- package/utils/SeededRandom.d.ts.map +1 -0
- package/utils/SeededRandom.js +56 -0
- package/utils/SeededRandom.js.map +1 -0
- package/utils/StringArrayToolkit.d.ts +25 -0
- package/utils/StringArrayToolkit.d.ts.map +1 -0
- package/utils/StringArrayToolkit.js +56 -0
- package/utils/StringArrayToolkit.js.map +1 -0
- package/utils/StringValueGuard.d.ts +24 -0
- package/utils/StringValueGuard.d.ts.map +1 -0
- package/utils/StringValueGuard.js +46 -0
- package/utils/StringValueGuard.js.map +1 -0
- package/utils/WarningCollector.d.ts +40 -0
- package/utils/WarningCollector.d.ts.map +1 -0
- package/utils/WarningCollector.js +83 -0
- package/utils/WarningCollector.js.map +1 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ISeedLogger } from '../logging/ISeedLogger.js';
|
|
2
|
+
import type { IJsonSeedLoadOptions, IJsonValidationResult } from './JsonSeedTypes.js';
|
|
3
|
+
/**
|
|
4
|
+
* Loader for JSON seed data files.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class JsonSeedLoader {
|
|
9
|
+
private readonly _fileSystem;
|
|
10
|
+
private readonly _logger;
|
|
11
|
+
private readonly _validator;
|
|
12
|
+
constructor(logger: ISeedLogger);
|
|
13
|
+
/**
|
|
14
|
+
* Load JSON files from the given sources (supports globs).
|
|
15
|
+
*
|
|
16
|
+
* @param sources File paths or glob patterns
|
|
17
|
+
* @param basePath Base path for resolving relative paths
|
|
18
|
+
* @returns Array of parsed JSON data
|
|
19
|
+
*/
|
|
20
|
+
load(sources: string | readonly string[], basePath: string, options?: IJsonSeedLoadOptions): Promise<unknown[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Load and validate JSON files against a schema.
|
|
23
|
+
*
|
|
24
|
+
* @param sources File paths or glob patterns
|
|
25
|
+
* @param schemaPath Path to JSON schema file
|
|
26
|
+
* @param basePath Base path for resolving relative paths
|
|
27
|
+
* @returns Validation result with data or errors
|
|
28
|
+
*/
|
|
29
|
+
loadWithSchema(sources: string | readonly string[], schemaPath: string, basePath: string, options?: IJsonSeedLoadOptions): Promise<IJsonValidationResult>;
|
|
30
|
+
private _extractData;
|
|
31
|
+
private _extractByPath;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=JsonSeedLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonSeedLoader.d.ts","sourceRoot":"","sources":["../../src/json/JsonSeedLoader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAKtF;;;;GAIG;AACH,qBAAa,cAAc;IAIvB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsB;gBAM9B,MAAM,EAAE,WAAW;IAUtC;;;;;;OAMG;IACU,IAAI,CACb,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACnC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,oBAAoB,GAC/B,OAAO,CAAC,OAAO,EAAE,CAAC;IAgCrB;;;;;;;OAOG;IACU,cAAc,CACvB,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EACnC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,oBAAoB,GAC/B,OAAO,CAAC,qBAAqB,CAAC;IA2DjC,OAAO,CAAC,YAAY;IAqDpB,OAAO,CAAC,cAAc;CAuBzB"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
import { FileSystem, Path } from '@breadstone-infrastructure/utilities';
|
|
3
|
+
import { JsonSchemaValidator } from './JsonSchemaValidator.js';
|
|
4
|
+
// #endregion
|
|
5
|
+
/**
|
|
6
|
+
* Loader for JSON seed data files.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export class JsonSeedLoader {
|
|
11
|
+
// #region Fields
|
|
12
|
+
_fileSystem;
|
|
13
|
+
_logger;
|
|
14
|
+
_validator;
|
|
15
|
+
// #endregion
|
|
16
|
+
// #region Ctor
|
|
17
|
+
constructor(logger) {
|
|
18
|
+
this._fileSystem = new FileSystem();
|
|
19
|
+
this._logger = logger;
|
|
20
|
+
this._validator = new JsonSchemaValidator(logger);
|
|
21
|
+
}
|
|
22
|
+
// #endregion
|
|
23
|
+
// #region Methods
|
|
24
|
+
/**
|
|
25
|
+
* Load JSON files from the given sources (supports globs).
|
|
26
|
+
*
|
|
27
|
+
* @param sources File paths or glob patterns
|
|
28
|
+
* @param basePath Base path for resolving relative paths
|
|
29
|
+
* @returns Array of parsed JSON data
|
|
30
|
+
*/
|
|
31
|
+
async load(sources, basePath, options) {
|
|
32
|
+
const sourceArray = Array.isArray(sources) ? sources : [sources];
|
|
33
|
+
const allData = [];
|
|
34
|
+
const normalizedOptions = {
|
|
35
|
+
wrapperKeys: options?.wrapperKeys?.length
|
|
36
|
+
? options.wrapperKeys
|
|
37
|
+
: undefined
|
|
38
|
+
};
|
|
39
|
+
for (const source of sourceArray) {
|
|
40
|
+
const absoluteSource = Path.isAbsolute(source) ? source : Path.combine(basePath, source);
|
|
41
|
+
const files = Path.glob(absoluteSource);
|
|
42
|
+
for (const file of files) {
|
|
43
|
+
try {
|
|
44
|
+
const content = await this._fileSystem.fileReadAllText(file, 'utf-8');
|
|
45
|
+
const parsed = JSON.parse(content);
|
|
46
|
+
const extracted = this._extractData(parsed, normalizedOptions);
|
|
47
|
+
if (extracted.length > 0) {
|
|
48
|
+
allData.push(...extracted);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
this._logger.error(`Failed to load JSON from ${file}: ${error}`);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return allData;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Load and validate JSON files against a schema.
|
|
61
|
+
*
|
|
62
|
+
* @param sources File paths or glob patterns
|
|
63
|
+
* @param schemaPath Path to JSON schema file
|
|
64
|
+
* @param basePath Base path for resolving relative paths
|
|
65
|
+
* @returns Validation result with data or errors
|
|
66
|
+
*/
|
|
67
|
+
async loadWithSchema(sources, schemaPath, basePath, options) {
|
|
68
|
+
try {
|
|
69
|
+
if (!schemaPath) {
|
|
70
|
+
const data = await this.load(sources, basePath, options);
|
|
71
|
+
return {
|
|
72
|
+
isValid: true,
|
|
73
|
+
errors: [],
|
|
74
|
+
data
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Load raw JSON files without extraction first for validation
|
|
78
|
+
const sourceArray = Array.isArray(sources) ? sources : [sources];
|
|
79
|
+
const rawDocuments = [];
|
|
80
|
+
for (const source of sourceArray) {
|
|
81
|
+
const absoluteSource = Path.isAbsolute(source) ? source : Path.combine(basePath, source);
|
|
82
|
+
const files = Path.glob(absoluteSource);
|
|
83
|
+
for (const file of files) {
|
|
84
|
+
try {
|
|
85
|
+
const content = await this._fileSystem.fileReadAllText(file, 'utf-8');
|
|
86
|
+
const parsed = JSON.parse(content);
|
|
87
|
+
rawDocuments.push(parsed);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
this._logger.error(`Failed to load JSON from ${file}: ${error}`);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Validate raw documents against schema
|
|
96
|
+
const absoluteSchemaPath = Path.isAbsolute(schemaPath)
|
|
97
|
+
? schemaPath
|
|
98
|
+
: Path.combine(basePath, schemaPath);
|
|
99
|
+
const validationResult = this._validator.validate(rawDocuments, absoluteSchemaPath);
|
|
100
|
+
if (!validationResult.isValid) {
|
|
101
|
+
return validationResult;
|
|
102
|
+
}
|
|
103
|
+
// Now extract the actual data items
|
|
104
|
+
const data = await this.load(sources, basePath, options);
|
|
105
|
+
return {
|
|
106
|
+
isValid: true,
|
|
107
|
+
errors: [],
|
|
108
|
+
data
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
return {
|
|
113
|
+
isValid: false,
|
|
114
|
+
errors: [String(error)],
|
|
115
|
+
data: undefined
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
_extractData(data, options) {
|
|
120
|
+
if (Array.isArray(data)) {
|
|
121
|
+
return data;
|
|
122
|
+
}
|
|
123
|
+
if (!data || typeof data !== 'object') {
|
|
124
|
+
return data === undefined ? [] : [data];
|
|
125
|
+
}
|
|
126
|
+
const candidate = data;
|
|
127
|
+
const wrapperKeys = options.wrapperKeys;
|
|
128
|
+
if (wrapperKeys && wrapperKeys.length > 0) {
|
|
129
|
+
const extracted = [];
|
|
130
|
+
for (const wrapperKey of wrapperKeys) {
|
|
131
|
+
const value = this._extractByPath(candidate, wrapperKey);
|
|
132
|
+
if (Array.isArray(value)) {
|
|
133
|
+
extracted.push(...value);
|
|
134
|
+
}
|
|
135
|
+
else if (value !== undefined) {
|
|
136
|
+
extracted.push(value);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (extracted.length > 0) {
|
|
140
|
+
return extracted;
|
|
141
|
+
}
|
|
142
|
+
this._logger.warn(`Wrapper key(s) ${wrapperKeys.join(', ')} not found in JSON payload. Falling back to default extraction.`);
|
|
143
|
+
}
|
|
144
|
+
if ('items' in candidate && Array.isArray(candidate['items'])) {
|
|
145
|
+
return candidate['items'];
|
|
146
|
+
}
|
|
147
|
+
if ('recipes' in candidate && Array.isArray(candidate['recipes'])) {
|
|
148
|
+
return candidate['recipes'];
|
|
149
|
+
}
|
|
150
|
+
if ('exercises' in candidate && Array.isArray(candidate['exercises'])) {
|
|
151
|
+
return candidate['exercises'];
|
|
152
|
+
}
|
|
153
|
+
if ('tips' in candidate && Array.isArray(candidate['tips'])) {
|
|
154
|
+
return candidate['tips'];
|
|
155
|
+
}
|
|
156
|
+
return [candidate];
|
|
157
|
+
}
|
|
158
|
+
_extractByPath(source, path) {
|
|
159
|
+
const segments = path.split('.').map((segment) => segment.trim())
|
|
160
|
+
.filter((segment) => segment.length > 0);
|
|
161
|
+
if (segments.length === 0) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
let current = source;
|
|
165
|
+
for (const segment of segments) {
|
|
166
|
+
if (current && typeof current === 'object' && segment in current) {
|
|
167
|
+
current = current[segment];
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return current;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=JsonSeedLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonSeedLoader.js","sourceRoot":"","sources":["../../src/json/JsonSeedLoader.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,sCAAsC,CAAC;AAGxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,aAAa;AAEb;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAEvB,iBAAiB;IAEA,WAAW,CAAa;IACxB,OAAO,CAAc;IACrB,UAAU,CAAsB;IAEjD,aAAa;IAEb,eAAe;IAEf,YAAmB,MAAmB;QAClC,IAAI,CAAC,WAAW,GAAG,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAED,aAAa;IAEb,kBAAkB;IAElB;;;;;;OAMG;IACI,KAAK,CAAC,IAAI,CACb,OAAmC,EACnC,QAAgB,EAChB,OAA8B;QAE9B,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACjE,MAAM,OAAO,GAAc,EAAE,CAAC;QAC9B,MAAM,iBAA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AAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;aAC5D,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE7C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,IAAI,OAAO,GAAY,MAAM,CAAC;QAE9B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,IAAK,OAAmC,EAAE,CAAC;gBAC5F,OAAO,GAAI,OAAmC,CAAC,OAAO,CAAC,CAAC;YAC5D,CAAC;iBAAM,CAAC;gBACJ,OAAO,SAAS,CAAC;YACrB,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CAIJ"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { ISeedContext } from '../config/ISeedContext.js';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for a JSON-based seeder.
|
|
4
|
+
*
|
|
5
|
+
* @template TJson The shape of the JSON data
|
|
6
|
+
* @template TPrisma The Prisma create input type
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface IJsonSeedConfig<TJson = unknown, TPrisma = unknown> {
|
|
10
|
+
/**
|
|
11
|
+
* Unique name for this JSON seeder.
|
|
12
|
+
*
|
|
13
|
+
* @readonly
|
|
14
|
+
*/
|
|
15
|
+
readonly name: string;
|
|
16
|
+
/**
|
|
17
|
+
* Path(s) to JSON data files (supports glob patterns).
|
|
18
|
+
* Relative to the seed.config.mjs location.
|
|
19
|
+
*
|
|
20
|
+
* @readonly
|
|
21
|
+
*/
|
|
22
|
+
readonly sources: string | readonly string[];
|
|
23
|
+
/**
|
|
24
|
+
* Optional key (or keys) selecting the array within the JSON payload that should
|
|
25
|
+
* be processed. Supports nested access via dot-notation.
|
|
26
|
+
*
|
|
27
|
+
* @readonly
|
|
28
|
+
*/
|
|
29
|
+
readonly wrapperKey?: string | readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* Optional JSON Schema path for validation.
|
|
32
|
+
* If omitted, no schema validation is performed.
|
|
33
|
+
*
|
|
34
|
+
* @readonly
|
|
35
|
+
*/
|
|
36
|
+
readonly schema?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Prisma model name (e.g., 'recipe', 'exercise').
|
|
39
|
+
*
|
|
40
|
+
* @readonly
|
|
41
|
+
*/
|
|
42
|
+
readonly model: string;
|
|
43
|
+
/**
|
|
44
|
+
* Mapper to transform JSON data to Prisma create input.
|
|
45
|
+
* If omitted, assumes JSON structure matches Prisma exactly.
|
|
46
|
+
*
|
|
47
|
+
* @readonly
|
|
48
|
+
*/
|
|
49
|
+
readonly mapper?: IJsonSeedMapper<TJson, TPrisma>;
|
|
50
|
+
/**
|
|
51
|
+
* Optional reference resolver configuration.
|
|
52
|
+
*
|
|
53
|
+
* @readonly
|
|
54
|
+
*/
|
|
55
|
+
readonly references?: IJsonReferenceConfig;
|
|
56
|
+
/**
|
|
57
|
+
* Upsert strategy configuration.
|
|
58
|
+
*
|
|
59
|
+
* @readonly
|
|
60
|
+
*/
|
|
61
|
+
readonly upsert?: {
|
|
62
|
+
/**
|
|
63
|
+
* Field(s) to use for identifying existing records.
|
|
64
|
+
*/
|
|
65
|
+
readonly uniqueFields: string | readonly string[];
|
|
66
|
+
/**
|
|
67
|
+
* Whether to update existing records (default: false).
|
|
68
|
+
*/
|
|
69
|
+
readonly updateExisting?: boolean;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Batch processing configuration.
|
|
73
|
+
*
|
|
74
|
+
* @readonly
|
|
75
|
+
*/
|
|
76
|
+
readonly batch?: {
|
|
77
|
+
/**
|
|
78
|
+
* Number of items to process in a single batch.
|
|
79
|
+
*/
|
|
80
|
+
readonly size?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Whether to use transactions for batches.
|
|
83
|
+
*/
|
|
84
|
+
readonly useTransaction?: boolean;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Whether this seeder is enabled.
|
|
88
|
+
*
|
|
89
|
+
* @readonly
|
|
90
|
+
*/
|
|
91
|
+
readonly enabled?: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Mapper interface for transforming JSON to Prisma input.
|
|
95
|
+
*
|
|
96
|
+
* @template TJson The JSON input type
|
|
97
|
+
* @template TPrisma The Prisma output type
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
export interface IJsonSeedMapper<TJson, TPrisma> {
|
|
101
|
+
/**
|
|
102
|
+
* Transform JSON data to Prisma create input.
|
|
103
|
+
*
|
|
104
|
+
* @param data The JSON data
|
|
105
|
+
* @param context The seed context
|
|
106
|
+
* @returns The Prisma create input
|
|
107
|
+
*/
|
|
108
|
+
mapToCreate(_data: TJson, _context: ISeedContext): Promise<TPrisma> | TPrisma;
|
|
109
|
+
/**
|
|
110
|
+
* Optional: Transform for update operations.
|
|
111
|
+
*
|
|
112
|
+
* @param data The JSON data
|
|
113
|
+
* @param existing The existing record
|
|
114
|
+
* @param context The seed context
|
|
115
|
+
* @returns The Prisma update input
|
|
116
|
+
*/
|
|
117
|
+
mapToUpdate?(_data: TJson, _existing: unknown, _context: ISeedContext): Promise<TPrisma> | TPrisma;
|
|
118
|
+
/**
|
|
119
|
+
* Optional: Pre-process JSON before mapping.
|
|
120
|
+
*
|
|
121
|
+
* @param data The JSON data
|
|
122
|
+
* @param context The seed context
|
|
123
|
+
* @returns The processed JSON data
|
|
124
|
+
*/
|
|
125
|
+
preProcess?(_data: TJson, _context: ISeedContext): Promise<TJson> | TJson;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Options controlling how JSON seed files are loaded.
|
|
129
|
+
*
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
export interface IJsonSeedLoadOptions {
|
|
133
|
+
/**
|
|
134
|
+
* Specific keys that should be extracted from the JSON payload.
|
|
135
|
+
* Accepts a single key or a list of keys (dot-notation supported).
|
|
136
|
+
*/
|
|
137
|
+
readonly wrapperKeys?: readonly string[];
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Reference resolution configuration.
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
export interface IJsonReferenceConfig {
|
|
145
|
+
/**
|
|
146
|
+
* Prefix for reference syntax (default: '@ref:').
|
|
147
|
+
*
|
|
148
|
+
* @readonly
|
|
149
|
+
*/
|
|
150
|
+
readonly prefix?: string;
|
|
151
|
+
/**
|
|
152
|
+
* Prefix for asset references (default: '@asset:').
|
|
153
|
+
*
|
|
154
|
+
* @readonly
|
|
155
|
+
*/
|
|
156
|
+
readonly assetPrefix?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Custom resolvers for specific reference types.
|
|
159
|
+
*
|
|
160
|
+
* @readonly
|
|
161
|
+
*/
|
|
162
|
+
readonly resolvers?: Record<string, IJsonReferenceResolver>;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Resolver for a specific reference type.
|
|
166
|
+
*
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
export interface IJsonReferenceResolver {
|
|
170
|
+
/**
|
|
171
|
+
* Resolve a reference key to an actual value (usually an ID).
|
|
172
|
+
*
|
|
173
|
+
* @param key The reference key
|
|
174
|
+
* @param context The seed context
|
|
175
|
+
* @returns The resolved value
|
|
176
|
+
*/
|
|
177
|
+
resolve(_key: string, _context: ISeedContext): Promise<string | number>;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Validation result from JSON schema validation.
|
|
181
|
+
*
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
export interface IJsonValidationResult {
|
|
185
|
+
/**
|
|
186
|
+
* Whether the validation was successful.
|
|
187
|
+
*
|
|
188
|
+
* @readonly
|
|
189
|
+
*/
|
|
190
|
+
readonly isValid: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Validation errors if any.
|
|
193
|
+
*
|
|
194
|
+
* @readonly
|
|
195
|
+
*/
|
|
196
|
+
readonly errors: readonly string[];
|
|
197
|
+
/**
|
|
198
|
+
* Validated data if successful.
|
|
199
|
+
*
|
|
200
|
+
* @readonly
|
|
201
|
+
*/
|
|
202
|
+
readonly data?: unknown;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=JsonSeedTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonSeedTypes.d.ts","sourceRoot":"","sources":["../../src/json/JsonSeedTypes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IAI/D;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAE7C;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAEjD;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAElD;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAE3C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE;QAEd;;W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,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;CAI/D;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IAInC;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;CAI3E;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IAIlC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAEnC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CAI3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonSeedTypes.js","sourceRoot":"","sources":["../../src/json/JsonSeedTypes.ts"],"names":[],"mappings":"AAAA,kBAAkB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IJsonSeedConfig } from './JsonSeedTypes.js';
|
|
2
|
+
import type { ISeeder } from '../config/ISeeder.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a JSON-based seeder that loads data from JSON files.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @template TJson The type of the JSON data
|
|
8
|
+
* @template TPrisma The type of the Prisma input
|
|
9
|
+
* @param config JSON seed configuration
|
|
10
|
+
* @returns A functional seeder that uses JSON files
|
|
11
|
+
*/
|
|
12
|
+
export declare function createJsonSeeder<TJson = unknown, TPrisma = unknown>(config: IJsonSeedConfig<TJson, TPrisma>): ISeeder;
|
|
13
|
+
//# sourceMappingURL=createJsonSeeder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createJsonSeeder.d.ts","sourceRoot":"","sources":["../../src/json/createJsonSeeder.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAUpD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAC/D,MAAM,EAAE,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,GACxC,OAAO,CA0QT"}
|