@holo-js/forms 0.3.27 → 0.3.28

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
+ import { HoloRequestHeaders } from '@holo-js/kernel';
1
2
  import { ValidationSchema, SchemaInputShape, ValidationErrorBag, InferValidationSchemaData, InferSchemaData, FormLikeValidationInput } from '@holo-js/validation';
2
3
 
3
4
  type FormFailureErrors = Readonly<Partial<Record<string, readonly string[]>>>;
@@ -42,11 +43,7 @@ interface FormSecurityOptions {
42
43
  readonly throttle?: string;
43
44
  readonly bag?: string;
44
45
  }
45
- type RequestLikeHeaders = Headers | ReadonlyArray<readonly [string, string]> | Record<string, string | readonly string[] | undefined> | {
46
- readonly get?: (name: string) => string | null | undefined;
47
- readonly forEach?: (callback: (value: string, key: string) => void) => void;
48
- readonly entries?: () => Iterable<readonly [string, string]>;
49
- };
46
+ type RequestLikeHeaders = HoloRequestHeaders;
50
47
  interface StructuredRequestLikeObject {
51
48
  readonly method?: string;
52
49
  readonly path?: string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { F as FormFailureErrors, a as FormFailureInput, b as FormFailureOptions, c as FormFailurePayload, d as FormRequestLikeInput, e as FormSecurityOptions, f as FormSubmissionFailure, g as FormSubmissionResult, h as FormSubmissionSuccess, i as FormSuccessPayload, I as InferFormData, S as SerializedFormSubmission, j as createFailedSubmission, k as createSuccessfulSubmission, l as formsInternals, s as safeParse, m as sanitizeFlashedInput, n as sensitiveInputInternals, v as validate } from './contracts-CJ9Aq8pS.js';
1
+ export { F as FormFailureErrors, a as FormFailureInput, b as FormFailureOptions, c as FormFailurePayload, d as FormRequestLikeInput, e as FormSecurityOptions, f as FormSubmissionFailure, g as FormSubmissionResult, h as FormSubmissionSuccess, i as FormSuccessPayload, I as InferFormData, S as SerializedFormSubmission, j as createFailedSubmission, k as createSuccessfulSubmission, l as formsInternals, s as safeParse, m as sanitizeFlashedInput, n as sensitiveInputInternals, v as validate } from './contracts-DzAvmYd0.js';
2
+ import '@holo-js/kernel';
2
3
  import '@holo-js/validation';
3
4
 
4
5
  declare class FormContractError extends Error {
package/dist/index.mjs CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  } from "./chunk-OFPH5LBY.mjs";
11
11
 
12
12
  // src/contracts.ts
13
+ import { resolveRequestUrl } from "@holo-js/kernel";
13
14
  import {
14
15
  ValidationException,
15
16
  createErrorBag,
@@ -188,18 +189,6 @@ function createFormDataRequestHeaders(requestHeaders) {
188
189
  });
189
190
  return formHeaders;
190
191
  }
191
- function resolveAmbientRequestUrl(headers) {
192
- const referer = headers.get("referer");
193
- if (referer) {
194
- try {
195
- return new URL(referer).href;
196
- } catch {
197
- }
198
- }
199
- const protocol = headers.get("x-forwarded-proto") ?? "http";
200
- const host = headers.get("x-forwarded-host") ?? headers.get("host") ?? "localhost";
201
- return `${protocol}://${host}/`;
202
- }
203
192
  function isNextHeadersModule(value) {
204
193
  return !!value && typeof value === "object" && typeof value.headers === "function";
205
194
  }
@@ -227,7 +216,7 @@ async function resolveAmbientFormDataRequest(input) {
227
216
  return void 0;
228
217
  }
229
218
  const requestHeaders = await nextHeadersModule.headers();
230
- return new Request(resolveAmbientRequestUrl(requestHeaders), {
219
+ return new Request(resolveRequestUrl({ headers: requestHeaders }), {
231
220
  method: "POST",
232
221
  headers: createFormDataRequestHeaders(requestHeaders),
233
222
  body: input
@@ -237,15 +226,7 @@ function getStructuredWebRequest(input) {
237
226
  return input.web?.request instanceof Request ? void 0 : input.web?.request;
238
227
  }
239
228
  function extractRequestLikeUrl(input, headers) {
240
- const webRequest = getStructuredWebRequest(input);
241
- const url = webRequest?.url ?? (typeof input.url === "string" ? input.url : input.url?.toString()) ?? (typeof input.req === "object" && !(input.req instanceof Request) ? input.req.url : void 0) ?? input.node?.req?.url ?? input.path ?? "/";
242
- try {
243
- return new URL(url).toString();
244
- } catch {
245
- const protocol = headers.get("x-forwarded-proto") ?? "http";
246
- const host = headers.get("x-forwarded-host") ?? headers.get("host") ?? "localhost";
247
- return new URL(url, `${protocol}://${host}`).toString();
248
- }
229
+ return resolveRequestUrl({ ...input, headers }).href;
249
230
  }
250
231
  function extractRequestLikeMethod(input) {
251
232
  const webRequest = getStructuredWebRequest(input);
@@ -1,5 +1,6 @@
1
- import { S as SerializedFormSubmission, c as FormFailurePayload, i as FormSuccessPayload, g as FormSubmissionResult, I as InferFormData } from '../contracts-CJ9Aq8pS.js';
1
+ import { S as SerializedFormSubmission, c as FormFailurePayload, i as FormSuccessPayload, g as FormSubmissionResult, I as InferFormData } from '../contracts-DzAvmYd0.js';
2
2
  import { ValidationErrorBag, WebFileLike, ValidationSchema, SchemaInputShape, FieldBuilderInput, InferFieldOutput } from '@holo-js/validation';
3
+ import '@holo-js/kernel';
3
4
 
4
5
  declare function collectFormDirtyPaths(current: unknown, initial: unknown, prefix?: string): readonly string[];
5
6
  declare class FormClientState<TValues, TSuccess = unknown> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holo-js/forms",
3
- "version": "0.3.27",
3
+ "version": "0.3.28",
4
4
  "description": "Holo-JS Framework - forms-first validation and submission contracts",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -28,11 +28,11 @@
28
28
  "test": "vitest --run && node --test --test-concurrency=3 ../../tests/forms-native-browser.mjs ../../tests/forms-native-packages.mjs"
29
29
  },
30
30
  "dependencies": {
31
- "@holo-js/kernel": "^0.3.27",
32
- "@holo-js/validation": "^0.3.27"
31
+ "@holo-js/kernel": "^0.3.28",
32
+ "@holo-js/validation": "^0.3.28"
33
33
  },
34
34
  "peerDependencies": {
35
- "@holo-js/security": "^0.3.27"
35
+ "@holo-js/security": "^0.3.28"
36
36
  },
37
37
  "peerDependenciesMeta": {
38
38
  "@holo-js/security": {