@lowdefy/build 0.0.0-experimental-20250915134255 → 0.0.0-experimental-20250926130521

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.
@@ -0,0 +1,63 @@
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 fs from 'fs';
16
+ import path from 'path';
17
+ async function writeDocs({ context, items }) {
18
+ try {
19
+ for (const { type, config, category, connectionType } of items){
20
+ // Try to read documentation.md from the package
21
+ let documentationContent = '';
22
+ try {
23
+ const packagePath = path.join(process.cwd(), 'node_modules', config.package);
24
+ let documentationPath;
25
+ if (category === 'requests') {
26
+ documentationPath = path.join(packagePath, 'dist', 'connections', connectionType, config.originalTypeName, 'documentation.md');
27
+ } else if (category === 'operators') {
28
+ // For operators, determine the environment
29
+ let env = 'shared';
30
+ if (config.groups && config.groups.length === 1) {
31
+ if (config.groups.includes('client')) {
32
+ env = 'client';
33
+ } else if (config.groups.includes('server')) {
34
+ env = 'server';
35
+ }
36
+ }
37
+ // If groups has both or none, use 'shared'
38
+ const name = config.originalTypeName.replace(/^_/, '');
39
+ documentationPath = path.join(packagePath, 'dist', 'operators', env, name, 'documentation.md');
40
+ } else {
41
+ documentationPath = path.join(packagePath, 'dist', category, config.originalTypeName, 'documentation.md');
42
+ }
43
+ if (fs.existsSync(documentationPath)) {
44
+ documentationContent = fs.readFileSync(documentationPath, 'utf8');
45
+ }
46
+ } catch (error) {
47
+ // Continue without documentation if it can't be read
48
+ context.logger.warn(`Could not read documentation for ${type}:`, error.message);
49
+ }
50
+ const documentationFileName = `${type}.md`;
51
+ let outputPath;
52
+ if (category === 'requests') {
53
+ outputPath = `docs/requests/${connectionType}/${documentationFileName}`;
54
+ } else {
55
+ outputPath = `docs/${category}/${documentationFileName}`;
56
+ }
57
+ await context.writeBuildArtifact(outputPath, documentationContent);
58
+ }
59
+ } catch (error) {
60
+ context.logger.warn('Failed to write plugin docs:', error.message);
61
+ }
62
+ }
63
+ export default writeDocs;
@@ -0,0 +1,73 @@
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 writeDocs from './writeDocs.js';
16
+ async function writePluginDocs({ context }) {
17
+ if (context.stage !== 'dev') {
18
+ return;
19
+ }
20
+ const blocks = context.typesMap.blocks || {};
21
+ const actions = context.typesMap.actions || {};
22
+ // const connections = context.typesMap.connections || {};
23
+ const operators = context.typesMap.operators || {};
24
+ // const allRequests = context.typesMap.requests || {};
25
+ const items = [
26
+ ...Object.entries(blocks).map(([type, config])=>({
27
+ type,
28
+ config,
29
+ category: 'blocks'
30
+ })),
31
+ ...Object.entries(actions).map(([type, config])=>({
32
+ type,
33
+ config,
34
+ category: 'actions'
35
+ }))
36
+ ];
37
+ // Add operators
38
+ const allOperators = {};
39
+ if (operators.client) {
40
+ for (const [operatorType, operatorConfig] of Object.entries(operators.client)){
41
+ allOperators[operatorType] = {
42
+ ...operatorConfig,
43
+ groups: [
44
+ 'client'
45
+ ]
46
+ };
47
+ }
48
+ }
49
+ if (operators.server) {
50
+ for (const [operatorType, operatorConfig] of Object.entries(operators.server)){
51
+ if (allOperators[operatorType]) {
52
+ allOperators[operatorType].groups.push('server');
53
+ } else {
54
+ allOperators[operatorType] = {
55
+ ...operatorConfig,
56
+ groups: [
57
+ 'server'
58
+ ]
59
+ };
60
+ }
61
+ }
62
+ }
63
+ items.push(...Object.entries(allOperators).map(([type, config])=>({
64
+ type,
65
+ config,
66
+ category: 'operators'
67
+ })));
68
+ await writeDocs({
69
+ context,
70
+ items
71
+ });
72
+ }
73
+ export default writePluginDocs;