@wavemaker-ai/react-codegen 1.0.0-rc.647684 → 12.0.0-rc.335

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 (69) hide show
  1. package/command.js +52 -7
  2. package/command.js.map +1 -1
  3. package/dist/transpiler/index.d.mts +42 -1
  4. package/dist/transpiler/index.mjs +682 -90
  5. package/dist/transpiler/index.mjs.map +1 -1
  6. package/dist/transpiler/wm-styles.css +10 -20
  7. package/index.js +7 -0
  8. package/index.js.map +1 -1
  9. package/package-lock.json +102 -102
  10. package/package.json +1 -1
  11. package/src/app.generator.js +223 -35
  12. package/src/app.generator.js.map +1 -1
  13. package/src/handlebar-helpers.js +32 -0
  14. package/src/handlebar-helpers.js.map +1 -1
  15. package/src/increment-builder.js +32 -2
  16. package/src/increment-builder.js.map +1 -1
  17. package/src/profiles/profile.js +2 -0
  18. package/src/profiles/profile.js.map +1 -1
  19. package/src/profiles/web-preview.profile.js +4 -0
  20. package/src/profiles/web-preview.profile.js.map +1 -1
  21. package/src/services/designtime-collector.js +235 -0
  22. package/src/services/designtime-collector.js.map +1 -0
  23. package/src/services/doc-normalizer.js +185 -0
  24. package/src/services/doc-normalizer.js.map +1 -0
  25. package/src/services/method-emitter.js +367 -0
  26. package/src/services/method-emitter.js.map +1 -0
  27. package/src/services/model-emitter.js +281 -0
  28. package/src/services/model-emitter.js.map +1 -0
  29. package/src/services/schema-to-ts.js +50 -0
  30. package/src/services/schema-to-ts.js.map +1 -0
  31. package/src/services/service.generator.js +223 -0
  32. package/src/services/service.generator.js.map +1 -0
  33. package/src/transpile/bind.ex.transformer.js +4 -1
  34. package/src/transpile/bind.ex.transformer.js.map +1 -1
  35. package/src/transpile/components/container/accordion.transformer.js +4 -4
  36. package/src/transpile/components/container/accordion.transformer.js.map +1 -1
  37. package/src/transpile/components/container/tabs.transformer.js +4 -2
  38. package/src/transpile/components/container/tabs.transformer.js.map +1 -1
  39. package/src/transpile/components/data/list/list-transformer.js +7 -2
  40. package/src/transpile/components/data/list/list-transformer.js.map +1 -1
  41. package/src/transpile/components/data/table/table.transformer.js +14 -20
  42. package/src/transpile/components/data/table/table.transformer.js.map +1 -1
  43. package/src/transpile/components/data/table/utils.js +90 -0
  44. package/src/transpile/components/data/table/utils.js.map +1 -1
  45. package/src/transpile/components/dialogs/dialog-actions.transformer.js +4 -6
  46. package/src/transpile/components/dialogs/dialog-actions.transformer.js.map +1 -1
  47. package/src/transpile/components/dialogs/dialog.transformer.js +14 -3
  48. package/src/transpile/components/dialogs/dialog.transformer.js.map +1 -1
  49. package/src/transpile/components/layout/layout-region-factory.js +8 -2
  50. package/src/transpile/components/layout/layout-region-factory.js.map +1 -1
  51. package/src/transpile/components/nav/nav.transformer.js +3 -5
  52. package/src/transpile/components/nav/nav.transformer.js.map +1 -1
  53. package/src/transpile/components/utils.js +11 -5
  54. package/src/transpile/components/utils.js.map +1 -1
  55. package/src/transpile/transpile.js +62 -21
  56. package/src/transpile/transpile.js.map +1 -1
  57. package/src/transpile/variables-template-source.js +2 -2
  58. package/src/transpile/variables-template-source.js.map +1 -1
  59. package/src/utils.browser.js +51 -6
  60. package/src/utils.browser.js.map +1 -1
  61. package/src/variables/variable.transformer.js +623 -12
  62. package/src/variables/variable.transformer.js.map +1 -1
  63. package/templates/project/app/client.layout.tsx +7 -7
  64. package/templates/project/app/components.css +10 -0
  65. package/templates/project/app/widgetInlineStylesOverride.css +0 -20
  66. package/templates/project/package.json +6 -5
  67. package/templates/project/services/base.service.ts +361 -0
  68. package/templates/service/service-class.hbs +19 -0
  69. package/templates/variables.template +67 -1
@@ -15,6 +15,23 @@ import {
15
15
  {{#each imports}}
16
16
  {{{this}}};
17
17
  {{/each}}
18
+ {{#each context}}
19
+ {{#each this}}
20
+ {{#ifEqualsAny classname (array 'ServiceVariable' 'LiveVariable') this}}
21
+ {{#if hasInvokeHttp}}
22
+ {{#onlyUniqueEntries this}}
23
+ import { {{#if serviceExportName}}{{serviceExportName}} as {{/if}}{{serviceInstanceName}} } from '@/services/{{#if serviceImportPath}}{{serviceImportPath}}{{else}}{{#if ../../isPrefabApp}}prefabs/{{../../prefabName}}/{{/if}}{{#if service}}{{service}}/{{/if}}{{serviceFileClass}}{{/if}}';
24
+ {{/onlyUniqueEntries}}
25
+ {{/if}}
26
+ {{/ifEqualsAny}}
27
+ {{#each crudTargets}}
28
+ {{#onlyUniqueEntries this}}
29
+ import { {{serviceExportName}} as {{serviceInstanceName}} } from '@/services/{{importPath}}';
30
+ {{/onlyUniqueEntries}}
31
+ {{/each}}
32
+ {{/each}}
33
+ {{/each}}
34
+
18
35
 
19
36
  export default ({{scope}}:any) => {
20
37
  return {
@@ -243,10 +260,59 @@ export default ({{scope}}:any) => {
243
260
  _id: '{{_id}}',
244
261
  {{/if}}
245
262
  {{#ifNotEmpty filterExpressions this}}
246
- filterExpressions: {{{stringify filterExpressions}}}
263
+ filterExpressions: {{{stringify filterExpressions}}},
247
264
  {{/ifNotEmpty}}
248
265
  {{/ifEquals}}
249
266
 
267
+ {{#if crudTargets}}
268
+ invokeHttp: async (...args: any) => {
269
+ // The runtime passes the CRUD operation this call is for as the 3rd argument
270
+ // (see useHttp's send()); a CrudVariable names a GROUP, not one operation.
271
+ const [requestParams, params, invokedOperation] = args;
272
+ const operation = invokedOperation ?? '{{operationType}}';
273
+ switch (operation) {
274
+ {{#each crudTargets}}
275
+ case '{{operationType}}':
276
+ return await {{serviceInstanceName}}.{{invokeFnName}}({{#each callArgs}}{{{this}}}, {{/each}}requestParams);
277
+ {{/each}}
278
+ default:
279
+ throw new Error(
280
+ `CrudVariable '{{name}}' has no generated operation for '${operation}' ` +
281
+ `(available: {{#each crudTargets}}{{operationType}} {{/each}})`
282
+ );
283
+ }
284
+ },
285
+ {{/if}}
286
+ {{#ifEqualsAny classname (array 'ServiceVariable' 'LiveVariable') this}}
287
+ {{#if hasInvokeHttp}}
288
+ {{#if liveTargets}}
289
+ invokeHttp: async (...args: any) => {
290
+ // `operation` on this variable is only the DEFAULT. Every LiveVariable carries
291
+ // all four record methods, and a table bound to it as `datasource` asks it for
292
+ // whichever the user performed — the manager names it in params.operation.
293
+ const [requestParams, params] = args;
294
+ switch (params?.operation) {
295
+ {{#each liveTargets}}
296
+ case '{{action}}':
297
+ return await {{../serviceInstanceName}}.{{invokeFnName}}({{#if hasResolvedCallArgs}}{{#each callArgs}}{{{this}}}, {{/each}}{{else}}params, {{/if}}requestParams);
298
+ {{/each}}
299
+ default:
300
+ throw new Error(
301
+ `LiveVariable '{{name}}' has no generated method for DB operation ` +
302
+ `'${params?.operation}' ` +
303
+ `(available: {{#each liveTargets}}{{action}} {{/each}})`
304
+ );
305
+ }
306
+ },
307
+ {{else}}
308
+ invokeHttp: async (...args: any) => {
309
+ const [requestParams, params] = args;
310
+ return await {{serviceInstanceName}}.{{invokeFnName}}({{#if hasResolvedCallArgs}}{{#each callArgs}}{{{this}}}, {{/each}}{{else}}params, {{/if}}requestParams);
311
+ },
312
+ {{/if}}
313
+ {{/if}}
314
+ {{/ifEqualsAny}}
315
+
250
316
  }),
251
317
  {{/each}}
252
318
  },