@slingr/cli 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.
Files changed (144) hide show
  1. package/README.md +320 -0
  2. package/bin/dev.cmd +3 -0
  3. package/bin/dev.js +5 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +5 -0
  6. package/dist/commands/cli-build.d.ts +9 -0
  7. package/dist/commands/cli-build.d.ts.map +1 -0
  8. package/dist/commands/cli-build.js +36 -0
  9. package/dist/commands/cli-build.js.map +1 -0
  10. package/dist/commands/create-app.d.ts +20 -0
  11. package/dist/commands/create-app.d.ts.map +1 -0
  12. package/dist/commands/create-app.js +246 -0
  13. package/dist/commands/create-app.js.map +1 -0
  14. package/dist/commands/ds.d.ts +28 -0
  15. package/dist/commands/ds.d.ts.map +1 -0
  16. package/dist/commands/ds.js +529 -0
  17. package/dist/commands/ds.js.map +1 -0
  18. package/dist/commands/gql.d.ts +22 -0
  19. package/dist/commands/gql.d.ts.map +1 -0
  20. package/dist/commands/gql.js +340 -0
  21. package/dist/commands/gql.js.map +1 -0
  22. package/dist/commands/infra/down.d.ts +13 -0
  23. package/dist/commands/infra/down.d.ts.map +1 -0
  24. package/dist/commands/infra/down.js +80 -0
  25. package/dist/commands/infra/down.js.map +1 -0
  26. package/dist/commands/infra/up.d.ts +13 -0
  27. package/dist/commands/infra/up.d.ts.map +1 -0
  28. package/dist/commands/infra/up.js +69 -0
  29. package/dist/commands/infra/up.js.map +1 -0
  30. package/dist/commands/infra/update.d.ts +14 -0
  31. package/dist/commands/infra/update.d.ts.map +1 -0
  32. package/dist/commands/infra/update.js +321 -0
  33. package/dist/commands/infra/update.js.map +1 -0
  34. package/dist/commands/run.d.ts +19 -0
  35. package/dist/commands/run.d.ts.map +1 -0
  36. package/dist/commands/run.js +315 -0
  37. package/dist/commands/run.js.map +1 -0
  38. package/dist/commands/setup.d.ts +18 -0
  39. package/dist/commands/setup.d.ts.map +1 -0
  40. package/dist/commands/setup.js +189 -0
  41. package/dist/commands/setup.js.map +1 -0
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +8 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/projectStructure.d.ts +10 -0
  47. package/dist/projectStructure.d.ts.map +1 -0
  48. package/dist/projectStructure.js +153 -0
  49. package/dist/projectStructure.js.map +1 -0
  50. package/dist/scripts/generate-schema.d.ts +10 -0
  51. package/dist/scripts/generate-schema.d.ts.map +1 -0
  52. package/dist/scripts/generate-schema.js +130 -0
  53. package/dist/scripts/generate-schema.js.map +1 -0
  54. package/dist/scripts/generate-schema.ts +143 -0
  55. package/dist/templates/.github/copilot-instructions.md.template +17 -0
  56. package/dist/templates/config/datasource.ts.template +9 -0
  57. package/dist/templates/config/jest.config.ts +30 -0
  58. package/dist/templates/config/jest.setup.ts +1 -0
  59. package/dist/templates/config/tsconfig.json.template +30 -0
  60. package/dist/templates/dataSources/mysql.ts.template +13 -0
  61. package/dist/templates/dataSources/postgres.ts.template +13 -0
  62. package/dist/templates/dataset-generator-script.ts.template +140 -0
  63. package/dist/templates/datasets/mysql-default/Address.jsonl.template +4 -0
  64. package/dist/templates/datasets/mysql-default/App.jsonl.template +5 -0
  65. package/dist/templates/datasets/mysql-default/Company.jsonl.template +4 -0
  66. package/dist/templates/datasets/mysql-default/Person.jsonl.template +3 -0
  67. package/dist/templates/datasets/postgres-default/Address.jsonl.template +4 -0
  68. package/dist/templates/datasets/postgres-default/App.jsonl.template +5 -0
  69. package/dist/templates/datasets/postgres-default/Company.jsonl.template +4 -0
  70. package/dist/templates/datasets/postgres-default/Person.jsonl.template +3 -0
  71. package/dist/templates/docs/app-description.md.template +34 -0
  72. package/dist/templates/gql/codegen.yml.template +25 -0
  73. package/dist/templates/gql/index.ts.template +24 -0
  74. package/dist/templates/gql/operations.graphql.template +30 -0
  75. package/dist/templates/package.json.template +38 -0
  76. package/dist/templates/prompt-analysis.md.template +111 -0
  77. package/dist/templates/prompt-script-generation.md.template +259 -0
  78. package/dist/templates/src/Address.ts.template +31 -0
  79. package/dist/templates/src/App.ts.template +61 -0
  80. package/dist/templates/src/Company.ts.template +48 -0
  81. package/dist/templates/src/Models.test.ts.template +655 -0
  82. package/dist/templates/src/Person.test.ts.template +289 -0
  83. package/dist/templates/src/Person.ts.template +105 -0
  84. package/dist/templates/src/actions/index.ts.template +12 -0
  85. package/dist/templates/src/index.ts +66 -0
  86. package/dist/templates/src/types/gql.d.ts.template +18 -0
  87. package/dist/templates/vscode/extensions.json +3 -0
  88. package/dist/templates/vscode/settings.json +11 -0
  89. package/dist/utils/datasourceParser.d.ts +12 -0
  90. package/dist/utils/datasourceParser.d.ts.map +1 -0
  91. package/dist/utils/datasourceParser.js +91 -0
  92. package/dist/utils/datasourceParser.js.map +1 -0
  93. package/dist/utils/jsonlLoader.d.ts +140 -0
  94. package/dist/utils/jsonlLoader.d.ts.map +1 -0
  95. package/dist/utils/jsonlLoader.js +583 -0
  96. package/dist/utils/jsonlLoader.js.map +1 -0
  97. package/dist/utils/model-analyzer.d.ts +86 -0
  98. package/dist/utils/model-analyzer.d.ts.map +1 -0
  99. package/dist/utils/model-analyzer.js +458 -0
  100. package/dist/utils/model-analyzer.js.map +1 -0
  101. package/dist/utils/portChecker.d.ts +36 -0
  102. package/dist/utils/portChecker.d.ts.map +1 -0
  103. package/dist/utils/portChecker.js +308 -0
  104. package/dist/utils/portChecker.js.map +1 -0
  105. package/dist/utils/synthetic-data-generator.d.ts +74 -0
  106. package/dist/utils/synthetic-data-generator.d.ts.map +1 -0
  107. package/dist/utils/synthetic-data-generator.js +443 -0
  108. package/dist/utils/synthetic-data-generator.js.map +1 -0
  109. package/oclif.manifest.json +435 -0
  110. package/package.json +118 -0
  111. package/src/templates/.github/copilot-instructions.md.template +17 -0
  112. package/src/templates/config/datasource.ts.template +9 -0
  113. package/src/templates/config/jest.config.ts +30 -0
  114. package/src/templates/config/jest.setup.ts +1 -0
  115. package/src/templates/config/tsconfig.json.template +30 -0
  116. package/src/templates/dataSources/mysql.ts.template +13 -0
  117. package/src/templates/dataSources/postgres.ts.template +13 -0
  118. package/src/templates/dataset-generator-script.ts.template +140 -0
  119. package/src/templates/datasets/mysql-default/Address.jsonl.template +4 -0
  120. package/src/templates/datasets/mysql-default/App.jsonl.template +5 -0
  121. package/src/templates/datasets/mysql-default/Company.jsonl.template +4 -0
  122. package/src/templates/datasets/mysql-default/Person.jsonl.template +3 -0
  123. package/src/templates/datasets/postgres-default/Address.jsonl.template +4 -0
  124. package/src/templates/datasets/postgres-default/App.jsonl.template +5 -0
  125. package/src/templates/datasets/postgres-default/Company.jsonl.template +4 -0
  126. package/src/templates/datasets/postgres-default/Person.jsonl.template +3 -0
  127. package/src/templates/docs/app-description.md.template +34 -0
  128. package/src/templates/gql/codegen.yml.template +25 -0
  129. package/src/templates/gql/index.ts.template +24 -0
  130. package/src/templates/gql/operations.graphql.template +30 -0
  131. package/src/templates/package.json.template +38 -0
  132. package/src/templates/prompt-analysis.md.template +111 -0
  133. package/src/templates/prompt-script-generation.md.template +259 -0
  134. package/src/templates/src/Address.ts.template +31 -0
  135. package/src/templates/src/App.ts.template +61 -0
  136. package/src/templates/src/Company.ts.template +48 -0
  137. package/src/templates/src/Models.test.ts.template +655 -0
  138. package/src/templates/src/Person.test.ts.template +289 -0
  139. package/src/templates/src/Person.ts.template +105 -0
  140. package/src/templates/src/actions/index.ts.template +12 -0
  141. package/src/templates/src/index.ts +66 -0
  142. package/src/templates/src/types/gql.d.ts.template +18 -0
  143. package/src/templates/vscode/extensions.json +3 -0
  144. package/src/templates/vscode/settings.json +11 -0
@@ -0,0 +1,140 @@
1
+ import { BaseModel, TypeOrmSqlDataSource } from 'slingr-framework';
2
+ import 'reflect-metadata';
3
+ /**
4
+ * Interface for model constructors that extend BaseModel
5
+ */
6
+ export interface ModelConstructor<T extends BaseModel> {
7
+ new (): T;
8
+ fromJSON(data: any): T;
9
+ prototype: T;
10
+ }
11
+ /**
12
+ * Interface for dataset loading options
13
+ */
14
+ export interface DatasetLoadOptions {
15
+ /**
16
+ * Directory containing the JSONL files
17
+ */
18
+ datasetPath: string;
19
+ /**
20
+ * Map of model name to model constructor
21
+ * Key: filename without .jsonl extension
22
+ * Value: Model constructor class
23
+ */
24
+ modelMap: Record<string, ModelConstructor<any>>;
25
+ /**
26
+ * Whether to validate each record after loading from JSON
27
+ * @default true
28
+ */
29
+ validateRecords?: boolean;
30
+ /**
31
+ * Whether to log detailed information during loading
32
+ * @default false
33
+ */
34
+ verbose?: boolean;
35
+ }
36
+ /**
37
+ * Interface for model dependency information
38
+ */
39
+ export interface ModelDependency {
40
+ modelName: string;
41
+ dependencies: string[];
42
+ dependents: string[];
43
+ }
44
+ /**
45
+ * Interface for dependency analysis result
46
+ */
47
+ export interface DependencyAnalysisResult {
48
+ dependencies: Record<string, ModelDependency>;
49
+ loadOrder: string[];
50
+ }
51
+ /**
52
+ * Result of loading a dataset
53
+ */
54
+ export interface DatasetLoadResult<T extends BaseModel = BaseModel> {
55
+ /**
56
+ * Name of the model/file that was loaded
57
+ */
58
+ modelName: string;
59
+ /**
60
+ * Array of loaded and converted model instances
61
+ */
62
+ records: T[];
63
+ /**
64
+ * Number of records successfully loaded
65
+ */
66
+ successCount: number;
67
+ /**
68
+ * Number of records that failed to load
69
+ */
70
+ errorCount: number;
71
+ /**
72
+ * Array of validation errors if any
73
+ */
74
+ errors: Array<{
75
+ recordIndex: number;
76
+ recordData: any;
77
+ validationErrors: any[];
78
+ }>;
79
+ }
80
+ /**
81
+ * Utility class for loading datasets from JSONL files using Slingr model fromJSON() functionality
82
+ */
83
+ export declare class JsonlDatasetLoader {
84
+ /**
85
+ * Analyze model dependencies to determine the correct loading order
86
+ */
87
+ analyzeDependencies(modelMap: Record<string, ModelConstructor<any>>, verbose?: boolean): DependencyAnalysisResult;
88
+ /**
89
+ * Extract dependencies from a model class by analyzing its decorators/metadata
90
+ */
91
+ private extractModelDependencies;
92
+ /**
93
+ * Perform topological sort to determine loading order
94
+ */
95
+ private topologicalSort;
96
+ /**
97
+ * Load all JSONL files from a dataset directory
98
+ */
99
+ loadDataset(options: DatasetLoadOptions): Promise<DatasetLoadResult[]>;
100
+ /**
101
+ * Load a single JSONL file and convert records using the model's fromJSON method
102
+ */
103
+ /**
104
+ * Resolves simple references in format {"id": "uuid"} to full objects from loaded entities
105
+ */
106
+ resolveSimpleReferences<T extends BaseModel>(data: any, ModelClass: ModelConstructor<T>, loadedEntities: Record<string, Record<string, any>>, verbose?: boolean): Promise<any>;
107
+ loadJsonlFile<T extends BaseModel>(filePath: string, ModelClass: ModelConstructor<T>, modelName: string, loadedEntities: Record<string, Record<string, any>>, validateRecords?: boolean, verbose?: boolean): Promise<DatasetLoadResult<T>>;
108
+ /**
109
+ * Convert loaded model instances to database-friendly format
110
+ * This method respects the model's field availability settings and converts camelCase to snake_case
111
+ */
112
+ convertToDbFormat<T extends BaseModel>(records: T[], verbose?: boolean): any[];
113
+ /**
114
+ * Convert camelCase string to snake_case
115
+ */
116
+ private camelToSnakeCase;
117
+ /**
118
+ * Load dataset into database using TypeORM with dynamic table creation
119
+ * This method creates tables dynamically and uses TypeORM for data insertion
120
+ * Note: Results should already be in dependency order from loadDataset()
121
+ */
122
+ loadDatasetToDatabase(results: DatasetLoadResult[], dataSource: TypeOrmSqlDataSource, verbose?: boolean): Promise<void>;
123
+ /**
124
+ * Create table dynamically using TypeORM (database-agnostic)
125
+ */
126
+ private createTableDynamically;
127
+ /**
128
+ * Insert data dynamically using TypeORM (database-agnostic)
129
+ */
130
+ private insertDataDynamically;
131
+ /**
132
+ * Get the database column schema based on ALL records to capture all possible fields
133
+ */
134
+ inferDbSchemaFromAllRecords(records: any[]): Record<string, string>;
135
+ }
136
+ /**
137
+ * Auto-discover models from the compiled JavaScript files
138
+ */
139
+ export declare function discoverModels(distPath: string): Promise<Record<string, ModelConstructor<any>>>;
140
+ //# sourceMappingURL=jsonlLoader.d.ts.map
@@ -0,0 +1 @@
1
+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