@khester/create-dynamics-app 2.1.0 → 2.2.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.
Files changed (121) hide show
  1. package/dist/artifacts/registry.d.ts +4 -3
  2. package/dist/artifacts/registry.d.ts.map +1 -1
  3. package/dist/artifacts/registry.js +121 -11
  4. package/dist/artifacts/registry.js.map +1 -1
  5. package/dist/artifacts/types.d.ts +1 -1
  6. package/dist/artifacts/types.d.ts.map +1 -1
  7. package/dist/index.js +2 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/injectDevTools.d.ts.map +1 -1
  10. package/dist/injectDevTools.js +4 -2
  11. package/dist/injectDevTools.js.map +1 -1
  12. package/dist/scaffold.d.ts +1 -0
  13. package/dist/scaffold.d.ts.map +1 -1
  14. package/dist/scaffold.js +3 -1
  15. package/dist/scaffold.js.map +1 -1
  16. package/package.json +3 -2
  17. package/templates/grid-starter/ARCHITECTURE.md +66 -0
  18. package/templates/grid-starter/README.md +122 -0
  19. package/templates/grid-starter/env.example +16 -0
  20. package/templates/grid-starter/gitignore +6 -0
  21. package/templates/grid-starter/index.html +16 -0
  22. package/templates/grid-starter/package.json +39 -0
  23. package/templates/grid-starter/src/App.tsx +23 -0
  24. package/templates/grid-starter/src/core/services/FetchApiService.ts +117 -0
  25. package/templates/grid-starter/src/core/services/IApiService.ts +37 -0
  26. package/templates/grid-starter/src/core/services/MockApiService.ts +72 -0
  27. package/templates/grid-starter/src/core/services/ServiceFactory.ts +58 -0
  28. package/templates/grid-starter/src/core/services/XrmApiService.ts +135 -0
  29. package/templates/grid-starter/src/core/services/crudLogging.ts +52 -0
  30. package/templates/grid-starter/src/dev-tools/DevPanel.tsx +239 -0
  31. package/templates/grid-starter/src/grid/GridPage.tsx +119 -0
  32. package/templates/grid-starter/src/index.tsx +18 -0
  33. package/templates/grid-starter/src/vite-env.d.ts +15 -0
  34. package/templates/grid-starter/tools/deploy/deploy-webresource.cjs +117 -0
  35. package/templates/grid-starter/tsconfig.json +19 -0
  36. package/templates/grid-starter/vite.config.ts +76 -0
  37. package/templates/pcf-field/_variants/ValueInput.boolean.tsx +2 -0
  38. package/templates/pcf-field/_variants/ValueInput.date.tsx +2 -0
  39. package/templates/pcf-field/_variants/ValueInput.number.tsx +2 -0
  40. package/templates/pcf-field/_variants/ValueInput.optionset.tsx +77 -0
  41. package/templates/pcf-field/_variants/ValueInput.text.tsx +2 -0
  42. package/templates/pcf-field/index.ts +1 -1
  43. package/templates/pcf-field/package.json +3 -1
  44. package/templates/pcf-field/{{componentName}}Component.tsx +2 -0
  45. package/templates/react-custom-page/ARCHITECTURE.md +75 -0
  46. package/templates/react-custom-page/README.md +74 -568
  47. package/templates/react-custom-page/env.example +16 -0
  48. package/templates/react-custom-page/gitignore +1 -0
  49. package/templates/react-custom-page/index.html +16 -0
  50. package/templates/react-custom-page/package.json +21 -49
  51. package/templates/react-custom-page/src/App.tsx +26 -0
  52. package/templates/react-custom-page/src/core/recordContext.test.ts +30 -0
  53. package/templates/react-custom-page/src/core/recordContext.ts +51 -0
  54. package/templates/react-custom-page/src/core/services/FetchApiService.ts +117 -0
  55. package/templates/react-custom-page/src/core/services/IApiService.ts +37 -0
  56. package/templates/react-custom-page/src/core/services/MockApiService.ts +73 -0
  57. package/templates/react-custom-page/src/core/services/ServiceFactory.ts +58 -0
  58. package/templates/react-custom-page/src/core/services/XrmApiService.ts +135 -0
  59. package/templates/react-custom-page/src/core/services/crudLogging.ts +52 -0
  60. package/templates/react-custom-page/src/dev-tools/DevPanel.tsx +238 -0
  61. package/templates/react-custom-page/src/domain/diff.test.ts +87 -0
  62. package/templates/react-custom-page/src/domain/diff.ts +38 -0
  63. package/templates/react-custom-page/src/example/ExamplePage.tsx +140 -0
  64. package/templates/react-custom-page/src/example/exampleError.ts +36 -0
  65. package/templates/react-custom-page/src/example/hooks/useExampleData.ts +40 -0
  66. package/templates/react-custom-page/src/example/hooks/useExampleForm.ts +99 -0
  67. package/templates/react-custom-page/src/example/mappers/accountMapper.test.ts +38 -0
  68. package/templates/react-custom-page/src/example/mappers/accountMapper.ts +55 -0
  69. package/templates/react-custom-page/src/example/models/Account.ts +74 -0
  70. package/templates/react-custom-page/src/index.tsx +18 -128
  71. package/templates/react-custom-page/src/vite-env.d.ts +15 -0
  72. package/templates/react-custom-page/tools/deploy/deploy-webresource.cjs +117 -0
  73. package/templates/react-custom-page/tsconfig.json +12 -22
  74. package/templates/react-custom-page/vite.config.ts +76 -0
  75. package/templates/starter-page/README.md +38 -0
  76. package/templates/starter-page/_variants/App.dashboard.v8.tsx +46 -0
  77. package/templates/starter-page/_variants/App.form.v8.tsx +59 -0
  78. package/templates/starter-page/_variants/App.master-detail.v8.tsx +61 -0
  79. package/templates/starter-page/_variants/App.panel.v8.tsx +99 -0
  80. package/templates/starter-page/gitignore +5 -0
  81. package/templates/starter-page/package.json +27 -0
  82. package/templates/starter-page/public/index.html +11 -0
  83. package/templates/starter-page/src/index.tsx +10 -0
  84. package/templates/starter-page/src/services/dataverse.ts +30 -0
  85. package/templates/starter-page/tsconfig.json +15 -0
  86. package/templates/starter-page/webpack.config.js +17 -0
  87. package/templates/react-custom-page/deployment/README.md +0 -484
  88. package/templates/react-custom-page/docs/ARCHITECTURE_OVERVIEW.md +0 -506
  89. package/templates/react-custom-page/docs/BEST_PRACTICES.md +0 -723
  90. package/templates/react-custom-page/docs/MIGRATION_GUIDE.md +0 -447
  91. package/templates/react-custom-page/public/index.html +0 -15
  92. package/templates/react-custom-page/scripts/custom-build.js +0 -255
  93. package/templates/react-custom-page/src/components/AccountForm.css +0 -71
  94. package/templates/react-custom-page/src/components/AccountForm.tsx +0 -541
  95. package/templates/react-custom-page/src/components/AccountManagement.css +0 -86
  96. package/templates/react-custom-page/src/components/AccountManagement.tsx +0 -370
  97. package/templates/react-custom-page/src/components/ContactForm.css +0 -48
  98. package/templates/react-custom-page/src/components/ContactForm.tsx +0 -327
  99. package/templates/react-custom-page/src/components/ContactManagement.css +0 -86
  100. package/templates/react-custom-page/src/components/ContactManagement.tsx +0 -357
  101. package/templates/react-custom-page/src/components/Logging/LogDialog.tsx +0 -291
  102. package/templates/react-custom-page/src/components/Logging/LoggingContext.tsx +0 -166
  103. package/templates/react-custom-page/src/components/Logging/LoggingDebugPanel.css +0 -192
  104. package/templates/react-custom-page/src/components/Logging/LoggingDebugPanel.tsx +0 -177
  105. package/templates/react-custom-page/src/components/Logging/LoggingProvider.tsx +0 -3
  106. package/templates/react-custom-page/src/components/Logging/logger.ts +0 -193
  107. package/templates/react-custom-page/src/constants/account.ts +0 -410
  108. package/templates/react-custom-page/src/constants/contact.ts +0 -362
  109. package/templates/react-custom-page/src/models/Account.ts +0 -480
  110. package/templates/react-custom-page/src/models/BaseEntity.ts +0 -204
  111. package/templates/react-custom-page/src/models/Contact.ts +0 -580
  112. package/templates/react-custom-page/src/pcf/ContactControlWrapper.tsx +0 -107
  113. package/templates/react-custom-page/src/pcf/MultiEntityControlWrapper.tsx +0 -205
  114. package/templates/react-custom-page/src/providers/DynamicsProvider.tsx +0 -353
  115. package/templates/react-custom-page/src/services/MockApiService.ts +0 -260
  116. package/templates/react-custom-page/src/services/ServiceFactory.ts +0 -65
  117. package/templates/react-custom-page/src/services/XrmApiService.ts +0 -213
  118. package/templates/react-custom-page/src/styles/index.css +0 -171
  119. package/templates/react-custom-page/tools/metadata-sync/index.js +0 -152
  120. package/templates/react-custom-page/webpack.config.js +0 -57
  121. /package/templates/_shared/dev-tools/auth/{get-token.js → get-token.cjs} +0 -0
@@ -1,152 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Metadata Sync — thin wrapper around @dataverse-kit/dataverse-codegen (dvgen).
5
- *
6
- * Pulls REAL entity metadata from a live Dataverse org and generates field
7
- * constants + typed models (and, optionally, the IApiService CRUD layer) into
8
- * `src/`. All org connection + auth is delegated to dvgen, which resolves, in
9
- * order: --url/--token/--env-file flags, the DYNAMICS_* / VITE_DYNAMICS_* /
10
- * REACT_APP_DYNAMICS_* env vars, then the Azure CLI (`az account get-access-token`).
11
- *
12
- * This replaces the previous mock pipeline (which returned hard-coded metadata).
13
- * dvgen is the same tool the rest of the toolkit uses, so output stays consistent
14
- * with `dvgen design`/`constants`/`models` everywhere.
15
- */
16
-
17
- const { program } = require('commander');
18
- const { spawnSync } = require('child_process');
19
- const path = require('path');
20
- const fs = require('fs');
21
-
22
- const DVGEN_CLI = path.join(
23
- process.cwd(),
24
- 'node_modules',
25
- '@dataverse-kit',
26
- 'dataverse-codegen',
27
- 'dist',
28
- 'cli.cjs'
29
- );
30
-
31
- function ensureDvgen() {
32
- if (!fs.existsSync(DVGEN_CLI)) {
33
- console.error(
34
- 'āœ— dvgen not found. Install it first:\n' +
35
- ' npm install -D @dataverse-kit/dataverse-codegen'
36
- );
37
- process.exit(1);
38
- }
39
- }
40
-
41
- function dvgen(args) {
42
- const result = spawnSync(process.execPath, [DVGEN_CLI, ...args], {
43
- stdio: 'inherit',
44
- });
45
- return result.status === 0;
46
- }
47
-
48
- function resolveEntities(opts) {
49
- if (opts.entities) {
50
- return opts.entities
51
- .split(',')
52
- .map((e) => e.trim())
53
- .filter(Boolean);
54
- }
55
- return ['account', 'contact'];
56
- }
57
-
58
- function connectionArgs(opts) {
59
- const args = [];
60
- if (opts.url) args.push('--url', opts.url);
61
- if (opts.token) args.push('--token', opts.token);
62
- if (opts.envFile) args.push('--env-file', opts.envFile);
63
- return args;
64
- }
65
-
66
- function run(opts, { diff = false } = {}) {
67
- ensureDvgen();
68
- const entities = resolveEntities(opts);
69
- const out = opts.out || 'src';
70
- const conn = connectionArgs(opts);
71
- const extra = diff ? ['--diff'] : [];
72
- if (opts.force && !diff) extra.push('--force');
73
- // The starter's shipped models import IApiService from
74
- // @khester/dynamics-ui-api-client, so point generated models at the same
75
- // module. When the dvgen-local CRUD layer is generated (--api), use that.
76
- const apiServiceImport = opts.api ? '../services/IApiService' : opts.apiService;
77
-
78
- console.log(
79
- `${diff ? 'šŸ” Diffing' : 'šŸ”„ Generating'} ${entities.join(
80
- ', '
81
- )} via dvgen → ${out}/\n`
82
- );
83
-
84
- // Shared CRUD layer once (offline; only when explicitly requested).
85
- if (opts.api && !diff) {
86
- if (!dvgen(['api', '--out', out])) process.exit(1);
87
- }
88
-
89
- let ok = true;
90
- for (const entity of entities) {
91
- console.log(`\n→ ${entity}`);
92
- if (
93
- !dvgen(['constants', '--entity', entity, '--out', out, ...conn, ...extra])
94
- ) {
95
- ok = false;
96
- }
97
- const modelArgs = ['models', '--entity', entity, '--out', out, ...conn, ...extra];
98
- if (apiServiceImport) modelArgs.push('--api-service', apiServiceImport);
99
- if (opts.withRetrieve) modelArgs.push('--with-retrieve');
100
- if (!dvgen(modelArgs)) ok = false;
101
- }
102
-
103
- if (!ok) {
104
- console.error('\nāœ— One or more entities failed.');
105
- process.exit(1);
106
- }
107
- console.log('\nāœ“ Done.');
108
- }
109
-
110
- function withCommon(cmd) {
111
- return cmd
112
- .option(
113
- '-e, --entities <list>',
114
- 'comma-separated entities (default: account,contact)'
115
- )
116
- .option('--url <url>', 'Dataverse org URL (else dvgen resolves env / Azure CLI)')
117
- .option('--token <token>', 'bearer token (else dvgen resolves env / Azure CLI)')
118
- .option('--env-file <path>', '.env file with DYNAMICS_URL / DYNAMICS_TOKEN')
119
- .option('-o, --out <dir>', 'output base dir', 'src')
120
- .option('--force', 'overwrite existing generated files (default: skip)')
121
- .option('--with-retrieve', 'include retrieveWithRelated() FetchXML scaffolds')
122
- .option(
123
- '--api-service <import>',
124
- 'IApiService module specifier for generated models',
125
- '@khester/dynamics-ui-api-client'
126
- )
127
- .option('--api', 'also (re)generate the IApiService CRUD layer');
128
- }
129
-
130
- program
131
- .name('metadata-sync')
132
- .description(
133
- 'Live Dataverse metadata → TypeScript (constants + models) via dvgen'
134
- );
135
-
136
- withCommon(program.command('sync'))
137
- .description('Pull live metadata and generate constants + models')
138
- .action((o) => run(o));
139
-
140
- withCommon(program.command('pull'))
141
- .description('Alias of sync (pull live metadata + generate)')
142
- .action((o) => run(o));
143
-
144
- withCommon(program.command('generate'))
145
- .description('Alias of sync (generate constants + models from the live org)')
146
- .action((o) => run(o));
147
-
148
- withCommon(program.command('validate'))
149
- .description('Diff generated code against the live org (no writes)')
150
- .action((o) => run(o, { diff: true }));
151
-
152
- program.parse();
@@ -1,57 +0,0 @@
1
- const path = require('path');
2
- const HtmlWebpackPlugin = require('html-webpack-plugin');
3
-
4
- module.exports = (env, argv) => {
5
- const isProduction = argv.mode === 'production';
6
-
7
- return {
8
- entry: './src/index.tsx',
9
- output: {
10
- path: path.resolve(__dirname, 'dist'),
11
- filename: isProduction ? '[name].[contenthash].js' : '[name].js',
12
- clean: true,
13
- publicPath: '/',
14
- },
15
- resolve: {
16
- extensions: ['.tsx', '.ts', '.js', '.jsx'],
17
- },
18
- module: {
19
- rules: [
20
- {
21
- test: /\.tsx?$/,
22
- use: {
23
- loader: 'ts-loader',
24
- options: {
25
- transpileOnly: true,
26
- },
27
- },
28
- exclude: /node_modules/,
29
- },
30
- {
31
- test: /\.css$/i,
32
- use: ['style-loader', 'css-loader'],
33
- },
34
- ],
35
- },
36
- plugins: [
37
- new HtmlWebpackPlugin({
38
- template: './public/index.html',
39
- filename: 'index.html',
40
- }),
41
- ],
42
- devServer: {
43
- static: {
44
- directory: path.join(__dirname, 'public'),
45
- },
46
- port: 3000,
47
- open: true,
48
- hot: true,
49
- historyApiFallback: true,
50
- },
51
- optimization: {
52
- splitChunks: {
53
- chunks: 'all',
54
- },
55
- },
56
- };
57
- };