@lowdefy/build 0.0.0-experimental-20251203205559 → 0.0.0-experimental-20260113081624

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.
Files changed (54) hide show
  1. package/dist/build/addKeys.js +2 -0
  2. package/dist/build/buildApi/buildEndpoint.js +6 -0
  3. package/dist/build/buildApi/buildRoutine/countStepTypes.js +1 -1
  4. package/dist/build/buildApi/validateStepReferences.js +65 -0
  5. package/dist/build/buildAuth/buildAuthPlugins.js +42 -12
  6. package/dist/build/buildAuth/validateAuthConfig.js +10 -2
  7. package/dist/build/buildAuth/validateMutualExclusivity.js +18 -4
  8. package/dist/build/buildConnections.js +25 -6
  9. package/dist/build/buildImports/buildIconImports.js +19 -36
  10. package/dist/build/buildLogger.js +41 -0
  11. package/dist/build/buildMenu.js +40 -13
  12. package/dist/build/buildPages/buildBlock/buildEvents.js +90 -9
  13. package/dist/build/buildPages/buildBlock/buildRequests.js +47 -7
  14. package/dist/build/buildPages/buildBlock/countBlockTypes.js +1 -1
  15. package/dist/build/buildPages/buildBlock/validateBlock.js +33 -7
  16. package/dist/build/buildPages/buildPage.js +28 -4
  17. package/dist/build/buildPages/buildPages.js +26 -1
  18. package/dist/build/buildPages/buildTestPage.js +9 -1
  19. package/dist/build/buildPages/validateLinkReferences.js +33 -0
  20. package/dist/build/buildPages/validatePayloadReferences.js +52 -0
  21. package/dist/build/buildPages/validateRequestReferences.js +33 -0
  22. package/dist/build/buildPages/validateStateReferences.js +52 -0
  23. package/dist/build/buildRefs/buildRefs.js +11 -33
  24. package/dist/build/buildRefs/evaluateBuildOperators.js +8 -2
  25. package/dist/build/buildRefs/getConfigFile.js +2 -1
  26. package/dist/build/buildRefs/getRefContent.js +17 -31
  27. package/dist/build/buildRefs/getRefsFromFile.js +8 -3
  28. package/dist/build/buildRefs/makeRefDefinition.js +9 -8
  29. package/dist/build/buildRefs/parseRefContent.js +61 -2
  30. package/dist/build/buildRefs/populateRefs.js +14 -11
  31. package/dist/build/buildRefs/recursiveBuild.js +62 -71
  32. package/dist/build/buildTypes.js +19 -2
  33. package/dist/build/formatBuildError.js +34 -0
  34. package/dist/build/writeLogger.js +19 -0
  35. package/dist/createContext.js +3 -19
  36. package/dist/defaultTypesMap.js +541 -534
  37. package/dist/index.js +138 -125
  38. package/dist/lowdefySchema.js +75 -0
  39. package/dist/test/testContext.js +2 -1
  40. package/dist/utils/collectConfigError.js +40 -0
  41. package/dist/utils/countOperators.js +24 -11
  42. package/dist/utils/createCheckDuplicateId.js +30 -9
  43. package/dist/utils/createCounter.js +15 -2
  44. package/dist/utils/extractOperatorKey.js +36 -0
  45. package/dist/utils/findSimilarString.js +53 -0
  46. package/dist/utils/formatConfigError.js +24 -0
  47. package/dist/utils/formatConfigMessage.js +33 -0
  48. package/dist/utils/formatConfigWarning.js +24 -0
  49. package/dist/utils/traverseConfig.js +43 -0
  50. package/dist/utils/tryBuildStep.js +38 -0
  51. package/package.json +39 -39
  52. package/dist/utils/createBuildProfiler.js +0 -125
  53. package/dist/utils/invalidateChangedFiles.js +0 -89
  54. package/dist/utils/makeRefHash.js +0 -15
@@ -0,0 +1,24 @@
1
+ /*
2
+ Copyright 2020-2024 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import formatConfigMessage from './formatConfigMessage.js';
16
+ function formatConfigError({ message, configKey, context }) {
17
+ return formatConfigMessage({
18
+ prefix: '[Config Error]',
19
+ message,
20
+ configKey,
21
+ context
22
+ });
23
+ }
24
+ export default formatConfigError;
@@ -0,0 +1,33 @@
1
+ /*
2
+ Copyright 2020-2024 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { resolveConfigLocation } from '@lowdefy/helpers';
16
+ function formatConfigMessage({ prefix, message, configKey, context }) {
17
+ if (!configKey || !context) {
18
+ return `${prefix} ${message}`;
19
+ }
20
+ const location = resolveConfigLocation({
21
+ configKey,
22
+ keyMap: context.keyMap,
23
+ refMap: context.refMap,
24
+ configDirectory: context.directories.config
25
+ });
26
+ if (!location) {
27
+ return `${prefix} ${message}`;
28
+ }
29
+ const source = location.source ? `${location.source} at ${location.config}` : '';
30
+ const link = location.link || '';
31
+ return `${prefix} ${message}\n ${source}\n ${link}`;
32
+ }
33
+ export default formatConfigMessage;
@@ -0,0 +1,24 @@
1
+ /*
2
+ Copyright 2020-2024 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import formatConfigMessage from './formatConfigMessage.js';
16
+ function formatConfigWarning({ message, configKey, context }) {
17
+ return formatConfigMessage({
18
+ prefix: '[Config Warning]',
19
+ message,
20
+ configKey,
21
+ context
22
+ });
23
+ }
24
+ export default formatConfigWarning;
@@ -0,0 +1,43 @@
1
+ /*
2
+ Copyright 2020-2024 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { type } from '@lowdefy/helpers';
16
+ /**
17
+ * Generic depth-first traversal of Lowdefy config objects.
18
+ * Visits every object and array in the tree, calling the visitor function for each.
19
+ *
20
+ * @param {Object} options
21
+ * @param {any} options.config - The config object to traverse
22
+ * @param {Function} options.visitor - Called for each object: visitor(obj) => void
23
+ */ function traverseConfig({ config, visitor }) {
24
+ if (!type.isObject(config) && !type.isArray(config)) return;
25
+ if (type.isObject(config)) {
26
+ visitor(config);
27
+ for (const value of Object.values(config)){
28
+ traverseConfig({
29
+ config: value,
30
+ visitor
31
+ });
32
+ }
33
+ }
34
+ if (type.isArray(config)) {
35
+ for (const item of config){
36
+ traverseConfig({
37
+ config: item,
38
+ visitor
39
+ });
40
+ }
41
+ }
42
+ }
43
+ export default traverseConfig;
@@ -0,0 +1,38 @@
1
+ /*
2
+ Copyright 2020-2024 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ /**
16
+ * Wraps a build step to collect errors instead of stopping immediately.
17
+ * Errors are collected in context.errors[] and logged, allowing the build to
18
+ * continue and report all errors at once before stopping.
19
+ *
20
+ * @param {Function} stepFn - Build step function to execute
21
+ * @param {string} stepName - Name of the build step (for debugging)
22
+ * @param {Object} params - Parameters object
23
+ * @param {Object} params.components - Build components
24
+ * @param {Object} params.context - Build context with errors array
25
+ * @returns {*} Result of the build step function
26
+ */ function tryBuildStep(stepFn, stepName, { components, context }) {
27
+ try {
28
+ return stepFn({
29
+ components,
30
+ context
31
+ });
32
+ } catch (error) {
33
+ // Collect error to show all errors at once
34
+ context.errors.push(error.message);
35
+ context.logger.error(error.message);
36
+ }
37
+ }
38
+ export default tryBuildStep;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/build",
3
- "version": "0.0.0-experimental-20251203205559",
3
+ "version": "0.0.0-experimental-20260113081624",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -44,14 +44,14 @@
44
44
  "dist/*"
45
45
  ],
46
46
  "dependencies": {
47
- "@lowdefy/ajv": "0.0.0-experimental-20251203205559",
48
- "@lowdefy/blocks-basic": "0.0.0-experimental-20251203205559",
49
- "@lowdefy/blocks-loaders": "0.0.0-experimental-20251203205559",
50
- "@lowdefy/helpers": "0.0.0-experimental-20251203205559",
51
- "@lowdefy/node-utils": "0.0.0-experimental-20251203205559",
52
- "@lowdefy/nunjucks": "0.0.0-experimental-20251203205559",
53
- "@lowdefy/operators": "0.0.0-experimental-20251203205559",
54
- "@lowdefy/operators-js": "0.0.0-experimental-20251203205559",
47
+ "@lowdefy/ajv": "0.0.0-experimental-20260113081624",
48
+ "@lowdefy/blocks-basic": "0.0.0-experimental-20260113081624",
49
+ "@lowdefy/blocks-loaders": "0.0.0-experimental-20260113081624",
50
+ "@lowdefy/helpers": "0.0.0-experimental-20260113081624",
51
+ "@lowdefy/node-utils": "0.0.0-experimental-20260113081624",
52
+ "@lowdefy/nunjucks": "0.0.0-experimental-20260113081624",
53
+ "@lowdefy/operators": "0.0.0-experimental-20260113081624",
54
+ "@lowdefy/operators-js": "0.0.0-experimental-20260113081624",
55
55
  "ajv": "8.12.0",
56
56
  "json5": "2.2.3",
57
57
  "yaml": "2.3.4",
@@ -59,36 +59,36 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@jest/globals": "28.1.3",
62
- "@lowdefy/actions-core": "0.0.0-experimental-20251203205559",
63
- "@lowdefy/actions-pdf-make": "0.0.0-experimental-20251203205559",
64
- "@lowdefy/blocks-aggrid": "0.0.0-experimental-20251203205559",
65
- "@lowdefy/blocks-algolia": "0.0.0-experimental-20251203205559",
66
- "@lowdefy/blocks-antd": "0.0.0-experimental-20251203205559",
67
- "@lowdefy/blocks-color-selectors": "0.0.0-experimental-20251203205559",
68
- "@lowdefy/blocks-echarts": "0.0.0-experimental-20251203205559",
69
- "@lowdefy/blocks-google-maps": "0.0.0-experimental-20251203205559",
70
- "@lowdefy/blocks-markdown": "0.0.0-experimental-20251203205559",
71
- "@lowdefy/blocks-qr": "0.0.0-experimental-20251203205559",
72
- "@lowdefy/connection-axios-http": "0.0.0-experimental-20251203205559",
73
- "@lowdefy/connection-elasticsearch": "0.0.0-experimental-20251203205559",
74
- "@lowdefy/connection-google-sheets": "0.0.0-experimental-20251203205559",
75
- "@lowdefy/connection-knex": "0.0.0-experimental-20251203205559",
76
- "@lowdefy/connection-mongodb": "0.0.0-experimental-20251203205559",
77
- "@lowdefy/connection-redis": "0.0.0-experimental-20251203205559",
78
- "@lowdefy/connection-sendgrid": "0.0.0-experimental-20251203205559",
79
- "@lowdefy/connection-stripe": "0.0.0-experimental-20251203205559",
80
- "@lowdefy/operators-change-case": "0.0.0-experimental-20251203205559",
81
- "@lowdefy/operators-diff": "0.0.0-experimental-20251203205559",
82
- "@lowdefy/operators-jsonata": "0.0.0-experimental-20251203205559",
83
- "@lowdefy/operators-moment": "0.0.0-experimental-20251203205559",
84
- "@lowdefy/operators-mql": "0.0.0-experimental-20251203205559",
85
- "@lowdefy/operators-nunjucks": "0.0.0-experimental-20251203205559",
86
- "@lowdefy/operators-uuid": "0.0.0-experimental-20251203205559",
87
- "@lowdefy/operators-yaml": "0.0.0-experimental-20251203205559",
88
- "@lowdefy/plugin-auth0": "0.0.0-experimental-20251203205559",
89
- "@lowdefy/plugin-aws": "0.0.0-experimental-20251203205559",
90
- "@lowdefy/plugin-csv": "0.0.0-experimental-20251203205559",
91
- "@lowdefy/plugin-next-auth": "0.0.0-experimental-20251203205559",
62
+ "@lowdefy/actions-core": "0.0.0-experimental-20260113081624",
63
+ "@lowdefy/actions-pdf-make": "0.0.0-experimental-20260113081624",
64
+ "@lowdefy/blocks-aggrid": "0.0.0-experimental-20260113081624",
65
+ "@lowdefy/blocks-algolia": "0.0.0-experimental-20260113081624",
66
+ "@lowdefy/blocks-antd": "0.0.0-experimental-20260113081624",
67
+ "@lowdefy/blocks-color-selectors": "0.0.0-experimental-20260113081624",
68
+ "@lowdefy/blocks-echarts": "0.0.0-experimental-20260113081624",
69
+ "@lowdefy/blocks-google-maps": "0.0.0-experimental-20260113081624",
70
+ "@lowdefy/blocks-markdown": "0.0.0-experimental-20260113081624",
71
+ "@lowdefy/blocks-qr": "0.0.0-experimental-20260113081624",
72
+ "@lowdefy/connection-axios-http": "0.0.0-experimental-20260113081624",
73
+ "@lowdefy/connection-elasticsearch": "0.0.0-experimental-20260113081624",
74
+ "@lowdefy/connection-google-sheets": "0.0.0-experimental-20260113081624",
75
+ "@lowdefy/connection-knex": "0.0.0-experimental-20260113081624",
76
+ "@lowdefy/connection-mongodb": "0.0.0-experimental-20260113081624",
77
+ "@lowdefy/connection-redis": "0.0.0-experimental-20260113081624",
78
+ "@lowdefy/connection-sendgrid": "0.0.0-experimental-20260113081624",
79
+ "@lowdefy/connection-stripe": "0.0.0-experimental-20260113081624",
80
+ "@lowdefy/operators-change-case": "0.0.0-experimental-20260113081624",
81
+ "@lowdefy/operators-diff": "0.0.0-experimental-20260113081624",
82
+ "@lowdefy/operators-jsonata": "0.0.0-experimental-20260113081624",
83
+ "@lowdefy/operators-moment": "0.0.0-experimental-20260113081624",
84
+ "@lowdefy/operators-mql": "0.0.0-experimental-20260113081624",
85
+ "@lowdefy/operators-nunjucks": "0.0.0-experimental-20260113081624",
86
+ "@lowdefy/operators-uuid": "0.0.0-experimental-20260113081624",
87
+ "@lowdefy/operators-yaml": "0.0.0-experimental-20260113081624",
88
+ "@lowdefy/plugin-auth0": "0.0.0-experimental-20260113081624",
89
+ "@lowdefy/plugin-aws": "0.0.0-experimental-20260113081624",
90
+ "@lowdefy/plugin-csv": "0.0.0-experimental-20260113081624",
91
+ "@lowdefy/plugin-next-auth": "0.0.0-experimental-20260113081624",
92
92
  "@swc/cli": "0.1.63",
93
93
  "@swc/core": "1.3.99",
94
94
  "@swc/jest": "0.2.29",
@@ -1,125 +0,0 @@
1
- /*
2
- Copyright 2020-2024 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */ function createBuildProfiler({ logger, prefix = '' }) {
16
- const timings = new Map();
17
- const isDebug = logger?.level === 'debug';
18
- const track = (name)=>{
19
- if (!isDebug) {
20
- return;
21
- }
22
- if (!timings.has(name)) {
23
- timings.set(name, {
24
- total: 0,
25
- count: 0,
26
- min: Infinity,
27
- max: 0
28
- });
29
- }
30
- };
31
- const time = async (name, fn)=>{
32
- if (!isDebug) {
33
- return fn();
34
- }
35
- track(name);
36
- const start = performance.now();
37
- const result = await fn();
38
- const duration = performance.now() - start;
39
- const entry = timings.get(name);
40
- entry.total += duration;
41
- entry.count += 1;
42
- entry.min = Math.min(entry.min, duration);
43
- entry.max = Math.max(entry.max, duration);
44
- return result;
45
- };
46
- const timeSync = (name, fn)=>{
47
- if (!isDebug) {
48
- return fn();
49
- }
50
- track(name);
51
- const start = performance.now();
52
- const result = fn();
53
- const duration = performance.now() - start;
54
- const entry = timings.get(name);
55
- entry.total += duration;
56
- entry.count += 1;
57
- entry.min = Math.min(entry.min, duration);
58
- entry.max = Math.max(entry.max, duration);
59
- return result;
60
- };
61
- const getTimings = ()=>{
62
- const result = [];
63
- timings.forEach((value, name)=>{
64
- result.push({
65
- name,
66
- ...value,
67
- avg: value.total / value.count
68
- });
69
- });
70
- return result;
71
- };
72
- const printSummary = ()=>{
73
- if (!isDebug || timings.size === 0) {
74
- return;
75
- }
76
- const entries = getTimings();
77
- const total = entries.reduce((sum, t)=>sum + t.total, 0);
78
- const displayPrefix = prefix ? `[${prefix}] ` : '';
79
- logger.debug('');
80
- logger.debug(`⏱️ ${displayPrefix}Build Performance Summary:`);
81
- logger.debug('─'.repeat(90));
82
- const header = [
83
- 'Step'.padEnd(30),
84
- 'Total'.padStart(10),
85
- '%'.padStart(6),
86
- 'Count'.padStart(7),
87
- 'Avg'.padStart(10),
88
- 'Min'.padStart(10),
89
- 'Max'.padStart(10)
90
- ].join(' ');
91
- logger.debug(header);
92
- logger.debug('─'.repeat(90));
93
- entries.sort((a, b)=>b.total - a.total).forEach(({ name, total: stepTotal, count, avg, min, max })=>{
94
- const pct = (stepTotal / total * 100).toFixed(1);
95
- const displayName = name.length > 28 ? `${name.slice(0, 25)}...` : name;
96
- const row = [
97
- displayName.padEnd(30),
98
- `${stepTotal.toFixed(2).padStart(8)}ms`,
99
- `${pct.padStart(6)}%`,
100
- String(count).padStart(7),
101
- `${avg.toFixed(2).padStart(8)}ms`,
102
- `${min.toFixed(2).padStart(8)}ms`,
103
- `${max.toFixed(2).padStart(8)}ms`
104
- ].join(' ');
105
- logger.debug(row);
106
- });
107
- logger.debug('─'.repeat(90));
108
- logger.debug(`${'TOTAL'.padEnd(30)} ${total.toFixed(2).padStart(8)}ms`);
109
- };
110
- const createSubProfiler = (subPrefix)=>{
111
- return createBuildProfiler({
112
- logger,
113
- prefix: prefix ? `${prefix}::${subPrefix}` : subPrefix
114
- });
115
- };
116
- return {
117
- time,
118
- timeSync,
119
- getTimings,
120
- printSummary,
121
- createSubProfiler,
122
- isDebug
123
- };
124
- }
125
- export default createBuildProfiler;
@@ -1,89 +0,0 @@
1
- /*
2
- Copyright 2020-2024 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */ /**
16
- * Find all files affected by changes to the given files.
17
- * Traverses the dependency graph upward to find all transitive dependents.
18
- *
19
- * @param {string[]} changedFiles - Array of file paths that changed
20
- * @param {Map<string, Set<string>>} dependencyGraph - Map of file -> Set of files that depend on it
21
- * @returns {Set<string>} - Set of all affected file paths (including the changed files)
22
- */ function getAffectedFiles(changedFiles, dependencyGraph) {
23
- const affected = new Set();
24
- const queue = [
25
- ...changedFiles
26
- ];
27
- while(queue.length > 0){
28
- const file = queue.shift();
29
- if (affected.has(file)) {
30
- continue;
31
- }
32
- affected.add(file);
33
- // Find files that depend on this file
34
- const dependents = dependencyGraph.get(file);
35
- if (dependents) {
36
- for (const dependent of dependents){
37
- if (!affected.has(dependent)) {
38
- queue.push(dependent);
39
- }
40
- }
41
- }
42
- }
43
- return affected;
44
- }
45
- /**
46
- * Invalidate cache entries for changed files and their dependents.
47
- *
48
- * @param {Object} options
49
- * @param {string[]} options.changedFiles - Array of file paths that changed
50
- * @param {Map<string, Set<string>>} options.dependencyGraph - Dependency graph
51
- * @param {Map<string, any>} options.parsedContentCache - Cache of parsed file content
52
- * @param {Map<string, any>} options.refCache - Cache of resolved refs
53
- * @param {Map<string, Set<string>>} options.pathToRefHashes - Maps file path to ref hashes
54
- * @param {Object} options.logger - Logger instance
55
- * @returns {Set<string>} - Set of affected file paths that were invalidated
56
- */ function invalidateChangedFiles({ changedFiles, dependencyGraph, parsedContentCache, refCache, pathToRefHashes, logger }) {
57
- if (!changedFiles || changedFiles.length === 0) {
58
- return new Set();
59
- }
60
- const affectedFiles = getAffectedFiles(changedFiles, dependencyGraph);
61
- // Invalidate parsedContentCache entries for affected files
62
- // The cache keys may include vars suffix for nunjucks files, so we need to check prefixes
63
- for (const cacheKey of parsedContentCache.keys()){
64
- const filePath = cacheKey.split('::')[0]; // Remove vars suffix if present
65
- if (affectedFiles.has(filePath)) {
66
- parsedContentCache.delete(cacheKey);
67
- }
68
- }
69
- // Invalidate refCache entries for affected files using pathToRefHashes mapping
70
- if (refCache && pathToRefHashes) {
71
- for (const filePath of affectedFiles){
72
- const hashes = pathToRefHashes.get(filePath);
73
- if (hashes) {
74
- for (const hash of hashes){
75
- refCache.delete(hash);
76
- }
77
- // Also clear the path mapping since it will be rebuilt
78
- pathToRefHashes.delete(filePath);
79
- }
80
- }
81
- }
82
- if (logger?.level === 'debug' && affectedFiles.size > 0) {
83
- logger.debug(`Incremental build: ${changedFiles.length} file(s) changed`);
84
- logger.debug(`Incremental build: ${affectedFiles.size} file(s) affected`);
85
- }
86
- return affectedFiles;
87
- }
88
- export default invalidateChangedFiles;
89
- export { getAffectedFiles };
@@ -1,15 +0,0 @@
1
- import { type } from '@lowdefy/helpers';
2
- import crypto from 'crypto';
3
- // Sort object keys to ensure stable stringification
4
- function stableStringify(obj) {
5
- if (type.isObject(obj)) {
6
- return '{' + Object.keys(obj).sort().map((k)=>`"${k}":${stableStringify(obj[k])}`).join(',') + '}';
7
- }
8
- if (type.isArray(obj)) {
9
- return '[' + obj.map(stableStringify).join(',') + ']';
10
- }
11
- return JSON.stringify(obj);
12
- }
13
- export default function makeRefHash(refDef) {
14
- return crypto.createHash('sha1').update(stableStringify(refDef) || '').digest('base64');
15
- }