@domain-first/project-structure 8.11.0 → 8.12.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 +1147 -0
- package/dist/{201.js → 878.js} +455 -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 +115 -4
- package/dist/graph.js +1 -1
- package/dist/index.cjs +129 -71
- package/dist/index.js +1 -1
- package/dist/init.cjs +49 -6
- package/dist/init.js +1 -1
- package/dist/integration.cjs +129 -71
- package/dist/integration.js +1 -1
- package/dist/integrations/openapi.d.ts +13 -3
- package/dist/lint.cjs +121 -9
- package/dist/lint.js +1 -1
- package/dist/react-module-move.d.ts +20 -2
- package/dist/react.cjs +185 -123
- package/dist/svelte.cjs +185 -123
- package/dist/upgrade-svelte.d.ts +15 -0
- package/dist/upgrade-svelte.spec.d.ts +1 -0
- package/dist/upgrade.cjs +296 -41
- package/dist/upgrade.js +132 -13
- package/dist/use-cases/scaffold-svelte-modules.d.ts +7 -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 +14 -9
- package/skills/df-ps-svelte/references/generators.md +5 -5
- package/dist/115.js +0 -616
package/dist/init.cjs
CHANGED
|
@@ -897,8 +897,26 @@ 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
|
+
widgetModel: 'hooks'
|
|
907
|
+
},
|
|
908
|
+
svelte: {
|
|
909
|
+
prefix: 'create',
|
|
910
|
+
shared: [
|
|
911
|
+
'shared',
|
|
912
|
+
'model'
|
|
913
|
+
],
|
|
914
|
+
widgetModel: 'model'
|
|
915
|
+
}
|
|
916
|
+
};
|
|
900
917
|
const react_module_move_kindLayouts = (framework)=>{
|
|
901
918
|
const { component, hook } = frontendExtensions[framework];
|
|
919
|
+
const { prefix, shared } = frontendLogicNaming[framework];
|
|
902
920
|
return {
|
|
903
921
|
page: {
|
|
904
922
|
folder: 'pages',
|
|
@@ -906,7 +924,7 @@ const react_module_move_kindLayouts = (framework)=>{
|
|
|
906
924
|
inFolder: false,
|
|
907
925
|
ownFile: (fileBase)=>new RegExp(`^${module_move_escapeRegExp(fileBase)}-page(?:\\.|$)`),
|
|
908
926
|
target: (reactFolder, { folders, fileName })=>external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page${component}`),
|
|
909
|
-
classPrefix:
|
|
927
|
+
classPrefix: `(${prefix})?`,
|
|
910
928
|
classSuffix: 'Page'
|
|
911
929
|
},
|
|
912
930
|
widget: {
|
|
@@ -914,7 +932,7 @@ const react_module_move_kindLayouts = (framework)=>{
|
|
|
914
932
|
nested: true,
|
|
915
933
|
inFolder: true,
|
|
916
934
|
target: (reactFolder, { folders, folderName })=>external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName),
|
|
917
|
-
classPrefix:
|
|
935
|
+
classPrefix: `(${prefix})?`,
|
|
918
936
|
classSuffix: 'Widget|UIModel',
|
|
919
937
|
storyTitle: (segments)=>[
|
|
920
938
|
'Widgets',
|
|
@@ -931,18 +949,43 @@ const react_module_move_kindLayouts = (framework)=>{
|
|
|
931
949
|
storyTitle: (segments)=>`UI-kit/${segments.join('')}`
|
|
932
950
|
},
|
|
933
951
|
hook: {
|
|
934
|
-
folder: '
|
|
952
|
+
folder: shared.join('/'),
|
|
935
953
|
nested: false,
|
|
936
954
|
inFolder: false,
|
|
937
|
-
ownFile: (fileBase)=>new RegExp(
|
|
938
|
-
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder,
|
|
939
|
-
classPrefix:
|
|
955
|
+
ownFile: (fileBase)=>new RegExp(`^${prefix}-${module_move_escapeRegExp(fileBase)}(?:\\.|$)`),
|
|
956
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, ...shared, `${prefix}-${fileName}${hook}`),
|
|
957
|
+
classPrefix: `(${prefix})`,
|
|
940
958
|
classSuffix: '(?![\\w$])'
|
|
941
959
|
}
|
|
942
960
|
};
|
|
943
961
|
};
|
|
944
962
|
react_module_move_kindLayouts('react');
|
|
945
963
|
react_module_move_kindLayouts('svelte');
|
|
964
|
+
const reactKindTitles = {
|
|
965
|
+
page: [
|
|
966
|
+
'Page',
|
|
967
|
+
'pages'
|
|
968
|
+
],
|
|
969
|
+
widget: [
|
|
970
|
+
'Widget',
|
|
971
|
+
'widgets'
|
|
972
|
+
],
|
|
973
|
+
'ui-kit': [
|
|
974
|
+
'UI-kit component',
|
|
975
|
+
'UI-kit components'
|
|
976
|
+
],
|
|
977
|
+
hook: [
|
|
978
|
+
'Shared hook',
|
|
979
|
+
'shared hooks'
|
|
980
|
+
]
|
|
981
|
+
};
|
|
982
|
+
({
|
|
983
|
+
...reactKindTitles,
|
|
984
|
+
hook: [
|
|
985
|
+
'Shared model',
|
|
986
|
+
'shared models'
|
|
987
|
+
]
|
|
988
|
+
});
|
|
946
989
|
const gitignore_addGitignoreEntry = (root, entry)=>{
|
|
947
990
|
const gitignore = new file_system_File(external_node_path_default().join(root, '.gitignore'));
|
|
948
991
|
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,26 @@ 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
|
+
widgetModel: 'hooks'
|
|
1846
|
+
},
|
|
1847
|
+
svelte: {
|
|
1848
|
+
prefix: 'create',
|
|
1849
|
+
shared: [
|
|
1850
|
+
'shared',
|
|
1851
|
+
'model'
|
|
1852
|
+
],
|
|
1853
|
+
widgetModel: 'model'
|
|
1854
|
+
}
|
|
1855
|
+
};
|
|
1839
1856
|
const kindLayouts = (framework)=>{
|
|
1840
1857
|
const { component, hook } = frontendExtensions[framework];
|
|
1858
|
+
const { prefix, shared } = frontendLogicNaming[framework];
|
|
1841
1859
|
return {
|
|
1842
1860
|
page: {
|
|
1843
1861
|
folder: 'pages',
|
|
@@ -1845,7 +1863,7 @@ const kindLayouts = (framework)=>{
|
|
|
1845
1863
|
inFolder: false,
|
|
1846
1864
|
ownFile: (fileBase)=>new RegExp(`^${escapeRegExp(fileBase)}-page(?:\\.|$)`),
|
|
1847
1865
|
target: (reactFolder, { folders, fileName })=>external_node_path_default().join(reactFolder, 'pages', ...folders, `${fileName}-page${component}`),
|
|
1848
|
-
classPrefix:
|
|
1866
|
+
classPrefix: `(${prefix})?`,
|
|
1849
1867
|
classSuffix: 'Page'
|
|
1850
1868
|
},
|
|
1851
1869
|
widget: {
|
|
@@ -1853,7 +1871,7 @@ const kindLayouts = (framework)=>{
|
|
|
1853
1871
|
nested: true,
|
|
1854
1872
|
inFolder: true,
|
|
1855
1873
|
target: (reactFolder, { folders, folderName })=>external_node_path_default().join(reactFolder, 'widgets', ...folders, folderName),
|
|
1856
|
-
classPrefix:
|
|
1874
|
+
classPrefix: `(${prefix})?`,
|
|
1857
1875
|
classSuffix: 'Widget|UIModel',
|
|
1858
1876
|
storyTitle: (segments)=>[
|
|
1859
1877
|
'Widgets',
|
|
@@ -1870,12 +1888,12 @@ const kindLayouts = (framework)=>{
|
|
|
1870
1888
|
storyTitle: (segments)=>`UI-kit/${segments.join('')}`
|
|
1871
1889
|
},
|
|
1872
1890
|
hook: {
|
|
1873
|
-
folder: '
|
|
1891
|
+
folder: shared.join('/'),
|
|
1874
1892
|
nested: false,
|
|
1875
1893
|
inFolder: false,
|
|
1876
|
-
ownFile: (fileBase)=>new RegExp(
|
|
1877
|
-
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder,
|
|
1878
|
-
classPrefix:
|
|
1894
|
+
ownFile: (fileBase)=>new RegExp(`^${prefix}-${escapeRegExp(fileBase)}(?:\\.|$)`),
|
|
1895
|
+
target: (reactFolder, { fileName })=>external_node_path_default().join(reactFolder, ...shared, `${prefix}-${fileName}${hook}`),
|
|
1896
|
+
classPrefix: `(${prefix})`,
|
|
1879
1897
|
classSuffix: '(?![\\w$])'
|
|
1880
1898
|
}
|
|
1881
1899
|
};
|
|
@@ -1901,7 +1919,15 @@ const reactKindTitles = {
|
|
|
1901
1919
|
'shared hooks'
|
|
1902
1920
|
]
|
|
1903
1921
|
};
|
|
1904
|
-
const
|
|
1922
|
+
const svelteKindTitles = {
|
|
1923
|
+
...reactKindTitles,
|
|
1924
|
+
hook: [
|
|
1925
|
+
'Shared model',
|
|
1926
|
+
'shared models'
|
|
1927
|
+
]
|
|
1928
|
+
};
|
|
1929
|
+
const frontendKindTitles = (framework)=>'svelte' === framework ? svelteKindTitles : reactKindTitles;
|
|
1930
|
+
const reactModuleName = (kind, rawName, framework = 'react')=>'hook' === kind ? rawName.trim().replace(new RegExp(`^${frontendLogicNaming[framework].prefix}-`), '') : rawName;
|
|
1905
1931
|
const react_module_move_nestedName = (folders, fileBase)=>{
|
|
1906
1932
|
const prefix = `${folders.join('-')}-`;
|
|
1907
1933
|
const last = folders.length && fileBase.startsWith(prefix) ? fileBase.slice(prefix.length) : fileBase;
|
|
@@ -1940,18 +1966,20 @@ const hookFile = {
|
|
|
1940
1966
|
svelte: /\.svelte\.[jt]s$/
|
|
1941
1967
|
};
|
|
1942
1968
|
const findHooks = (reactFolder, framework)=>{
|
|
1943
|
-
const
|
|
1969
|
+
const { prefix, shared } = frontendLogicNaming[framework];
|
|
1970
|
+
const root = external_node_path_default().join(reactFolder, ...shared);
|
|
1944
1971
|
if (!external_node_fs_default().existsSync(root)) return [];
|
|
1945
1972
|
const extension = hookFile[framework];
|
|
1946
|
-
|
|
1947
|
-
|
|
1973
|
+
const ownPrefix = new RegExp(`^${prefix}-`);
|
|
1974
|
+
return external_node_fs_default().readdirSync(root).filter((file)=>ownPrefix.test(file) && extension.test(file) && !/\.(spec|test)\./.test(file)).map((file)=>{
|
|
1975
|
+
const name = file.replace(ownPrefix, '').replace(extension, '');
|
|
1948
1976
|
const content = external_node_fs_default().readFileSync(external_node_path_default().join(root, file), 'utf8');
|
|
1949
1977
|
return {
|
|
1950
1978
|
kind: 'hook',
|
|
1951
1979
|
name,
|
|
1952
1980
|
path: external_node_path_default().join(root, file),
|
|
1953
1981
|
fileBase: name,
|
|
1954
|
-
ClassName: content.match(
|
|
1982
|
+
ClassName: content.match(new RegExp(`export\\s+(?:const|function)\\s+${prefix}(\\w+)\\b`))?.[1] ?? new NestedName(name).ClassName
|
|
1955
1983
|
};
|
|
1956
1984
|
});
|
|
1957
1985
|
};
|
|
@@ -1986,11 +2014,11 @@ const findReactModules = (reactFolder, kind, framework = 'react')=>{
|
|
|
1986
2014
|
});
|
|
1987
2015
|
return modules.sort((a, b)=>a.name.localeCompare(b.name));
|
|
1988
2016
|
};
|
|
1989
|
-
const react_module_move_targetPath = (reactFolder, module, rawName, framework)=>frontendKindLayouts(framework)[module.kind].target(reactFolder, new NestedName(reactModuleName(module.kind, rawName)));
|
|
2017
|
+
const react_module_move_targetPath = (reactFolder, module, rawName, framework)=>frontendKindLayouts(framework)[module.kind].target(reactFolder, new NestedName(reactModuleName(module.kind, rawName, framework)));
|
|
1990
2018
|
const validateMove = (reactFolder, module, rawName, framework = 'react')=>{
|
|
1991
2019
|
const nameError = NestedName.validate(rawName);
|
|
1992
2020
|
if (true !== nameError) return nameError;
|
|
1993
|
-
if (!
|
|
2021
|
+
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
2022
|
const target = react_module_move_targetPath(reactFolder, module, rawName, framework);
|
|
1995
2023
|
if (target !== module.path && external_node_fs_default().existsSync(target)) return `${external_node_path_default().relative(reactFolder, target)} already exists`;
|
|
1996
2024
|
if (target.startsWith(`${module.path}${external_node_path_default().sep}`)) return 'A widget cannot be moved into itself';
|
|
@@ -2005,10 +2033,11 @@ const routeFiles = (folder)=>external_node_fs_default().existsSync(folder) ? ext
|
|
|
2005
2033
|
}).filter((entry)=>entry.isFile()).map((entry)=>external_node_path_default().join(folder, entry.name)) : [];
|
|
2006
2034
|
const moveReactModule = (projectRoot, reactFolder, module, rawName, route, framework = 'react')=>{
|
|
2007
2035
|
const layout = frontendKindLayouts(framework)[module.kind];
|
|
2008
|
-
const newName = new NestedName(reactModuleName(module.kind, rawName));
|
|
2036
|
+
const newName = new NestedName(reactModuleName(module.kind, rawName, framework));
|
|
2037
|
+
const { prefix } = frontendLogicNaming[framework];
|
|
2009
2038
|
const target = react_module_move_targetPath(reactFolder, module, rawName, framework);
|
|
2010
2039
|
const newClassName = newName.ClassName;
|
|
2011
|
-
const renameFile = (name)=>name.replace(new RegExp(`^(
|
|
2040
|
+
const renameFile = (name)=>name.replace(new RegExp(`^(${prefix}-)?${escapeRegExp(module.fileBase)}(?=[-.]|$)`), (_, own = '')=>`${own}${newName.fileName}`);
|
|
2012
2041
|
const oldFolder = layout.inFolder ? module.path : external_node_path_default().dirname(module.path);
|
|
2013
2042
|
const newFolder = layout.inFolder ? target : external_node_path_default().dirname(target);
|
|
2014
2043
|
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));
|
|
@@ -2135,6 +2164,28 @@ export const Default: Story = {
|
|
|
2135
2164
|
args: {}
|
|
2136
2165
|
}
|
|
2137
2166
|
`.trim();
|
|
2167
|
+
const svelteUIModelContent = (ClassName, propsType)=>`
|
|
2168
|
+
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
2169
|
+
|
|
2170
|
+
/**
|
|
2171
|
+
* - widgetProps is the $props() proxy as a whole: destructuring it in the
|
|
2172
|
+
* signature (({ a }) =>) or copying it ({ ...props }) loses reactivity
|
|
2173
|
+
* - values depending on props: $derived, exposed through getters only
|
|
2174
|
+
* - local state: $state; methods: plain functions of the returned object
|
|
2175
|
+
* - getters satisfy ${ClassName}WidgetUIProps
|
|
2176
|
+
*/
|
|
2177
|
+
export const create${ClassName}UIModel = (
|
|
2178
|
+
widgetProps: ${propsType},
|
|
2179
|
+
): ${ClassName}WidgetUIProps => {
|
|
2180
|
+
// derived values go here
|
|
2181
|
+
// const value = $derived(widgetProps.value)
|
|
2182
|
+
|
|
2183
|
+
return {
|
|
2184
|
+
// expose values via getters to keep reactivity:
|
|
2185
|
+
// get value() { return value },
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
`.trim();
|
|
2138
2189
|
const scaffold_svelte_modules_storybookFramework = ()=>config_file_ConfigFile.Instance.data.frontend?.svelte?.storybookFramework;
|
|
2139
2190
|
const svelteKitRouteContent = (ClassName, pageImport)=>`
|
|
2140
2191
|
<script lang="ts">
|
|
@@ -2200,7 +2251,7 @@ const scaffoldSvelteWidget = async (presentationSvelteFolder)=>{
|
|
|
2200
2251
|
].join('/');
|
|
2201
2252
|
const widgetFileName = `${fileName}-widget`;
|
|
2202
2253
|
const uiFileName = `${fileName}-widget-ui`;
|
|
2203
|
-
const uiModelFileName = `
|
|
2254
|
+
const uiModelFileName = `create-${fileName}-ui-model`;
|
|
2204
2255
|
if ('monolithic' === widgetType) {
|
|
2205
2256
|
folder.createFile('index.ts', `
|
|
2206
2257
|
export { default as ${ClassName}Widget } from './${widgetFileName}.svelte'
|
|
@@ -2223,10 +2274,12 @@ export type ${ClassName}WidgetUIProps = { }
|
|
|
2223
2274
|
<script lang="ts">
|
|
2224
2275
|
import type { ${ClassName}WidgetProps } from './types'
|
|
2225
2276
|
import ${ClassName}WidgetUI from './ui/${uiFileName}.svelte'
|
|
2226
|
-
import {
|
|
2277
|
+
import { create${ClassName}UIModel } from './model/${uiModelFileName}.svelte'
|
|
2227
2278
|
|
|
2228
2279
|
let props: ${ClassName}WidgetProps = $props()
|
|
2229
|
-
|
|
2280
|
+
// The $props() proxy stays reactive: the model reads it in $derived and getters
|
|
2281
|
+
// svelte-ignore state_referenced_locally
|
|
2282
|
+
const uiModel = create${ClassName}UIModel(props)
|
|
2230
2283
|
</script>
|
|
2231
2284
|
|
|
2232
2285
|
<${ClassName}WidgetUI {...uiModel} />
|
|
@@ -2245,14 +2298,8 @@ export type ${ClassName}WidgetUIProps = { }
|
|
|
2245
2298
|
'ui'
|
|
2246
2299
|
]).createFile(`${uiFileName}.stories.ts`, svelteStory(framework, `${ClassName}WidgetUI`, `${uiFileName}.svelte`, storyTitle));
|
|
2247
2300
|
folder.subitem([
|
|
2248
|
-
'
|
|
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());
|
|
2301
|
+
'model'
|
|
2302
|
+
]).createFile(`${uiModelFileName}.svelte.ts`, svelteUIModelContent(ClassName, `${ClassName}WidgetProps`));
|
|
2256
2303
|
return;
|
|
2257
2304
|
}
|
|
2258
2305
|
folder.createFile('types.ts', `
|
|
@@ -2267,23 +2314,19 @@ export type ${ClassName}WidgetProps = {
|
|
|
2267
2314
|
folder.createFile(`${widgetFileName}.svelte`, `
|
|
2268
2315
|
<script lang="ts">
|
|
2269
2316
|
import type { ${ClassName}WidgetProps } from './types'
|
|
2270
|
-
import {
|
|
2317
|
+
import { create${ClassName}UIModel } from './model/${uiModelFileName}.svelte'
|
|
2271
2318
|
|
|
2272
2319
|
let { UI, ...widgetProps }: ${ClassName}WidgetProps = $props()
|
|
2273
|
-
|
|
2320
|
+
// The rest of $props() stays reactive, a copy made by hand would not
|
|
2321
|
+
// svelte-ignore state_referenced_locally
|
|
2322
|
+
const uiModel = create${ClassName}UIModel(widgetProps)
|
|
2274
2323
|
</script>
|
|
2275
2324
|
|
|
2276
2325
|
<UI {...uiModel} />
|
|
2277
2326
|
`.trim());
|
|
2278
2327
|
folder.subitem([
|
|
2279
|
-
'
|
|
2280
|
-
]).createFile(`${uiModelFileName}.svelte.ts`, `
|
|
2281
|
-
import type { ${ClassName}WidgetProps, ${ClassName}WidgetUIProps } from '../types'
|
|
2282
|
-
|
|
2283
|
-
export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps, 'UI'>): ${ClassName}WidgetUIProps => {
|
|
2284
|
-
return {}
|
|
2285
|
-
}
|
|
2286
|
-
`.trim());
|
|
2328
|
+
'model'
|
|
2329
|
+
]).createFile(`${uiModelFileName}.svelte.ts`, svelteUIModelContent(ClassName, `Omit<${ClassName}WidgetProps, 'UI'>`));
|
|
2287
2330
|
};
|
|
2288
2331
|
const scaffoldSvelteUIKitComponent = async (presentationSvelteFolder)=>{
|
|
2289
2332
|
const name = await interaction_input({
|
|
@@ -2303,16 +2346,17 @@ export type { ${ClassName}Props } from './${fileName}.svelte'
|
|
|
2303
2346
|
const framework = scaffold_svelte_modules_storybookFramework();
|
|
2304
2347
|
if (framework) componentFolder.createFile(`${fileName}.stories.ts`, svelteStory(framework, ClassName, `${fileName}.svelte`, `UI-kit/${ClassName}`));
|
|
2305
2348
|
};
|
|
2306
|
-
const
|
|
2349
|
+
const scaffoldSvelteSharedModel = async (presentationSvelteFolder)=>{
|
|
2307
2350
|
const name = await interaction_input({
|
|
2308
2351
|
key: 'name',
|
|
2309
|
-
message: 'Name without "
|
|
2352
|
+
message: 'Name without "create" (e.g. debounce): '
|
|
2310
2353
|
});
|
|
2311
|
-
const { ClassName, fileName } = new UnknownFormatNaming(name.trim().replace(/^
|
|
2354
|
+
const { ClassName, fileName } = new UnknownFormatNaming(name.trim().replace(/^create-/, ''));
|
|
2312
2355
|
presentationSvelteFolder.subitem([
|
|
2313
|
-
'
|
|
2314
|
-
|
|
2315
|
-
|
|
2356
|
+
'shared',
|
|
2357
|
+
'model'
|
|
2358
|
+
]).createFile(`create-${fileName}.svelte.ts`, `
|
|
2359
|
+
export const create${ClassName} = () => {
|
|
2316
2360
|
return {}
|
|
2317
2361
|
}
|
|
2318
2362
|
`.trim());
|
|
@@ -2510,22 +2554,30 @@ const swaggerPage = (rootFolder, outputPath, withNext = false)=>{
|
|
|
2510
2554
|
});
|
|
2511
2555
|
return withNext ? `'use client'\n\n${page}` : page;
|
|
2512
2556
|
};
|
|
2513
|
-
const
|
|
2557
|
+
const svelteKitStaticFolder = 'static/';
|
|
2558
|
+
const svelteKitStaticUrl = (outputPath)=>outputPath.startsWith(svelteKitStaticFolder) ? `/${outputPath.slice(svelteKitStaticFolder.length)}` : void 0;
|
|
2559
|
+
const svelteSwaggerPage = (rootFolder, outputPath, url)=>`
|
|
2514
2560
|
<script lang="ts" module>
|
|
2515
2561
|
export type SwaggerPageProps = {}
|
|
2516
2562
|
</script>
|
|
2517
2563
|
|
|
2518
2564
|
<script lang="ts">
|
|
2519
|
-
import 'swagger-ui
|
|
2520
|
-
import {
|
|
2521
|
-
import
|
|
2565
|
+
import 'swagger-ui-dist/swagger-ui.css'
|
|
2566
|
+
import type { SwaggerUIBundle as SwaggerUIBundleType } from 'swagger-ui-dist'
|
|
2567
|
+
import { onMount } from 'svelte'${url ? '' : `
|
|
2568
|
+
import spec from '${specImportOf(swaggerPagePath(rootFolder, 'svelte'), outputPath)}'`}
|
|
2522
2569
|
|
|
2523
2570
|
let props: SwaggerPageProps = $props()
|
|
2524
2571
|
let container: HTMLDivElement
|
|
2525
2572
|
|
|
2526
2573
|
onMount(async () => {
|
|
2527
|
-
|
|
2528
|
-
|
|
2574
|
+
// Self-contained bundle: React is bundled inside, no react deps in the project
|
|
2575
|
+
const { default: SwaggerUIBundle } = (await import(
|
|
2576
|
+
// @ts-expect-error -- swagger-ui-dist ships no types for this entry point
|
|
2577
|
+
'swagger-ui-dist/swagger-ui-bundle.js'
|
|
2578
|
+
)) as { default: SwaggerUIBundleType }
|
|
2579
|
+
|
|
2580
|
+
SwaggerUIBundle({ domNode: container, ${url ? `url: '${url}'` : 'spec'}, displayOperationId: true })
|
|
2529
2581
|
})
|
|
2530
2582
|
</script>
|
|
2531
2583
|
|
|
@@ -2537,8 +2589,8 @@ const swaggerPackages = {
|
|
|
2537
2589
|
types: '@types/swagger-ui-react'
|
|
2538
2590
|
},
|
|
2539
2591
|
svelte: {
|
|
2540
|
-
dependency: 'swagger-ui',
|
|
2541
|
-
types: '@types/swagger-ui'
|
|
2592
|
+
dependency: 'swagger-ui-dist',
|
|
2593
|
+
types: '@types/swagger-ui-dist'
|
|
2542
2594
|
}
|
|
2543
2595
|
};
|
|
2544
2596
|
const openapiScripts = {
|
|
@@ -2625,15 +2677,16 @@ const addOpenapi = async ()=>{
|
|
|
2625
2677
|
if (!generatorFile.exists || generatorFile.data !== content) generatorFile.data = content;
|
|
2626
2678
|
const routeFile = withSwaggerPage && 'react' === framework && usesNext() ? `${nextAppFolder(root)}/swagger/page.tsx` : withSwaggerPage && 'svelte' === framework && usesSvelteKit() ? `${svelteKitRoutesFolder(root)}/swagger/+page.svelte` : void 0;
|
|
2627
2679
|
let routeHint;
|
|
2680
|
+
const specUrl = 'svelte' === framework && usesSvelteKit() ? svelteKitStaticUrl(splitPath(outputPath).join('/')) : void 0;
|
|
2628
2681
|
if (withSwaggerPage) {
|
|
2629
2682
|
const pagePath = external_node_path_default().join(root, swaggerPagePath(rootFolder, framework));
|
|
2630
2683
|
const pageFile = new file_system_File(pagePath);
|
|
2631
|
-
const page = 'svelte' === framework ? svelteSwaggerPage(rootFolder, splitPath(outputPath).join('/')) : swaggerPage(rootFolder, splitPath(outputPath).join('/'), !!routeFile);
|
|
2684
|
+
const page = 'svelte' === framework ? svelteSwaggerPage(rootFolder, splitPath(outputPath).join('/'), specUrl) : swaggerPage(rootFolder, splitPath(outputPath).join('/'), !!routeFile);
|
|
2632
2685
|
if (!pageFile.exists || pageFile.data !== page) pageFile.data = page;
|
|
2633
2686
|
if (routeFile) routeHint = ('svelte' === framework ? scaffoldSvelteKitRoute : scaffoldNextRoute)(new NestedName('swagger'), pagePath);
|
|
2634
2687
|
}
|
|
2635
2688
|
const packages = swaggerPackages[framework ?? 'react'];
|
|
2636
|
-
const resolveJsonModule = withSwaggerPage ? compilerOption(external_node_path_default().join(root, 'tsconfig.json'), 'resolveJsonModule') : true;
|
|
2689
|
+
const resolveJsonModule = withSwaggerPage && !specUrl ? compilerOption(external_node_path_default().join(root, 'tsconfig.json'), 'resolveJsonModule') : true;
|
|
2637
2690
|
const hasRestHandlers = new file_system_File(external_node_path_default().join(root, rootFolder, 'presentation', 'rest', 'index.ts')).exists;
|
|
2638
2691
|
const missingExtractorPackages = withExtractor ? extractorPackages.filter((name)=>!dependencies[name]) : [];
|
|
2639
2692
|
return [
|
|
@@ -2847,7 +2900,7 @@ const addOrval = async ()=>{
|
|
|
2847
2900
|
message: 'Generate:',
|
|
2848
2901
|
choices: [
|
|
2849
2902
|
{
|
|
2850
|
-
name: 'svelte' === framework ? 'Svelte Query
|
|
2903
|
+
name: 'svelte' === framework ? 'Svelte Query (createQuery)' : 'React Query hooks',
|
|
2851
2904
|
value: 'hooks',
|
|
2852
2905
|
checked: true
|
|
2853
2906
|
},
|
|
@@ -5114,7 +5167,7 @@ const scaffoldRequestSchema = external_zod_default().discriminatedUnion('operati
|
|
|
5114
5167
|
aggregate: agent_requests_name.optional()
|
|
5115
5168
|
})
|
|
5116
5169
|
]);
|
|
5117
|
-
const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnion('operation', [
|
|
5170
|
+
const frontendRequestSchema = (router, shared)=>external_zod_default().discriminatedUnion('operation', [
|
|
5118
5171
|
agent_requests_operation('page', {
|
|
5119
5172
|
...common,
|
|
5120
5173
|
name: agent_requests_nestedName
|
|
@@ -5132,7 +5185,7 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5132
5185
|
...common,
|
|
5133
5186
|
name: agent_requests_name
|
|
5134
5187
|
}),
|
|
5135
|
-
agent_requests_operation(
|
|
5188
|
+
agent_requests_operation(shared, {
|
|
5136
5189
|
...common,
|
|
5137
5190
|
name: agent_requests_name
|
|
5138
5191
|
}),
|
|
@@ -5156,7 +5209,7 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5156
5209
|
module: agent_requests_name,
|
|
5157
5210
|
name: agent_requests_name
|
|
5158
5211
|
}),
|
|
5159
|
-
agent_requests_operation(
|
|
5212
|
+
agent_requests_operation(`move-${shared}`, {
|
|
5160
5213
|
...common,
|
|
5161
5214
|
module: agent_requests_name,
|
|
5162
5215
|
name: agent_requests_name
|
|
@@ -5165,7 +5218,7 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5165
5218
|
...common,
|
|
5166
5219
|
module: agent_requests_name
|
|
5167
5220
|
}),
|
|
5168
|
-
agent_requests_operation(
|
|
5221
|
+
agent_requests_operation(`delete-${shared}`, {
|
|
5169
5222
|
...common,
|
|
5170
5223
|
module: agent_requests_name
|
|
5171
5224
|
}),
|
|
@@ -5175,8 +5228,8 @@ const frontendRequestSchema = (router)=>external_zod_default().discriminatedUnio
|
|
|
5175
5228
|
name: agent_requests_nestedName
|
|
5176
5229
|
})
|
|
5177
5230
|
]);
|
|
5178
|
-
const reactRequestSchema = frontendRequestSchema('Next.js');
|
|
5179
|
-
const svelteRequestSchema = frontendRequestSchema('SvelteKit');
|
|
5231
|
+
const reactRequestSchema = frontendRequestSchema('Next.js', 'shared-hook');
|
|
5232
|
+
const svelteRequestSchema = frontendRequestSchema('SvelteKit', 'shared-model');
|
|
5180
5233
|
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
5234
|
const integrationRequestSchema = agent_requests_operation('add', {
|
|
5182
5235
|
...common,
|
|
@@ -5284,11 +5337,11 @@ const frameworkTitles = {
|
|
|
5284
5337
|
const deleteReactModuleUseCase = async (presentationReactFolder, kind, framework = 'react')=>{
|
|
5285
5338
|
const reactFolder = presentationReactFolder.path;
|
|
5286
5339
|
const modules = findReactModules(reactFolder, kind, framework);
|
|
5287
|
-
if (!modules.length) return void report(`No ${
|
|
5340
|
+
if (!modules.length) return void report(`No ${frontendKindTitles(framework)[kind][1]} generated by ${frameworkTitles[framework].cli} were found.`);
|
|
5288
5341
|
const module = await interaction_select({
|
|
5289
5342
|
key: 'module',
|
|
5290
5343
|
id: (value)=>value.name,
|
|
5291
|
-
message: `${
|
|
5344
|
+
message: `${frontendKindTitles(framework)[kind][0]} to delete:`,
|
|
5292
5345
|
choices: modules.map((value)=>({
|
|
5293
5346
|
name: value.name,
|
|
5294
5347
|
value,
|
|
@@ -5454,11 +5507,11 @@ const promptRouteMove = async (root, page, newName, framework)=>{
|
|
|
5454
5507
|
const moveReactModuleUseCase = async (presentationReactFolder, kind, framework = 'react')=>{
|
|
5455
5508
|
const reactFolder = presentationReactFolder.path;
|
|
5456
5509
|
const modules = findReactModules(reactFolder, kind, framework);
|
|
5457
|
-
if (!modules.length) return void report(`No ${
|
|
5510
|
+
if (!modules.length) return void report(`No ${frontendKindTitles(framework)[kind][1]} generated by ${frameworkTitles[framework].cli} were found.`);
|
|
5458
5511
|
const module = await interaction_select({
|
|
5459
5512
|
key: 'module',
|
|
5460
5513
|
id: (value)=>value.name,
|
|
5461
|
-
message: `${
|
|
5514
|
+
message: `${frontendKindTitles(framework)[kind][0]}:`,
|
|
5462
5515
|
choices: modules.map((value)=>({
|
|
5463
5516
|
name: value.name,
|
|
5464
5517
|
value,
|
|
@@ -6812,17 +6865,22 @@ export const use${ClassName}UIModel = (widgetProps: Omit<${ClassName}WidgetProps
|
|
|
6812
6865
|
break;
|
|
6813
6866
|
}
|
|
6814
6867
|
};
|
|
6868
|
+
const sharedLogicOperation = {
|
|
6869
|
+
react: 'shared-hook',
|
|
6870
|
+
svelte: 'shared-model'
|
|
6871
|
+
};
|
|
6815
6872
|
const frontendOperations = (folder, framework)=>{
|
|
6873
|
+
const shared = sharedLogicOperation[framework];
|
|
6816
6874
|
const scaffold = 'svelte' === framework ? {
|
|
6817
6875
|
page: scaffoldSveltePage,
|
|
6818
6876
|
widget: scaffoldSvelteWidget,
|
|
6819
6877
|
'ui-kit-component': scaffoldSvelteUIKitComponent,
|
|
6820
|
-
|
|
6878
|
+
shared: scaffoldSvelteSharedModel
|
|
6821
6879
|
} : {
|
|
6822
6880
|
page: scaffoldReactPage,
|
|
6823
6881
|
widget: scaffoldReactWidget,
|
|
6824
6882
|
'ui-kit-component': scaffoldReactUIKitComponent,
|
|
6825
|
-
|
|
6883
|
+
shared: scaffoldReactSharedHook
|
|
6826
6884
|
};
|
|
6827
6885
|
const move = (kind)=>()=>moveReactModuleUseCase(folder, kind, framework);
|
|
6828
6886
|
const remove = (kind)=>()=>deleteReactModuleUseCase(folder, kind, framework);
|
|
@@ -6830,15 +6888,15 @@ const frontendOperations = (folder, framework)=>{
|
|
|
6830
6888
|
page: ()=>scaffold.page(folder),
|
|
6831
6889
|
widget: ()=>scaffold.widget(folder),
|
|
6832
6890
|
'ui-kit-component': ()=>scaffold['ui-kit-component'](folder),
|
|
6833
|
-
|
|
6891
|
+
[shared]: ()=>scaffold.shared(folder),
|
|
6834
6892
|
'move-page': move('page'),
|
|
6835
6893
|
'move-widget': move('widget'),
|
|
6836
6894
|
'move-ui-kit-component': move('ui-kit'),
|
|
6837
|
-
|
|
6895
|
+
[`move-${shared}`]: move('hook'),
|
|
6838
6896
|
'delete-page': remove('page'),
|
|
6839
6897
|
'delete-widget': remove('widget'),
|
|
6840
6898
|
'delete-ui-kit-component': remove('ui-kit'),
|
|
6841
|
-
|
|
6899
|
+
[`delete-${shared}`]: remove('hook')
|
|
6842
6900
|
};
|
|
6843
6901
|
};
|
|
6844
6902
|
const requireProject = ()=>{
|
|
@@ -6884,7 +6942,7 @@ const frontendModules = (root, rootFolder, framework)=>[
|
|
|
6884
6942
|
'ui-kit',
|
|
6885
6943
|
'hook'
|
|
6886
6944
|
].flatMap((kind)=>findReactModules(external_node_path_default().join(root, rootFolder, 'presentation', framework), kind, framework).map((module)=>({
|
|
6887
|
-
kind,
|
|
6945
|
+
kind: 'svelte' === framework && 'hook' === kind ? 'model' : kind,
|
|
6888
6946
|
name: module.name,
|
|
6889
6947
|
file: external_node_path_default().relative(root, module.path).split(external_node_path_default().sep).join('/')
|
|
6890
6948
|
})));
|
|
@@ -7072,9 +7130,9 @@ const executeFrontend = async (request, framework)=>{
|
|
|
7072
7130
|
'presentation',
|
|
7073
7131
|
framework
|
|
7074
7132
|
]);
|
|
7075
|
-
const kindOf = (operation)=>operation.endsWith('-page') ? 'page' : operation.endsWith('-widget') ? 'widget' : operation.endsWith('-ui-kit-component') ? 'ui-kit' :
|
|
7133
|
+
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
7134
|
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} ${
|
|
7135
|
+
if (kind && !findReactModules(folder.path, kind, framework).length) throw new RequestError('TARGET_NOT_FOUND', `No ${frameworkTitles[framework].title} ${frontendKindTitles(framework)[kind][1]} here.`);
|
|
7078
7136
|
return frontendOperations(folder, framework)[request.operation]();
|
|
7079
7137
|
};
|
|
7080
7138
|
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
|
};
|