routesync 1.0.1 → 1.0.3

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/core.d.mts CHANGED
@@ -26,6 +26,10 @@ declare class HttpClient {
26
26
  private setupInterceptors;
27
27
  setToken(token: string): void;
28
28
  removeToken(): void;
29
+ private isFileOrBlob;
30
+ private hasFiles;
31
+ private toFormData;
32
+ private prepareRequest;
29
33
  get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
30
34
  post<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
31
35
  put<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
@@ -191,16 +195,34 @@ interface RouteManifest {
191
195
  version: string;
192
196
  baseURL: string;
193
197
  routes: ParsedRoute[];
198
+ channels?: ParsedChannel[];
199
+ models?: ParsedModel[];
194
200
  generatedAt: string;
195
201
  }
202
+ interface ParsedChannel {
203
+ name: string;
204
+ isPrivate: boolean;
205
+ isPresence: boolean;
206
+ }
196
207
  interface ParsedRoute {
197
208
  name: string;
198
209
  method: string;
199
210
  path: string;
200
211
  auth: boolean;
201
212
  middleware: string[];
213
+ schema?: Record<string, any>;
202
214
  group?: string;
203
215
  action?: string;
204
216
  }
217
+ interface ParsedColumn {
218
+ name: string;
219
+ type: string;
220
+ nullable: boolean;
221
+ }
222
+ interface ParsedModel {
223
+ name: string;
224
+ table: string;
225
+ columns: ParsedColumn[];
226
+ }
205
227
 
206
- export { type ApiDefinition, ApiError, type ApiResponse, type AuthConfig, AuthMiddleware, ErrorHandler, HttpClient, type HttpMethod, Interceptor, type PaginationMeta, type ParsedRoute, PathResolver, QueryBuilder, Request, type RequestOptions, Response, type RetryConfig, type RouteDefinition, type RouteManifest, type RouteMapper, type RouteParserSchema, type RouteSchema, type RouteSchemaMap, type RouteSchemaValue, type RouteTransform, type RouteTransformMap, type ServiceConfig, TokenManager };
228
+ export { type ApiDefinition, ApiError, type ApiResponse, type AuthConfig, AuthMiddleware, ErrorHandler, HttpClient, type HttpMethod, Interceptor, type PaginationMeta, type ParsedChannel, type ParsedColumn, type ParsedModel, type ParsedRoute, PathResolver, QueryBuilder, Request, type RequestOptions, Response, type RetryConfig, type RouteDefinition, type RouteManifest, type RouteMapper, type RouteParserSchema, type RouteSchema, type RouteSchemaMap, type RouteSchemaValue, type RouteTransform, type RouteTransformMap, type ServiceConfig, TokenManager };
package/dist/core.d.ts CHANGED
@@ -26,6 +26,10 @@ declare class HttpClient {
26
26
  private setupInterceptors;
27
27
  setToken(token: string): void;
28
28
  removeToken(): void;
29
+ private isFileOrBlob;
30
+ private hasFiles;
31
+ private toFormData;
32
+ private prepareRequest;
29
33
  get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
30
34
  post<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
31
35
  put<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
@@ -191,16 +195,34 @@ interface RouteManifest {
191
195
  version: string;
192
196
  baseURL: string;
193
197
  routes: ParsedRoute[];
198
+ channels?: ParsedChannel[];
199
+ models?: ParsedModel[];
194
200
  generatedAt: string;
195
201
  }
202
+ interface ParsedChannel {
203
+ name: string;
204
+ isPrivate: boolean;
205
+ isPresence: boolean;
206
+ }
196
207
  interface ParsedRoute {
197
208
  name: string;
198
209
  method: string;
199
210
  path: string;
200
211
  auth: boolean;
201
212
  middleware: string[];
213
+ schema?: Record<string, any>;
202
214
  group?: string;
203
215
  action?: string;
204
216
  }
217
+ interface ParsedColumn {
218
+ name: string;
219
+ type: string;
220
+ nullable: boolean;
221
+ }
222
+ interface ParsedModel {
223
+ name: string;
224
+ table: string;
225
+ columns: ParsedColumn[];
226
+ }
205
227
 
206
- export { type ApiDefinition, ApiError, type ApiResponse, type AuthConfig, AuthMiddleware, ErrorHandler, HttpClient, type HttpMethod, Interceptor, type PaginationMeta, type ParsedRoute, PathResolver, QueryBuilder, Request, type RequestOptions, Response, type RetryConfig, type RouteDefinition, type RouteManifest, type RouteMapper, type RouteParserSchema, type RouteSchema, type RouteSchemaMap, type RouteSchemaValue, type RouteTransform, type RouteTransformMap, type ServiceConfig, TokenManager };
228
+ export { type ApiDefinition, ApiError, type ApiResponse, type AuthConfig, AuthMiddleware, ErrorHandler, HttpClient, type HttpMethod, Interceptor, type PaginationMeta, type ParsedChannel, type ParsedColumn, type ParsedModel, type ParsedRoute, PathResolver, QueryBuilder, Request, type RequestOptions, Response, type RetryConfig, type RouteDefinition, type RouteManifest, type RouteMapper, type RouteParserSchema, type RouteSchema, type RouteSchemaMap, type RouteSchemaValue, type RouteTransform, type RouteTransformMap, type ServiceConfig, TokenManager };
package/dist/core.js CHANGED
@@ -80,20 +80,67 @@ var HttpClient = class {
80
80
  removeToken() {
81
81
  delete this.client.defaults.headers.common["Authorization"];
82
82
  }
83
+ isFileOrBlob(val) {
84
+ return typeof File !== "undefined" && val instanceof File || typeof Blob !== "undefined" && val instanceof Blob;
85
+ }
86
+ hasFiles(body) {
87
+ if (!body || typeof body !== "object") return false;
88
+ if (this.isFileOrBlob(body)) return true;
89
+ if (Array.isArray(body)) {
90
+ return body.some((item) => this.hasFiles(item));
91
+ }
92
+ for (const key of Object.keys(body)) {
93
+ if (this.hasFiles(body[key])) return true;
94
+ }
95
+ return false;
96
+ }
97
+ toFormData(body, formData = new FormData(), parentKey = "") {
98
+ if (body === null || body === void 0) return formData;
99
+ if (this.isFileOrBlob(body)) {
100
+ formData.append(parentKey, body);
101
+ } else if (Array.isArray(body)) {
102
+ body.forEach((item, index) => {
103
+ this.toFormData(item, formData, `${parentKey}[${index}]`);
104
+ });
105
+ } else if (typeof body === "object") {
106
+ Object.keys(body).forEach((key) => {
107
+ const propName = parentKey ? `${parentKey}[${key}]` : key;
108
+ this.toFormData(body[key], formData, propName);
109
+ });
110
+ } else {
111
+ formData.append(parentKey, String(body));
112
+ }
113
+ return formData;
114
+ }
115
+ prepareRequest(body, config) {
116
+ if (!body || !this.hasFiles(body)) {
117
+ return { processedBody: body, processedConfig: config };
118
+ }
119
+ const formData = this.toFormData(body);
120
+ const newConfig = { ...config };
121
+ if (!newConfig.headers) {
122
+ newConfig.headers = {};
123
+ }
124
+ newConfig.headers["Content-Type"] = "multipart/form-data";
125
+ return { processedBody: formData, processedConfig: newConfig };
126
+ }
83
127
  async get(url, config) {
84
128
  const response = await this.client.get(url, config);
85
129
  return response.data;
86
130
  }
87
131
  async post(url, body, config) {
88
- const response = await this.client.post(url, body, config);
132
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
133
+ const response = await this.client.post(url, processedBody, processedConfig);
89
134
  return response.data;
90
135
  }
91
136
  async put(url, body, config) {
92
- const response = await this.client.put(url, body, config);
137
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
138
+ const response = await this.client.put(url, processedBody, processedConfig);
93
139
  return response.data;
94
140
  }
95
141
  async patch(url, body, config) {
96
- const response = await this.client.patch(url, body, config);
142
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
143
+ const response = await this.client.patch(url, processedBody, processedConfig);
97
144
  return response.data;
98
145
  }
99
146
  async delete(url, config) {
package/dist/core.mjs CHANGED
@@ -35,20 +35,67 @@ var HttpClient = class {
35
35
  removeToken() {
36
36
  delete this.client.defaults.headers.common["Authorization"];
37
37
  }
38
+ isFileOrBlob(val) {
39
+ return typeof File !== "undefined" && val instanceof File || typeof Blob !== "undefined" && val instanceof Blob;
40
+ }
41
+ hasFiles(body) {
42
+ if (!body || typeof body !== "object") return false;
43
+ if (this.isFileOrBlob(body)) return true;
44
+ if (Array.isArray(body)) {
45
+ return body.some((item) => this.hasFiles(item));
46
+ }
47
+ for (const key of Object.keys(body)) {
48
+ if (this.hasFiles(body[key])) return true;
49
+ }
50
+ return false;
51
+ }
52
+ toFormData(body, formData = new FormData(), parentKey = "") {
53
+ if (body === null || body === void 0) return formData;
54
+ if (this.isFileOrBlob(body)) {
55
+ formData.append(parentKey, body);
56
+ } else if (Array.isArray(body)) {
57
+ body.forEach((item, index) => {
58
+ this.toFormData(item, formData, `${parentKey}[${index}]`);
59
+ });
60
+ } else if (typeof body === "object") {
61
+ Object.keys(body).forEach((key) => {
62
+ const propName = parentKey ? `${parentKey}[${key}]` : key;
63
+ this.toFormData(body[key], formData, propName);
64
+ });
65
+ } else {
66
+ formData.append(parentKey, String(body));
67
+ }
68
+ return formData;
69
+ }
70
+ prepareRequest(body, config) {
71
+ if (!body || !this.hasFiles(body)) {
72
+ return { processedBody: body, processedConfig: config };
73
+ }
74
+ const formData = this.toFormData(body);
75
+ const newConfig = { ...config };
76
+ if (!newConfig.headers) {
77
+ newConfig.headers = {};
78
+ }
79
+ newConfig.headers["Content-Type"] = "multipart/form-data";
80
+ return { processedBody: formData, processedConfig: newConfig };
81
+ }
38
82
  async get(url, config) {
39
83
  const response = await this.client.get(url, config);
40
84
  return response.data;
41
85
  }
42
86
  async post(url, body, config) {
43
- const response = await this.client.post(url, body, config);
87
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
88
+ const response = await this.client.post(url, processedBody, processedConfig);
44
89
  return response.data;
45
90
  }
46
91
  async put(url, body, config) {
47
- const response = await this.client.put(url, body, config);
92
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
93
+ const response = await this.client.put(url, processedBody, processedConfig);
48
94
  return response.data;
49
95
  }
50
96
  async patch(url, body, config) {
51
- const response = await this.client.patch(url, body, config);
97
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
98
+ const response = await this.client.patch(url, processedBody, processedConfig);
52
99
  return response.data;
53
100
  }
54
101
  async delete(url, config) {
package/dist/sdk.d.mts CHANGED
@@ -20,6 +20,10 @@ declare class HttpClient {
20
20
  private setupInterceptors;
21
21
  setToken(token: string): void;
22
22
  removeToken(): void;
23
+ private isFileOrBlob;
24
+ private hasFiles;
25
+ private toFormData;
26
+ private prepareRequest;
23
27
  get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
24
28
  post<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
25
29
  put<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
package/dist/sdk.d.ts CHANGED
@@ -20,6 +20,10 @@ declare class HttpClient {
20
20
  private setupInterceptors;
21
21
  setToken(token: string): void;
22
22
  removeToken(): void;
23
+ private isFileOrBlob;
24
+ private hasFiles;
25
+ private toFormData;
26
+ private prepareRequest;
23
27
  get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
24
28
  post<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
25
29
  put<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
package/dist/sdk.js CHANGED
@@ -84,20 +84,67 @@ var HttpClient = class {
84
84
  removeToken() {
85
85
  delete this.client.defaults.headers.common["Authorization"];
86
86
  }
87
+ isFileOrBlob(val) {
88
+ return typeof File !== "undefined" && val instanceof File || typeof Blob !== "undefined" && val instanceof Blob;
89
+ }
90
+ hasFiles(body) {
91
+ if (!body || typeof body !== "object") return false;
92
+ if (this.isFileOrBlob(body)) return true;
93
+ if (Array.isArray(body)) {
94
+ return body.some((item) => this.hasFiles(item));
95
+ }
96
+ for (const key of Object.keys(body)) {
97
+ if (this.hasFiles(body[key])) return true;
98
+ }
99
+ return false;
100
+ }
101
+ toFormData(body, formData = new FormData(), parentKey = "") {
102
+ if (body === null || body === void 0) return formData;
103
+ if (this.isFileOrBlob(body)) {
104
+ formData.append(parentKey, body);
105
+ } else if (Array.isArray(body)) {
106
+ body.forEach((item, index) => {
107
+ this.toFormData(item, formData, `${parentKey}[${index}]`);
108
+ });
109
+ } else if (typeof body === "object") {
110
+ Object.keys(body).forEach((key) => {
111
+ const propName = parentKey ? `${parentKey}[${key}]` : key;
112
+ this.toFormData(body[key], formData, propName);
113
+ });
114
+ } else {
115
+ formData.append(parentKey, String(body));
116
+ }
117
+ return formData;
118
+ }
119
+ prepareRequest(body, config) {
120
+ if (!body || !this.hasFiles(body)) {
121
+ return { processedBody: body, processedConfig: config };
122
+ }
123
+ const formData = this.toFormData(body);
124
+ const newConfig = { ...config };
125
+ if (!newConfig.headers) {
126
+ newConfig.headers = {};
127
+ }
128
+ newConfig.headers["Content-Type"] = "multipart/form-data";
129
+ return { processedBody: formData, processedConfig: newConfig };
130
+ }
87
131
  async get(url, config) {
88
132
  const response = await this.client.get(url, config);
89
133
  return response.data;
90
134
  }
91
135
  async post(url, body, config) {
92
- const response = await this.client.post(url, body, config);
136
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
137
+ const response = await this.client.post(url, processedBody, processedConfig);
93
138
  return response.data;
94
139
  }
95
140
  async put(url, body, config) {
96
- const response = await this.client.put(url, body, config);
141
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
142
+ const response = await this.client.put(url, processedBody, processedConfig);
97
143
  return response.data;
98
144
  }
99
145
  async patch(url, body, config) {
100
- const response = await this.client.patch(url, body, config);
146
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
147
+ const response = await this.client.patch(url, processedBody, processedConfig);
101
148
  return response.data;
102
149
  }
103
150
  async delete(url, config) {
package/dist/sdk.mjs CHANGED
@@ -42,20 +42,67 @@ var HttpClient = class {
42
42
  removeToken() {
43
43
  delete this.client.defaults.headers.common["Authorization"];
44
44
  }
45
+ isFileOrBlob(val) {
46
+ return typeof File !== "undefined" && val instanceof File || typeof Blob !== "undefined" && val instanceof Blob;
47
+ }
48
+ hasFiles(body) {
49
+ if (!body || typeof body !== "object") return false;
50
+ if (this.isFileOrBlob(body)) return true;
51
+ if (Array.isArray(body)) {
52
+ return body.some((item) => this.hasFiles(item));
53
+ }
54
+ for (const key of Object.keys(body)) {
55
+ if (this.hasFiles(body[key])) return true;
56
+ }
57
+ return false;
58
+ }
59
+ toFormData(body, formData = new FormData(), parentKey = "") {
60
+ if (body === null || body === void 0) return formData;
61
+ if (this.isFileOrBlob(body)) {
62
+ formData.append(parentKey, body);
63
+ } else if (Array.isArray(body)) {
64
+ body.forEach((item, index) => {
65
+ this.toFormData(item, formData, `${parentKey}[${index}]`);
66
+ });
67
+ } else if (typeof body === "object") {
68
+ Object.keys(body).forEach((key) => {
69
+ const propName = parentKey ? `${parentKey}[${key}]` : key;
70
+ this.toFormData(body[key], formData, propName);
71
+ });
72
+ } else {
73
+ formData.append(parentKey, String(body));
74
+ }
75
+ return formData;
76
+ }
77
+ prepareRequest(body, config) {
78
+ if (!body || !this.hasFiles(body)) {
79
+ return { processedBody: body, processedConfig: config };
80
+ }
81
+ const formData = this.toFormData(body);
82
+ const newConfig = { ...config };
83
+ if (!newConfig.headers) {
84
+ newConfig.headers = {};
85
+ }
86
+ newConfig.headers["Content-Type"] = "multipart/form-data";
87
+ return { processedBody: formData, processedConfig: newConfig };
88
+ }
45
89
  async get(url, config) {
46
90
  const response = await this.client.get(url, config);
47
91
  return response.data;
48
92
  }
49
93
  async post(url, body, config) {
50
- const response = await this.client.post(url, body, config);
94
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
95
+ const response = await this.client.post(url, processedBody, processedConfig);
51
96
  return response.data;
52
97
  }
53
98
  async put(url, body, config) {
54
- const response = await this.client.put(url, body, config);
99
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
100
+ const response = await this.client.put(url, processedBody, processedConfig);
55
101
  return response.data;
56
102
  }
57
103
  async patch(url, body, config) {
58
- const response = await this.client.patch(url, body, config);
104
+ const { processedBody, processedConfig } = this.prepareRequest(body, config);
105
+ const response = await this.client.patch(url, processedBody, processedConfig);
59
106
  return response.data;
60
107
  }
61
108
  async delete(url, config) {
package/dist/vue.d.mts CHANGED
@@ -22,6 +22,10 @@ declare class HttpClient {
22
22
  private setupInterceptors;
23
23
  setToken(token: string): void;
24
24
  removeToken(): void;
25
+ private isFileOrBlob;
26
+ private hasFiles;
27
+ private toFormData;
28
+ private prepareRequest;
25
29
  get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
26
30
  post<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
27
31
  put<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
package/dist/vue.d.ts CHANGED
@@ -22,6 +22,10 @@ declare class HttpClient {
22
22
  private setupInterceptors;
23
23
  setToken(token: string): void;
24
24
  removeToken(): void;
25
+ private isFileOrBlob;
26
+ private hasFiles;
27
+ private toFormData;
28
+ private prepareRequest;
25
29
  get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
26
30
  post<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
27
31
  put<T>(url: string, body?: any, config?: AxiosRequestConfig): Promise<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routesync",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Laravel routes to typed frontend SDKs.",
5
5
  "main": "./dist/sdk.js",
6
6
  "module": "./dist/sdk.mjs",