@signal24/vue-foundation 4.2.1 → 4.2.4

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.
@@ -1,3 +1,4 @@
1
1
  import type { ObjectDirective } from 'vue';
2
- import { type IInfiniteScrollOptions } from '../hooks/infinite-scroll';
3
- export declare const vInfiniteScroll: ObjectDirective<Element, IInfiniteScrollOptions>;
2
+ type InfiniteScrollBindingValue = () => void;
3
+ export declare const vInfiniteScroll: ObjectDirective<Element, InfiniteScrollBindingValue>;
4
+ export {};
@@ -14,10 +14,15 @@ interface IRequestOptions {
14
14
  interface IBaseHttpRequest {
15
15
  request<T>(options: IRequestOptions): ICancelablePromise<T>;
16
16
  }
17
- interface IApiClient {
17
+ export interface IApiClient {
18
18
  request: IBaseHttpRequest;
19
19
  }
20
- declare class ICancelablePromise<T = any> {
20
+ export interface IApiError extends Error {
21
+ status: number;
22
+ statusText: string;
23
+ body: any;
24
+ }
25
+ export declare class ICancelablePromise<T = any> {
21
26
  constructor(executor: (resolve: (value: any) => void, reject: (reason: any) => void, onCancel: (cancel: () => void) => void) => void);
22
27
  then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
23
28
  catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
@@ -30,5 +35,6 @@ interface IWrappedApiClientOptions<P extends ICancelablePromise = ICancelablePro
30
35
  onError?: (err: Error, options: IRequestOptions) => Error | null | void;
31
36
  CancelablePromise: new (...arguments_: Arguments) => P;
32
37
  }
38
+ export declare function isApiError(err: any): err is IApiError;
33
39
  export declare function installApiClientInterceptors({ apiClient, onRequest, onError, CancelablePromise }: IWrappedApiClientOptions): void;
34
40
  export {};
@@ -3,3 +3,4 @@ export declare function nl2br(value: string): string;
3
3
  export declare function desnakeCase(value: string): string;
4
4
  export declare function formatPhone(value: string): string;
5
5
  export declare function formatUSCurrency(value: string | number): string;
6
+ export declare function uuid(): string;
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { existsSync } from 'fs';
3
- import { generateOpenapiClient } from './vite-openapi-plugin.js';
3
+ import { generateOpenapiClient, loadOpenapiOverrides } from './vite-openapi-plugin.js';
4
4
  if (!process.argv[2]) {
5
- throw new Error('Usage: vf-generate-openapi-client <openapi-yaml-path>');
5
+ throw new Error('Usage: vf-generate-openapi-client <openapi-yaml-path> [<openapi-output-path>]');
6
6
  }
7
7
  if (!existsSync(process.argv[2])) {
8
8
  throw new Error(`OpenAPI YAML file not found: ${process.argv[2]}`);
9
9
  }
10
- await generateOpenapiClient(process.argv[2]);
10
+ loadOpenapiOverrides();
11
+ await generateOpenapiClient(process.argv[2], process.argv[3]);
@@ -1,7 +1,8 @@
1
- export declare function openapiClientGeneratorPlugin(openapiYamlPath: string): {
1
+ export declare function loadOpenapiOverrides(): void;
2
+ export declare function openapiClientGeneratorPlugin(openapiYamlPath: string, outPath?: string): {
2
3
  name: string;
3
- apply: string;
4
+ apply: 'serve';
4
5
  buildStart(): void;
5
6
  closeBundle(): void;
6
7
  };
7
- export declare function generateOpenapiClient(openapiYamlPath: string): Promise<void>;
8
+ export declare function generateOpenapiClient(openapiYamlPath: string, outPath?: string): Promise<void>;
@@ -1,39 +1,60 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { existsSync, readFileSync, watch } from 'node:fs';
2
+ import { copyFileSync, existsSync, readFileSync, watch } from 'node:fs';
3
3
  import { rm } from 'node:fs/promises';
4
4
  import * as OpenAPI from 'openapi-typescript-codegen';
5
+ const DEFAULT_OUT_PATH = './src/openapi-client-generated';
5
6
  let generatedHash = null;
6
- export function openapiClientGeneratorPlugin(openapiYamlPath) {
7
+ let overridesMap = null;
8
+ let overridesInverseMap = null;
9
+ export function loadOpenapiOverrides() {
10
+ if (!existsSync('./openapi-specs.dev.json')) {
11
+ return;
12
+ }
13
+ try {
14
+ const overridesContent = readFileSync('./openapi-specs.dev.json', 'utf8');
15
+ overridesMap = JSON.parse(overridesContent);
16
+ overridesInverseMap = Object.fromEntries(Object.entries(overridesMap).map(([k, v]) => [v, k]));
17
+ }
18
+ catch (e) {
19
+ console.error('Failed to load openapi-specs.dev.json:', e);
20
+ }
21
+ }
22
+ export function openapiClientGeneratorPlugin(openapiYamlPath, outPath = DEFAULT_OUT_PATH) {
7
23
  let generator = null;
8
24
  return {
9
25
  name: 'openapi-types-generator',
10
26
  apply: 'serve',
11
27
  buildStart() {
12
- generator = getGenerator(openapiYamlPath);
28
+ // apply a slight delay so any output doesn't get pushed off screen
29
+ setTimeout(() => {
30
+ loadOpenapiOverrides();
31
+ generator = getGenerator(openapiYamlPath, outPath);
32
+ }, 250);
13
33
  },
14
34
  closeBundle() {
15
35
  generator?.close();
16
36
  }
17
37
  };
18
38
  }
19
- function getGenerator(openapiYamlPath) {
20
- if (!existsSync(openapiYamlPath)) {
21
- console.log(`OpenAPI YAML file not found: ${openapiYamlPath}`);
39
+ function getGenerator(openapiYamlPath, outPath) {
40
+ const resolvedPath = overridesMap?.[openapiYamlPath] ?? openapiYamlPath;
41
+ if (!existsSync(resolvedPath)) {
42
+ console.log(`OpenAPI YAML file not found: ${resolvedPath}`);
22
43
  return null;
23
44
  }
24
- const watcher = watch(openapiYamlPath);
45
+ const watcher = watch(resolvedPath);
25
46
  watcher.on('change', () => {
26
47
  // give the writes a moment to settle
27
- setTimeout(() => generateOpenapiClient(openapiYamlPath), 100);
48
+ setTimeout(() => generateOpenapiClient(resolvedPath, outPath), 100);
28
49
  });
29
- generateOpenapiClient(openapiYamlPath);
50
+ generateOpenapiClient(resolvedPath, outPath);
30
51
  return {
31
52
  close() {
32
53
  watcher.close();
33
54
  }
34
55
  };
35
56
  }
36
- export async function generateOpenapiClient(openapiYamlPath) {
57
+ async function generateOpenapiClientInternal(openapiYamlPath, outPath = DEFAULT_OUT_PATH) {
37
58
  const yaml = readFileSync(openapiYamlPath, 'utf8');
38
59
  const hash = createHash('sha256').update(yaml).digest('hex');
39
60
  if (hash === generatedHash) {
@@ -42,21 +63,28 @@ export async function generateOpenapiClient(openapiYamlPath) {
42
63
  generatedHash = hash;
43
64
  try {
44
65
  try {
45
- await rm('./src/openapi-client-generated', { recursive: true });
66
+ await rm(outPath, { recursive: true });
46
67
  }
47
68
  catch (e) {
48
69
  // ignore
49
70
  }
50
71
  await OpenAPI.generate({
51
72
  input: openapiYamlPath,
52
- output: './src/openapi-client-generated',
73
+ output: outPath,
53
74
  clientName: 'ApiClient',
54
75
  useOptions: true,
55
76
  useUnionTypes: true
56
77
  });
57
- console.log(`[${new Date().toISOString()}] Generated client from ${openapiYamlPath} to ./src/openapi-client/`);
78
+ if (overridesInverseMap?.[openapiYamlPath]) {
79
+ copyFileSync(openapiYamlPath, overridesInverseMap[openapiYamlPath]);
80
+ }
81
+ console.log(`[${new Date().toISOString()}] Generated client from ${openapiYamlPath} to ${outPath}/`);
58
82
  }
59
83
  catch (err) {
60
84
  console.error(`[${new Date().toISOString()}] Error generating client from ${openapiYamlPath}:`, err);
61
85
  }
62
86
  }
87
+ export async function generateOpenapiClient(openapiYamlPath, outPath = DEFAULT_OUT_PATH) {
88
+ const resolvedPath = overridesMap?.[openapiYamlPath] ?? openapiYamlPath;
89
+ return generateOpenapiClientInternal(resolvedPath, outPath);
90
+ }