@rxap/plugin-llm 20.0.0-dev.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 (69) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/GETSTARTED.md +0 -0
  3. package/GUIDES.md +0 -0
  4. package/LICENSE.md +621 -0
  5. package/README.md +11 -0
  6. package/generators.json +36 -0
  7. package/package.json +49 -0
  8. package/src/generators/documentation/generator.d.ts +4 -0
  9. package/src/generators/documentation/generator.js +187 -0
  10. package/src/generators/documentation/generator.js.map +1 -0
  11. package/src/generators/documentation/index.d.ts +2 -0
  12. package/src/generators/documentation/index.js +7 -0
  13. package/src/generators/documentation/index.js.map +1 -0
  14. package/src/generators/documentation/schema.d.ts +13 -0
  15. package/src/generators/documentation/schema.json +34 -0
  16. package/src/generators/documentation/system-prompts/context.xsd +35 -0
  17. package/src/generators/documentation/system-prompts/exmaple.txt +134 -0
  18. package/src/generators/documentation/system-prompts/generic.txt +242 -0
  19. package/src/generators/init/generator.d.ts +4 -0
  20. package/src/generators/init/generator.js +105 -0
  21. package/src/generators/init/generator.js.map +1 -0
  22. package/src/generators/init/index.d.ts +2 -0
  23. package/src/generators/init/index.js +7 -0
  24. package/src/generators/init/index.js.map +1 -0
  25. package/src/generators/init/schema.d.ts +3 -0
  26. package/src/generators/init/schema.json +8 -0
  27. package/src/generators/package-description/generator.d.ts +4 -0
  28. package/src/generators/package-description/generator.js +53 -0
  29. package/src/generators/package-description/generator.js.map +1 -0
  30. package/src/generators/package-description/index.d.ts +2 -0
  31. package/src/generators/package-description/index.js +7 -0
  32. package/src/generators/package-description/index.js.map +1 -0
  33. package/src/generators/package-description/schema.d.ts +15 -0
  34. package/src/generators/package-description/schema.json +37 -0
  35. package/src/generators/package-description/system-prompts/generic.txt +44 -0
  36. package/src/index.d.ts +0 -0
  37. package/src/index.js +1 -0
  38. package/src/index.js.map +1 -0
  39. package/src/lib/__snapshots__/cleanup-js-doc.spec.ts.snap +32 -0
  40. package/src/lib/add-js-doc.d.ts +2 -0
  41. package/src/lib/add-js-doc.js +7 -0
  42. package/src/lib/add-js-doc.js.map +1 -0
  43. package/src/lib/assert-token-limit.d.ts +2 -0
  44. package/src/lib/assert-token-limit.js +13 -0
  45. package/src/lib/assert-token-limit.js.map +1 -0
  46. package/src/lib/cleanup-js-doc.d.ts +1 -0
  47. package/src/lib/cleanup-js-doc.js +26 -0
  48. package/src/lib/cleanup-js-doc.js.map +1 -0
  49. package/src/lib/clear-all-js-docs.d.ts +2 -0
  50. package/src/lib/clear-all-js-docs.js +23 -0
  51. package/src/lib/clear-all-js-docs.js.map +1 -0
  52. package/src/lib/clear-js-doc.d.ts +2 -0
  53. package/src/lib/clear-js-doc.js +7 -0
  54. package/src/lib/clear-js-doc.js.map +1 -0
  55. package/src/lib/completion.d.ts +11 -0
  56. package/src/lib/completion.js +49 -0
  57. package/src/lib/completion.js.map +1 -0
  58. package/src/lib/compose-context.d.ts +9 -0
  59. package/src/lib/compose-context.js +35 -0
  60. package/src/lib/compose-context.js.map +1 -0
  61. package/src/lib/count-tokens.d.ts +2 -0
  62. package/src/lib/count-tokens.js +18 -0
  63. package/src/lib/count-tokens.js.map +1 -0
  64. package/src/lib/has-js-doc.d.ts +2 -0
  65. package/src/lib/has-js-doc.js +7 -0
  66. package/src/lib/has-js-doc.js.map +1 -0
  67. package/src/lib/model.d.ts +16 -0
  68. package/src/lib/model.js +19 -0
  69. package/src/lib/model.js.map +1 -0
@@ -0,0 +1,36 @@
1
+ {
2
+ "generators": {
3
+ "init": {
4
+ "factory": "./src/generators/init/generator",
5
+ "schema": "./src/generators/init/schema.json",
6
+ "description": "Initialize the package in the workspace"
7
+ },
8
+ "documentation": {
9
+ "factory": "./src/generators/documentation/generator",
10
+ "schema": "./src/generators/documentation/schema.json",
11
+ "description": "Automatically generate the documenation for all exported typescript symboles"
12
+ },
13
+ "package-description": {
14
+ "factory": "./src/generators/package-description/generator",
15
+ "schema": "./src/generators/package-description/schema.json",
16
+ "description": "Generates a package description based on the source code"
17
+ }
18
+ },
19
+ "schematics": {
20
+ "init": {
21
+ "factory": "./src/generators/init/index",
22
+ "schema": "./src/generators/init/schema.json",
23
+ "description": "Initialize the package in the workspace"
24
+ },
25
+ "documentation": {
26
+ "factory": "./src/generators/documentation/index",
27
+ "schema": "./src/generators/documentation/schema.json",
28
+ "description": "Automatically generate the documenation for all exported typescript symboles"
29
+ },
30
+ "package-description": {
31
+ "factory": "./src/generators/package-description/index",
32
+ "schema": "./src/generators/package-description/schema.json",
33
+ "description": "Generates a package description based on the source code"
34
+ }
35
+ }
36
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "version": "20.0.0-dev.1",
3
+ "name": "@rxap/plugin-llm",
4
+ "description": "This npm package provides tools for generating documentation and package descriptions using large language models (LLMs). It includes functionality for cleaning JSDoc comments, counting tokens, composing context for LLM prompts, and integrating with services like OpenAI. The package also offers generators for automatically adding documentation to TypeScript code and creating package descriptions based on project source code.\n",
5
+ "license": "GPL-3.0-or-later",
6
+ "dependencies": {
7
+ "@nx/devkit": "20.4.2",
8
+ "@rxap/workspace-ts-morph": "^19.1.9-dev.13",
9
+ "@rxap/workspace-utilities": "^19.6.1-dev.12",
10
+ "colors": "1.4.0",
11
+ "openai": "^4.82.0",
12
+ "tiktoken": "^1.0.20",
13
+ "ts-morph": "18.0.0",
14
+ "tslib": "^2.3.0",
15
+ "xml2js": "^0.6.2"
16
+ },
17
+ "author": {
18
+ "name": "Merzough Münker",
19
+ "email": "mmuenker@digitaix.com"
20
+ },
21
+ "bugs": {
22
+ "url": "https://gitlab.com/rxap/packages/-/issues",
23
+ "email": "incoming+rxap-packages-14898188-issue-@incoming.gitlab.com"
24
+ },
25
+ "generators": "./generators.json",
26
+ "gitHead": "969f0867a1da05a157f626d5bdd316bd0a67494a",
27
+ "homepage": "https:/gitlab.com/rxap/packages/packages/plugin/llm",
28
+ "keywords": [
29
+ "nx",
30
+ "nx-plugin",
31
+ "packages",
32
+ "plugin",
33
+ "plugin-llm",
34
+ "rxap"
35
+ ],
36
+ "main": "./src/index.js",
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "directory": "../../../dist/packages/plugin/llm"
40
+ },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://gitlab.com/rxap/packages.git",
44
+ "directory": "packages/plugin/llm"
45
+ },
46
+ "schematics": "./generators.json",
47
+ "type": "commonjs",
48
+ "types": "./src/index.d.ts"
49
+ }
@@ -0,0 +1,4 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { DocumentationGeneratorSchema } from './schema';
3
+ export declare function documentationGenerator(tree: Tree, options: DocumentationGeneratorSchema): Promise<void>;
4
+ export default documentationGenerator;
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.documentationGenerator = documentationGenerator;
4
+ const tslib_1 = require("tslib");
5
+ const workspace_ts_morph_1 = require("@rxap/workspace-ts-morph");
6
+ const node_fs_1 = require("node:fs");
7
+ const node_path_1 = require("node:path");
8
+ const path_1 = require("path");
9
+ const ts_morph_1 = require("ts-morph");
10
+ const add_js_doc_1 = require("../../lib/add-js-doc");
11
+ const cleanup_js_doc_1 = require("../../lib/cleanup-js-doc");
12
+ const clear_all_js_docs_1 = require("../../lib/clear-all-js-docs");
13
+ const clear_js_doc_1 = require("../../lib/clear-js-doc");
14
+ const completion_1 = require("../../lib/completion");
15
+ const compose_context_1 = require("../../lib/compose-context");
16
+ const model_1 = require("../../lib/model");
17
+ function generateTsDoc(_a) {
18
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ context, target, question, node, systemPrompt, options }) {
19
+ // console.log(`${question}`.blue);
20
+ try {
21
+ const jsDoc = yield (0, completion_1.completion)(systemPrompt, [context, target, question].join('\n\n'), options);
22
+ // console.log(jsDoc.grey);
23
+ (0, clear_js_doc_1.clearJsDoc)(node);
24
+ (0, add_js_doc_1.addJsDoc)(node, (0, cleanup_js_doc_1.cleanupJsDoc)(jsDoc));
25
+ }
26
+ catch (e) {
27
+ console.log(`${e.message}`.red, e.stack);
28
+ return false;
29
+ }
30
+ return true;
31
+ });
32
+ }
33
+ function documentationGenerator(tree, options) {
34
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
35
+ const { model = 'anthropic/claude-3-5-sonnet', apiKey, orgId, projectId, baseUrl } = options;
36
+ if (model && !Object.keys(model_1.tokenLimits).includes(model)) {
37
+ throw new Error(`The model '${model}' is not supported in the documentation generator`);
38
+ }
39
+ // relative path form the workspace root
40
+ const cwd = (0, node_path_1.relative)(tree.root, process.cwd());
41
+ const path = options.path ? (0, path_1.join)(cwd, options.path) : cwd;
42
+ console.log(`base path: ${path}`.grey);
43
+ const systemPrompt = (0, node_fs_1.readFileSync)((0, path_1.join)(__dirname, 'system-prompts', 'generic.txt'), 'utf-8');
44
+ const operation = (project) => tslib_1.__awaiter(this, void 0, void 0, function* () {
45
+ const failed = [];
46
+ for (const sourceFile of project.getSourceFiles()) {
47
+ if (sourceFile.getFilePath().match(/\.(spec|cy|stories|d|test)\.ts$/)) {
48
+ continue;
49
+ }
50
+ console.log(`PROCESS`.grey + ' ' + `${sourceFile.getFilePath()}`.cyan);
51
+ const context = (0, compose_context_1.composeContext)(sourceFile);
52
+ // console.log('CONTEXT'.bgGreen + '\n' + `${context}`.grey);
53
+ let target = `<sourceFile path="${sourceFile.getFilePath()}">\n`;
54
+ target += (0, clear_all_js_docs_1.clearAllJsDocs)(sourceFile).getFullText();
55
+ target += '</sourceFile>\n';
56
+ // console.log('TARGET'.bgGreen + '\n' + `${target}`.grey);
57
+ for (const functionDeclaration of sourceFile.getFunctions()) {
58
+ console.log(`PROCESS`.grey + ' ' + `function ${functionDeclaration.getName()}`.green);
59
+ const question = `TASK: create the TSDoc documentation for the function \`${functionDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\``;
60
+ const success = yield generateTsDoc({
61
+ systemPrompt,
62
+ question,
63
+ target,
64
+ context,
65
+ node: functionDeclaration,
66
+ options: { model: model, apiKey, orgId, projectId, baseUrl },
67
+ });
68
+ if (!success) {
69
+ failed.push(`${sourceFile.getFilePath()}#function:${functionDeclaration.getName()}`);
70
+ }
71
+ }
72
+ for (const interfaceDeclaration of sourceFile.getInterfaces()) {
73
+ console.log(`PROCESS`.grey + ' ' + `interface ${interfaceDeclaration.getName()}`.green);
74
+ let question = `TASK: create the TSDoc documentation for the interface \`${interfaceDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\``;
75
+ const success = yield generateTsDoc({
76
+ systemPrompt,
77
+ question,
78
+ target,
79
+ context,
80
+ node: interfaceDeclaration,
81
+ options: { model: model, apiKey, orgId, projectId, baseUrl },
82
+ });
83
+ if (!success) {
84
+ failed.push(`${sourceFile.getFilePath()}#interface:${interfaceDeclaration.getName()}`);
85
+ }
86
+ for (const method of interfaceDeclaration.getMethods()) {
87
+ console.log(`PROCESS`.grey + ' ' + `method ${interfaceDeclaration.getName()}::${method.getName()}`.green);
88
+ question = `TASK: create the TSDoc documentation for the method \`${method.getName()}\` of interface \`${interfaceDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\``;
89
+ const success = yield generateTsDoc({
90
+ systemPrompt,
91
+ question,
92
+ target,
93
+ context,
94
+ node: method,
95
+ options: { model: model, apiKey, orgId, projectId, baseUrl },
96
+ });
97
+ if (!success) {
98
+ failed.push(`${sourceFile.getFilePath()}#method:${interfaceDeclaration.getName()}::${method.getName()}`);
99
+ }
100
+ }
101
+ for (const property of interfaceDeclaration.getProperties()) {
102
+ console.log(`PROCESS`.grey + ' ' + `interface ${interfaceDeclaration.getName()}::${property.getName()}`.green);
103
+ question = `TASK: create the TSDoc documentation for the method \`${property.getName()}\` of interface \`${interfaceDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\``;
104
+ const success = yield generateTsDoc({
105
+ systemPrompt,
106
+ question,
107
+ target,
108
+ context,
109
+ node: property,
110
+ options: { model: model, apiKey, orgId, projectId, baseUrl },
111
+ });
112
+ if (!success) {
113
+ failed.push(`${sourceFile.getFilePath()}#method:${interfaceDeclaration.getName()}::${property.getName()}`);
114
+ }
115
+ }
116
+ }
117
+ for (const typeDeclaration of sourceFile.getTypeAliases()) {
118
+ console.log(`PROCESS`.grey + ' ' + `type ${typeDeclaration.getName()}`.green);
119
+ const question = `TASK: create the TSDoc documentation for the type \`${typeDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\``;
120
+ const success = yield generateTsDoc({
121
+ systemPrompt,
122
+ question,
123
+ target,
124
+ context,
125
+ node: typeDeclaration,
126
+ options: { model: model, apiKey, orgId, projectId, baseUrl },
127
+ });
128
+ if (!success) {
129
+ failed.push(`${sourceFile.getFilePath()}#type:${typeDeclaration.getName()}`);
130
+ }
131
+ }
132
+ for (const classDeclaration of sourceFile.getClasses()) {
133
+ console.log(`PROCESS`.grey + ' ' + `class ${classDeclaration.getName()}`.green);
134
+ let question = `TASK: create the TSDoc documentation for the class \`${classDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\``;
135
+ const success = yield generateTsDoc({
136
+ systemPrompt,
137
+ question,
138
+ target,
139
+ context,
140
+ node: classDeclaration,
141
+ options: { model: model, apiKey, orgId, projectId, baseUrl },
142
+ });
143
+ if (!success) {
144
+ failed.push(`${sourceFile.getFilePath()}#class:${classDeclaration.getName()}`);
145
+ }
146
+ for (const method of classDeclaration.getMethods().filter(method => !method.getScope() || method.getScope() === ts_morph_1.Scope.Public)) {
147
+ console.log(`PROCESS`.grey + ' ' + `method ${classDeclaration.getName()}::${method.getName()}`.green);
148
+ question = `TASK: create the TSDoc documentation for the method \`${method.getName()}\` of class \`${classDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\``;
149
+ const success = yield generateTsDoc({
150
+ systemPrompt,
151
+ question,
152
+ target,
153
+ context,
154
+ node: method,
155
+ options: { model: model, apiKey, orgId, projectId, baseUrl },
156
+ });
157
+ if (!success) {
158
+ failed.push(`${sourceFile.getFilePath()}#method:${classDeclaration.getName()}::${method.getName()}`);
159
+ }
160
+ }
161
+ for (const property of classDeclaration.getProperties().filter(property => !property.getScope() || property.getScope() === ts_morph_1.Scope.Public)) {
162
+ console.log(`PROCESS`.grey + ' ' + `method ${classDeclaration.getName()}::${property.getName()}`.green);
163
+ question = `TASK: create the TSDoc documentation for the property \`${property.getName()}\` of class \`${classDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\``;
164
+ const success = yield generateTsDoc({
165
+ systemPrompt,
166
+ question,
167
+ target,
168
+ context,
169
+ node: property,
170
+ options: { model: model, apiKey, orgId, projectId, baseUrl },
171
+ });
172
+ if (!success) {
173
+ failed.push(`${sourceFile.getFilePath()}#method:${classDeclaration.getName()}::${property.getName()}`);
174
+ }
175
+ }
176
+ }
177
+ }
178
+ if (failed.length > 0) {
179
+ console.log('Some documentation generation failed:'.bgRed);
180
+ console.log(`${failed.map(item => ' - ' + item).join('\n')}`.red);
181
+ }
182
+ });
183
+ yield (0, workspace_ts_morph_1.TsMorphTransform)(tree, path, operation);
184
+ });
185
+ }
186
+ exports.default = documentationGenerator;
187
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/llm/src/generators/documentation/generator.ts"],"names":[],"mappings":";;AAyDA,wDA8LC;;AAtPD,iEAGkC;AAClC,qCAAuC;AACvC,yCAAqC;AACrC,+BAA4B;AAC5B,uCAIkB;AAElB,qDAAgD;AAChD,6DAAwD;AACxD,mEAA6D;AAC7D,yDAAoD;AACpD,qDAG8B;AAC9B,+DAA2D;AAC3D,2CAGyB;AAWzB,SAAe,aAAa;iEAAC,EAAG,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAwB;QAE5G,mCAAmC;QACnC,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,IAAA,uBAAU,EAAC,YAAY,EAAE,CAAE,OAAO,EAAE,MAAM,EAAE,QAAQ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CAAgB,EAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IAEhD,CAAC;CAAA;AAED,kBAAe,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const schematic: (generatorOptions: import("./schema").DocumentationGeneratorSchema) => (tree: any, context: any) => Promise<any>;
2
+ export default schematic;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const generator_1 = require("./generator");
5
+ const schematic = (0, devkit_1.convertNxGenerator)(generator_1.default);
6
+ exports.default = schematic;
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/llm/src/generators/documentation/index.ts"],"names":[],"mappings":";;AAAA,uCAAgD;AAChD,2CAAoC;AAEpC,MAAM,SAAS,GAAG,IAAA,2BAAkB,EAAC,mBAAS,CAAC,CAAC;AAChD,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,13 @@
1
+ export interface DocumentationGeneratorSchema {
2
+ path?: string;
3
+ /** The openai api key */
4
+ apiKey?: string;
5
+ /** The openai organization id */
6
+ orgId?: string;
7
+ /** The openai project id */
8
+ projectId?: string;
9
+ /** The openai base url */
10
+ baseUrl?: string;
11
+ /** Set the LLM model to be used */
12
+ model?: string;
13
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "Documentation",
4
+ "title": "",
5
+ "type": "object",
6
+ "properties": {
7
+ "path": {
8
+ "type": "string",
9
+ "format": "path"
10
+ },
11
+ "apiKey": {
12
+ "type": "string",
13
+ "description": "The openai api key"
14
+ },
15
+ "orgId": {
16
+ "type": "string",
17
+ "description": "The openai organization id"
18
+ },
19
+ "projectId": {
20
+ "type": "string",
21
+ "description": "The openai project id"
22
+ },
23
+ "baseUrl": {
24
+ "type": "string",
25
+ "description": "The openai base url"
26
+ },
27
+ "model": {
28
+ "type": "string",
29
+ "description": "Set the LLM model to be used",
30
+ "default": "anthropic/claude-3-5-sonnet"
31
+ }
32
+ },
33
+ "required": []
34
+ }
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3
+ elementFormDefault="qualified">
4
+
5
+ <!-- Definition of the sourceFileType to capture the 'path' attribute -->
6
+ <xsd:complexType name="sourceFileType">
7
+ <xsd:attribute name="path" type="xsd:string" use="required"/>
8
+ </xsd:complexType>
9
+
10
+ <!-- Root element 'context' -->
11
+ <xsd:element name="context">
12
+ <xsd:complexType>
13
+ <xsd:sequence>
14
+ <!-- 'referenced' element with multiple 'source-file' elements -->
15
+ <xsd:element name="referenced" minOccurs="0" maxOccurs="1">
16
+ <xsd:complexType>
17
+ <xsd:sequence>
18
+ <xsd:element name="source-file" type="sourceFileType" minOccurs="0" maxOccurs="unbounded"/>
19
+ </xsd:sequence>
20
+ </xsd:complexType>
21
+ </xsd:element>
22
+
23
+ <!-- 'used' element with multiple 'source-file' elements -->
24
+ <xsd:element name="used" minOccurs="0" maxOccurs="1">
25
+ <xsd:complexType>
26
+ <xsd:sequence>
27
+ <xsd:element name="source-file" type="sourceFileType" minOccurs="0" maxOccurs="unbounded"/>
28
+ </xsd:sequence>
29
+ </xsd:complexType>
30
+ </xsd:element>
31
+ </xsd:sequence>
32
+ </xsd:complexType>
33
+ </xsd:element>
34
+
35
+ </xsd:schema>
@@ -0,0 +1,134 @@
1
+ Example Input:
2
+ ------------------------------------------------------------
3
+ <context>
4
+ <referenced>
5
+ <sourceFile path="/delete-undefined-properties.ts">
6
+ export function DeleteUndefinedProperties<T extends {}>(obj: T, recursive?: boolean): Exclude<T, undefined> {
7
+ if (!obj || typeof obj !== 'object') {
8
+ return obj as any;
9
+ }
10
+
11
+ const keys = Object.keys(obj);
12
+ const cloneObj: any = {};
13
+
14
+ for (const key of keys) {
15
+ if ((obj as any)[key] !== undefined) {
16
+ const value = (obj as any)[key];
17
+ cloneObj[key] = value;
18
+ if (recursive && value) {
19
+ if (Array.isArray(value)) {
20
+ cloneObj[key] = value.map((item) => DeleteUndefinedProperties(item, true));
21
+ } else if (typeof value === 'object') {
22
+ cloneObj[key] = DeleteUndefinedProperties(value, true);
23
+ }
24
+ }
25
+ }
26
+ }
27
+
28
+ return cloneObj;
29
+ }
30
+ </sourceFile>
31
+ <sourceFile path="/delete-null-properties.ts">
32
+ export function DeleteNullProperties<T extends {}>(obj: T, recursive?: boolean): Exclude<T, null> {
33
+ if (!obj || typeof obj !== 'object') {
34
+ return obj as any;
35
+ }
36
+
37
+ const keys = Object.keys(obj);
38
+ const cloneObj: any = {};
39
+
40
+ for (const key of keys) {
41
+ if ((obj as any)[key] !== null) {
42
+ const value = (obj as any)[key];
43
+ cloneObj[key] = value;
44
+ if (recursive && value) {
45
+ if (Array.isArray(value)) {
46
+ cloneObj[key] = value.map((item) => DeleteNullProperties(item, true));
47
+ } else if (typeof value === 'object') {
48
+ cloneObj[key] = DeleteNullProperties(value, true);
49
+ }
50
+ }
51
+ }
52
+ }
53
+
54
+ return cloneObj;
55
+ }
56
+ </sourceFile>
57
+ </referenced>
58
+ <used>
59
+ <sourceFile path="/delete-empty-properties.spec.ts">
60
+ import { DeleteEmptyProperties } from './delete-empty-properties';
61
+
62
+ describe('DeleteEmptyProperties function', () => {
63
+ test('should remove null properties from an object', () => {
64
+ const inputObj = {
65
+ a: 1,
66
+ b: null,
67
+ c: 'test',
68
+ };
69
+
70
+ const expectedOutput = {
71
+ a: 1,
72
+ c: 'test',
73
+ };
74
+
75
+ expect(DeleteEmptyProperties(inputObj)).toEqual(expectedOutput);
76
+ });
77
+
78
+ test('should not remove null properties from nested objects if recursive flag is not set', () => {
79
+ const inputObj = {
80
+ a: 1,
81
+ b: null,
82
+ c: {
83
+ d: 3,
84
+ e: null,
85
+ },
86
+ };
87
+
88
+ const expectedOutput = {
89
+ a: 1,
90
+ c: {
91
+ d: 3,
92
+ e: null,
93
+ },
94
+ };
95
+
96
+ expect(DeleteEmptyProperties(inputObj)).toEqual(expectedOutput);
97
+ });
98
+
99
+ test('should remove null properties from nested objects if recursive flag is set', () => {
100
+ const inputObj = {
101
+ a: 1,
102
+ b: null,
103
+ c: {
104
+ d: 3,
105
+ e: null,
106
+ },
107
+ };
108
+
109
+ const expectedOutput = {
110
+ a: 1,
111
+ c: {
112
+ d: 3,
113
+ },
114
+ };
115
+
116
+ expect(DeleteEmptyProperties(inputObj, true)).toEqual(expectedOutput);
117
+ });
118
+ });
119
+ </sourceFile>
120
+ </used>
121
+ </context>
122
+
123
+
124
+ <sourceFile path="/delete-empty-properties.ts">
125
+ import { DeleteUndefinedProperties } from './delete-undefined-properties';
126
+ import { DeleteNullProperties } from './delete-null-properties';
127
+
128
+ export function DeleteEmptyProperties<T extends {}>(obj: T, recursive?: boolean): Exclude<Exclude<T, null>, undefined> {
129
+ return DeleteUndefinedProperties(DeleteNullProperties(obj, recursive), recursive);
130
+ }
131
+ </sourceFile>
132
+
133
+ TASK: create the JsDoc documentation for the function DeleteEmptyProperties from the file `delete-empty-properties.ts`
134
+ ------------------------------------------------------------