@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,110 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
// #endregion
|
|
3
|
+
/**
|
|
4
|
+
* Service for analyzing Prisma models and providing context for AI generation.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export class PrismaModelAnalyzer {
|
|
9
|
+
_prisma;
|
|
10
|
+
// #region Ctor
|
|
11
|
+
constructor(_prisma) {
|
|
12
|
+
this._prisma = _prisma;
|
|
13
|
+
}
|
|
14
|
+
// #endregion
|
|
15
|
+
// #region Methods
|
|
16
|
+
/**
|
|
17
|
+
* Analyze a Prisma model and extract schema information.
|
|
18
|
+
*/
|
|
19
|
+
async analyzeModel(modelName) {
|
|
20
|
+
const modelSchema = await this._extractModelSchema(modelName);
|
|
21
|
+
const existingData = await this._getExistingData(modelName);
|
|
22
|
+
const relatedData = await this._getRelatedData(modelName);
|
|
23
|
+
const constraints = await this._getModelConstraints(modelName);
|
|
24
|
+
return {
|
|
25
|
+
modelSchema,
|
|
26
|
+
existingData,
|
|
27
|
+
relatedData,
|
|
28
|
+
constraints
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Extract the schema definition for a Prisma model.
|
|
33
|
+
*/
|
|
34
|
+
async _extractModelSchema(modelName) {
|
|
35
|
+
// This would use Prisma's internal schema introspection
|
|
36
|
+
// For now, we'll return a basic structure based on common models
|
|
37
|
+
// Get the model delegate
|
|
38
|
+
const modelDelegate = this._prisma[this._toCamelCase(modelName)];
|
|
39
|
+
if (!modelDelegate) {
|
|
40
|
+
throw new Error(`Model ${modelName} not found in Prisma client`);
|
|
41
|
+
}
|
|
42
|
+
return {};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get existing data for uniqueness validation.
|
|
46
|
+
*/
|
|
47
|
+
async _getExistingData(modelName) {
|
|
48
|
+
const modelDelegate = this._prisma[this._toCamelCase(modelName)];
|
|
49
|
+
if (!modelDelegate) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
// Get a sample of existing data (limit for performance)
|
|
54
|
+
const data = await modelDelegate.findMany({
|
|
55
|
+
take: 1000,
|
|
56
|
+
select: {}
|
|
57
|
+
});
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get related data from other models that this model references.
|
|
66
|
+
*/
|
|
67
|
+
async _getRelatedData(modelName) {
|
|
68
|
+
const relations = [];
|
|
69
|
+
const relatedData = {};
|
|
70
|
+
for (const relation of relations) {
|
|
71
|
+
try {
|
|
72
|
+
const modelDelegate = this._prisma[this._toCamelCase(relation.targetModel)];
|
|
73
|
+
if (modelDelegate) {
|
|
74
|
+
const data = await modelDelegate.findMany({
|
|
75
|
+
take: 100,
|
|
76
|
+
select: {
|
|
77
|
+
id: true,
|
|
78
|
+
...relation.fields
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
relatedData[relation.targetModel] = data;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Ignore errors for missing relations
|
|
86
|
+
relatedData[relation.targetModel] = [];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return relatedData;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get database constraints for the model.
|
|
93
|
+
*/
|
|
94
|
+
async _getModelConstraints(modelName) {
|
|
95
|
+
// This would analyze unique constraints, foreign keys, etc.
|
|
96
|
+
// For now, return basic constraints based on common patterns
|
|
97
|
+
return {
|
|
98
|
+
uniqueFields: {},
|
|
99
|
+
requiredFields: {},
|
|
100
|
+
foreignKeys: {}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Convert model name to camelCase for Prisma client access.
|
|
105
|
+
*/
|
|
106
|
+
_toCamelCase(modelName) {
|
|
107
|
+
return modelName.charAt(0).toLowerCase() + modelName.slice(1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=PrismaModelAnalyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismaModelAnalyzer.js","sourceRoot":"","sources":["../../src/ai/PrismaModelAnalyzer.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAKlB,aAAa;AAEb;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAKP;IAHrB,eAAe;IAEf,YACqB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IACtC,CAAC;IAEL,aAAa;IAEb,kBAAkB;IAElB;;OAEG;IACI,KAAK,CAAC,YAAY,CAAC,SAAiB;QACvC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAC9D,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAC5D,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;QAE/D,OAAO;YACH,WAAW;YACX,YAAY;YACZ,WAAW;YACX,WAAW;SACd,CAAC;IACN,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,mBAAmB,CAAC,SAAiB;QAC/C,wDAAwD;QACxD,iEAAiE;QAEjE,yBAAyB;QACzB,MAAM,aAAa,GAAI,IAAI,CAAC,OAAe,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,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MAAM,CAAC;gBACL,sCAAsC;gBACtC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;YAC3C,CAAC;QACL,CAAC;QAED,OAAO,WAAW,CAAC;IACvB,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,oBAAoB,CAAC,SAAiB;QAChD,4DAA4D;QAC5D,6DAA6D;QAC7D,OAAO;YACH,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,EAAE;YAClB,WAAW,EAAE,EAAE;SAClB,CAAC;IACN,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,SAAiB;QAClC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;CAIJ"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Type-safe schema generator that uses Prisma model types.
|
|
4
|
+
* No external dependencies needed in seed configs - just specify the Prisma model type.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PrismaTypeSchemaGenerator {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a Zod schema for basic Prisma model structure.
|
|
9
|
+
* This is a runtime helper that provides common field types.
|
|
10
|
+
*/
|
|
11
|
+
static createBasicSchema(): z.ZodObject<Record<string, z.ZodTypeAny>>;
|
|
12
|
+
/**
|
|
13
|
+
* Extends the basic schema with model-specific fields.
|
|
14
|
+
* Users can call this and specify their fields based on their Prisma model.
|
|
15
|
+
*/
|
|
16
|
+
static extendSchema(fields: Record<string, z.ZodTypeAny>): z.ZodObject<any>;
|
|
17
|
+
/**
|
|
18
|
+
* Common field types for easy schema construction.
|
|
19
|
+
*/
|
|
20
|
+
static readonly Fields: {
|
|
21
|
+
email: () => z.ZodString;
|
|
22
|
+
username: (min?: number, max?: number) => z.ZodString;
|
|
23
|
+
name: (max?: number) => z.ZodString;
|
|
24
|
+
text: (max?: number) => z.ZodString;
|
|
25
|
+
url: () => z.ZodString;
|
|
26
|
+
uuid: () => z.ZodString;
|
|
27
|
+
cuid: () => z.ZodString;
|
|
28
|
+
int: (min?: number, max?: number) => z.ZodNumber;
|
|
29
|
+
float: (min?: number, max?: number) => z.ZodNumber;
|
|
30
|
+
boolean: () => z.ZodBoolean;
|
|
31
|
+
date: () => z.ZodDate;
|
|
32
|
+
optional: <T extends z.ZodTypeAny>(field: T) => z.ZodOptional<T>;
|
|
33
|
+
nullable: <T extends z.ZodTypeAny>(field: T) => z.ZodNullable<T>;
|
|
34
|
+
enum: <T extends readonly [string, ...string[]]>(values: T) => z.ZodEnum<{ [k_1 in T[number]]: k_1; } extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never>;
|
|
35
|
+
array: <T extends z.ZodTypeAny>(itemSchema: T) => z.ZodArray<T>;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=PrismaTypeSchemaGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismaTypeSchemaGenerator.d.ts","sourceRoot":"","sources":["../../src/ai/PrismaTypeSchemaGenerator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;GAGG;AACH,qBAAa,yBAAyB;IAElC;;;OAGG;WACW,iBAAiB,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;IAS5E;;;OAGG;WACW,YAAY,CACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,GACrC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC;IAInB;;OAEG;IACH,gBAAuB,MAAM;;;;;;;;oBAab,MAAM,QAAQ,MAAM;sBAMlB,MAAM,QAAQ,MAAM;;;mBAYvB,CAAC,SAAS,CAAC,CAAC,UAAU,SAAS,CAAC;mBAChC,CAAC,SAAS,CAAC,CAAC,UAAU,SAAS,CAAC;eAGpC,CAAC,SAAS,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC;gBAGlD,CAAC,SAAS,CAAC,CAAC,UAAU,cAAc,CAAC;MAC/C;CAEL"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
// #endregion
|
|
4
|
+
/**
|
|
5
|
+
* Type-safe schema generator that uses Prisma model types.
|
|
6
|
+
* No external dependencies needed in seed configs - just specify the Prisma model type.
|
|
7
|
+
*/
|
|
8
|
+
export class PrismaTypeSchemaGenerator {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a Zod schema for basic Prisma model structure.
|
|
11
|
+
* This is a runtime helper that provides common field types.
|
|
12
|
+
*/
|
|
13
|
+
static createBasicSchema() {
|
|
14
|
+
return z.object({
|
|
15
|
+
id: z.string().cuid()
|
|
16
|
+
.optional(),
|
|
17
|
+
createdAt: z.date().optional(),
|
|
18
|
+
updatedAt: z.date().optional()
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Extends the basic schema with model-specific fields.
|
|
23
|
+
* Users can call this and specify their fields based on their Prisma model.
|
|
24
|
+
*/
|
|
25
|
+
static extendSchema(fields) {
|
|
26
|
+
return this.createBasicSchema().extend(fields);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Common field types for easy schema construction.
|
|
30
|
+
*/
|
|
31
|
+
static Fields = {
|
|
32
|
+
// String fields
|
|
33
|
+
email: () => z.string().email(),
|
|
34
|
+
username: (min = 3, max = 50) => z.string().min(min)
|
|
35
|
+
.max(max),
|
|
36
|
+
name: (max = 100) => z.string().min(1)
|
|
37
|
+
.max(max),
|
|
38
|
+
text: (max = 1000) => z.string().max(max),
|
|
39
|
+
url: () => z.string().url(),
|
|
40
|
+
uuid: () => z.string().uuid(),
|
|
41
|
+
cuid: () => z.string().cuid(),
|
|
42
|
+
// Number fields
|
|
43
|
+
int: (min, max) => {
|
|
44
|
+
let schema = z.number().int();
|
|
45
|
+
if (min !== undefined)
|
|
46
|
+
schema = schema.min(min);
|
|
47
|
+
if (max !== undefined)
|
|
48
|
+
schema = schema.max(max);
|
|
49
|
+
return schema;
|
|
50
|
+
},
|
|
51
|
+
float: (min, max) => {
|
|
52
|
+
let schema = z.number();
|
|
53
|
+
if (min !== undefined)
|
|
54
|
+
schema = schema.min(min);
|
|
55
|
+
if (max !== undefined)
|
|
56
|
+
schema = schema.max(max);
|
|
57
|
+
return schema;
|
|
58
|
+
},
|
|
59
|
+
// Boolean and Date
|
|
60
|
+
boolean: () => z.boolean(),
|
|
61
|
+
date: () => z.date(),
|
|
62
|
+
// Optional variations
|
|
63
|
+
optional: (field) => field.optional(),
|
|
64
|
+
nullable: (field) => field.nullable(),
|
|
65
|
+
// Enums
|
|
66
|
+
enum: (values) => z.enum(values),
|
|
67
|
+
// Arrays
|
|
68
|
+
array: (itemSchema) => z.array(itemSchema)
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=PrismaTypeSchemaGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismaTypeSchemaGenerator.js","sourceRoot":"","sources":["../../src/ai/PrismaTypeSchemaGenerator.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,aAAa;AAEb;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IAElC;;;OAGG;IACI,MAAM,CAAC,iBAAiB;QAC3B,OAAO,CAAC,CAAC,MAAM,CAAC;YACZ,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;iBAChB,QAAQ,EAAE;YACf,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;YAC9B,SAAS,EAAE,CAAC,CAAC,IAAI,E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AAI,GAAG,KAAK,SAAS;gBAAE,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAChD,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,KAAK,EAAE,CAAC,GAAY,EAAE,GAAY,EAAE,EAAE;YAClC,IAAI,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;YACxB,IAAI,GAAG,KAAK,SAAS;gBAAE,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAChD,IAAI,GAAG,KAAK,SAAS;gBAAE,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAChD,OAAO,MAAM,CAAC;QAClB,CAAC;QAED,mBAAmB;QACnB,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE;QAC1B,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE;QAEpB,sBAAsB;QACtB,QAAQ,EAAE,CAAyB,KAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE;QAChE,QAAQ,EAAE,CAAyB,KAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE;QAEhE,QAAQ;QACR,IAAI,EAAE,CAA2C,MAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAE7E,SAAS;QACT,KAAK,EAAE,CAAyB,UAAa,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;KACxE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IAISeedConfig } from './AISeedTypes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create an AI-powered seeder that generates entities using language models.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
* @template T The type of the entity to be generated
|
|
7
|
+
* @param config AI seed configuration
|
|
8
|
+
* @returns A functional seeder that uses AI to generate data
|
|
9
|
+
*/
|
|
10
|
+
export declare function createAISeeder<T>(config: IAISeedConfig<T>): import("../index.js").ISeeder;
|
|
11
|
+
//# sourceMappingURL=createAISeeder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAISeeder.d.ts","sourceRoot":"","sources":["../../src/ai/createAISeeder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAStD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,iCA4CzD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
import { createFunctionalSeeder } from '../base/functionalSeeder.js';
|
|
3
|
+
import { AISeedGenerator } from './AISeedGenerator.js';
|
|
4
|
+
// #endregion
|
|
5
|
+
/**
|
|
6
|
+
* Create an AI-powered seeder that generates entities using language models.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @template T The type of the entity to be generated
|
|
10
|
+
* @param config AI seed configuration
|
|
11
|
+
* @returns A functional seeder that uses AI to generate data
|
|
12
|
+
*/
|
|
13
|
+
export function createAISeeder(config) {
|
|
14
|
+
return createFunctionalSeeder({
|
|
15
|
+
name: `ai-${config.schema.modelName}-generator`,
|
|
16
|
+
run: async (context, utilities) => {
|
|
17
|
+
const generator = new AISeedGenerator(context.prisma);
|
|
18
|
+
return await generator.generateEntities(config, context, utilities);
|
|
19
|
+
},
|
|
20
|
+
validate: async (context) => {
|
|
21
|
+
// Basic validation - check if AI generation is possible
|
|
22
|
+
if (!config.enabled) {
|
|
23
|
+
return true; // Skip validation if AI is disabled
|
|
24
|
+
}
|
|
25
|
+
// Check if the model exists in Prisma
|
|
26
|
+
const modelName = config.schema.modelName.charAt(0).toLowerCase() + config.schema.modelName.slice(1);
|
|
27
|
+
const modelDelegate = context.prisma[modelName];
|
|
28
|
+
if (!modelDelegate) {
|
|
29
|
+
context.logger.warn(`Model ${config.schema.modelName} not found in Prisma client`);
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
// Check if AI provider is configured
|
|
33
|
+
const providerKey = config.provider.apiKey || getProviderEnvKey(config.provider.provider);
|
|
34
|
+
if (!providerKey && !process.env[getProviderEnvKey(config.provider.provider)]) {
|
|
35
|
+
context.logger.warn(`AI provider ${config.provider.provider} not configured - missing API key`);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
},
|
|
40
|
+
cleanup: async (context) => {
|
|
41
|
+
// Clean up generated entities if needed
|
|
42
|
+
if (config.enabled) {
|
|
43
|
+
const modelName = config.schema.modelName.charAt(0).toLowerCase() + config.schema.modelName.slice(1);
|
|
44
|
+
const modelDelegate = context.prisma[modelName];
|
|
45
|
+
if (modelDelegate) {
|
|
46
|
+
context.logger.debug(`Cleaning up AI-generated ${config.schema.modelName} data...`);
|
|
47
|
+
await modelDelegate.deleteMany({});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get the environment variable key for the given AI provider
|
|
55
|
+
*
|
|
56
|
+
* @private
|
|
57
|
+
* @param provider The AI provider name
|
|
58
|
+
* @returns The corresponding environment variable key
|
|
59
|
+
*/
|
|
60
|
+
function getProviderEnvKey(provider) {
|
|
61
|
+
switch (provider) {
|
|
62
|
+
case 'openai':
|
|
63
|
+
return 'OPENAI_API_KEY';
|
|
64
|
+
case 'anthropic':
|
|
65
|
+
return 'ANTHROPIC_API_KEY';
|
|
66
|
+
case 'google':
|
|
67
|
+
return 'GOOGLE_API_KEY';
|
|
68
|
+
default:
|
|
69
|
+
return `${provider.toUpperCase()}_API_KEY`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=createAISeeder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAISeeder.js","sourceRoot":"","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;IACnD,CAAC;AACL,CAAC"}
|
package/ai/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { IAIProviderConfig, IAIGenerationContext, IAISeedSchema, IAISeedConfig, IAISeedExecutionContext } from './AISeedTypes.js';
|
|
2
|
+
export { AISeedGenerator } from './AISeedGenerator.js';
|
|
3
|
+
export { PrismaModelAnalyzer } from './PrismaModelAnalyzer.js';
|
|
4
|
+
export { PrismaTypeSchemaGenerator } from './PrismaTypeSchemaGenerator.js';
|
|
5
|
+
export { createAISeeder } from './createAISeeder.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,aAAa,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACvI,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
package/ai/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AISeedGenerator } from './AISeedGenerator.js';
|
|
2
|
+
export { PrismaModelAnalyzer } from './PrismaModelAnalyzer.js';
|
|
3
|
+
export { PrismaTypeSchemaGenerator } from './PrismaTypeSchemaGenerator.js';
|
|
4
|
+
export { createAISeeder } from './createAISeeder.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
package/ai/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { ISeedLogger } from '../logging/ISeedLogger';
|
|
2
|
+
import type { IBlobAdapter } from './adapters/interfaces/IBlobAdapter.js';
|
|
3
|
+
import type { IImageTransformOptions } from './IImageTransformOptions.js';
|
|
4
|
+
export declare const AssetImageTransformMatchKinds: {
|
|
5
|
+
readonly Exact: "exact";
|
|
6
|
+
readonly Prefix: "prefix";
|
|
7
|
+
readonly Extension: "extension";
|
|
8
|
+
};
|
|
9
|
+
export type AssetImageTransformMatchKind = typeof AssetImageTransformMatchKinds[keyof typeof AssetImageTransformMatchKinds];
|
|
10
|
+
export interface IAssetImageTransformRule {
|
|
11
|
+
/**
|
|
12
|
+
* Match evaluation strategy.
|
|
13
|
+
*/
|
|
14
|
+
readonly match: AssetImageTransformMatchKind;
|
|
15
|
+
/**
|
|
16
|
+
* Pattern interpreted according to the configured match strategy.
|
|
17
|
+
*/
|
|
18
|
+
readonly pattern: string;
|
|
19
|
+
/**
|
|
20
|
+
* Transformation options applied when the rule matches.
|
|
21
|
+
*/
|
|
22
|
+
readonly options: IImageTransformOptions;
|
|
23
|
+
}
|
|
24
|
+
export interface IAssetImageTransformConfiguration {
|
|
25
|
+
/**
|
|
26
|
+
* Fallback transformation applied when no rule matches.
|
|
27
|
+
*/
|
|
28
|
+
readonly defaultOptions?: IImageTransformOptions;
|
|
29
|
+
/**
|
|
30
|
+
* Ordered set of matching rules used to determine transformations.
|
|
31
|
+
*/
|
|
32
|
+
readonly rules?: readonly IAssetImageTransformRule[];
|
|
33
|
+
}
|
|
34
|
+
export interface IAssetManagerOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Base directory containing seed assets (defaults to `.seed/assets`)
|
|
37
|
+
*/
|
|
38
|
+
assetsDir?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to upload assets to blob storage during seeding
|
|
41
|
+
*/
|
|
42
|
+
uploadToBlob?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Blob adapter for files (optional)
|
|
45
|
+
*/
|
|
46
|
+
blobAdapter?: IBlobAdapter | null;
|
|
47
|
+
/**
|
|
48
|
+
* Optional image transformation configuration executed before uploads.
|
|
49
|
+
*/
|
|
50
|
+
imageTransforms?: IAssetImageTransformConfiguration;
|
|
51
|
+
}
|
|
52
|
+
export interface IAssetInfo {
|
|
53
|
+
/**
|
|
54
|
+
* Relative path from assets directory
|
|
55
|
+
*/
|
|
56
|
+
relativePath: string;
|
|
57
|
+
/**
|
|
58
|
+
* Absolute file system path
|
|
59
|
+
*/
|
|
60
|
+
absolutePath: string;
|
|
61
|
+
/**
|
|
62
|
+
* File name without extension
|
|
63
|
+
*/
|
|
64
|
+
name: string;
|
|
65
|
+
/**
|
|
66
|
+
* File extension (including dot)
|
|
67
|
+
*/
|
|
68
|
+
extension: string;
|
|
69
|
+
/**
|
|
70
|
+
* File size in bytes
|
|
71
|
+
*/
|
|
72
|
+
size: number;
|
|
73
|
+
/**
|
|
74
|
+
* MIME type (detected from extension)
|
|
75
|
+
*/
|
|
76
|
+
mimeType: string;
|
|
77
|
+
}
|
|
78
|
+
export interface IAssetUploadResult {
|
|
79
|
+
/**
|
|
80
|
+
* Original asset information
|
|
81
|
+
*/
|
|
82
|
+
asset: IAssetInfo;
|
|
83
|
+
/**
|
|
84
|
+
* Generated blob key
|
|
85
|
+
*/
|
|
86
|
+
key: string;
|
|
87
|
+
/**
|
|
88
|
+
* Public URL to access the asset
|
|
89
|
+
*/
|
|
90
|
+
url: string;
|
|
91
|
+
/**
|
|
92
|
+
* Upload metadata
|
|
93
|
+
*/
|
|
94
|
+
metadata: Record<string, unknown>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Manages asset discovery, upload, and URL generation for seed operations.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export declare class AssetManager {
|
|
102
|
+
private readonly _options;
|
|
103
|
+
private readonly _logger;
|
|
104
|
+
private readonly _discoveredAssets;
|
|
105
|
+
private readonly _uploadedAssets;
|
|
106
|
+
private static readonly _validResizeFits;
|
|
107
|
+
private static readonly _formatContentTypeMap;
|
|
108
|
+
/**
|
|
109
|
+
* Constructs a new instance of the AssetManager class.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
constructor(logger: ISeedLogger, options?: IAssetManagerOptions);
|
|
114
|
+
/**
|
|
115
|
+
* Reconfigures the blob adapter for this AssetManager instance.
|
|
116
|
+
* This allows switching adapters between different feature asset processing runs.
|
|
117
|
+
*
|
|
118
|
+
* @public
|
|
119
|
+
* @param blobAdapter The new blob adapter to use
|
|
120
|
+
*/
|
|
121
|
+
reconfigureBlobAdapter(blobAdapter: IBlobAdapter | null): void;
|
|
122
|
+
/**
|
|
123
|
+
* Discovers all assets in the configured assets directory.
|
|
124
|
+
*
|
|
125
|
+
* @public
|
|
126
|
+
* @param seedConfigPath Path to the seed configuration file (for resolving assets directory)
|
|
127
|
+
* @returns Promise that resolves when discovery is complete
|
|
128
|
+
*/
|
|
129
|
+
discoverAssets(seedConfigPath: string): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Gets asset information by relative path.
|
|
132
|
+
*
|
|
133
|
+
* @public
|
|
134
|
+
* @param relativePath The relative path of the asset
|
|
135
|
+
* @returns The asset information or undefined if not found
|
|
136
|
+
*/
|
|
137
|
+
getAssetInfo(relativePath: string): IAssetInfo | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Gets the URL for an uploaded asset by key.
|
|
140
|
+
*
|
|
141
|
+
* @public
|
|
142
|
+
* @param key The asset key
|
|
143
|
+
* @returns The asset URL or undefined if not found
|
|
144
|
+
*/
|
|
145
|
+
getAsset(key: string): string | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* Resolves an asset URL by its key. Alias for getAsset().
|
|
148
|
+
* Automatically strips @asset: prefix if present.
|
|
149
|
+
*
|
|
150
|
+
* @public
|
|
151
|
+
* @param key The asset key (with or without @asset: prefix)
|
|
152
|
+
* @returns The asset URL or undefined if not found
|
|
153
|
+
*/
|
|
154
|
+
resolve(key: string | undefined): string | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* Gets all assets in a specific subdirectory.
|
|
157
|
+
*
|
|
158
|
+
* @public
|
|
159
|
+
* @param subDir The subdirectory to filter assets by
|
|
160
|
+
* @returns Assets within the specified subdirectory
|
|
161
|
+
*/
|
|
162
|
+
getAssetsInDirectory(subDir: string): IAssetInfo[];
|
|
163
|
+
/**
|
|
164
|
+
* Gets all discovered assets.
|
|
165
|
+
*
|
|
166
|
+
* @public
|
|
167
|
+
* @returns All discovered assets
|
|
168
|
+
*/
|
|
169
|
+
getAllAssets(): IAssetInfo[];
|
|
170
|
+
/**
|
|
171
|
+
* Uploads assets to blob storage.
|
|
172
|
+
*
|
|
173
|
+
* @public
|
|
174
|
+
* @param assets The assets to upload
|
|
175
|
+
* @returns The upload results
|
|
176
|
+
*/
|
|
177
|
+
uploadAssets(assets: IAssetInfo[]): Promise<IAssetUploadResult[]>;
|
|
178
|
+
/**
|
|
179
|
+
* Processes asset file mappings - discovers and uploads assets based on configuration.
|
|
180
|
+
*
|
|
181
|
+
* @public
|
|
182
|
+
* @param seedConfigPath Path to the seed configuration file (for resolving assets directory)
|
|
183
|
+
* @param fileMap Optional mapping of keys to asset paths or directories
|
|
184
|
+
* @returns Promise that resolves when processing is complete
|
|
185
|
+
*/
|
|
186
|
+
processAssets(seedConfigPath: string, fileMap?: Record<string, string>): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Gets a random asset URL from a directory prefix.
|
|
189
|
+
*
|
|
190
|
+
* @public
|
|
191
|
+
* @param directoryPrefix The directory prefix to filter assets by
|
|
192
|
+
* @param random Optional random function (defaults to Math.random)
|
|
193
|
+
* @returns A random asset URL or undefined if none found
|
|
194
|
+
*/
|
|
195
|
+
getRandomAssetUrl(directoryPrefix: string, random?: () => number): string | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* Sets a custom blob adapter for asset uploads.
|
|
198
|
+
*
|
|
199
|
+
* @public
|
|
200
|
+
* @param adapter The blob adapter to use (or null to disable)
|
|
201
|
+
*/
|
|
202
|
+
setBlobAdapter(adapter: IBlobAdapter | null): void;
|
|
203
|
+
private _discoverAssetsRecursive;
|
|
204
|
+
private _getMimeType;
|
|
205
|
+
private _optimizeAssetBuffer;
|
|
206
|
+
private _resolveImageTransformOptions;
|
|
207
|
+
private _doesRuleApply;
|
|
208
|
+
private _validateImageTransformOptions;
|
|
209
|
+
private _createResizeOptions;
|
|
210
|
+
private _createFormatOptions;
|
|
211
|
+
private _resolveImageContentType;
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=AssetManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssetManager.d.ts","sourceRoot":"","sources":["../../src/assets/AssetManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAE1E,OAAO,KAAK,EAAE,sBAAsB,EAAqC,MAAM,6BAA6B,CAAC;AAO7G,eAAO,MAAM,6BAA6B;;;;CAIhC,CAAC;AAEX,MAAM,MAAM,4BAA4B,GAAG,OAAO,6BAA6B,CAAC,MAAM,OAAO,6BAA6B,CAAC,CAAC;AAE5H,MAAM,WAAW,wBAAwB;IAErC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,4BAA4B,CAAC;IAE7C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;CAE5C;AAED,MAAM,WAAW,iCA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