markuno_lib 1.1.25 → 1.1.27

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.
@@ -0,0 +1,552 @@
1
+ export class Ambiente {
2
+ constructor(cat?: string, maxdelays?: number, righevuote?: boolean);
3
+ righevuote: boolean;
4
+ maxdelays: number;
5
+ setcatalog(cat: any): any;
6
+ cat: any;
7
+ item: any;
8
+ rule: any;
9
+ model: any;
10
+ get muvalutatore(): {
11
+ getcolonne: typeof getcolonne;
12
+ muCalc: typeof muCalc;
13
+ muEval: typeof muEval;
14
+ tipifree: string[];
15
+ };
16
+ azzera(mode?: boolean): void;
17
+ /** @type {Variabile} */
18
+ vari: Variabile;
19
+ ruleheader: string;
20
+ /** @type {Object.<string, Macro>} */
21
+ macro: {};
22
+ /** @type {Object.<string, Variante>} */
23
+ varianti: {};
24
+ varelenco: {};
25
+ macroelenco: {};
26
+ scripts: {};
27
+ setfndot(fndotcallback: any): Promise<void>;
28
+ fndotcallback: any;
29
+ parseheaderfrominfo(tm: any): void;
30
+ setitem(item: any, rule: any, model: any, datadelgiorno: any): void;
31
+ data: any;
32
+ getheader(cod: any): Promise<any>;
33
+ getalias(): Promise<any>;
34
+ get deriva(): any;
35
+ getmacro(riga: any): Promise<{
36
+ macro: any;
37
+ pars: string[];
38
+ } | {
39
+ macro?: undefined;
40
+ pars?: undefined;
41
+ }>;
42
+ getvariante(cod: any): Promise<any>;
43
+ varcompila(v: any, callback: any): Promise<void>;
44
+ macrocompila(v: any, callback: any): Promise<void>;
45
+ barrecompila(articolibarre: any, titolibarre: any, callback: any): Promise<CodiceBarra>;
46
+ tojson(d: any): Promise<any>;
47
+ compila(info: any, callback: any): Promise<void>;
48
+ getheaderfromdb(name: any): Promise<{
49
+ head: any;
50
+ rows: any;
51
+ macros: any;
52
+ }>;
53
+ getlinkedmacros(rule: any, macros: any): Promise<void>;
54
+ setruleheader(rule: any, pars: any): Promise<any>;
55
+ getruleheader(): any;
56
+ setvariante(cod: any, opz: any): Promise<any>;
57
+ valuta(codice: any): Promise<any>;
58
+ setinfos(tm: any): void;
59
+ #private;
60
+ }
61
+ export class CodiceBarra {
62
+ barre: {};
63
+ azzera(): void;
64
+ oriented(t: any, l: any, a: any, p: any): {
65
+ t: string;
66
+ x: any;
67
+ y?: undefined;
68
+ z?: undefined;
69
+ } | {
70
+ t: any;
71
+ x: any;
72
+ y: any;
73
+ z: any;
74
+ };
75
+ getcode(codicebarratot: any, l: any, a: any, p: any, callback: any): Promise<any>;
76
+ compila(vettore: any, headers: any): void;
77
+ }
78
+ export class Macro {
79
+ constructor(amb: any, name: any);
80
+ name: any;
81
+ cat: string;
82
+ /** @type {Ambiente} */
83
+ amb: any;
84
+ azzera(): void;
85
+ key: string;
86
+ localvar: {};
87
+ head: any[] | {
88
+ cod: any;
89
+ t: string;
90
+ }[];
91
+ frontend: boolean;
92
+ valid: any[];
93
+ parametri: {};
94
+ paralias: {};
95
+ formula: {};
96
+ settings: {};
97
+ errori: any[];
98
+ codice: any;
99
+ genera: {};
100
+ get isgenera(): number;
101
+ get iscodice(): any;
102
+ get isheader(): number;
103
+ geterrori(): any[];
104
+ getparametri(): {};
105
+ setparametri(pars: any): Promise<{}>;
106
+ setparametro(name: any, value: any, propaga?: boolean): Promise<any>;
107
+ impostaparametri(parimposta: any, parcall: any, ismacro?: boolean): Promise<void>;
108
+ checkvalid(formula: any): Promise<boolean>;
109
+ getmacrostr(): string;
110
+ getmacro(): any;
111
+ setmacro(vv: any): void;
112
+ load(xname: any, xcat: any): Promise<boolean>;
113
+ loadAndCompile(file: any, cat: any, acapo?: boolean): Promise<any>;
114
+ parsedata(res: any, acapo?: boolean): Promise<void>;
115
+ cleanfiltraparametri(key: any, codice: any, acapo: any): any[];
116
+ #private;
117
+ }
118
+ export class Variabile {
119
+ static isValidKey(key: any): boolean;
120
+ static sanitizeKey(key: any): any;
121
+ dictionary: {};
122
+ vec: any[];
123
+ counter: number;
124
+ setfndot(fndotcallback: any): void;
125
+ fndotcallback: any;
126
+ /**
127
+ * Salva lo stato corrente delle variabili nello stack
128
+ */ push(): void;
129
+ /**
130
+ * Ripristina l'ultimo stato salvato delle variabili
131
+ */ pop(): void;
132
+ /**
133
+ * Rimuove tutte le variabili e pulisce lo stack
134
+ */ clear(): void;
135
+ azzera: () => void;
136
+ var(key: any): any;
137
+ getvar(key: any): any;
138
+ colonna(value: any, index: any): any;
139
+ /**
140
+ * Restituisce un dump delle variabili
141
+ */ dump(isstr?: boolean): string[] | {
142
+ cod: string;
143
+ val: any;
144
+ }[];
145
+ /**
146
+ * Aggiunge o rimuove una variabile
147
+ */ add(key: any, value: any): void;
148
+ /**
149
+ * Valuta un'espressione con supporto per callback asincroni
150
+ */ valutasync(str: any): any;
151
+ valuta(ex: any, callback: any): Promise<any>;
152
+ parametrokeyval(p: any): Promise<{
153
+ k?: undefined;
154
+ v?: undefined;
155
+ } | {
156
+ k: any;
157
+ v: any;
158
+ }>;
159
+ }
160
+ /**
161
+ * Classe per gestire le varianti di un prodotto.
162
+ * Permette di caricare, manipolare e convertire varianti di prodotto con relativi attributi e limiti.
163
+ * @class
164
+ * @exports
165
+ */ export class Variante {
166
+ /**
167
+ * Crea una nuova istanza di Variante
168
+ * @param {Object} amb - Ambiente di esecuzione contenente il contesto applicativo
169
+ */
170
+ constructor(amb: any);
171
+ rows: {};
172
+ name: string;
173
+ key: string;
174
+ /** @type {Ambiente} */
175
+ amb: any;
176
+ /**
177
+ * Imposta i dati principali della variante
178
+ * @param {string} id - Identificativo univoco della variante
179
+ * @param {string} cat - Categoria di appartenenza
180
+ * @returns {Object} Oggetto contenente nome e categoria normalizzati
181
+ */ setheader(id: string, cat: string): any;
182
+ cat: string;
183
+ alias: string;
184
+ obbligo: boolean;
185
+ des: any;
186
+ vdef: any[] | string[];
187
+ h: any[] | {
188
+ des: string;
189
+ }[];
190
+ /**
191
+ * Cerca la riga con dimensione più vicina a quella richiesta
192
+ * @param {number|string} dim - Dimensione target da cercare
193
+ * @param {number} colonna - Indice della colonna (1-based) contenente la dimensione
194
+ * @returns {string} Riga formattata nel formato CSV
195
+ */ fromdim(dim: number | string, colonna?: number): string;
196
+ /**
197
+ * Carica una variante dal database o da file
198
+ * @param {string} id - Identificativo della variante
199
+ * @param {string} cat - Categoria della variante
200
+ * @param {boolean} nofilter - Se true, non carica i filtri associati
201
+ * @returns {Promise<boolean>} Promise che risolve a true se il caricamento ha successo
202
+ */ load(id: string, cat: string, nofilter?: boolean): Promise<boolean>;
203
+ limits: {}[] | {
204
+ v: any[];
205
+ datai: number;
206
+ dataf: number;
207
+ }[];
208
+ /**
209
+ * Carica il contenuto della variante da array di stringhe
210
+ * @private
211
+ * @param {string[]} lines - Array di stringhe contenenti la definizione della variante
212
+ * @returns {Promise<boolean>} Promise che risolve a true se il caricamento ha successo
213
+ */ private _loadContent;
214
+ noerp: boolean;
215
+ /**
216
+ * Converte la variante in un vettore di righe
217
+ * @returns {string[]} Array di righe formattate
218
+ */ tovec(): string[];
219
+ /**
220
+ * Converte un codice nella sua rappresentazione CSV
221
+ * @param {string} cod - Codice da convertire
222
+ * @returns {string} Stringa CSV o codice originale se non trovato
223
+ */ tovar(cod: string, vcod?: string): string;
224
+ /**
225
+ * Verifica se un'opzione è valida
226
+ * @param {string} opz - Opzione da verificare
227
+ * @returns {boolean} True se l'opzione è valida
228
+ */ isvalidopz(opz: string): boolean;
229
+ /**
230
+ * Trova la prima opzione valida tra quelle disponibili
231
+ * @param {string} opz - Opzione da controllare per prima
232
+ * @returns {string|undefined} Prima opzione valida trovata o undefined
233
+ */ firstvalid(opz: string): string | undefined;
234
+ /**
235
+ * Resetta tutti i filtri applicati alla variante
236
+ */ resetfilter(): void;
237
+ /**
238
+ * Restituisce le chiavi valide ordinate alfabeticamente
239
+ * @returns {string[]} Array di chiavi valide
240
+ */ validkeys(): string[];
241
+ limitfiltra(filtra: any): void;
242
+ /**
243
+ * Applica i limiti configurati alle opzioni della variante
244
+ * @returns {Array|void} Array di limiti applicati o void se reset
245
+ */ limita(filtra: any): any[] | void;
246
+ /**
247
+ * Carica il contenuto esteso della variante
248
+ * @param {Object|string} content - Contenuto da caricare, può essere un oggetto o una stringa
249
+ * @returns {Promise<void>} Promise che si risolve al completamento del caricamento
250
+ */ loadContentExtended(content: any | string): Promise<void>;
251
+ todata(): {
252
+ name: string;
253
+ des: any;
254
+ alias: string;
255
+ obbligo: boolean;
256
+ h: any[] | {
257
+ des: string;
258
+ }[];
259
+ rows: {};
260
+ limits: {}[] | {
261
+ v: any[];
262
+ datai: number;
263
+ dataf: number;
264
+ }[];
265
+ key: string;
266
+ };
267
+ #private;
268
+ }
269
+ /**
270
+ * Valida e separa un identificatore e una categoria
271
+ * @param {string} id - Identificatore da validare (formato: "categoria/nome" o solo "nome")
272
+ * @param {string} cat - Categoria di default
273
+ * @throws {Error} Se manca la categoria
274
+ * @returns {{name: string, cat: string}} Oggetto con nome e categoria validati
275
+ */ export function checkmu(id: string, cat: string): {
276
+ name: string;
277
+ cat: string;
278
+ };
279
+ /**
280
+ * Valida un identificatore verificando che contenga solo caratteri permessi
281
+ * @param {string} id - Identificatore da validare
282
+ * @throws {Error} Se l'identificatore contiene caratteri non validi
283
+ * @returns {string} Identificatore validato in minuscolo
284
+ */ export function checkname(id: string): string;
285
+ export function clamp(n: any, min?: number, max?: number): any;
286
+ export function clean(k: any, locase?: boolean): any;
287
+ export function dammivariante(amb: any, macro: any, ky: any): Promise<any>;
288
+ export const errori: {
289
+ /**
290
+ * Azzera la lista degli errori
291
+ */ azzera(): void;
292
+ err: any[];
293
+ /**
294
+ * Aggiunge un errore alla lista
295
+ * @param {string} msg - Messaggio di errore
296
+ * @param {Object} row - Informazioni aggiuntive sull'errore
297
+ */ add(msg: string, row: any): void;
298
+ /**
299
+ * Restituisce la lista completa degli errori
300
+ * @returns {Array} Lista degli errori
301
+ */ get(): any[];
302
+ /**
303
+ * Restituisce il numero di errori presenti
304
+ * @returns {number} Numero di errori
305
+ */ readonly length: number;
306
+ /**
307
+ * Converte la lista degli errori in stringa
308
+ * @returns {string} Rappresentazione testuale degli errori
309
+ */ toString(): string;
310
+ };
311
+ /**
312
+ * Converte una stringa in un oggetto JSON, gestendo errori e restituendo un valore di default se non valido
313
+ * @param {string|Array|Object} str - Stringa da convertire in JSON, array o oggetto da restituire direttamente
314
+ * @param {*} [def={}] - Valore di default da restituire in caso di errore di parsing
315
+ * @throws {Error} Non genera eccezioni, gli errori vengono loggati internamente
316
+ * @returns {*} L'oggetto JSON convertito dalla stringa, l'input originale se è un array/oggetto, o il valore di default in caso di errore
317
+ * @example
318
+ * fromjson('{"a": 1}') // returns {a: 1}
319
+ * fromjson([1,2,3]) // returns [1,2,3]
320
+ * fromjson('invalid json', {}) // returns {}
321
+ */ export function fromjson(str: string | any[] | any, def?: any): any;
322
+ /**
323
+ * Estrae le proprietà non-funzione da un oggetto, escludendo chiavi specificate
324
+ * @param {Object} obj - Oggetto da cui estrarre le proprietà
325
+ * @param {string[]} [exclude] - Array di chiavi da escludere
326
+ * @returns {Object} Nuovo oggetto con le proprietà estratte
327
+ */ export function getOggetto(obj: any, exclude?: string[]): any;
328
+ /**
329
+ * Converte una stringa in array di colonne, gestendo diversi formati
330
+ * @param {string} value - Stringa da convertire
331
+ * @returns {string[]} Array di colonne
332
+ */ export function getcolonne(value: string, keepquote?: boolean): string[];
333
+ /**
334
+ * Analizza una stringa per estrarre una coppia chiave-valore
335
+ * @param {string} r - Stringa da analizzare (es: "chiave=valore")
336
+ * @param {string} [sep='='] - Carattere separatore
337
+ * @returns {{v: string, o: string, fl: boolean}} Oggetto contenente chiave (v), valore (o) e flag presenza separatore (fl)
338
+ */ export function getcouple(r: string, sep?: string, locase?: boolean): {
339
+ v: string;
340
+ o: string;
341
+ fl: boolean;
342
+ };
343
+ /**
344
+ * Formatta un messaggio di errore rimuovendo informazioni non necessarie
345
+ * @param {Error|string} err - L'errore da formattare
346
+ * @returns {string} Il messaggio di errore formattato
347
+ */ export function geterrdes(err: Error | string): string;
348
+ export function getheaddims(dims: any): any;
349
+ export function gettipocolonna(cod: any): string;
350
+ export function gettipofolder(cod: any): string;
351
+ export function hash(obj: any): string;
352
+ export function impostavariante(amb: any, macro: any, a: any, b: any, head: any): Promise<any>;
353
+ export function intvaluta(amb: any, mac: any, str: any): Promise<any>;
354
+ export function muInit(cat: any, cbGetMacro: any, cbGetVariante: any, cbFunc: any, cbInfo: any, cbGetFile: any, cbLogga: any): Ambiente;
355
+ /**
356
+ * Funzione di logging che utilizza un callback personalizzato se disponibile
357
+ * @param {...any} args - Argomenti da loggare
358
+ */ export function logga(...args: any[]): void;
359
+ /**
360
+ * Valuta un'espressione matematica o logica e restituisce il risultato
361
+ * @param {string|number} expression - L'espressione da valutare
362
+ * @returns {number} Il risultato della valutazione dell'espressione
363
+ * @description
364
+ * Supporta operazioni matematiche di base, funzioni trigonometriche,
365
+ * operatori di confronto e operazioni logiche.
366
+ * Le funzioni supportate includono: sqrt, floor, abs, sin, cos, random, clamp, round
367
+ */ export function muCalc(expression: string | number): number;
368
+ /**
369
+ * Rimuove i commenti dal codice sorgente mantenendo la struttura del codice
370
+ * @param {string} codice - Il codice sorgente da processare
371
+ * @param {boolean} tienivuoti - Se true mantiene le righe vuote
372
+ * @returns {string[]} Array di righe di codice senza commenti
373
+ */ export function muClComments(codice: string, tienivuoti: boolean): string[];
374
+ /**
375
+ * Analizza e organizza il codice in una struttura dati gerarchica
376
+ * @param {string[]} tt - Array di righe di codice da analizzare
377
+ * @param {boolean} acapo - Se true mantiene i ritorni a capo nel contenuto
378
+ * @returns {Object[]} Array di oggetti rappresentanti la struttura del codice
379
+ * @throws {Error} Se tt non è un array
380
+ */ export function muClean(tt: string[], acapo?: boolean): any[];
381
+ export function muCompileScript(codice: any): any;
382
+ export function muEval(amb: any, mac: any, codice: any, options: any): any;
383
+ export function muEvalScript(amb: Ambiente, codice: any, pars: any, reset?: boolean): Promise<{
384
+ output: any;
385
+ vari: {};
386
+ errori: {
387
+ /**
388
+ * Azzera la lista degli errori
389
+ */ azzera(): void;
390
+ err: any[];
391
+ /**
392
+ * Aggiunge un errore alla lista
393
+ * @param {string} msg - Messaggio di errore
394
+ * @param {Object} row - Informazioni aggiuntive sull'errore
395
+ */ add(msg: string, row: any): void;
396
+ /**
397
+ * Restituisce la lista completa degli errori
398
+ * @returns {Array} Lista degli errori
399
+ */ get(): any[];
400
+ /**
401
+ * Restituisce il numero di errori presenti
402
+ * @returns {number} Numero di errori
403
+ */ readonly length: number;
404
+ /**
405
+ * Converte la lista degli errori in stringa
406
+ * @returns {string} Rappresentazione testuale degli errori
407
+ */ toString(): string;
408
+ };
409
+ }>;
410
+ export function muGenerate(macro: any, amb: any, genera: any, callback: any, isTestmode?: number): Promise<boolean>;
411
+ /**
412
+ * Analizza e processa i limiti definiti nel codice
413
+ * @param {string} dati - Dati contenenti le definizioni dei limiti
414
+ * @returns {Object[]} Array di oggetti rappresentanti i limiti processati
415
+ */ export function muLimits(dati: string): any[];
416
+ /**
417
+ * Analizza il codice sorgente e restituisce un array di token con classi CSS
418
+ * @param {string} tt - Il codice sorgente da analizzare
419
+ * @param {boolean} isvar - Flag che indica se analizzare come variabile
420
+ * @returns {Array<{class: string, text: string}>} Array di token con classi CSS
421
+ */ export function muParsecode(tt: string, isvar: boolean): Array<{
422
+ class: string;
423
+ text: string;
424
+ }>;
425
+ export function muValuta(mu: any, codice: any, azzera: any): any;
426
+ export namespace mustr {
427
+ namespace mus {
428
+ namespace variants {
429
+ let cod: string;
430
+ let des: string;
431
+ let alias: string;
432
+ let info: string;
433
+ let md: string;
434
+ let __pk: string;
435
+ }
436
+ namespace extras {
437
+ export let tipo: string;
438
+ let cod_1: string;
439
+ export { cod_1 as cod };
440
+ let info_1: string;
441
+ export { info_1 as info };
442
+ let __pk_1: string;
443
+ export { __pk_1 as __pk };
444
+ }
445
+ namespace macros {
446
+ let cod_2: string;
447
+ export { cod_2 as cod };
448
+ let des_1: string;
449
+ export { des_1 as des };
450
+ let info_2: string;
451
+ export { info_2 as info };
452
+ let md_1: string;
453
+ export { md_1 as md };
454
+ export let def: string;
455
+ export let isgenera: string;
456
+ export let iscodice: string;
457
+ export let isheader: string;
458
+ let __pk_2: string;
459
+ export { __pk_2 as __pk };
460
+ }
461
+ namespace infos {
462
+ let cod_3: string;
463
+ export { cod_3 as cod };
464
+ let des_2: string;
465
+ export { des_2 as des };
466
+ let info_3: string;
467
+ export { info_3 as info };
468
+ let __pk_3: string;
469
+ export { __pk_3 as __pk };
470
+ }
471
+ namespace barcodes {
472
+ let cod_4: string;
473
+ export { cod_4 as cod };
474
+ let des_3: string;
475
+ export { des_3 as des };
476
+ let info_4: string;
477
+ export { info_4 as info };
478
+ let __pk_4: string;
479
+ export { __pk_4 as __pk };
480
+ }
481
+ }
482
+ }
483
+ export function newAmbiente(cat: any, maxmillis?: number): Ambiente;
484
+ export function newMacro(amb: any, name: any): Macro;
485
+ export function newVariabile(): Variabile;
486
+ export function newVariante(cod: any, cat: any, amb: any): Promise<Variante>;
487
+ export function parselimitifromdb(rr: any): {}[];
488
+ export function parselimitifromrule(limvec: any): {
489
+ v: any[];
490
+ datai: number;
491
+ dataf: number;
492
+ }[];
493
+ /**
494
+ * Analizza variabili in un'espressione usando delimitatori
495
+ * @param {string} ex - Espressione da analizzare
496
+ * @param {number} k0 - Posizione iniziale
497
+ * @param {string} inipar - Delimitatore iniziale ([, (, {)
498
+ * @param {string} endpar - Delimitatore finale (], ), })
499
+ * @param {boolean} [nonewline=false] - Se true, termina all'incontro di un newline
500
+ * @returns {{i: number, res: string[]}} Risultato dell'analisi con posizione finale e array risultati
501
+ */ export function parsevar(ex: string, k0: number, inipar: string, endpar: string, nonewline?: boolean): {
502
+ i: number;
503
+ res: string[];
504
+ };
505
+ export function poppars(amb: any, tm: any): Promise<void>;
506
+ export function pushpars(amb: any, macro: any, parsfunzione: any, parsinit: any): Promise<{
507
+ v: string;
508
+ o: any;
509
+ }[]>;
510
+ export function quote(v: any): any;
511
+ /**
512
+ * Classe per la gestione degli errori con funzionalità di accumulo e formattazione
513
+ */
514
+ /**
515
+ * Copia le proprietà non-funzione da un oggetto sorgente a uno destinazione
516
+ * @param {Object} objDestinazione - Oggetto destinazione
517
+ * @param {Object} objSorgente - Oggetto sorgente
518
+ */
519
+ export function setOggetto(objDestinazione: any, objSorgente: any): void;
520
+ /**
521
+ * Esegue una semplice somma sincrona di due numeri
522
+ * @param {number} a - Primo numero da sommare
523
+ * @param {number} b - Secondo numero da sommare
524
+ * @returns {number} La somma dei due numeri
525
+ */
526
+ export function testsync(a: number, b: number): number;
527
+ export const tipicolonna: ({
528
+ cod: string;
529
+ des: string;
530
+ folder?: undefined;
531
+ } | {
532
+ cod: string;
533
+ des: string;
534
+ folder: string;
535
+ })[];
536
+ export const tipifree: string[];
537
+ export const tipiheader: {
538
+ cod: string;
539
+ des: string;
540
+ }[];
541
+ /**
542
+ * Restituisce il timestamp corrente in millisecondi
543
+ * @returns {number} Timestamp corrente
544
+ */ export function tk(): number;
545
+ export function toCadPars(str: any): {};
546
+ export function toJson(t: any): string;
547
+ export function tonum(s: any, dec?: number): number;
548
+ /**
549
+ * Restituisce il timestamp corrente in millisecondi
550
+ * @returns {number} Timestamp corrente
551
+ */ export function xdt(): number;
552
+ export { muInit as jsTest };
File without changes