shiftapi 0.0.20 → 0.0.22

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.
@@ -59,13 +59,12 @@ function indent(text, spaces = 2) {
59
59
  const prefix = " ".repeat(spaces);
60
60
  return text.split("\n").map((line) => line ? prefix + line : line).join("\n");
61
61
  }
62
- function dtsTemplate(generatedTypes, openapiImport) {
63
- const src = openapiImport ?? "openapi-fetch";
62
+ function dtsTemplate(generatedTypes) {
64
63
  return `// Auto-generated by shiftapi. Do not edit.
65
64
  declare module "@shiftapi/client" {
66
65
  ${indent(generatedTypes)}
67
66
 
68
- import type createClient from "${src}";
67
+ import type createClient from "openapi-fetch";
69
68
 
70
69
  export const client: ReturnType<typeof createClient<paths>>;
71
70
  export { createClient };
@@ -147,22 +146,18 @@ function writeGeneratedFiles(typesRoot, generatedDts, baseUrl, options) {
147
146
  if (!existsSync(outDir)) {
148
147
  mkdirSync(outDir, { recursive: true });
149
148
  }
150
- const useLocalOpenapi = !!options?.openapiSource;
151
- writeFileSync(resolve(outDir, "client.d.ts"), dtsTemplate(generatedDts, useLocalOpenapi ? "./openapi-fetch.js" : void 0));
149
+ writeFileSync(resolve(outDir, "client.d.ts"), dtsTemplate(generatedDts));
152
150
  writeFileSync(resolve(outDir, "client.js"), options?.clientJsContent ?? clientJsTemplate(baseUrl));
153
151
  if (options?.openapiSource) {
154
152
  writeFileSync(resolve(outDir, "openapi-fetch.js"), options.openapiSource);
155
153
  }
156
- if (options?.openapiDts) {
157
- writeFileSync(resolve(outDir, "openapi-fetch.d.ts"), options.openapiDts);
158
- }
159
154
  writeFileSync(
160
155
  resolve(outDir, "tsconfig.json"),
161
156
  JSON.stringify(
162
157
  {
163
158
  compilerOptions: {
164
159
  paths: {
165
- [MODULE_ID]: ["./client.d.ts"]
160
+ [MODULE_ID]: ["./client"]
166
161
  }
167
162
  }
168
163
  },
@@ -184,15 +179,15 @@ function patchTsConfigPaths(tsconfigDir, typesRoot) {
184
179
  );
185
180
  return;
186
181
  }
187
- const dtsRel = relative(tsconfigDir, resolve(typesRoot, ".shiftapi", "client.d.ts"));
188
- const dtsPath = dtsRel.startsWith("..") ? dtsRel : `./${dtsRel}`;
182
+ const clientRel = relative(tsconfigDir, resolve(typesRoot, ".shiftapi", "client"));
183
+ const clientPath = clientRel.startsWith("..") ? clientRel : `./${clientRel}`;
189
184
  tsconfig.compilerOptions = tsconfig.compilerOptions || {};
190
185
  tsconfig.compilerOptions.paths = tsconfig.compilerOptions.paths || {};
191
186
  const existing = tsconfig.compilerOptions.paths[MODULE_ID];
192
- if (Array.isArray(existing) && existing.length === 1 && existing[0] === dtsPath) {
187
+ if (Array.isArray(existing) && existing.length === 1 && existing[0] === clientPath) {
193
188
  return;
194
189
  }
195
- tsconfig.compilerOptions.paths[MODULE_ID] = [dtsPath];
190
+ tsconfig.compilerOptions.paths[MODULE_ID] = [clientPath];
196
191
  const detectedIndent = raw.match(/^[ \t]+/m)?.[0] ?? " ";
197
192
  writeFileSync(tsconfigPath, stringify(tsconfig, null, detectedIndent) + "\n");
198
193
  console.log(
@@ -8,7 +8,6 @@ declare function regenerateTypes(serverEntry: string, goRoot: string, baseUrl: s
8
8
  declare function writeGeneratedFiles(typesRoot: string, generatedDts: string, baseUrl: string, options?: {
9
9
  clientJsContent?: string;
10
10
  openapiSource?: string;
11
- openapiDts?: string;
12
11
  }): void;
13
12
  declare function patchTsConfigPaths(tsconfigDir: string, typesRoot: string): void;
14
13
 
@@ -25,7 +24,7 @@ declare function extractSpec(serverEntry: string, goRoot: string): object;
25
24
  */
26
25
  declare function generateTypes(spec: object): Promise<string>;
27
26
 
28
- declare function dtsTemplate(generatedTypes: string, openapiImport?: string): string;
27
+ declare function dtsTemplate(generatedTypes: string): string;
29
28
  declare function clientJsTemplate(baseUrl: string): string;
30
29
  declare function nextClientJsTemplate(port: number, baseUrl: string, devApiPrefix?: string): string;
31
30
  declare function virtualModuleTemplate(baseUrl: string, devApiPrefix?: string): string;
package/dist/internal.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  regenerateTypes,
12
12
  virtualModuleTemplate,
13
13
  writeGeneratedFiles
14
- } from "./chunk-BF2EOAV4.js";
14
+ } from "./chunk-JLLHD7QU.js";
15
15
  import {
16
16
  defineConfig,
17
17
  findConfigDir,
package/dist/prepare.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  generateTypes,
5
5
  patchTsConfigPaths,
6
6
  writeGeneratedFiles
7
- } from "./chunk-BF2EOAV4.js";
7
+ } from "./chunk-JLLHD7QU.js";
8
8
  import {
9
9
  loadConfig
10
10
  } from "./chunk-EQN44FQG.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shiftapi",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "CLI and codegen for shiftapi – fully-typed TypeScript clients from Go servers",
5
5
  "author": "Frank Chiarulli Jr. <frank@frankchiarulli.com>",
6
6
  "license": "MIT",