@domain-first/project-structure 8.11.0 → 8.13.0
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.
- package/README.md +1 -1
- package/dist/287.js +36 -967
- package/dist/364.js +3 -3
- package/dist/38.js +4 -3
- package/dist/561.js +76 -67
- package/dist/783.js +1115 -0
- package/dist/{201.js → 878.js} +453 -1
- package/dist/agent-cli.d.ts +5 -5
- package/dist/agent-requests.d.ts +9 -9
- package/dist/frontend-modules.d.ts +6 -1
- package/dist/graph.cjs +113 -4
- package/dist/graph.js +1 -1
- package/dist/index.cjs +105 -81
- package/dist/index.js +1 -1
- package/dist/init.cjs +47 -6
- package/dist/init.js +1 -1
- package/dist/integration.cjs +105 -81
- package/dist/integration.js +1 -1
- package/dist/integrations/openapi.d.ts +13 -3
- package/dist/lint.cjs +119 -9
- package/dist/lint.js +1 -1
- package/dist/react-module-move.d.ts +18 -2
- package/dist/react.cjs +161 -133
- package/dist/svelte.cjs +161 -133
- package/dist/upgrade-svelte.d.ts +22 -0
- package/dist/upgrade-svelte.spec.d.ts +1 -0
- package/dist/upgrade.cjs +381 -41
- package/dist/upgrade.js +219 -13
- package/dist/use-cases/scaffold-svelte-modules.d.ts +3 -2
- package/package.json +1 -1
- package/skills/df-ps-scaffold/SKILL.md +2 -2
- package/skills/df-ps-scaffold/references/agent-operations.md +2 -2
- package/skills/df-ps-svelte/SKILL.md +16 -11
- package/skills/df-ps-svelte/references/generators.md +6 -5
- package/dist/115.js +0 -616
package/dist/init.cjs
CHANGED
|
@@ -897,8 +897,24 @@ const frontendExtensions = {
|
|
|
897
897
|
hook: '.svelte.ts'
|
|
898
898
|
}
|
|
899
899
|
};
|
|
900
|
+
const frontendLogicNaming = {
|
|
901
|
+
react: {
|
|
902
|
+
prefix: 'use',
|
|
903
|
+
shared: [
|
|
904
|
+
'hooks'
|
|
905
|
+
]
|
|
906
|
+
},
|
|
907
|
+
svelte: {
|
|
908
|
+
prefix: 'create',
|
|
909
|
+
shared: [
|
|
910
|
+
'shared',
|
|
911
|
+
'model'
|
|
912
|
+
]
|
|
913
|
+
}
|
|
914
|
+
};
|
|
900
915
|
const react_module_move_kindLayouts = (framework)=>{
|
|
901
916
|
const { component, hook } = frontendExtensions[framework];
|
|
917
|
+
const { prefix, shared } = frontendLogicNaming[framework];
|
|
902
918
|
return {
|
|
903
919
|
page: {
|
|
904
920
|
folder: 'pages',
|
|
@@ -906,7 +922,7 @@ const react_module_move_kindLayouts = (framework)=>{
|
|
|
906
922
|
inFolder: false,
|
|
907
923
|
ownFile: (fileBase)=>new RegExp(`^${module_move_escapeRegExp(fileBase)}-page(?:\\.|$)`),
|
|
908
924
|
target: (reactFolder, { folders, fileName })=>external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page${component}`),
|
|
909
|
-
classPrefix:
|
|
925
|
+
classPrefix: `(${prefix})?`,
|
|
910
926
|
classSuffix: 'Page'
|
|
911
927
|
},
|
|
912
928
|
widget: {
|
|
@@ -914,7 +930,7 @@ const react_module_move_kindLayouts = (framework)=>{
|
|
|
914
930
|
nested: true,
|
|
915
931
|
inFolder: true,
|
|
916
932
|
target: (reactFolder, { folders, folderName })=>external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName),
|
|
917
|
-
classPrefix:
|
|
933
|
+
classPrefix: `(${prefix})?`,
|
|
918
934
|
classSuffix: 'Widget|UIModel',
|
|
919
935
|
storyTitle: (segments)=>[
|
|
920
936
|
'Widgets',
|
|
@@ -931,18 +947,43 @@ const react_module_move_kindLayouts = (framework)=>{
|
|
|
931
947
|
storyTitle: (segments)=>`UI-kit/${segments.join('')}`
|
|
932
948
|
},
|
|
933
949
|
hook: {
|
|
934
|
-
folder: '
|
|
950
|
+
folder: shared.join('/'),
|
|
935
951
|
nested: false,
|
|
936
952
|
inFolder: false,
|
|
937
|
-
ownFile: (fileBase)=>new RegExp(
|
|
938
|
-
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder,
|
|
939
|
-
classPrefix:
|
|
953
|
+
ownFile: (fileBase)=>new RegExp(`^${prefix}-${module_move_escapeRegExp(fileBase)}(?:\\.|$)`),
|
|
954
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, ...shared, `${prefix}-${fileName}${hook}`),
|
|
955
|
+
classPrefix: `(${prefix})`,
|
|
940
956
|
classSuffix: '(?![\\w$])'
|
|
941
957
|
}
|
|
942
958
|
};
|
|
943
959
|
};
|
|
944
960
|
react_module_move_kindLayouts('react');
|
|
945
961
|
react_module_move_kindLayouts('svelte');
|
|
962
|
+
const reactKindTitles = {
|
|
963
|
+
page: [
|
|
964
|
+
'Page',
|
|
965
|
+
'pages'
|
|
966
|
+
],
|
|
967
|
+
widget: [
|
|
968
|
+
'Widget',
|
|
969
|
+
'widgets'
|
|
970
|
+
],
|
|
971
|
+
'ui-kit': [
|
|
972
|
+
'UI-kit component',
|
|
973
|
+
'UI-kit components'
|
|
974
|
+
],
|
|
975
|
+
hook: [
|
|
976
|
+
'Shared hook',
|
|
977
|
+
'shared hooks'
|
|
978
|
+
]
|
|
979
|
+
};
|
|
980
|
+
({
|
|
981
|
+
...reactKindTitles,
|
|
982
|
+
hook: [
|
|
983
|
+
'Shared model',
|
|
984
|
+
'shared models'
|
|
985
|
+
]
|
|
986
|
+
});
|
|
946
987
|
const gitignore_addGitignoreEntry = (root, entry)=>{
|
|
947
988
|
const gitignore = new file_system_File(external_node_path_default().join(root, '.gitignore'));
|
|
948
989
|
const ignored = gitignore.exists ? gitignore.data : '';
|
package/dist/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
|
-
import { ConfigFile, outdatedConfigMessage } from "./
|
|
3
|
+
import { ConfigFile, outdatedConfigMessage } from "./878.js";
|
|
4
4
|
import { printNextSteps, configurationSections, initializeUseCase, savePendingChanges } from "./287.js";
|
|
5
5
|
const help = `Usage: df-init [--section project|backend|frontend]
|
|
6
6
|
|
package/dist/integration.cjs
CHANGED
|
@@ -1836,8 +1836,24 @@ const frontendExtensions = {
|
|
|
1836
1836
|
hook: '.svelte.ts'
|
|
1837
1837
|
}
|
|
1838
1838
|
};
|
|
1839
|
+
const frontendLogicNaming = {
|
|
1840
|
+
react: {
|
|
1841
|
+
prefix: 'use',
|
|
1842
|
+
shared: [
|
|
1843
|
+
'hooks'
|
|
1844
|
+
]
|
|
1845
|
+
},
|
|
1846
|
+
svelte: {
|
|
1847
|
+
prefix: 'create',
|
|
1848
|
+
shared: [
|
|
1849
|
+
'shared',
|
|
1850
|
+
'model'
|
|
1851
|
+
]
|
|
1852
|
+
}
|
|
1853
|
+
};
|
|
1839
1854
|
const kindLayouts = (framework)=>{
|
|
1840
1855
|
const { component, hook } = frontendExtensions[framework];
|
|
1856
|
+
const { prefix, shared } = frontendLogicNaming[framework];
|
|
1841
1857
|
return {
|
|
1842
1858
|
page: {
|
|
1843
1859
|
folder: 'pages',
|
|
@@ -1845,7 +1861,7 @@ const kindLayouts = (framework)=>{
|
|
|
1845
1861
|
inFolder: false,
|
|
1846
1862
|
ownFile: (fileBase)=>new RegExp(`^${escapeRegExp(fileBase)}-page(?:\\.|$)`),
|
|
1847
1863
|
target: (reactFolder, { folders, fileName })=>external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page${component}`),
|
|
1848
|
-
classPrefix:
|
|
1864
|
+
classPrefix: `(${prefix})?`,
|
|
1849
1865
|
classSuffix: 'Page'
|
|
1850
1866
|
},
|
|
1851
1867
|
widget: {
|
|
@@ -1853,7 +1869,7 @@ const kindLayouts = (framework)=>{
|
|
|
1853
1869
|
nested: true,
|
|
1854
1870
|
inFolder: true,
|
|
1855
1871
|
target: (reactFolder, { folders, folderName })=>external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName),
|
|
1856
|
-
classPrefix:
|
|
1872
|
+
classPrefix: `(${prefix})?`,
|
|
1857
1873
|
classSuffix: 'Widget|UIModel',
|
|
1858
1874
|
storyTitle: (segments)=>[
|
|
1859
1875
|
'Widgets',
|
|
@@ -1870,12 +1886,12 @@ const kindLayouts = (framework)=>{
|
|
|
1870
1886
|
storyTitle: (segments)=>`UI-kit/${segments.join('')}`
|
|
1871
1887
|
},
|
|
1872
1888
|
hook: {
|
|
1873
|
-
folder: '
|
|
1889
|
+
folder: shared.join('/'),
|
|
1874
1890
|
nested: false,
|
|
1875
1891
|
inFolder: false,
|
|
1876
|
-
ownFile: (fileBase)=>new RegExp(
|
|
1877
|
-
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder,
|
|
1878
|
-
classPrefix:
|
|
1892
|
+
ownFile: (fileBase)=>new RegExp(`^${prefix}-${escapeRegExp(fileBase)}(?:\\.|$)`),
|
|
1893
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, ...shared, `${prefix}-${fileName}${hook}`),
|
|
1894
|
+
classPrefix: `(${prefix})`,
|
|
1879
1895
|
classSuffix: '(?![\\w$])'
|
|
1880
1896
|
}
|
|
1881
1897
|
};
|
|
@@ -1901,7 +1917,15 @@ const reactKindTitles = {
|
|
|
1901
1917
|
'shared hooks'
|
|
1902
1918
|
]
|
|
1903
1919
|
};
|
|
1904
|
-
const
|
|
1920
|
+
const svelteKindTitles = {
|
|
1921
|
+
...reactKindTitles,
|
|
1922
|
+
hook: [
|
|
1923
|
+
'Shared model',
|
|
1924
|
+
'shared models'
|
|
1925
|
+
]
|
|
1926
|
+
};
|
|
1927
|
+
const frontendKindTitles = (framework)=>'svelte' === framework ? svelteKindTitles : reactKindTitles;
|
|
1928
|
+
const reactModuleName = (kind, rawName, framework = 'react')=>'hook' === kind ? rawName.trim().replace(new RegExp(`^${frontendLogicNaming[framework].prefix}-`), '') : rawName;
|
|
1905
1929
|
const react_module_move_nestedName = (folders, fileBase)=>{
|
|
1906
1930
|
const prefix = `${folders.join('-')}-`;
|
|
1907
1931
|
const last = folders.length && fileBase.startsWith(prefix) ? fileBase.slice(prefix.length) : fileBase;
|
|
@@ -1940,18 +1964,20 @@ const hookFile = {
|
|
|
1940
1964
|
svelte: /\.svelte\.[jt]s$/
|
|
1941
1965
|
};
|
|
1942
1966
|
const findHooks = (reactFolder, framework)=>{
|
|
1943
|
-
const
|
|
1967
|
+
const { prefix, shared } = frontendLogicNaming[framework];
|
|
1968
|
+
const root = external_node_path_default().join(reactFolder, ...shared);
|
|
1944
1969
|
if (!external_node_fs_default().existsSync(root)) return [];
|
|
1945
1970
|
const extension = hookFile[framework];
|
|
1946
|
-
|
|
1947
|
-
|
|
1971
|
+
const ownPrefix = new RegExp(`^${prefix}-`);
|
|
1972
|
+
return external_node_fs_default().readdirSync(root).filter((file)=>ownPrefix.test(file) && extension.test(file) && !/\.(spec|test)\./.test(file)).map((file)=>{
|
|
1973
|
+
const name = file.replace(ownPrefix, '').replace(extension, '');
|
|
1948
1974
|
const content = external_node_fs_default().readFileSync(external_node_path_default().join(root, file), 'utf8');
|
|
1949
1975
|
return {
|
|
1950
1976
|
kind: 'hook',
|
|
1951
1977
|
name,
|
|
1952
1978
|
path: external_node_path_default().join(root, file),
|
|
1953
1979
|
fileBase: name,
|
|
1954
|
-
ClassName: content.match(
|
|
1980
|
+
ClassName: content.match(new RegExp(`export\\s+(?:const|function)\\s+${prefix}(\\w+)\\b`))?.[1] ?? new NestedName(name).ClassName
|
|
1955
1981
|
};
|
|
1956
1982
|
});
|
|
1957
1983
|
};
|
|
@@ -1986,11 +2012,11 @@ const findReactModules = (reactFolder, kind, framework = 'react')=>{
|
|
|
1986
2012
|
});
|
|
1987
2013
|
return modules.sort((a, b)=>a.name.localeCompare(b.name));
|
|
1988
2014
|
};
|
|
1989
|
-
const react_module_move_targetPath = (reactFolder, module, rawName, framework)=>frontendKindLayouts(framework)[module.kind].target(reactFolder, new NestedName(reactModuleName(module.kind, rawName)));
|
|
2015
|
+
const react_module_move_targetPath = (reactFolder, module, rawName, framework)=>frontendKindLayouts(framework)[module.kind].target(reactFolder, new NestedName(reactModuleName(module.kind, rawName, framework)));
|
|
1990
2016
|
const validateMove = (reactFolder, module, rawName, framework = 'react')=>{
|
|
1991
2017
|
const nameError = NestedName.validate(rawName);
|
|
1992
2018
|
if (true !== nameError) return nameError;
|
|
1993
|
-
if (!
|
|
2019
|
+
if (!frontendKindLayouts(framework)[module.kind].nested && /[\\/]/.test(rawName)) return `UI-kit components and ${frontendKindTitles(framework).hook[1]} have no folders: enter a name without "/"`;
|
|
1994
2020
|
const target = react_module_move_targetPath(reactFolder, module, rawName, framework);
|
|
1995
2021
|
if (target !== module.path && external_node_fs_default().existsSync(target)) return `${external_node_path_default().relative(reactFolder, target)} already exists`;
|
|
1996
2022
|
if (target.startsWith(`${module.path}${external_node_path_default().sep}`)) return 'A widget cannot be moved into itself';
|
|
@@ -2005,10 +2031,11 @@ const routeFiles = (folder)=>external_node_fs_default().existsSync(folder) ? ext
|
|
|
2005
2031
|
}).filter((entry)=>entry.isFile()).map((entry)=>external_node_path_default().join(folder, entry.name)) : [];
|
|
2006
2032
|
const moveReactModule = (projectRoot, reactFolder, module, rawName, route, framework = 'react')=>{
|
|
2007
2033
|
const layout = frontendKindLayouts(framework)[module.kind];
|
|
2008
|
-
const newName = new NestedName(reactModuleName(module.kind, rawName));
|
|
2034
|
+
const newName = new NestedName(reactModuleName(module.kind, rawName, framework));
|
|
2035
|
+
const { prefix } = frontendLogicNaming[framework];
|
|
2009
2036
|
const target = react_module_move_targetPath(reactFolder, module, rawName, framework);
|
|
2010
2037
|
const newClassName = newName.ClassName;
|
|
2011
|
-
const renameFile = (name)=>name.replace(new RegExp(`^(
|
|
2038
|
+
const renameFile = (name)=>name.replace(new RegExp(`^(${prefix}-)?${escapeRegExp(module.fileBase)}(?=[-.]|$)`), (_, own = '')=>`${own}${newName.fileName}`);
|
|
2012
2039
|
const oldFolder = layout.inFolder ? module.path : external_node_path_default().dirname(module.path);
|
|
2013
2040
|
const newFolder = layout.inFolder ? target : external_node_path_default().dirname(target);
|
|
2014
2041
|
const ownsPath = (candidate)=>layout.inFolder ? candidate === oldFolder || candidate.startsWith(`${oldFolder}${external_node_path_default().sep}`) : external_node_path_default().dirname(candidate) === oldFolder && layout.ownFile(module.fileBase).test(external_node_path_default().basename(candidate));
|
|
@@ -2118,7 +2145,7 @@ const svelteComponentContent = (propsType)=>`
|
|
|
2118
2145
|
let props: ${propsType} = $props()
|
|
2119
2146
|
</script>
|
|
2120
2147
|
`.trim();
|
|
2121
|
-
const svelteStory = (storybookFramework, componentName, componentFile, title)=>`
|
|
2148
|
+
const svelteStory = (storybookFramework, componentName, componentFile, title, propsType)=>`
|
|
2122
2149
|
import type { Meta, StoryObj } from '${storybookFramework}'
|
|
2123
2150
|
import ${componentName} from './${componentFile}'
|
|
2124
2151
|
|
|
@@ -2132,6 +2159,7 @@ export default meta
|
|
|
2132
2159
|
type Story = StoryObj<typeof meta>
|
|
2133
2160
|
|
|
2134
2161
|
export const Default: Story = {
|
|
2162
|
+
// fill required props of ${propsType}
|
|
2135
2163
|
args: {}
|
|
2136
2164
|
}
|
|
2137
2165
|
`.trim();
|
|
@@ -2200,7 +2228,6 @@ const scaffoldSvelteWidget = async (presentationSvelteFolder)=>{
|
|
|
2200
2228
|
].join('/');
|
|
2201
2229
|
const widgetFileName = `${fileName}-widget`;
|
|
2202
2230
|
const uiFileName = `${fileName}-widget-ui`;
|
|
2203
|
-
const uiModelFileName = `use-${fileName}-ui-model`;
|
|
2204
2231
|
if ('monolithic' === widgetType) {
|
|
2205
2232
|
folder.createFile('index.ts', `
|
|
2206
2233
|
export { default as ${ClassName}Widget } from './${widgetFileName}.svelte'
|
|
@@ -2221,15 +2248,15 @@ export type ${ClassName}WidgetUIProps = { }
|
|
|
2221
2248
|
`.trim());
|
|
2222
2249
|
folder.createFile(`${widgetFileName}.svelte`, `
|
|
2223
2250
|
<script lang="ts">
|
|
2224
|
-
import type { ${ClassName}WidgetProps } from './types'
|
|
2251
|
+
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from './types'
|
|
2225
2252
|
import ${ClassName}WidgetUI from './ui/${uiFileName}.svelte'
|
|
2226
|
-
import { use${ClassName}UIModel } from './hooks/${uiModelFileName}.svelte'
|
|
2227
2253
|
|
|
2228
2254
|
let props: ${ClassName}WidgetProps = $props()
|
|
2229
|
-
|
|
2255
|
+
|
|
2256
|
+
const toUIProps = (): ${ClassName}WidgetUIProps => ({})
|
|
2230
2257
|
</script>
|
|
2231
2258
|
|
|
2232
|
-
<${ClassName}WidgetUI {...
|
|
2259
|
+
<${ClassName}WidgetUI {...toUIProps()} />
|
|
2233
2260
|
`.trim());
|
|
2234
2261
|
folder.subitem([
|
|
2235
2262
|
'ui'
|
|
@@ -2243,16 +2270,7 @@ export type ${ClassName}WidgetUIProps = { }
|
|
|
2243
2270
|
const framework = scaffold_svelte_modules_storybookFramework();
|
|
2244
2271
|
if (framework) folder.subitem([
|
|
2245
2272
|
'ui'
|
|
2246
|
-
]).createFile(`${uiFileName}.stories.ts`, svelteStory(framework, `${ClassName}WidgetUI`, `${uiFileName}.svelte`, storyTitle));
|
|
2247
|
-
folder.subitem([
|
|
2248
|
-
'hooks'
|
|
2249
|
-
]).createFile(`${uiModelFileName}.svelte.ts`, `
|
|
2250
|
-
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
2251
|
-
|
|
2252
|
-
export const use${ClassName}UIModel = (widgetProps: ${ClassName}WidgetProps): ${ClassName}WidgetUIProps => {
|
|
2253
|
-
return {}
|
|
2254
|
-
}
|
|
2255
|
-
`.trim());
|
|
2273
|
+
]).createFile(`${uiFileName}.stories.ts`, svelteStory(framework, `${ClassName}WidgetUI`, `${uiFileName}.svelte`, storyTitle, `${ClassName}WidgetUIProps`));
|
|
2256
2274
|
return;
|
|
2257
2275
|
}
|
|
2258
2276
|
folder.createFile('types.ts', `
|
|
@@ -2266,23 +2284,14 @@ export type ${ClassName}WidgetProps = {
|
|
|
2266
2284
|
`.trim());
|
|
2267
2285
|
folder.createFile(`${widgetFileName}.svelte`, `
|
|
2268
2286
|
<script lang="ts">
|
|
2269
|
-
import type { ${ClassName}WidgetProps } from './types'
|
|
2270
|
-
import { use${ClassName}UIModel } from './hooks/${uiModelFileName}.svelte'
|
|
2287
|
+
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from './types'
|
|
2271
2288
|
|
|
2272
|
-
let { UI, ...
|
|
2273
|
-
const uiModel = use${ClassName}UIModel(widgetProps)
|
|
2274
|
-
</script>
|
|
2289
|
+
let { UI, ...rest }: ${ClassName}WidgetProps = $props()
|
|
2275
2290
|
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
folder.subitem([
|
|
2279
|
-
'hooks'
|
|
2280
|
-
]).createFile(`${uiModelFileName}.svelte.ts`, `
|
|
2281
|
-
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
2291
|
+
const toUIProps = (): ${ClassName}WidgetUIProps => ({})
|
|
2292
|
+
</script>
|
|
2282
2293
|
|
|
2283
|
-
|
|
2284
|
-
return {}
|
|
2285
|
-
}
|
|
2294
|
+
<UI {...toUIProps()} />
|
|
2286
2295
|
`.trim());
|
|
2287
2296
|
};
|
|
2288
2297
|
const scaffoldSvelteUIKitComponent = async (presentationSvelteFolder)=>{
|
|
@@ -2301,18 +2310,19 @@ export type { ${ClassName}Props } from './${fileName}.svelte'
|
|
|
2301
2310
|
`.trim());
|
|
2302
2311
|
componentFolder.createFile(`${fileName}.svelte`, svelteComponentContent(`${ClassName}Props`));
|
|
2303
2312
|
const framework = scaffold_svelte_modules_storybookFramework();
|
|
2304
|
-
if (framework) componentFolder.createFile(`${fileName}.stories.ts`, svelteStory(framework, ClassName, `${fileName}.svelte`, `UI-kit/${ClassName}`));
|
|
2313
|
+
if (framework) componentFolder.createFile(`${fileName}.stories.ts`, svelteStory(framework, ClassName, `${fileName}.svelte`, `UI-kit/${ClassName}`, `${ClassName}Props`));
|
|
2305
2314
|
};
|
|
2306
|
-
const
|
|
2315
|
+
const scaffoldSvelteSharedModel = async (presentationSvelteFolder)=>{
|
|
2307
2316
|
const name = await interaction_input({
|
|
2308
2317
|
key: 'name',
|
|
2309
|
-
message: 'Name without "
|
|
2318
|
+
message: 'Name without "create" (e.g. debounce): '
|
|
2310
2319
|
});
|
|
2311
|
-
const { ClassName, fileName } = new UnknownFormatNaming(name.trim().replace(/^
|
|
2320
|
+
const { ClassName, fileName } = new UnknownFormatNaming(name.trim().replace(/^create-/, ''));
|
|
2312
2321
|
presentationSvelteFolder.subitem([
|
|
2313
|
-
'
|
|
2314
|
-
|
|
2315
|
-
|
|
2322
|
+
'shared',
|
|
2323
|
+
'model'
|
|
2324
|
+
]).createFile(`create-${fileName}.svelte.ts`, `
|
|
2325
|
+
export const create${ClassName} = () => {
|
|
2316
2326
|
return {}
|
|
2317
2327
|
}
|
|
2318
2328
|
`.trim());
|
|
@@ -2510,22 +2520,30 @@ const swaggerPage = (rootFolder, outputPath, withNext = false)=>{
|
|
|
2510
2520
|
});
|
|
2511
2521
|
return withNext ? `'use client'\n\n${page}` : page;
|
|
2512
2522
|
};
|
|
2513
|
-
const
|
|
2523
|
+
const svelteKitStaticFolder = 'static/';
|
|
2524
|
+
const svelteKitStaticUrl = (outputPath)=>outputPath.startsWith(svelteKitStaticFolder) ? `/${outputPath.slice(svelteKitStaticFolder.length)}` : void 0;
|
|
2525
|
+
const svelteSwaggerPage = (rootFolder, outputPath, url)=>`
|
|
2514
2526
|
<script lang="ts" module>
|
|
2515
2527
|
export type SwaggerPageProps = {}
|
|
2516
2528
|
</script>
|
|
2517
2529
|
|
|
2518
2530
|
<script lang="ts">
|
|
2519
|
-
import 'swagger-ui
|
|
2520
|
-
import {
|
|
2521
|
-
import
|
|
2531
|
+
import 'swagger-ui-dist/swagger-ui.css'
|
|
2532
|
+
import type { SwaggerUIBundle as SwaggerUIBundleType } from 'swagger-ui-dist'
|
|
2533
|
+
import { onMount } from 'svelte'${url ? '' : `
|
|
2534
|
+
import spec from '${specImportOf(swaggerPagePath(rootFolder, 'svelte'), outputPath)}'`}
|
|
2522
2535
|
|
|
2523
2536
|
let props: SwaggerPageProps = $props()
|
|
2524
2537
|
let container: HTMLDivElement
|
|
2525
2538
|
|
|
2526
2539
|
onMount(async () => {
|
|
2527
|
-
|
|
2528
|
-
|
|
2540
|
+
// Self-contained bundle: React is bundled inside, no react deps in the project
|
|
2541
|
+
const { default: SwaggerUIBundle } = (await import(
|
|
2542
|
+
// @ts-expect-error -- swagger-ui-dist ships no types for this entry point
|
|
2543
|
+
'swagger-ui-dist/swagger-ui-bundle.js'
|
|
2544
|
+
)) as { default: SwaggerUIBundleType }
|
|
2545
|
+
|
|
2546
|
+
SwaggerUIBundle({ domNode: container, ${url ? `url: '${url}'` : 'spec'}, displayOperationId: true })
|
|
2529
2547
|
})
|
|
2530
2548
|
</script>
|
|
2531
2549
|
|
|
@@ -2537,8 +2555,8 @@ const swaggerPackages = {
|
|
|
2537
2555
|
types: '@types/swagger-ui-react'
|
|
2538
2556
|
},
|
|
2539
2557
|
svelte: {
|
|
2540
|
-
dependency: 'swagger-ui',
|
|
2541
|
-
types: '@types/swagger-ui'
|
|
2558
|
+
dependency: 'swagger-ui-dist',
|
|
2559
|
+
types: '@types/swagger-ui-dist'
|
|
2542
2560
|
}
|
|
2543
2561
|
};
|
|
2544
2562
|
const openapiScripts = {
|
|
@@ -2625,15 +2643,16 @@ const addOpenapi = async ()=>{
|
|
|
2625
2643
|
if (!generatorFile.exists || generatorFile.data !== content) generatorFile.data = content;
|
|
2626
2644
|
const routeFile = withSwaggerPage && 'react' === framework && usesNext() ? `${nextAppFolder(root)}/swagger/page.tsx` : withSwaggerPage && 'svelte' === framework && usesSvelteKit() ? `${svelteKitRoutesFolder(root)}/swagger/+page.svelte` : void 0;
|
|
2627
2645
|
let routeHint;
|
|
2646
|
+
const specUrl = 'svelte' === framework && usesSvelteKit() ? svelteKitStaticUrl(splitPath(outputPath).join('/')) : void 0;
|
|
2628
2647
|
if (withSwaggerPage) {
|
|
2629
2648
|
const pagePath = external_node_path_default().join(root, swaggerPagePath(rootFolder, framework));
|
|
2630
2649
|
const pageFile = new file_system_File(pagePath);
|
|
2631
|
-
const page = 'svelte' === framework ? svelteSwaggerPage(rootFolder, splitPath(outputPath).join('/')) : swaggerPage(rootFolder, splitPath(outputPath).join('/'), !!routeFile);
|
|
2650
|
+
const page = 'svelte' === framework ? svelteSwaggerPage(rootFolder, splitPath(outputPath).join('/'), specUrl) : swaggerPage(rootFolder, splitPath(outputPath).join('/'), !!routeFile);
|
|
2632
2651
|
if (!pageFile.exists || pageFile.data !== page) pageFile.data = page;
|
|
2633
2652
|
if (routeFile) routeHint = ('svelte' === framework ? scaffoldSvelteKitRoute : scaffoldNextRoute)(new NestedName('swagger'), pagePath);
|
|
2634
2653
|
}
|
|
2635
2654
|
const packages = swaggerPackages[framework ?? 'react'];
|
|
2636
|
-
const resolveJsonModule = withSwaggerPage ? compilerOption(external_node_path_default().join(root, 'tsconfig.json'), 'resolveJsonModule') : true;
|
|
2655
|
+
const resolveJsonModule = withSwaggerPage && !specUrl ? compilerOption(external_node_path_default().join(root, 'tsconfig.json'), 'resolveJsonModule') : true;
|
|
2637
2656
|
const hasRestHandlers = new file_system_File(external_node_path_default().join(root, rootFolder, 'presentation', 'rest', 'index.ts')).exists;
|
|
2638
2657
|
const missingExtractorPackages = withExtractor ? extractorPackages.filter((name)=>!dependencies[name]) : [];
|
|
2639
2658
|
return [
|
|
@@ -2847,7 +2866,7 @@ const addOrval = async ()=>{
|
|
|
2847
2866
|
message: 'Generate:',
|
|
2848
2867
|
choices: [
|
|
2849
2868
|
{
|
|
2850
|
-
name: 'svelte' === framework ? 'Svelte Query
|
|
2869
|
+
name: 'svelte' === framework ? 'Svelte Query (createQuery)' : 'React Query hooks',
|
|
2851
2870
|
value: 'hooks',
|
|
2852
2871
|
checked: true
|
|
2853
2872
|
},
|
|
@@ -5114,7 +5133,7 @@ const scaffoldRequestSchema = external_zod_default().discriminatedUnion('operati
|
|
|
5114
5133
|
aggregate: agent_requests_name.optional()
|
|
5115
5134
|
})
|
|
5116
5135
|
]);
|
|
5117
|
-
const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnion('operation', [
|
|
5136
|
+
const frontendRequestSchema = (router, shared)=>external_zod_default().discriminatedUnion('operation', [
|
|
5118
5137
|
agent_requests_operation('page', {
|
|
5119
5138
|
...common,
|
|
5120
5139
|
name: agent_requests_nestedName
|
|
@@ -5132,7 +5151,7 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5132
5151
|
...common,
|
|
5133
5152
|
name: agent_requests_name
|
|
5134
5153
|
}),
|
|
5135
|
-
agent_requests_operation(
|
|
5154
|
+
agent_requests_operation(shared, {
|
|
5136
5155
|
...common,
|
|
5137
5156
|
name: agent_requests_name
|
|
5138
5157
|
}),
|
|
@@ -5156,7 +5175,7 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5156
5175
|
module: agent_requests_name,
|
|
5157
5176
|
name: agent_requests_name
|
|
5158
5177
|
}),
|
|
5159
|
-
agent_requests_operation(
|
|
5178
|
+
agent_requests_operation(`move-${shared}`, {
|
|
5160
5179
|
...common,
|
|
5161
5180
|
module: agent_requests_name,
|
|
5162
5181
|
name: agent_requests_name
|
|
@@ -5165,7 +5184,7 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5165
5184
|
...common,
|
|
5166
5185
|
module: agent_requests_name
|
|
5167
5186
|
}),
|
|
5168
|
-
agent_requests_operation(
|
|
5187
|
+
agent_requests_operation(`delete-${shared}`, {
|
|
5169
5188
|
...common,
|
|
5170
5189
|
module: agent_requests_name
|
|
5171
5190
|
}),
|
|
@@ -5175,8 +5194,8 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5175
5194
|
name: agent_requests_nestedName
|
|
5176
5195
|
})
|
|
5177
5196
|
]);
|
|
5178
|
-
const reactRequestSchema = frontendRequestSchema('Next.js');
|
|
5179
|
-
const svelteRequestSchema = frontendRequestSchema('SvelteKit');
|
|
5197
|
+
const reactRequestSchema = frontendRequestSchema('Next.js', 'shared-hook');
|
|
5198
|
+
const svelteRequestSchema = frontendRequestSchema('SvelteKit', 'shared-model');
|
|
5180
5199
|
const agent_requests_relativePath = external_zod_default().string().regex(/^[a-zA-Z0-9_.-]+(?:\/[a-zA-Z0-9_.-]+)*$/).refine((value)=>!value.split('/').some((part)=>'.' === part || '..' === part), 'Use a project-relative path without . or .. segments.');
|
|
5181
5200
|
const integrationRequestSchema = agent_requests_operation('add', {
|
|
5182
5201
|
...common,
|
|
@@ -5284,11 +5303,11 @@ const frameworkTitles = {
|
|
|
5284
5303
|
const deleteReactModuleUseCase = async (presentationReactFolder, kind, framework = 'react')=>{
|
|
5285
5304
|
const reactFolder = presentationReactFolder.path;
|
|
5286
5305
|
const modules = findReactModules(reactFolder, kind, framework);
|
|
5287
|
-
if (!modules.length) return void report(`No ${
|
|
5306
|
+
if (!modules.length) return void report(`No ${frontendKindTitles(framework)[kind][1]} generated by ${frameworkTitles[framework].cli} were found.`);
|
|
5288
5307
|
const module = await interaction_select({
|
|
5289
5308
|
key: 'module',
|
|
5290
5309
|
id: (value)=>value.name,
|
|
5291
|
-
message: `${
|
|
5310
|
+
message: `${frontendKindTitles(framework)[kind][0]} to delete:`,
|
|
5292
5311
|
choices: modules.map((value)=>({
|
|
5293
5312
|
name: value.name,
|
|
5294
5313
|
value,
|
|
@@ -5454,11 +5473,11 @@ const promptRouteMove = async (root, page, newName, framework)=>{
|
|
|
5454
5473
|
const moveReactModuleUseCase = async (presentationReactFolder, kind, framework = 'react')=>{
|
|
5455
5474
|
const reactFolder = presentationReactFolder.path;
|
|
5456
5475
|
const modules = findReactModules(reactFolder, kind, framework);
|
|
5457
|
-
if (!modules.length) return void report(`No ${
|
|
5476
|
+
if (!modules.length) return void report(`No ${frontendKindTitles(framework)[kind][1]} generated by ${frameworkTitles[framework].cli} were found.`);
|
|
5458
5477
|
const module = await interaction_select({
|
|
5459
5478
|
key: 'module',
|
|
5460
5479
|
id: (value)=>value.name,
|
|
5461
|
-
message: `${
|
|
5480
|
+
message: `${frontendKindTitles(framework)[kind][0]}:`,
|
|
5462
5481
|
choices: modules.map((value)=>({
|
|
5463
5482
|
name: value.name,
|
|
5464
5483
|
value,
|
|
@@ -6812,17 +6831,22 @@ export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps
|
|
|
6812
6831
|
break;
|
|
6813
6832
|
}
|
|
6814
6833
|
};
|
|
6834
|
+
const sharedLogicOperation = {
|
|
6835
|
+
react: 'shared-hook',
|
|
6836
|
+
svelte: 'shared-model'
|
|
6837
|
+
};
|
|
6815
6838
|
const frontendOperations = (folder, framework)=>{
|
|
6839
|
+
const shared = sharedLogicOperation[framework];
|
|
6816
6840
|
const scaffold = 'svelte' === framework ? {
|
|
6817
6841
|
page: scaffoldSveltePage,
|
|
6818
6842
|
widget: scaffoldSvelteWidget,
|
|
6819
6843
|
'ui-kit-component': scaffoldSvelteUIKitComponent,
|
|
6820
|
-
|
|
6844
|
+
shared: scaffoldSvelteSharedModel
|
|
6821
6845
|
} : {
|
|
6822
6846
|
page: scaffoldReactPage,
|
|
6823
6847
|
widget: scaffoldReactWidget,
|
|
6824
6848
|
'ui-kit-component': scaffoldReactUIKitComponent,
|
|
6825
|
-
|
|
6849
|
+
shared: scaffoldReactSharedHook
|
|
6826
6850
|
};
|
|
6827
6851
|
const move = (kind)=>()=>moveReactModuleUseCase(folder, kind, framework);
|
|
6828
6852
|
const remove = (kind)=>()=>deleteReactModuleUseCase(folder, kind, framework);
|
|
@@ -6830,15 +6854,15 @@ const frontendOperations = (folder, framework)=>{
|
|
|
6830
6854
|
page: ()=>scaffold.page(folder),
|
|
6831
6855
|
widget: ()=>scaffold.widget(folder),
|
|
6832
6856
|
'ui-kit-component': ()=>scaffold['ui-kit-component'](folder),
|
|
6833
|
-
|
|
6857
|
+
[shared]: ()=>scaffold.shared(folder),
|
|
6834
6858
|
'move-page': move('page'),
|
|
6835
6859
|
'move-widget': move('widget'),
|
|
6836
6860
|
'move-ui-kit-component': move('ui-kit'),
|
|
6837
|
-
|
|
6861
|
+
[`move-${shared}`]: move('hook'),
|
|
6838
6862
|
'delete-page': remove('page'),
|
|
6839
6863
|
'delete-widget': remove('widget'),
|
|
6840
6864
|
'delete-ui-kit-component': remove('ui-kit'),
|
|
6841
|
-
|
|
6865
|
+
[`delete-${shared}`]: remove('hook')
|
|
6842
6866
|
};
|
|
6843
6867
|
};
|
|
6844
6868
|
const requireProject = ()=>{
|
|
@@ -6884,7 +6908,7 @@ const frontendModules = (root, rootFolder, framework)=>[
|
|
|
6884
6908
|
'ui-kit',
|
|
6885
6909
|
'hook'
|
|
6886
6910
|
].flatMap((kind)=>findReactModules(external_node_path_default().join(root, rootFolder, 'presentation', framework), kind, framework).map((module)=>({
|
|
6887
|
-
kind,
|
|
6911
|
+
kind: 'svelte' === framework && 'hook' === kind ? 'model' : kind,
|
|
6888
6912
|
name: module.name,
|
|
6889
6913
|
file: external_node_path_default().relative(root, module.path).split(external_node_path_default().sep).join('/')
|
|
6890
6914
|
})));
|
|
@@ -7072,9 +7096,9 @@ const executeFrontend = async (request, framework)=>{
|
|
|
7072
7096
|
'presentation',
|
|
7073
7097
|
framework
|
|
7074
7098
|
]);
|
|
7075
|
-
const kindOf = (operation)=>operation.endsWith('-page') ? 'page' : operation.endsWith('-widget') ? 'widget' : operation.endsWith('-ui-kit-component') ? 'ui-kit' :
|
|
7099
|
+
const kindOf = (operation)=>operation.endsWith('-page') ? 'page' : operation.endsWith('-widget') ? 'widget' : operation.endsWith('-ui-kit-component') ? 'ui-kit' : /-shared-(hook|model)$/.test(operation) ? 'hook' : void 0;
|
|
7076
7100
|
const kind = /^(move|delete)-/.test(request.operation) ? kindOf(request.operation) : void 0;
|
|
7077
|
-
if (kind && !findReactModules(folder.path, kind, framework).length) throw new RequestError('TARGET_NOT_FOUND', `No ${frameworkTitles[framework].title} ${
|
|
7101
|
+
if (kind && !findReactModules(folder.path, kind, framework).length) throw new RequestError('TARGET_NOT_FOUND', `No ${frameworkTitles[framework].title} ${frontendKindTitles(framework)[kind][1]} here.`);
|
|
7078
7102
|
return frontendOperations(folder, framework)[request.operation]();
|
|
7079
7103
|
};
|
|
7080
7104
|
const executeAgentRequest = async (command, value)=>{
|
package/dist/integration.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
3
|
import { runCLI } from "./561.js";
|
|
4
|
-
import { ConfigFile, outdatedConfigMessage } from "./
|
|
4
|
+
import { ConfigFile, outdatedConfigMessage } from "./878.js";
|
|
5
5
|
import { addIntegration } from "./287.js";
|
|
6
6
|
runCLI('df-integration', async ()=>{
|
|
7
7
|
const help = `Usage: df-integration
|
|
@@ -10,10 +10,20 @@ export declare const swaggerPagePath: (rootFolder: string, framework?: FrontendF
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const swaggerPage: (rootFolder: string, outputPath: string, withNext?: boolean) => string;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* The URL SvelteKit serves the document at, when it is in `static/`:
|
|
14
|
+
* `static/docs/openapi.json` → `/docs/openapi.json`.
|
|
15
15
|
*/
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const svelteKitStaticUrl: (outputPath: string) => string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* A Svelte page rendering the OpenAPI document with Swagger UI. It uses
|
|
19
|
+
* the self-contained bundle of `swagger-ui-dist`, with its own React
|
|
20
|
+
* inside: `swagger-ui` takes React from the project, where Storybook may
|
|
21
|
+
* bring React 19 without the `createRoot` it calls. The bundle needs the
|
|
22
|
+
* browser, so it is loaded on mount and never runs during SSR. A document
|
|
23
|
+
* served from SvelteKit's `static/` is fetched by its `url`, so a
|
|
24
|
+
* regenerated one shows on reload and no JSON import is needed.
|
|
25
|
+
*/
|
|
26
|
+
export declare const svelteSwaggerPage: (rootFolder: string, outputPath: string, url?: string) => string;
|
|
17
27
|
export declare const openapiScripts: {
|
|
18
28
|
openapi: string;
|
|
19
29
|
};
|