@ps-aux/api-client-gen 0.0.1 → 0.0.2

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/dist/go.js CHANGED
@@ -80,6 +80,7 @@ const generateOpenApiModel = (name, input, outputDir, log, isNode = false) => __
80
80
  // extractRequestBody: true,
81
81
  cleanOutput: true,
82
82
  moduleNameFirstTag: true,
83
+ // @ts-ignore
83
84
  codeGenConstructs: (struct) => ({
84
85
  // @ts-ignore
85
86
  Keyword: specialMapping,
@@ -115,7 +116,7 @@ const generateModel = ({ dstDir, apiName, env, srcSpec, }, log = console.log) =>
115
116
  });
116
117
  }
117
118
  const clientDir = Path.resolve(dir, 'client');
118
- const specPath = yield getSpecPath(srcSpec, dir);
119
+ const specPath = yield getSpecPath(srcSpec, dir, log);
119
120
  yield generateOpenApiModel(apiName + '-api', specPath, clientDir, log, env === 'node');
120
121
  // TODO does not seem to currently generate all schemas
121
122
  // generateSchemas(
@@ -123,14 +124,16 @@ const generateModel = ({ dstDir, apiName, env, srcSpec, }, log = console.log) =>
123
124
  // Path.resolve(dir, 'schemas.ts')
124
125
  // )
125
126
  });
126
- const getSpecPath = (urlOrPath, dir) => __awaiter(void 0, void 0, void 0, function* () {
127
+ const getSpecPath = (urlOrPath, dir, log) => __awaiter(void 0, void 0, void 0, function* () {
127
128
  if (!urlOrPath.startsWith('http')) {
128
129
  if (!fs.existsSync(urlOrPath))
129
130
  throw new Error(`Spec file ${urlOrPath} does not exists`);
130
131
  return urlOrPath;
131
132
  }
132
133
  const specPath = Path.resolve(dir, `spec.json`);
134
+ log(`Will download the API spec from ${urlOrPath} to ${specPath}`);
133
135
  yield downloadSpec(specPath, urlOrPath);
136
+ return specPath;
134
137
  });
135
138
 
136
139
  const conf = cosmiconfig.cosmiconfigSync('api-client-gen')
package/dist/index.esm.js CHANGED
@@ -76,6 +76,7 @@ const generateOpenApiModel = (name, input, outputDir, log, isNode = false) => __
76
76
  // extractRequestBody: true,
77
77
  cleanOutput: true,
78
78
  moduleNameFirstTag: true,
79
+ // @ts-ignore
79
80
  codeGenConstructs: (struct) => ({
80
81
  // @ts-ignore
81
82
  Keyword: specialMapping,
@@ -111,7 +112,7 @@ const generateModel = ({ dstDir, apiName, env, srcSpec, }, log = console.log) =>
111
112
  });
112
113
  }
113
114
  const clientDir = Path.resolve(dir, 'client');
114
- const specPath = yield getSpecPath(srcSpec, dir);
115
+ const specPath = yield getSpecPath(srcSpec, dir, log);
115
116
  yield generateOpenApiModel(apiName + '-api', specPath, clientDir, log, env === 'node');
116
117
  // TODO does not seem to currently generate all schemas
117
118
  // generateSchemas(
@@ -119,14 +120,16 @@ const generateModel = ({ dstDir, apiName, env, srcSpec, }, log = console.log) =>
119
120
  // Path.resolve(dir, 'schemas.ts')
120
121
  // )
121
122
  });
122
- const getSpecPath = (urlOrPath, dir) => __awaiter(void 0, void 0, void 0, function* () {
123
+ const getSpecPath = (urlOrPath, dir, log) => __awaiter(void 0, void 0, void 0, function* () {
123
124
  if (!urlOrPath.startsWith('http')) {
124
125
  if (!fs.existsSync(urlOrPath))
125
126
  throw new Error(`Spec file ${urlOrPath} does not exists`);
126
127
  return urlOrPath;
127
128
  }
128
129
  const specPath = Path.resolve(dir, `spec.json`);
130
+ log(`Will download the API spec from ${urlOrPath} to ${specPath}`);
129
131
  yield downloadSpec(specPath, urlOrPath);
132
+ return specPath;
130
133
  });
131
134
 
132
135
  // Bcs of mixing for ESM and CommonJS - todo fix somehow
package/dist/index.js CHANGED
@@ -76,6 +76,7 @@
76
76
  // extractRequestBody: true,
77
77
  cleanOutput: true,
78
78
  moduleNameFirstTag: true,
79
+ // @ts-ignore
79
80
  codeGenConstructs: (struct) => ({
80
81
  // @ts-ignore
81
82
  Keyword: specialMapping,
@@ -111,7 +112,7 @@
111
112
  });
112
113
  }
113
114
  const clientDir = Path.resolve(dir, 'client');
114
- const specPath = yield getSpecPath(srcSpec, dir);
115
+ const specPath = yield getSpecPath(srcSpec, dir, log);
115
116
  yield generateOpenApiModel(apiName + '-api', specPath, clientDir, log, env === 'node');
116
117
  // TODO does not seem to currently generate all schemas
117
118
  // generateSchemas(
@@ -119,14 +120,16 @@
119
120
  // Path.resolve(dir, 'schemas.ts')
120
121
  // )
121
122
  });
122
- const getSpecPath = (urlOrPath, dir) => __awaiter(void 0, void 0, void 0, function* () {
123
+ const getSpecPath = (urlOrPath, dir, log) => __awaiter(void 0, void 0, void 0, function* () {
123
124
  if (!urlOrPath.startsWith('http')) {
124
125
  if (!fs.existsSync(urlOrPath))
125
126
  throw new Error(`Spec file ${urlOrPath} does not exists`);
126
127
  return urlOrPath;
127
128
  }
128
129
  const specPath = Path.resolve(dir, `spec.json`);
130
+ log(`Will download the API spec from ${urlOrPath} to ${specPath}`);
129
131
  yield downloadSpec(specPath, urlOrPath);
132
+ return specPath;
130
133
  });
131
134
 
132
135
  // Bcs of mixing for ESM and CommonJS - todo fix somehow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ps-aux/api-client-gen",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": {
package/src/gen-model.ts CHANGED
@@ -30,7 +30,7 @@ export const generateModel = async ({
30
30
  }
31
31
  const clientDir = Path.resolve(dir, 'client')
32
32
 
33
- const specPath = await getSpecPath(srcSpec, dir)
33
+ const specPath = await getSpecPath(srcSpec, dir, log)
34
34
 
35
35
  await generateOpenApiModel(
36
36
  apiName + '-api',
@@ -47,7 +47,7 @@ export const generateModel = async ({
47
47
  // )
48
48
  }
49
49
 
50
- const getSpecPath = async (urlOrPath: string, dir: string): Promise<string> => {
50
+ const getSpecPath = async (urlOrPath: string, dir: string, log: (str: string) => void): Promise<string> => {
51
51
  if (!urlOrPath.startsWith('http')) {
52
52
  if (!fs.existsSync(urlOrPath))
53
53
  throw new Error(`Spec file ${urlOrPath} does not exists`)
@@ -55,5 +55,8 @@ const getSpecPath = async (urlOrPath: string, dir: string): Promise<string> => {
55
55
  }
56
56
  const specPath = Path.resolve(dir, `spec.json`)
57
57
 
58
+ log(`Will download the API spec from ${urlOrPath} to ${specPath}`)
58
59
  await downloadSpec(specPath, urlOrPath)
60
+
61
+ return specPath
59
62
  }
@@ -32,6 +32,7 @@ export const generateOpenApiModel = async (
32
32
  // extractRequestBody: true,
33
33
  cleanOutput: true,
34
34
  moduleNameFirstTag: true,
35
+ // @ts-ignore
35
36
  codeGenConstructs: (struct) => ({
36
37
  // @ts-ignore
37
38
  Keyword: specialMapping,