@lowdefy/build 0.0.0-experimental-20260112140412 → 0.0.0-experimental-20260113090459

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.
@@ -13,9 +13,9 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { type } from '@lowdefy/helpers';
16
+ import collectConfigError from '../utils/collectConfigError.js';
16
17
  import countOperators from '../utils/countOperators.js';
17
18
  import createCheckDuplicateId from '../utils/createCheckDuplicateId.js';
18
- import formatConfigError from '../utils/formatConfigError.js';
19
19
  function buildConnections({ components, context }) {
20
20
  // Store connection IDs for validation in buildRequests
21
21
  context.connectionIds = new Set();
@@ -27,29 +27,29 @@ function buildConnections({ components, context }) {
27
27
  components.connections.forEach((connection)=>{
28
28
  const configKey = connection['~k'];
29
29
  if (type.isUndefined(connection.id)) {
30
- throw new Error(formatConfigError({
30
+ collectConfigError({
31
31
  message: 'Connection id missing.',
32
32
  configKey,
33
33
  context
34
- }));
34
+ });
35
35
  }
36
36
  if (!type.isString(connection.id)) {
37
- throw new Error(formatConfigError({
37
+ collectConfigError({
38
38
  message: `Connection id is not a string. Received ${JSON.stringify(connection.id)}.`,
39
39
  configKey,
40
40
  context
41
- }));
41
+ });
42
42
  }
43
43
  checkDuplicateConnectionId({
44
44
  id: connection.id,
45
45
  configKey
46
46
  });
47
47
  if (!type.isString(connection.type)) {
48
- throw new Error(formatConfigError({
48
+ collectConfigError({
49
49
  message: `Connection type is not a string at connection "${connection.id}". Received ${JSON.stringify(connection.type)}.`,
50
50
  configKey,
51
51
  context
52
- }));
52
+ });
53
53
  }
54
54
  context.typeCounters.connections.increment(connection.type, connection['~k']);
55
55
  connection.connectionId = connection.id;
@@ -16,7 +16,7 @@
16
16
  function buildJs({ components, context }) {
17
17
  components.pages = components.pages.map((page)=>{
18
18
  const pageRequests = [
19
- ...page.requests
19
+ ...page.requests ?? []
20
20
  ];
21
21
  delete page.requests;
22
22
  const cleanPage = jsMapParser({
@@ -79,12 +79,16 @@ async function recursiveBuild({ context, refDef, count, referencedFrom, refChain
79
79
  });
80
80
  const reviver = (_, value)=>{
81
81
  if (!type.isObject(value)) return value;
82
- Object.defineProperty(value, '~r', {
83
- value: refDef.id,
84
- enumerable: false,
85
- writable: true,
86
- configurable: true
87
- });
82
+ // Only set ~r if not already present to preserve original file references from nested imports.
83
+ // Use child file's ref ID (parsedRefDef.id) not parent's (refDef.id) for correct error tracing.
84
+ if (value['~r'] === undefined) {
85
+ Object.defineProperty(value, '~r', {
86
+ value: parsedRefDef.id,
87
+ enumerable: false,
88
+ writable: true,
89
+ configurable: true
90
+ });
91
+ }
88
92
  return value;
89
93
  };
90
94
  // Use serializer.copy to preserve non-enumerable properties like ~l
@@ -12,9 +12,18 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import { serializer } from '@lowdefy/helpers';
15
+ */ import { serializer, type } from '@lowdefy/helpers';
16
+ import formatConfigError from '../utils/formatConfigError.js';
16
17
  async function writeRequestsOnPage({ page, context }) {
17
- return Promise.all(page.requests.map(async (request)=>{
18
+ const requests = page.requests ?? [];
19
+ if (!type.isArray(requests)) {
20
+ throw new Error(formatConfigError({
21
+ message: `Page requests must be an array. Received ${JSON.stringify(requests)}.`,
22
+ configKey: page['~k'],
23
+ context
24
+ }));
25
+ }
26
+ return Promise.all(requests.map(async (request)=>{
18
27
  await context.writeBuildArtifact(`pages/${page.pageId}/requests/${request.requestId}.json`, serializer.serializeToString(request ?? {}));
19
28
  delete request.properties;
20
29
  delete request.type;
@@ -21,6 +21,7 @@ function createContext({ customTypesMap, directories, logger, refResolver, stage
21
21
  const context = {
22
22
  connectionIds: new Set(),
23
23
  directories,
24
+ errors: [],
24
25
  jsMap: {},
25
26
  keyMap: {},
26
27
  logger,