@appweaver/client 1.0.11 → 1.0.13

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.
@@ -19,12 +19,8 @@ const constants_1 = require("../constants");
19
19
  */
20
20
  async function generateClient(schema, clientName, framework = 'fetch', typesPath, noTypes = false) {
21
21
  const schemaObject = typeof schema === 'string' ? await (0, utils_1.toSchemaObject)(schema) : schema;
22
- // Resolve the client class name
23
- let className = clientName;
24
- if (!className) {
25
- const openApiTitle = schemaObject.info?.title || 'Weaver';
26
- className = `${openApiTitle.replace(' ', '')}Client`;
27
- }
22
+ // Resolve the client class name, convert to CamelCase, and sanitize
23
+ const className = (clientName || `${toCamelCase(schemaObject.info.title) || 'Weaver'}Client`).replace(/[^a-zA-Z0-9_$]/g, '');
28
24
  // Resolve the type import statement and types prefix
29
25
  const typeName = 'Type';
30
26
  const typePrefix = typesPath ? `${typeName}.` : '';
@@ -392,3 +388,14 @@ function resourceOperation(pathSuffix, method) {
392
388
  };
393
389
  return operationMap[method]?.[pathSuffix.replace(/^\//, '')];
394
390
  }
391
+ /**
392
+ * Converts a given string to CamelCase format.
393
+ * Words in the input string can be separated by spaces, dashes, or underscores.
394
+ *
395
+ * @param {string} text - The input string to be converted to CamelCase.
396
+ * @return {string} The converted string in CamelCase format.
397
+ */
398
+ function toCamelCase(text) {
399
+ const result = text.replace(/[\s\-_]+[a-z0-9]/g, (match) => match.replace(/[\s\-_]+/, '').toUpperCase());
400
+ return result.charAt(0).toUpperCase() + result.slice(1);
401
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appweaver/client",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Appweaver - the backend framework for AI-first development (@client)",
5
5
  "author": "Luka Matosevic",
6
6
  "license": "MIT",
@@ -37,18 +37,10 @@
37
37
  "openapi-typescript": "7.13.0",
38
38
  "openapi-typescript-helpers": "0.1.0",
39
39
  "prettier": "3.8.4",
40
+ "rxjs": "^7.8.0",
40
41
  "typescript": "5.9.3"
41
42
  },
42
43
  "devDependencies": {
43
- "@types/js-yaml": "4.0.9",
44
- "rxjs": "7.8.2"
45
- },
46
- "peerDependencies": {
47
- "rxjs": "^7.8.0"
48
- },
49
- "peerDependenciesMeta": {
50
- "rxjs": {
51
- "optional": true
52
- }
44
+ "@types/js-yaml": "4.0.9"
53
45
  }
54
46
  }