nuxt-outfit 1.2.2 → 1.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.
package/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@nuxt/outfit",
3
3
  "configKey": "outfit",
4
- "version": "1.2.2"
4
+ "version": "1.2.4"
5
5
  }
@@ -5,6 +5,10 @@ export declare const useEcho: () => {
5
5
  * @param callback
6
6
  */
7
7
  connected: (callback: any) => void;
8
+ /**
9
+ * Get socket id
10
+ */
11
+ getSocketId: () => any;
8
12
  /**
9
13
  * Connect to the socket
10
14
  *
@@ -25,6 +25,12 @@ export const useEcho = () => {
25
25
  });
26
26
  }
27
27
  },
28
+ /**
29
+ * Get socket id
30
+ */
31
+ getSocketId: () => {
32
+ return $echo.socketId();
33
+ },
28
34
  /**
29
35
  * Connect to the socket
30
36
  *
@@ -4,7 +4,7 @@ export declare const useForm: (opts?: {}) => {
4
4
  repeatArray: (property: any) => void;
5
5
  removeArray: (property: any, index: any) => void;
6
6
  isPending: import("vue").Ref<boolean>;
7
- handleSubmit: () => Promise<void>;
7
+ handleSubmit: (action?: null) => Promise<void>;
8
8
  clearError: (field: any) => void;
9
9
  reset: () => void;
10
10
  onSuccess: (callback: any) => void;
@@ -81,12 +81,12 @@ export const useForm = (opts = {}) => {
81
81
  _onSuccess(hit);
82
82
  }
83
83
  };
84
- const validate = () => {
85
- return opts?.schema.validate(deepClone(fields), { abortEarly: false }).then((validated) => http(opts?.action, { method: "POST", body: validated })).then((hit) => handleSuccess(hit)).catch((fail) => handleFail(fail));
84
+ const validate = (action) => {
85
+ return opts?.schema.validate(deepClone(fields), { abortEarly: false }).then((validated) => http(action ?? opts?.action, { method: "POST", body: validated })).then((hit) => handleSuccess(hit)).catch((fail) => handleFail(fail));
86
86
  };
87
- const handleSubmit = async () => {
87
+ const handleSubmit = async (action = null) => {
88
88
  processing();
89
- await validate();
89
+ await validate(action);
90
90
  processed();
91
91
  };
92
92
  return {
@@ -5,4 +5,8 @@ export declare const useSpaHeaders: (additionalHeaders?: {}) => {
5
5
  }): Promise<void>;
6
6
  } | {
7
7
  headers: {};
8
+ onRequest({ request, options }: {
9
+ request: any;
10
+ options: any;
11
+ }): Promise<void>;
8
12
  };
@@ -1,11 +1,17 @@
1
- import { useRuntimeConfig, useRequestEvent, useRequestHeaders } from "#imports";
1
+ import { useRuntimeConfig, useRequestEvent, useRequestHeaders, useEcho } from "#imports";
2
2
  import { appendHeader } from "h3";
3
3
  import { parse, splitCookiesString as split } from "set-cookie-parser";
4
4
  import { serialize } from "cookie";
5
5
  export const useSpaHeaders = (additionalHeaders = {}) => {
6
6
  if (process.client) {
7
+ const { getSocketId } = useEcho();
7
8
  return {
8
- headers: additionalHeaders
9
+ headers: additionalHeaders,
10
+ async onRequest({ request, options }) {
11
+ if (getSocketId() !== void 0) {
12
+ options.headers["X-Socket-ID"] = getSocketId();
13
+ }
14
+ }
9
15
  };
10
16
  }
11
17
  const serverUrl = useRuntimeConfig().outfit.serverUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-outfit",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Outfit - Connection Laravel and Nuxt",
5
5
  "repository": {
6
6
  "type": "git",