@murumets-ee/imports 0.49.0 → 0.51.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/dist/carmaker-feed-C_MnDaOC.mjs +2 -0
- package/dist/{carmaker-feed-CxhZBrkO.mjs.map → carmaker-feed-C_MnDaOC.mjs.map} +1 -1
- package/dist/carmaker-feed-DlD2xPs0.d.mts +58 -0
- package/dist/carmaker-feed-DlD2xPs0.d.mts.map +1 -0
- package/dist/{cleanup-CHjDgvKT.mjs → cleanup-DdILFoAP.mjs} +2 -2
- package/dist/{cleanup-CHjDgvKT.mjs.map → cleanup-DdILFoAP.mjs.map} +1 -1
- package/dist/index.d.mts +7 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/mapping/index.d.mts +2 -359
- package/dist/mapping/index.d.mts.map +1 -1
- package/dist/mapping/index.mjs +1 -1
- package/dist/{mapping-transform-D76b-P-p.mjs → mapping-transform-AMFEg1rS.mjs} +2 -2
- package/dist/{mapping-transform-D76b-P-p.mjs.map → mapping-transform-AMFEg1rS.mjs.map} +1 -1
- package/dist/{parts-schema-D0gMhNWj.mjs → parts-schema-BBUINSdN.mjs} +2 -2
- package/dist/{parts-schema-D0gMhNWj.mjs.map → parts-schema-BBUINSdN.mjs.map} +1 -1
- package/dist/{parts-schema-x8_GRYWc.d.mts → parts-schema-u5kr5zFg.d.mts} +359 -3
- package/dist/parts-schema-u5kr5zFg.d.mts.map +1 -0
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.mjs +1 -1
- package/dist/plugin.mjs.map +1 -1
- package/dist/runner-wPnCZlB4.mjs +2 -0
- package/dist/runner-wPnCZlB4.mjs.map +1 -0
- package/dist/{schema-registry-C_lQje-K.mjs → schema-registry-B_7AweTa.mjs} +2 -2
- package/dist/{schema-registry-C_lQje-K.mjs.map → schema-registry-B_7AweTa.mjs.map} +1 -1
- package/dist/storage-resolver.d.mts +1 -1
- package/dist/transform-DwAQ4b-j.mjs +2 -0
- package/dist/transform-DwAQ4b-j.mjs.map +1 -0
- package/dist/{transform-CABBaYmF.d.mts → transform-WeiiLdYP.d.mts} +12 -1
- package/dist/transform-WeiiLdYP.d.mts.map +1 -0
- package/dist/transforms.d.mts +2 -46
- package/dist/transforms.mjs +1 -1
- package/dist/{worker-DRTgbtT7.d.mts → worker-DH3SN-91.d.mts} +189 -4
- package/dist/worker-DH3SN-91.d.mts.map +1 -0
- package/dist/worker.d.mts +1 -1
- package/dist/worker.mjs +1 -1
- package/dist/worker.mjs.map +1 -1
- package/dist/{xlsx-reader-Ccesszbc.mjs → xlsx-reader-Dsq_ERiB.mjs} +2 -2
- package/dist/{xlsx-reader-Ccesszbc.mjs.map → xlsx-reader-Dsq_ERiB.mjs.map} +1 -1
- package/package.json +8 -8
- package/dist/carmaker-feed-CxhZBrkO.mjs +0 -2
- package/dist/parts-schema-x8_GRYWc.d.mts.map +0 -1
- package/dist/runner-C-s6SD7t.mjs +0 -2
- package/dist/runner-C-s6SD7t.mjs.map +0 -1
- package/dist/transform-CABBaYmF.d.mts.map +0 -1
- package/dist/transform-DIzWppgJ.mjs +0 -2
- package/dist/transform-DIzWppgJ.mjs.map +0 -1
- package/dist/transforms.d.mts.map +0 -1
- package/dist/worker-DRTgbtT7.d.mts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as RowResult } from "./transform-
|
|
1
|
+
import { i as RowTransform, r as RowResult } from "./transform-WeiiLdYP.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { PartsDocument } from "@murumets-ee/search-elasticsearch";
|
|
4
4
|
|
|
@@ -250,6 +250,362 @@ declare function rowError(errorType: string, message: string, field: string): {
|
|
|
250
250
|
};
|
|
251
251
|
};
|
|
252
252
|
//#endregion
|
|
253
|
+
//#region src/mapping/engine.d.ts
|
|
254
|
+
/** One column-map entry. `target` is checked against the schema whitelist separately. */
|
|
255
|
+
declare const mappingColumnSchema: z.ZodObject<{
|
|
256
|
+
/** Source header name (or positional index string for headerless feeds). */source: z.ZodString; /** Target field key — must be in the chosen schema's whitelist (enforced in `buildMappingTransform`). */
|
|
257
|
+
target: z.ZodString; /** Ordered per-column cleaning ops. Defaults to none. */
|
|
258
|
+
transforms: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
|
|
259
|
+
op: z.ZodLiteral<"trim">;
|
|
260
|
+
}, "strip", z.ZodTypeAny, {
|
|
261
|
+
op: "trim";
|
|
262
|
+
}, {
|
|
263
|
+
op: "trim";
|
|
264
|
+
}>, z.ZodObject<{
|
|
265
|
+
op: z.ZodLiteral<"uppercase">;
|
|
266
|
+
}, "strip", z.ZodTypeAny, {
|
|
267
|
+
op: "uppercase";
|
|
268
|
+
}, {
|
|
269
|
+
op: "uppercase";
|
|
270
|
+
}>, z.ZodObject<{
|
|
271
|
+
op: z.ZodLiteral<"lowercase">;
|
|
272
|
+
}, "strip", z.ZodTypeAny, {
|
|
273
|
+
op: "lowercase";
|
|
274
|
+
}, {
|
|
275
|
+
op: "lowercase";
|
|
276
|
+
}>, z.ZodObject<{
|
|
277
|
+
op: z.ZodLiteral<"stripPrefix">;
|
|
278
|
+
value: z.ZodString;
|
|
279
|
+
}, "strip", z.ZodTypeAny, {
|
|
280
|
+
value: string;
|
|
281
|
+
op: "stripPrefix";
|
|
282
|
+
}, {
|
|
283
|
+
value: string;
|
|
284
|
+
op: "stripPrefix";
|
|
285
|
+
}>, z.ZodObject<{
|
|
286
|
+
op: z.ZodLiteral<"stripSuffix">;
|
|
287
|
+
value: z.ZodString;
|
|
288
|
+
}, "strip", z.ZodTypeAny, {
|
|
289
|
+
value: string;
|
|
290
|
+
op: "stripSuffix";
|
|
291
|
+
}, {
|
|
292
|
+
value: string;
|
|
293
|
+
op: "stripSuffix";
|
|
294
|
+
}>, z.ZodObject<{
|
|
295
|
+
op: z.ZodLiteral<"defaultIfEmpty">;
|
|
296
|
+
value: z.ZodString;
|
|
297
|
+
}, "strip", z.ZodTypeAny, {
|
|
298
|
+
value: string;
|
|
299
|
+
op: "defaultIfEmpty";
|
|
300
|
+
}, {
|
|
301
|
+
value: string;
|
|
302
|
+
op: "defaultIfEmpty";
|
|
303
|
+
}>, z.ZodObject<{
|
|
304
|
+
op: z.ZodLiteral<"number">;
|
|
305
|
+
}, "strip", z.ZodTypeAny, {
|
|
306
|
+
op: "number";
|
|
307
|
+
}, {
|
|
308
|
+
op: "number";
|
|
309
|
+
}>, z.ZodObject<{
|
|
310
|
+
op: z.ZodLiteral<"europeanNumber">;
|
|
311
|
+
}, "strip", z.ZodTypeAny, {
|
|
312
|
+
op: "europeanNumber";
|
|
313
|
+
}, {
|
|
314
|
+
op: "europeanNumber";
|
|
315
|
+
}>]>, "many">>;
|
|
316
|
+
}, "strip", z.ZodTypeAny, {
|
|
317
|
+
source: string;
|
|
318
|
+
target: string;
|
|
319
|
+
transforms: ({
|
|
320
|
+
op: "trim";
|
|
321
|
+
} | {
|
|
322
|
+
op: "uppercase";
|
|
323
|
+
} | {
|
|
324
|
+
op: "lowercase";
|
|
325
|
+
} | {
|
|
326
|
+
value: string;
|
|
327
|
+
op: "stripPrefix";
|
|
328
|
+
} | {
|
|
329
|
+
value: string;
|
|
330
|
+
op: "stripSuffix";
|
|
331
|
+
} | {
|
|
332
|
+
value: string;
|
|
333
|
+
op: "defaultIfEmpty";
|
|
334
|
+
} | {
|
|
335
|
+
op: "number";
|
|
336
|
+
} | {
|
|
337
|
+
op: "europeanNumber";
|
|
338
|
+
})[];
|
|
339
|
+
}, {
|
|
340
|
+
source: string;
|
|
341
|
+
target: string;
|
|
342
|
+
transforms?: ({
|
|
343
|
+
op: "trim";
|
|
344
|
+
} | {
|
|
345
|
+
op: "uppercase";
|
|
346
|
+
} | {
|
|
347
|
+
op: "lowercase";
|
|
348
|
+
} | {
|
|
349
|
+
value: string;
|
|
350
|
+
op: "stripPrefix";
|
|
351
|
+
} | {
|
|
352
|
+
value: string;
|
|
353
|
+
op: "stripSuffix";
|
|
354
|
+
} | {
|
|
355
|
+
value: string;
|
|
356
|
+
op: "defaultIfEmpty";
|
|
357
|
+
} | {
|
|
358
|
+
op: "number";
|
|
359
|
+
} | {
|
|
360
|
+
op: "europeanNumber";
|
|
361
|
+
})[] | undefined;
|
|
362
|
+
}>;
|
|
363
|
+
type MappingColumn = z.infer<typeof mappingColumnSchema>;
|
|
364
|
+
/**
|
|
365
|
+
* Decimal + thousands separators for the `number` transform.
|
|
366
|
+
*
|
|
367
|
+
* The two MUST differ: `parseNumber` strips every thousands separator FIRST, so a
|
|
368
|
+
* config where `decimal === thousands` (e.g. both `,`) would strip the decimal
|
|
369
|
+
* separator too — `326,88` → `32688`, a silent 100× error rather than a row error.
|
|
370
|
+
* Rejected at save (`assertValidMapping`) AND at run (`mappingConfigSchema`).
|
|
371
|
+
*/
|
|
372
|
+
declare const numberFormatSchema: z.ZodEffects<z.ZodObject<{
|
|
373
|
+
decimal: z.ZodEnum<[".", ","]>;
|
|
374
|
+
thousands: z.ZodEnum<["", ".", ",", " "]>;
|
|
375
|
+
}, "strip", z.ZodTypeAny, {
|
|
376
|
+
decimal: "." | ",";
|
|
377
|
+
thousands: "" | "." | "," | " ";
|
|
378
|
+
}, {
|
|
379
|
+
decimal: "." | ",";
|
|
380
|
+
thousands: "" | "." | "," | " ";
|
|
381
|
+
}>, {
|
|
382
|
+
decimal: "." | ",";
|
|
383
|
+
thousands: "" | "." | "," | " ";
|
|
384
|
+
}, {
|
|
385
|
+
decimal: "." | ",";
|
|
386
|
+
thousands: "" | "." | "," | " ";
|
|
387
|
+
}>;
|
|
388
|
+
/**
|
|
389
|
+
* The portable mapping config — the subset of an `import_mapping` row the engine
|
|
390
|
+
* needs. The enqueuer SNAPSHOTS this into `import_run.params.mapping` so a run
|
|
391
|
+
* records the exact mapping it used (reproducible) and the transform stays a pure
|
|
392
|
+
* function of `(row, ctx)` with no per-row DB I/O.
|
|
393
|
+
*/
|
|
394
|
+
declare const mappingConfigSchema: z.ZodObject<{
|
|
395
|
+
targetSchema: z.ZodString;
|
|
396
|
+
numberFormat: z.ZodEffects<z.ZodObject<{
|
|
397
|
+
decimal: z.ZodEnum<[".", ","]>;
|
|
398
|
+
thousands: z.ZodEnum<["", ".", ",", " "]>;
|
|
399
|
+
}, "strip", z.ZodTypeAny, {
|
|
400
|
+
decimal: "." | ",";
|
|
401
|
+
thousands: "" | "." | "," | " ";
|
|
402
|
+
}, {
|
|
403
|
+
decimal: "." | ",";
|
|
404
|
+
thousands: "" | "." | "," | " ";
|
|
405
|
+
}>, {
|
|
406
|
+
decimal: "." | ",";
|
|
407
|
+
thousands: "" | "." | "," | " ";
|
|
408
|
+
}, {
|
|
409
|
+
decimal: "." | ",";
|
|
410
|
+
thousands: "" | "." | "," | " ";
|
|
411
|
+
}>;
|
|
412
|
+
columnMap: z.ZodArray<z.ZodObject<{
|
|
413
|
+
/** Source header name (or positional index string for headerless feeds). */source: z.ZodString; /** Target field key — must be in the chosen schema's whitelist (enforced in `buildMappingTransform`). */
|
|
414
|
+
target: z.ZodString; /** Ordered per-column cleaning ops. Defaults to none. */
|
|
415
|
+
transforms: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
|
|
416
|
+
op: z.ZodLiteral<"trim">;
|
|
417
|
+
}, "strip", z.ZodTypeAny, {
|
|
418
|
+
op: "trim";
|
|
419
|
+
}, {
|
|
420
|
+
op: "trim";
|
|
421
|
+
}>, z.ZodObject<{
|
|
422
|
+
op: z.ZodLiteral<"uppercase">;
|
|
423
|
+
}, "strip", z.ZodTypeAny, {
|
|
424
|
+
op: "uppercase";
|
|
425
|
+
}, {
|
|
426
|
+
op: "uppercase";
|
|
427
|
+
}>, z.ZodObject<{
|
|
428
|
+
op: z.ZodLiteral<"lowercase">;
|
|
429
|
+
}, "strip", z.ZodTypeAny, {
|
|
430
|
+
op: "lowercase";
|
|
431
|
+
}, {
|
|
432
|
+
op: "lowercase";
|
|
433
|
+
}>, z.ZodObject<{
|
|
434
|
+
op: z.ZodLiteral<"stripPrefix">;
|
|
435
|
+
value: z.ZodString;
|
|
436
|
+
}, "strip", z.ZodTypeAny, {
|
|
437
|
+
value: string;
|
|
438
|
+
op: "stripPrefix";
|
|
439
|
+
}, {
|
|
440
|
+
value: string;
|
|
441
|
+
op: "stripPrefix";
|
|
442
|
+
}>, z.ZodObject<{
|
|
443
|
+
op: z.ZodLiteral<"stripSuffix">;
|
|
444
|
+
value: z.ZodString;
|
|
445
|
+
}, "strip", z.ZodTypeAny, {
|
|
446
|
+
value: string;
|
|
447
|
+
op: "stripSuffix";
|
|
448
|
+
}, {
|
|
449
|
+
value: string;
|
|
450
|
+
op: "stripSuffix";
|
|
451
|
+
}>, z.ZodObject<{
|
|
452
|
+
op: z.ZodLiteral<"defaultIfEmpty">;
|
|
453
|
+
value: z.ZodString;
|
|
454
|
+
}, "strip", z.ZodTypeAny, {
|
|
455
|
+
value: string;
|
|
456
|
+
op: "defaultIfEmpty";
|
|
457
|
+
}, {
|
|
458
|
+
value: string;
|
|
459
|
+
op: "defaultIfEmpty";
|
|
460
|
+
}>, z.ZodObject<{
|
|
461
|
+
op: z.ZodLiteral<"number">;
|
|
462
|
+
}, "strip", z.ZodTypeAny, {
|
|
463
|
+
op: "number";
|
|
464
|
+
}, {
|
|
465
|
+
op: "number";
|
|
466
|
+
}>, z.ZodObject<{
|
|
467
|
+
op: z.ZodLiteral<"europeanNumber">;
|
|
468
|
+
}, "strip", z.ZodTypeAny, {
|
|
469
|
+
op: "europeanNumber";
|
|
470
|
+
}, {
|
|
471
|
+
op: "europeanNumber";
|
|
472
|
+
}>]>, "many">>;
|
|
473
|
+
}, "strip", z.ZodTypeAny, {
|
|
474
|
+
source: string;
|
|
475
|
+
target: string;
|
|
476
|
+
transforms: ({
|
|
477
|
+
op: "trim";
|
|
478
|
+
} | {
|
|
479
|
+
op: "uppercase";
|
|
480
|
+
} | {
|
|
481
|
+
op: "lowercase";
|
|
482
|
+
} | {
|
|
483
|
+
value: string;
|
|
484
|
+
op: "stripPrefix";
|
|
485
|
+
} | {
|
|
486
|
+
value: string;
|
|
487
|
+
op: "stripSuffix";
|
|
488
|
+
} | {
|
|
489
|
+
value: string;
|
|
490
|
+
op: "defaultIfEmpty";
|
|
491
|
+
} | {
|
|
492
|
+
op: "number";
|
|
493
|
+
} | {
|
|
494
|
+
op: "europeanNumber";
|
|
495
|
+
})[];
|
|
496
|
+
}, {
|
|
497
|
+
source: string;
|
|
498
|
+
target: string;
|
|
499
|
+
transforms?: ({
|
|
500
|
+
op: "trim";
|
|
501
|
+
} | {
|
|
502
|
+
op: "uppercase";
|
|
503
|
+
} | {
|
|
504
|
+
op: "lowercase";
|
|
505
|
+
} | {
|
|
506
|
+
value: string;
|
|
507
|
+
op: "stripPrefix";
|
|
508
|
+
} | {
|
|
509
|
+
value: string;
|
|
510
|
+
op: "stripSuffix";
|
|
511
|
+
} | {
|
|
512
|
+
value: string;
|
|
513
|
+
op: "defaultIfEmpty";
|
|
514
|
+
} | {
|
|
515
|
+
op: "number";
|
|
516
|
+
} | {
|
|
517
|
+
op: "europeanNumber";
|
|
518
|
+
})[] | undefined;
|
|
519
|
+
}>, "many">;
|
|
520
|
+
}, "strip", z.ZodTypeAny, {
|
|
521
|
+
targetSchema: string;
|
|
522
|
+
numberFormat: {
|
|
523
|
+
decimal: "." | ",";
|
|
524
|
+
thousands: "" | "." | "," | " ";
|
|
525
|
+
};
|
|
526
|
+
columnMap: {
|
|
527
|
+
source: string;
|
|
528
|
+
target: string;
|
|
529
|
+
transforms: ({
|
|
530
|
+
op: "trim";
|
|
531
|
+
} | {
|
|
532
|
+
op: "uppercase";
|
|
533
|
+
} | {
|
|
534
|
+
op: "lowercase";
|
|
535
|
+
} | {
|
|
536
|
+
value: string;
|
|
537
|
+
op: "stripPrefix";
|
|
538
|
+
} | {
|
|
539
|
+
value: string;
|
|
540
|
+
op: "stripSuffix";
|
|
541
|
+
} | {
|
|
542
|
+
value: string;
|
|
543
|
+
op: "defaultIfEmpty";
|
|
544
|
+
} | {
|
|
545
|
+
op: "number";
|
|
546
|
+
} | {
|
|
547
|
+
op: "europeanNumber";
|
|
548
|
+
})[];
|
|
549
|
+
}[];
|
|
550
|
+
}, {
|
|
551
|
+
targetSchema: string;
|
|
552
|
+
numberFormat: {
|
|
553
|
+
decimal: "." | ",";
|
|
554
|
+
thousands: "" | "." | "," | " ";
|
|
555
|
+
};
|
|
556
|
+
columnMap: {
|
|
557
|
+
source: string;
|
|
558
|
+
target: string;
|
|
559
|
+
transforms?: ({
|
|
560
|
+
op: "trim";
|
|
561
|
+
} | {
|
|
562
|
+
op: "uppercase";
|
|
563
|
+
} | {
|
|
564
|
+
op: "lowercase";
|
|
565
|
+
} | {
|
|
566
|
+
value: string;
|
|
567
|
+
op: "stripPrefix";
|
|
568
|
+
} | {
|
|
569
|
+
value: string;
|
|
570
|
+
op: "stripSuffix";
|
|
571
|
+
} | {
|
|
572
|
+
value: string;
|
|
573
|
+
op: "defaultIfEmpty";
|
|
574
|
+
} | {
|
|
575
|
+
op: "number";
|
|
576
|
+
} | {
|
|
577
|
+
op: "europeanNumber";
|
|
578
|
+
})[] | undefined;
|
|
579
|
+
}[];
|
|
580
|
+
}>;
|
|
581
|
+
type MappingConfig = z.infer<typeof mappingConfigSchema>;
|
|
582
|
+
/**
|
|
583
|
+
* Build a `RowTransform` from a validated mapping config + its target schema.
|
|
584
|
+
*
|
|
585
|
+
* Throws at BUILD time if any `column_map` target is outside the schema's
|
|
586
|
+
* whitelist (deny-by-default, R02) — so a misconfigured mapping fails loudly
|
|
587
|
+
* before a single row is written, rather than silently dropping a column.
|
|
588
|
+
*
|
|
589
|
+
* Generic over the schema's output type, so passing the concrete `partsSchema`
|
|
590
|
+
* yields a `RowTransform<PartsDocument>` (the carmaker path keeps its typing); the
|
|
591
|
+
* registry-resolved `TargetSchema<unknown>` yields `RowTransform<unknown>` (the
|
|
592
|
+
* `commerce:mapping` path, where the output type isn't known until runtime).
|
|
593
|
+
*/
|
|
594
|
+
declare function buildMappingTransform<TOut>(config: MappingConfig, schema: TargetSchema<TOut>): RowTransform<TOut>;
|
|
595
|
+
/** The minimal shape `resolveMapping` needs — satisfied by an `import_mapping` row or a test fixture. */
|
|
596
|
+
interface ResolvableMapping {
|
|
597
|
+
/** `null` = supplier default (applies to all brands). */
|
|
598
|
+
brandId: string | null;
|
|
599
|
+
active: boolean;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Most-specific resolution (D002 ladder): given the candidate mappings for one
|
|
603
|
+
* `(supplier, target_schema)` and the requested brand, return the brand-specific
|
|
604
|
+
* mapping if one exists, else the supplier-default (`brandId === null`). Inactive
|
|
605
|
+
* mappings are skipped. Returns `undefined` when nothing matches.
|
|
606
|
+
*/
|
|
607
|
+
declare function resolveMapping<M extends ResolvableMapping>(mappings: readonly M[], brandId: string | null): M | undefined;
|
|
608
|
+
//#endregion
|
|
253
609
|
//#region src/mapping/parts-schema.d.ts
|
|
254
610
|
/**
|
|
255
611
|
* Params the `parts` schema reads from the run — the per-(supplier, brand)
|
|
@@ -305,5 +661,5 @@ declare function normalizeCode(s: string): string;
|
|
|
305
661
|
*/
|
|
306
662
|
declare const partsSchema: TargetSchema<PartsDocument>;
|
|
307
663
|
//#endregion
|
|
308
|
-
export {
|
|
309
|
-
//# sourceMappingURL=parts-schema-
|
|
664
|
+
export { parseNumber as A, ColumnTransform as C, columnTransformSchema as D, applyColumnTransforms as E, NumberFormat as O, CellValue as S, ColumnTransformOpDescriptor as T, TargetSchema as _, MappingColumn as a, textOrNull as b, buildMappingTransform as c, numberFormatSchema as d, resolveMapping as f, TargetField as g, NumberOutcome as h, partsSchema as i, toMinorUnits as j, parseEuropeanNumber as k, mappingColumnSchema as l, MappedRow as m, normalizeCode as n, MappingConfig as o, BuildRowContext as p, partsParamsSchema as r, ResolvableMapping as s, PartsParams as t, mappingConfigSchema as u, numberCell as v, ColumnTransformOp as w, COLUMN_TRANSFORM_OPS as x, rowError as y };
|
|
665
|
+
//# sourceMappingURL=parts-schema-u5kr5zFg.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts-schema-u5kr5zFg.d.mts","names":[],"sources":["../src/mapping/number-format.ts","../src/mapping/column-transforms.ts","../src/mapping/target-schema.ts","../src/mapping/engine.ts","../src/mapping/parts-schema.ts"],"mappings":"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"}
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as EsClientResolver, r as FilePathResolver, s as PairSink, t as EnsureIndexResolver } from "./worker-
|
|
1
|
+
import { n as EsClientResolver, r as FilePathResolver, s as PairSink, t as EnsureIndexResolver } from "./worker-DH3SN-91.mjs";
|
|
2
2
|
import { ImportsStorageFactory } from "./storage.mjs";
|
|
3
3
|
import { IndexConfig } from "@murumets-ee/search-elasticsearch";
|
|
4
4
|
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,o as t,u as n}from"./transform-
|
|
1
|
+
import{n as e,o as t,u as n}from"./transform-DwAQ4b-j.mjs";import{registerImportsStorageFactory as r}from"./storage.mjs";import{i,t as a}from"./carmaker-feed-C_MnDaOC.mjs";import{n as o,t as s}from"./mapping-transform-AMFEg1rS.mjs";import{createImportsRunDeadListener as c,createRunImportHandler as l,importsRunJob as u}from"./worker.mjs";import{definePlugin as d}from"@murumets-ee/core";import{z as f}from"zod";import{inArray as p}from"drizzle-orm";import{createIndex as m,dropIndex as h,readAliasTargets as g,reindex as _}from"@murumets-ee/search-elasticsearch";import{defineJob as v}from"@murumets-ee/queue/client";const y=f.object({toIndex:f.string().min(1).optional(),allowExisting:f.boolean().optional(),dropOld:f.boolean().optional(),batchSize:f.number().int().min(1).max(1e4).optional()}),b=v({name:`imports:reindex`,description:`Copy the aliased parts index into a new physical index built with the current mapping, then atomically swap the alias onto it.`,schema:y,defaultRetries:0}),x=[`pending`,`running`];async function S(e){let t=e.getTable();return e.count({where:p(t.status,[...x])})}function C(e){let t=/^(.*)_v(\d+)$/.exec(e);if(!t)return null;let[,n,r]=t;if(n===void 0||r===void 0)return null;let i=Number.parseInt(r,10)+1;return Number.isSafeInteger(i)?`${n}_v${i}`:null}function w(e){let{esClient:t,esIndex:n,indexConfig:r,importRuns:i,logger:a}=e;return async e=>{let o=a?.child({jobId:e.id,type:`imports:reindex`});if(r===void 0)throw Error(`imports:reindex requires imports({ indexConfig }) — the destination index must be created with the settings + mappings this app intends, otherwise Elasticsearch auto-creates it with inferred text mappings and the reindex silently discards the mapping change it exists to ship. Pass your app's index config (for the parts catalog: partsIndexConfig from @murumets-ee/search-elasticsearch).`);let s=y.parse(e.payload);if(i!==void 0){let e=await S(i);if(e>0)throw Error(`imports:reindex: ${e} feed import(s) are pending or running. An import writes through the alias "${n}", which points at the SOURCE index for the whole copy, so anything it writes now would be lost at the swap. Wait for them to finish (or cancel them) and re-run.`)}let c=await t(),l=Object.keys(await g(c,n)).sort();if(l.length>1)throw Error(`imports:reindex: alias "${n}" points at ${l.length} indices (${l.join(`, `)}). Reindexing would copy only one of them and then swap, leaving the alias on a mix of stale and fresh data. Resolve the alias to a single index first, then re-run. An interrupted reindex cannot cause this — swapAlias sends its remove with must_exist, so a stale swap fails instead of adding a second target. Look for a manual alias edit, another tool writing to this cluster, or a swap issued before that guard existed.`);let u=l[0];if(u===void 0)throw Error(`imports:reindex: alias "${n}" does not exist, so there is nothing to reindex. Run an import first — imports({ ensureIndex }) bootstraps the alias on the import path.`);let d=s.toIndex??C(u);if(d===null)throw Error(`imports:reindex: alias "${n}" points at "${u}", which does not follow the "<name>_v<N>" convention, so the next version cannot be derived. Pass an explicit destination (\`lumi imports:reindex --to <index>\`).`);let f=d;if(f===u)throw Error(`imports:reindex: destination "${f}" is the index the alias already points at. Reindexing an index onto itself would copy every document over itself and swap the alias onto where it already is. Pass a different --to.`);let p=await c.indices.exists({index:f});if(p&&s.allowExisting!==!0)throw Error(`imports:reindex: destination "${f}" already exists. If it is debris from a failed run, re-run with --resume to continue into it (bulkUpsert is idempotent by _id, so already-copied documents are simply overwritten); if it was created by hand with a different mapping, delete it or pass --to <another-index> instead. Refusing to reuse it silently, because doing so would apply ITS mapping rather than the one you changed.`);e.updateProgress({phase:p?`resuming`:`creating`,fromIndex:u,toIndex:f,processed:0,total:0}),p?o?.warn({fromIndex:u,toIndex:f},`imports:reindex: resuming into an existing destination index (--resume); its EXISTING mapping applies, not indexConfig`):(o?.info({fromIndex:u,toIndex:f},`imports:reindex: creating destination index`),await m(c,{name:f,config:r})),o?.info({fromIndex:u,toIndex:f},`imports:reindex: copying documents`);let v=await _({client:c,alias:n,fromIndex:u,toIndex:f,refreshOnCompletion:!0,...s.batchSize!==void 0&&{batchSize:s.batchSize},...i!==void 0&&{beforeSwap:async()=>{let e=await S(i);if(e>0)throw Error(`imports:reindex: ${e} feed import(s) started while the copy was running. Their documents went to the source index through the alias and are NOT in "${f}", so swapping now would drop them. The alias is untouched and "${f}" is left in place — wait for the import(s), then re-run with --resume to finish.`)}},reportProgress:async({processed:t,total:n})=>{e.updateProgress({phase:`copying`,fromIndex:u,toIndex:f,processed:t,total:n})}});e.updateProgress({phase:`swapped`,fromIndex:u,toIndex:f,processed:v.processed,total:v.processed+v.skipped,skipped:v.skipped}),o?.info({fromIndex:u,toIndex:f,processed:v.processed,skipped:v.skipped},`imports:reindex: alias swapped onto destination`),s.dropOld===!0&&(await h(c,u),o?.info({fromIndex:u},`imports:reindex: dropped source index (--drop-old)`))}}const T=Symbol.for(`@murumets-ee/imports:dead-listener-unsubscribe`);function E(f){let p=f.esIndex,m=f.storageBucket===null?null:{bucket:f.storageBucket??`lumi-imports`,orphanTtlHours:f.orphanUploadTtlHours??2,processedRetentionDays:f.processedRetentionDays??7};return f.storage&&r(f.storage),d({name:`@murumets-ee/imports`,server:{entities:[n,t],init:async t=>{let r=e();if(r.has(`commerce:mapping`)||r.register(s,o),r.has(`commerce:carmaker-feed`)||r.register(a,i),!t.plugins.all().some(e=>e.name===`@murumets-ee/queue`)){t.logger.warn(`imports: queue() plugin not in plugins array — imports:run jobs will not be processed`);return}let d=await import(`@murumets-ee/queue/client`),h=t.getClient(n);d.registerJob(u,l({importRuns:h,transforms:r,esClient:f.esClient,esIndex:p,...f.ensureIndex!==void 0&&{ensureIndex:f.ensureIndex},...f.resolveFilePath!==void 0&&{resolveFilePath:f.resolveFilePath},...f.pairSink!==void 0&&{pairSink:f.pairSink},logger:t.logger.child({pkg:`imports`})})),d.registerJob(b,w({esClient:f.esClient,esIndex:p,importRuns:h,...f.indexConfig!==void 0&&{indexConfig:f.indexConfig},logger:t.logger.child({pkg:`imports`})}));let g=globalThis[T];g&&g();let _=d.addQueueTerminalListener(c({importRuns:h,logger:t.logger.child({pkg:`imports`})}));if(globalThis[T]=_,m!==null){let{cleanupOrphanedImports:e,cleanupProcessedImports:n}=await import(`./cleanup-DdILFoAP.mjs`).then(e=>e.r),{runAsCli:r}=await import(`@murumets-ee/core`),i=t.logger.child({pkg:`imports`,job:`cleanup`});d.registerJob(d.defineJob({name:`imports:cleanup-orphaned-uploads`,description:`Delete toolkit_files rows in the imports bucket with no matching import_run reference and createdAt older than the configured TTL.`,schedule:`@every 1h`}),async()=>{await r(()=>e({app:t,bucket:m.bucket,ttlHours:m.orphanTtlHours,logger:i}))}),d.registerJob(d.defineJob({name:`imports:cleanup-processed-uploads`,description:`Delete toolkit_files rows for import_runs in terminal status (succeeded/failed/cancelled) whose finishedAt is older than the configured retention window. The import_run row itself is preserved.`,schedule:`@every 1h`}),async()=>{await r(()=>n({app:t,bucket:m.bucket,retentionDays:m.processedRetentionDays,logger:i}))})}t.logger.info({esIndex:p,cleanup:m===null?{enabled:!1}:{enabled:!0,...m}},`Imports plugin initialized`)}}})}export{E as imports};
|
|
2
2
|
//# sourceMappingURL=plugin.mjs.map
|