@valbuild/next 0.84.1 → 0.84.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.
@@ -7,7 +7,7 @@ var core = require('@valbuild/core');
7
7
  var stega = require('@valbuild/react/stega');
8
8
  var React = require('react');
9
9
  var ValOverlayContext = require('../../dist/ValOverlayContext-c82a4507.cjs.dev.js');
10
- var initValRouteFromVal = require('../../dist/initValRouteFromVal-12bdc5f5.cjs.dev.js');
10
+ var initValRouteFromVal = require('../../dist/initValRouteFromVal-65dd1262.cjs.dev.js');
11
11
  require('../../dist/createForOfIteratorHelper-0445603c.cjs.dev.js');
12
12
  require('../../dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
13
13
  require('../../dist/objectSpread2-792eb2c2.cjs.dev.js');
@@ -7,7 +7,7 @@ var core = require('@valbuild/core');
7
7
  var stega = require('@valbuild/react/stega');
8
8
  var React = require('react');
9
9
  var ValOverlayContext = require('../../dist/ValOverlayContext-942f1294.cjs.prod.js');
10
- var initValRouteFromVal = require('../../dist/initValRouteFromVal-b9806908.cjs.prod.js');
10
+ var initValRouteFromVal = require('../../dist/initValRouteFromVal-0f4f2d39.cjs.prod.js');
11
11
  require('../../dist/createForOfIteratorHelper-d4afcad8.cjs.prod.js');
12
12
  require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
13
13
  require('../../dist/objectSpread2-3c87fb4f.cjs.prod.js');
@@ -3,7 +3,7 @@ import { Internal } from '@valbuild/core';
3
3
  import { getModuleIds, stegaEncode } from '@valbuild/react/stega';
4
4
  import React from 'react';
5
5
  import { useValOverlayContext } from '../../dist/ValOverlayContext-6635a4d7.esm.js';
6
- import { i as initValRouteFromVal } from '../../dist/initValRouteFromVal-d84b3563.esm.js';
6
+ import { i as initValRouteFromVal } from '../../dist/initValRouteFromVal-4e6253bf.esm.js';
7
7
  import '../../dist/createForOfIteratorHelper-5758a730.esm.js';
8
8
  import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
9
9
  import '../../dist/objectSpread2-c1340c1c.esm.js';
@@ -18,7 +18,7 @@ declare const initFetchValRouteStega: (config: ValConfig, valApiEndpoints: strin
18
18
  name: string;
19
19
  value: string;
20
20
  } | undefined;
21
- }>) => <T extends ValModule<GenericSelector<SourceObject, undefined>>>(selector: T, params: Promise<Record<string, string | string[]>> | Record<string, string | string[]>) => Promise<FetchValRouteReturnType<T>>;
21
+ }>) => <T extends ValModule<GenericSelector<SourceObject, undefined>>>(selector: T, params: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<FetchValRouteReturnType<T>>;
22
22
  type ValNextRscConfig = {
23
23
  draftMode: typeof draftMode;
24
24
  headers: typeof headers;
@@ -70,14 +70,19 @@ val) {
70
70
  if (part.type === "literal") {
71
71
  fullPathParts.push(part.name);
72
72
  } else if (part.type === "array-param" || part.type === "string-param") {
73
- var value = resolvedParams[part.paramName];
73
+ var key = part.paramName;
74
+ var value = resolvedParams === null || resolvedParams === void 0 ? void 0 : resolvedParams[key];
74
75
  if (typeof value !== "string" && !Array.isArray(value)) {
75
76
  missingPatterns.push(part);
76
77
  } else if (Array.isArray(value)) {
77
- delete missingParamKeys[part.paramName];
78
+ if (missingParamKeys !== null && missingParamKeys !== void 0 && missingParamKeys[key]) {
79
+ delete missingParamKeys[key];
80
+ }
78
81
  fullPathParts.push(value.join("/"));
79
82
  } else {
80
- delete missingParamKeys[part.paramName];
83
+ if (missingParamKeys !== null && missingParamKeys !== void 0 && missingParamKeys[key]) {
84
+ delete missingParamKeys[key];
85
+ }
81
86
  fullPathParts.push(value);
82
87
  }
83
88
  }
@@ -87,13 +92,28 @@ val) {
87
92
  } finally {
88
93
  _iterator.f();
89
94
  }
95
+ var lastPattern = missingPatterns === null || missingPatterns === void 0 ? void 0 : missingPatterns[missingPatterns.length - 1];
96
+ var isLastOptional = lastPattern && lastPattern.type === "array-param" && lastPattern.optional;
97
+ if (isLastOptional) {
98
+ // We **think** that if the last pattern is optional we might still want to match
99
+ // An example: /some-path/[[...test]]
100
+ // Or even: /[[...path]]
101
+ // We believe there's no other legal ways to have optional patterns? Right?
102
+ missingPatterns.pop();
103
+ }
90
104
  if (missingPatterns.length > 0) {
91
105
  var errorMessageParams = missingPatterns.map(function (part) {
92
106
  if (part.type === "literal") {
93
107
  return part.name;
94
108
  } else if (part.type === "string-param") {
109
+ if (part.optional) {
110
+ return "[[".concat(part.paramName, "]]");
111
+ }
95
112
  return "[".concat(part.paramName, "]");
96
113
  } else if (part.type === "array-param") {
114
+ if (part.optional) {
115
+ return "[[...".concat(part.paramName, "]]");
116
+ }
97
117
  return "[...".concat(part.paramName, "]");
98
118
  }
99
119
  });
@@ -68,14 +68,19 @@ val) {
68
68
  if (part.type === "literal") {
69
69
  fullPathParts.push(part.name);
70
70
  } else if (part.type === "array-param" || part.type === "string-param") {
71
- var value = resolvedParams[part.paramName];
71
+ var key = part.paramName;
72
+ var value = resolvedParams === null || resolvedParams === void 0 ? void 0 : resolvedParams[key];
72
73
  if (typeof value !== "string" && !Array.isArray(value)) {
73
74
  missingPatterns.push(part);
74
75
  } else if (Array.isArray(value)) {
75
- delete missingParamKeys[part.paramName];
76
+ if (missingParamKeys !== null && missingParamKeys !== void 0 && missingParamKeys[key]) {
77
+ delete missingParamKeys[key];
78
+ }
76
79
  fullPathParts.push(value.join("/"));
77
80
  } else {
78
- delete missingParamKeys[part.paramName];
81
+ if (missingParamKeys !== null && missingParamKeys !== void 0 && missingParamKeys[key]) {
82
+ delete missingParamKeys[key];
83
+ }
79
84
  fullPathParts.push(value);
80
85
  }
81
86
  }
@@ -85,13 +90,28 @@ val) {
85
90
  } finally {
86
91
  _iterator.f();
87
92
  }
93
+ var lastPattern = missingPatterns === null || missingPatterns === void 0 ? void 0 : missingPatterns[missingPatterns.length - 1];
94
+ var isLastOptional = lastPattern && lastPattern.type === "array-param" && lastPattern.optional;
95
+ if (isLastOptional) {
96
+ // We **think** that if the last pattern is optional we might still want to match
97
+ // An example: /some-path/[[...test]]
98
+ // Or even: /[[...path]]
99
+ // We believe there's no other legal ways to have optional patterns? Right?
100
+ missingPatterns.pop();
101
+ }
88
102
  if (missingPatterns.length > 0) {
89
103
  var errorMessageParams = missingPatterns.map(function (part) {
90
104
  if (part.type === "literal") {
91
105
  return part.name;
92
106
  } else if (part.type === "string-param") {
107
+ if (part.optional) {
108
+ return "[[".concat(part.paramName, "]]");
109
+ }
93
110
  return "[".concat(part.paramName, "]");
94
111
  } else if (part.type === "array-param") {
112
+ if (part.optional) {
113
+ return "[[...".concat(part.paramName, "]]");
114
+ }
95
115
  return "[...".concat(part.paramName, "]");
96
116
  }
97
117
  });
@@ -70,14 +70,19 @@ val) {
70
70
  if (part.type === "literal") {
71
71
  fullPathParts.push(part.name);
72
72
  } else if (part.type === "array-param" || part.type === "string-param") {
73
- var value = resolvedParams[part.paramName];
73
+ var key = part.paramName;
74
+ var value = resolvedParams === null || resolvedParams === void 0 ? void 0 : resolvedParams[key];
74
75
  if (typeof value !== "string" && !Array.isArray(value)) {
75
76
  missingPatterns.push(part);
76
77
  } else if (Array.isArray(value)) {
77
- delete missingParamKeys[part.paramName];
78
+ if (missingParamKeys !== null && missingParamKeys !== void 0 && missingParamKeys[key]) {
79
+ delete missingParamKeys[key];
80
+ }
78
81
  fullPathParts.push(value.join("/"));
79
82
  } else {
80
- delete missingParamKeys[part.paramName];
83
+ if (missingParamKeys !== null && missingParamKeys !== void 0 && missingParamKeys[key]) {
84
+ delete missingParamKeys[key];
85
+ }
81
86
  fullPathParts.push(value);
82
87
  }
83
88
  }
@@ -87,13 +92,28 @@ val) {
87
92
  } finally {
88
93
  _iterator.f();
89
94
  }
95
+ var lastPattern = missingPatterns === null || missingPatterns === void 0 ? void 0 : missingPatterns[missingPatterns.length - 1];
96
+ var isLastOptional = lastPattern && lastPattern.type === "array-param" && lastPattern.optional;
97
+ if (isLastOptional) {
98
+ // We **think** that if the last pattern is optional we might still want to match
99
+ // An example: /some-path/[[...test]]
100
+ // Or even: /[[...path]]
101
+ // We believe there's no other legal ways to have optional patterns? Right?
102
+ missingPatterns.pop();
103
+ }
90
104
  if (missingPatterns.length > 0) {
91
105
  var errorMessageParams = missingPatterns.map(function (part) {
92
106
  if (part.type === "literal") {
93
107
  return part.name;
94
108
  } else if (part.type === "string-param") {
109
+ if (part.optional) {
110
+ return "[[".concat(part.paramName, "]]");
111
+ }
95
112
  return "[".concat(part.paramName, "]");
96
113
  } else if (part.type === "array-param") {
114
+ if (part.optional) {
115
+ return "[[...".concat(part.paramName, "]]");
116
+ }
97
117
  return "[...".concat(part.paramName, "]");
98
118
  }
99
119
  });
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "next",
9
9
  "react"
10
10
  ],
11
- "version": "0.84.1",
11
+ "version": "0.84.2",
12
12
  "scripts": {
13
13
  "typecheck": "tsc --noEmit",
14
14
  "test": "jest"
@@ -45,11 +45,11 @@
45
45
  "exports": true
46
46
  },
47
47
  "dependencies": {
48
- "@valbuild/core": "~0.84.1",
49
- "@valbuild/react": "~0.84.1",
50
- "@valbuild/server": "~0.84.1",
51
- "@valbuild/shared": "~0.84.1",
52
- "@valbuild/ui": "~0.84.1",
48
+ "@valbuild/core": "~0.84.2",
49
+ "@valbuild/react": "~0.84.2",
50
+ "@valbuild/server": "~0.84.2",
51
+ "@valbuild/shared": "~0.84.2",
52
+ "@valbuild/ui": "~0.84.2",
53
53
  "client-only": "^0.0.1",
54
54
  "server-only": "^0.0.1"
55
55
  },
@@ -10,7 +10,7 @@ var core = require('@valbuild/core');
10
10
  var internal = require('@valbuild/shared/internal');
11
11
  var server = require('@valbuild/server');
12
12
  var version = require('../../dist/version-82faa1d0.cjs.dev.js');
13
- var initValRouteFromVal = require('../../dist/initValRouteFromVal-12bdc5f5.cjs.dev.js');
13
+ var initValRouteFromVal = require('../../dist/initValRouteFromVal-65dd1262.cjs.dev.js');
14
14
  require('../../dist/createForOfIteratorHelper-0445603c.cjs.dev.js');
15
15
  require('../../dist/unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
16
16
  require('../../dist/slicedToArray-44036a76.cjs.dev.js');
@@ -10,7 +10,7 @@ var core = require('@valbuild/core');
10
10
  var internal = require('@valbuild/shared/internal');
11
11
  var server = require('@valbuild/server');
12
12
  var version = require('../../dist/version-a9a6a619.cjs.prod.js');
13
- var initValRouteFromVal = require('../../dist/initValRouteFromVal-b9806908.cjs.prod.js');
13
+ var initValRouteFromVal = require('../../dist/initValRouteFromVal-0f4f2d39.cjs.prod.js');
14
14
  require('../../dist/createForOfIteratorHelper-d4afcad8.cjs.prod.js');
15
15
  require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
16
16
  require('../../dist/slicedToArray-ce613de6.cjs.prod.js');
@@ -6,7 +6,7 @@ import { Internal } from '@valbuild/core';
6
6
  import { VAL_SESSION_COOKIE } from '@valbuild/shared/internal';
7
7
  import { createValServer } from '@valbuild/server';
8
8
  import { V as VERSION } from '../../dist/version-98ec5c7a.esm.js';
9
- import { i as initValRouteFromVal } from '../../dist/initValRouteFromVal-d84b3563.esm.js';
9
+ import { i as initValRouteFromVal } from '../../dist/initValRouteFromVal-4e6253bf.esm.js';
10
10
  import '../../dist/createForOfIteratorHelper-5758a730.esm.js';
11
11
  import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
12
12
  import '../../dist/slicedToArray-aa291011.esm.js';