@equinor/fusion-framework-module-http 7.0.0 → 7.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.
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
  *
5
5
  * @link https://www.rfc-editor.org/rfc/rfc7231#section-4.1
6
6
  */
7
- export declare const requestMethodCasing: () => z.ZodType<string>;
7
+ export declare const requestMethodCasing: () => z.ZodType<string | undefined>;
8
8
  /**
9
9
  * Creates a Zod enum schema for HTTP request methods.
10
10
  *
@@ -28,7 +28,7 @@ export declare const requestMethodVerb: () => z.ZodEnum<{
28
28
  CONNECT: "CONNECT";
29
29
  TRACE: "TRACE";
30
30
  }>;
31
- export declare const requestMethod: () => z.ZodPipe<z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>, z.ZodEnum<{
31
+ export declare const requestMethod: () => z.ZodOptional<z.ZodEnum<{
32
32
  GET: "GET";
33
33
  POST: "POST";
34
34
  PUT: "PUT";
@@ -69,7 +69,7 @@ export declare const requestInitSchema: z.ZodObject<{
69
69
  headers: z.ZodUnion<[z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>, z.ZodCustom<Headers, Headers>]>;
70
70
  integrity: z.ZodOptional<z.ZodString>;
71
71
  keepalive: z.ZodOptional<z.ZodBoolean>;
72
- method: z.ZodOptional<z.ZodPipe<z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>, z.ZodEnum<{
72
+ method: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
73
73
  GET: "GET";
74
74
  POST: "POST";
75
75
  PUT: "PUT";
@@ -140,7 +140,7 @@ export declare const fetchRequestSchema: z.ZodObject<{
140
140
  headers: z.ZodUnion<[z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>, z.ZodCustom<Headers, Headers>]>;
141
141
  integrity: z.ZodOptional<z.ZodString>;
142
142
  keepalive: z.ZodOptional<z.ZodBoolean>;
143
- method: z.ZodOptional<z.ZodPipe<z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>, z.ZodEnum<{
143
+ method: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
144
144
  GET: "GET";
145
145
  POST: "POST";
146
146
  PUT: "PUT";
@@ -1 +1 @@
1
- export declare const version = "7.0.0";
1
+ export declare const version = "7.0.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-http",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -59,8 +59,8 @@
59
59
  "dependencies": {
60
60
  "rxjs": "^7.8.1",
61
61
  "zod": "^4.1.8",
62
- "@equinor/fusion-framework-module": "^5.0.1",
63
- "@equinor/fusion-framework-module-msal": "^5.0.0"
62
+ "@equinor/fusion-framework-module": "^5.0.3",
63
+ "@equinor/fusion-framework-module-msal": "^5.0.1"
64
64
  },
65
65
  "devDependencies": {
66
66
  "typescript": "^5.8.2",
@@ -5,14 +5,17 @@ import { z } from 'zod';
5
5
  *
6
6
  * @link https://www.rfc-editor.org/rfc/rfc7231#section-4.1
7
7
  */
8
- export const requestMethodCasing = (): z.ZodType<string> => {
9
- return z.string().refine((value) => value === value?.toUpperCase(), {
10
- message: [
11
- 'Provided HTTP method must be in uppercase.',
12
- 'See RFC 7231 Section 4.1 for more information',
13
- 'https://www.rfc-editor.org/rfc/rfc7231#section-4.1',
14
- ].join(' '),
15
- });
8
+ export const requestMethodCasing = (): z.ZodType<string | undefined> => {
9
+ return z
10
+ .string()
11
+ .optional()
12
+ .refine((value) => value === undefined || value === value?.toUpperCase(), {
13
+ message: [
14
+ 'Provided HTTP method must be in uppercase.',
15
+ 'See RFC 7231 Section 4.1 for more information',
16
+ 'https://www.rfc-editor.org/rfc/rfc7231#section-4.1',
17
+ ].join(' '),
18
+ });
16
19
  };
17
20
 
18
21
  /**
@@ -34,7 +37,7 @@ export const requestMethodVerb = () => {
34
37
  });
35
38
  };
36
39
 
37
- export const requestMethod = () => requestMethodCasing().pipe(requestMethodVerb());
40
+ export const requestMethod = () => requestMethodVerb().optional();
38
41
 
39
42
  /**
40
43
  * Schema for validating the initialization options of a request.
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '7.0.0';
2
+ export const version = '7.0.2';
@@ -30,9 +30,17 @@ describe('capitalizeRequestMethodOperator', () => {
30
30
 
31
31
  const result = executeOperator(operator, { method: 'get' });
32
32
 
33
- expect(result).resolves.toMatchObject({ method: 'GET' });
33
+ await expect(result).resolves.toMatchObject({ method: 'GET' });
34
34
  expect(consoleWarn).toHaveBeenCalled();
35
35
  });
36
+
37
+ it('should handle undefined request method', async () => {
38
+ const operator = capitalizeRequestMethodOperator();
39
+
40
+ const result = executeOperator(operator, { method: undefined });
41
+
42
+ await expect(result).resolves.toMatchObject({ method: undefined });
43
+ });
36
44
  });
37
45
 
38
46
  describe('requestValidationOperator', () => {
@@ -50,7 +58,7 @@ describe('requestValidationOperator', () => {
50
58
 
51
59
  const result = executeOperator(operator, mockRequest);
52
60
 
53
- expect(result).resolves.toBeUndefined();
61
+ await expect(result).resolves.toBeUndefined();
54
62
  });
55
63
 
56
64
  it('should parse valid request parameters', async () => {
@@ -58,7 +66,7 @@ describe('requestValidationOperator', () => {
58
66
 
59
67
  const result = executeOperator(operator, mockRequest);
60
68
 
61
- expect(result).resolves.toStrictEqual(mockRequest);
69
+ await expect(result).resolves.toStrictEqual(mockRequest);
62
70
  });
63
71
 
64
72
  it('should allow additional properties when strict validation is disabled', async () => {
@@ -70,8 +78,8 @@ describe('requestValidationOperator', () => {
70
78
  additionalProperty: 'some-value',
71
79
  });
72
80
 
73
- expect(result).resolves.toMatchObject(mockRequest);
74
- expect(result).resolves.toHaveProperty('additionalProperty', 'some-value');
81
+ await expect(result).resolves.toMatchObject(mockRequest);
82
+ await expect(result).resolves.toHaveProperty('additionalProperty', 'some-value');
75
83
  });
76
84
 
77
85
  it('should remove additional properties when strict validation is enabled', async () => {
@@ -84,8 +92,8 @@ describe('requestValidationOperator', () => {
84
92
  method: 'GET',
85
93
  });
86
94
 
87
- expect(result).resolves.toStrictEqual(mockRequest);
88
- expect(result).resolves.not.toHaveProperty('additionalProperty');
95
+ await expect(result).resolves.toStrictEqual(mockRequest);
96
+ await expect(result).resolves.not.toHaveProperty('additionalProperty');
89
97
  });
90
98
 
91
99
  it('should throw an error for invalid request parameters', async () => {
@@ -96,6 +104,6 @@ describe('requestValidationOperator', () => {
96
104
  method: 'GETS', // invalid method
97
105
  });
98
106
 
99
- expect(result).rejects.toThrowError('RFC 2615');
107
+ await expect(result).rejects.toThrowError('RFC 2615');
100
108
  });
101
109
  });