@vario-software/vario-app-framework-backend 2026.10.0 → 2026.10.2
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/package.json +1 -1
- package/utils/migrator.js +176 -17
package/package.json
CHANGED
package/utils/migrator.js
CHANGED
|
@@ -330,6 +330,26 @@ const Migrator = class
|
|
|
330
330
|
return finance;
|
|
331
331
|
},
|
|
332
332
|
|
|
333
|
+
getMultipartImportPreset: async id =>
|
|
334
|
+
{
|
|
335
|
+
const { data: importMultipartPreset } = await this.ApiAdapter.fetch(
|
|
336
|
+
`/cmn/data-import/runs/multi-part/${id}`,
|
|
337
|
+
{ method: 'GET' },
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
return importMultipartPreset;
|
|
341
|
+
},
|
|
342
|
+
|
|
343
|
+
getImportMappingRuleSet: async id =>
|
|
344
|
+
{
|
|
345
|
+
const { data: importMappingRuleSet } = await this.ApiAdapter.fetch(
|
|
346
|
+
`/cmn/data-import/rule-sets/${id}`,
|
|
347
|
+
{ method: 'GET' },
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
return importMappingRuleSet;
|
|
351
|
+
},
|
|
352
|
+
|
|
333
353
|
updateMultipartImportPreset: async (id, importMultipartPresetTemplate) =>
|
|
334
354
|
{
|
|
335
355
|
const { data: importMultipartPreset } = await this.app.erp.fetch(
|
|
@@ -344,17 +364,8 @@ const Migrator = class
|
|
|
344
364
|
return importMultipartPreset;
|
|
345
365
|
},
|
|
346
366
|
|
|
347
|
-
|
|
367
|
+
getOrCreateScriptModuleGroup: async () =>
|
|
348
368
|
{
|
|
349
|
-
const existingProxyId = await this.methods.getAppScriptingTriggerId(triggerId);
|
|
350
|
-
|
|
351
|
-
if (existingProxyId)
|
|
352
|
-
{
|
|
353
|
-
await this.methods.updateAppScriptingTrigger(triggerId, script, existingProxyId);
|
|
354
|
-
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
369
|
const { data: existingGroups } = await this.ApiAdapter.fetch(
|
|
359
370
|
'/cmn/computed-queries/scripting/script-module-groups',
|
|
360
371
|
{
|
|
@@ -376,24 +387,172 @@ const Migrator = class
|
|
|
376
387
|
},
|
|
377
388
|
);
|
|
378
389
|
|
|
379
|
-
|
|
390
|
+
if (existingGroups?.data?.length > 0)
|
|
391
|
+
{
|
|
392
|
+
return existingGroups.data[0];
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const { data: newGroup } = await this.ApiAdapter.fetch(
|
|
396
|
+
'/cmn/scripting/module-groups',
|
|
397
|
+
{
|
|
398
|
+
method: 'POST',
|
|
399
|
+
body: { name: this.app.client.appIdentifier },
|
|
400
|
+
},
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
await this.methods.log(`Script-Module-Group "${this.app.client.appIdentifier}" created (ID: ${newGroup.id})\n`);
|
|
404
|
+
|
|
405
|
+
return newGroup;
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
getOrCreateImportScriptPresetting: async (name, script, existingInlineScript) =>
|
|
409
|
+
{
|
|
410
|
+
const scriptGroup = await this.methods.getOrCreateScriptModuleGroup();
|
|
411
|
+
|
|
412
|
+
const { data: existingModules } = await this.ApiAdapter.fetch(
|
|
413
|
+
'/cmn/computed-queries/scripting/script-modules',
|
|
414
|
+
{
|
|
415
|
+
method: 'POST',
|
|
416
|
+
body: {
|
|
417
|
+
adhocPreset: {
|
|
418
|
+
queryPredicate: {
|
|
419
|
+
type: 'JUNCTION',
|
|
420
|
+
operator: 'AND',
|
|
421
|
+
children: [
|
|
422
|
+
{
|
|
423
|
+
type: 'FILTER',
|
|
424
|
+
operator: 'EQUALS',
|
|
425
|
+
property: 'name',
|
|
426
|
+
values: [name],
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
type: 'FILTER',
|
|
430
|
+
operator: 'EQUALS',
|
|
431
|
+
property: 'group.id',
|
|
432
|
+
values: [scriptGroup.id],
|
|
433
|
+
},
|
|
434
|
+
],
|
|
435
|
+
},
|
|
436
|
+
results: [
|
|
437
|
+
{ property: 'id' },
|
|
438
|
+
{ property: 'name' },
|
|
439
|
+
],
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
);
|
|
444
|
+
|
|
445
|
+
const scriptContent = typeof script === 'string' ? script : JSON.stringify(script);
|
|
446
|
+
let scriptModuleRef;
|
|
380
447
|
|
|
381
|
-
if (
|
|
448
|
+
if (existingModules?.data?.length > 0)
|
|
382
449
|
{
|
|
383
|
-
|
|
450
|
+
const moduleId = existingModules.data[0].id;
|
|
451
|
+
|
|
452
|
+
const { data: existingPresetting } = await this.ApiAdapter.fetch(
|
|
453
|
+
`/cmn/scripting/modules/${moduleId}/presettings`,
|
|
454
|
+
{ method: 'GET' },
|
|
455
|
+
);
|
|
456
|
+
|
|
457
|
+
await this.ApiAdapter.fetch(
|
|
458
|
+
`/cmn/scripting/modules/${moduleId}/presettings`,
|
|
459
|
+
{
|
|
460
|
+
method: 'PUT',
|
|
461
|
+
body: {
|
|
462
|
+
...existingPresetting,
|
|
463
|
+
script: scriptContent,
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
);
|
|
467
|
+
|
|
468
|
+
await this.methods.log(`Script-Module-Presetting "${name}" updated (ID: ${moduleId})\n`);
|
|
469
|
+
|
|
470
|
+
scriptModuleRef = { id: moduleId };
|
|
384
471
|
}
|
|
385
472
|
else
|
|
386
473
|
{
|
|
387
|
-
const { data:
|
|
388
|
-
'/cmn/scripting/
|
|
474
|
+
const { data: scriptModule } = await this.ApiAdapter.fetch(
|
|
475
|
+
'/cmn/scripting/modules/presettings',
|
|
389
476
|
{
|
|
390
477
|
method: 'POST',
|
|
391
|
-
body: {
|
|
478
|
+
body: {
|
|
479
|
+
name,
|
|
480
|
+
script: scriptContent,
|
|
481
|
+
domain: 'IMPORT_BATCH_PROCESSING',
|
|
482
|
+
groupRef: { id: scriptGroup.id },
|
|
483
|
+
permissionAggregation: {
|
|
484
|
+
operationForAllUsers: 'READ_AND_EDIT',
|
|
485
|
+
},
|
|
486
|
+
},
|
|
392
487
|
},
|
|
393
488
|
);
|
|
394
|
-
|
|
489
|
+
|
|
490
|
+
await this.methods.log(`Script-Module-Presetting "${name}" created (ID: ${scriptModule.id})\n`);
|
|
491
|
+
|
|
492
|
+
scriptModuleRef = { id: scriptModule.id };
|
|
493
|
+
|
|
494
|
+
// Migrate existing inline script as user script on the new module
|
|
495
|
+
if (existingInlineScript)
|
|
496
|
+
{
|
|
497
|
+
const inlineScriptContent = typeof existingInlineScript === 'string'
|
|
498
|
+
? existingInlineScript
|
|
499
|
+
: JSON.stringify(existingInlineScript);
|
|
500
|
+
|
|
501
|
+
const { data: createdModule } = await this.ApiAdapter.fetch(
|
|
502
|
+
`/cmn/scripting/modules/${scriptModule.id}`,
|
|
503
|
+
{ method: 'GET' },
|
|
504
|
+
);
|
|
505
|
+
|
|
506
|
+
await this.ApiAdapter.fetch(
|
|
507
|
+
`/cmn/scripting/modules/${scriptModule.id}`,
|
|
508
|
+
{
|
|
509
|
+
method: 'PUT',
|
|
510
|
+
body: {
|
|
511
|
+
...createdModule,
|
|
512
|
+
script: inlineScriptContent,
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
);
|
|
516
|
+
|
|
517
|
+
await this.methods.log(`Migrated existing inline script for "${name}" to script module\n`);
|
|
518
|
+
}
|
|
395
519
|
}
|
|
396
520
|
|
|
521
|
+
const existingProxyId = await this.methods.getAppScriptingTriggerId(name);
|
|
522
|
+
|
|
523
|
+
if (!existingProxyId)
|
|
524
|
+
{
|
|
525
|
+
await this.ApiAdapter.fetch(
|
|
526
|
+
`/community/${this.app.version}/cmn/system/app-scripting-proxy`,
|
|
527
|
+
{
|
|
528
|
+
method: 'POST',
|
|
529
|
+
body: {
|
|
530
|
+
appIdentifier: this.app.client.appIdentifier,
|
|
531
|
+
triggerId: name,
|
|
532
|
+
scriptModuleRef,
|
|
533
|
+
},
|
|
534
|
+
},
|
|
535
|
+
);
|
|
536
|
+
|
|
537
|
+
await this.methods.log(`App-Script-Proxy for "${name}" successfully created\n`);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
return scriptModuleRef;
|
|
541
|
+
},
|
|
542
|
+
|
|
543
|
+
addAppScriptingTrigger: async (triggerId, script) =>
|
|
544
|
+
{
|
|
545
|
+
const existingProxyId = await this.methods.getAppScriptingTriggerId(triggerId);
|
|
546
|
+
|
|
547
|
+
if (existingProxyId)
|
|
548
|
+
{
|
|
549
|
+
await this.methods.updateAppScriptingTrigger(triggerId, script, existingProxyId);
|
|
550
|
+
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
const scriptGroup = await this.methods.getOrCreateScriptModuleGroup();
|
|
555
|
+
|
|
397
556
|
const { data: scriptModule } = await this.ApiAdapter.fetch(
|
|
398
557
|
'/cmn/scripting/modules/presettings',
|
|
399
558
|
{
|