@walkeros/core 0.4.1 → 0.5.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="left">
2
- <a href="https://elbwalker.com">
3
- <img title="elbwalker" src="https://www.elbwalker.com/img/elbwalker_logo.png" width="256px"/>
2
+ <a href="https://www.walkeros.io">
3
+ <img title="elbwalker" src="https://www.walkeros.io/img/elbwalker_logo.png" width="256px"/>
4
4
  </a>
5
5
  </p>
6
6
 
@@ -15,7 +15,35 @@ data manipulation, validation, mapping, and more.
15
15
 
16
16
  ## Installation
17
17
 
18
- Import the core utilities directly from the `@walkeros/core` package:
18
+ ```bash
19
+ npm install @walkeros/core
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ The core package provides types and utilities used across walkerOS. In a Flow
25
+ configuration:
26
+
27
+ ```json
28
+ {
29
+ "version": 1,
30
+ "flows": {
31
+ "default": {
32
+ "web": {},
33
+ "destinations": {
34
+ "api": {
35
+ "package": "@walkeros/web-destination-api",
36
+ "config": {
37
+ "url": "https://collect.example.com/events"
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ ```
45
+
46
+ Import utilities directly:
19
47
 
20
48
  ```ts
21
49
  import { assign, anonymizeIP, getMappingValue } from '@walkeros/core';
@@ -119,7 +147,7 @@ getId(10); // Returns 10-character string
119
147
 
120
148
  `getMappingValue(event: WalkerOS.Event, mapping: Mapping.Data, options?: Mapping.Options): Promise<WalkerOS.Property | undefined>`
121
149
  extracts values from events using
122
- [mapping configurations](https://www.elbwalker.com/docs/destinations/event-mapping).
150
+ [mapping configurations](https://www.walkeros.io/docs/destinations/event-mapping).
123
151
 
124
152
  ```ts
125
153
  // Simple path mapping
@@ -300,13 +328,22 @@ validates event structure and throws on invalid events.
300
328
 
301
329
  Validates that values conform to walkerOS property types.
302
330
 
303
- ---
331
+ ## Type Definitions
332
+
333
+ See [src/types/](./src/types/) for TypeScript interfaces:
334
+
335
+ - [event.ts](./src/types/event.ts) - Event structure
336
+ - [destination.ts](./src/types/destination.ts) - Destination interface
337
+ - [source.ts](./src/types/source.ts) - Source interface
338
+ - [mapping.ts](./src/types/mapping.ts) - Mapping configuration
304
339
 
305
- For platform-specific utilities, see:
340
+ ## Related
306
341
 
307
- - [Web Core](https://www.elbwalker.com/docs/core/web) - Browser-specific
342
+ - [Website Documentation](https://www.walkeros.io/docs/)
343
+ - [Collector Package](../collector/) - Event processing engine
344
+ - [Web Core](https://www.walkeros.io/docs/sources/web/) - Browser-specific
308
345
  functions
309
- - [Server Core](https://www.elbwalker.com/docs/core/server) - Node.js server
346
+ - [Server Core](https://www.walkeros.io/docs/sources/server/) - Node.js server
310
347
  functions
311
348
 
312
349
  ## Contribute
package/dist/dev.d.mts CHANGED
@@ -3371,7 +3371,7 @@ declare namespace source {
3371
3371
  * Mirrors: types/flow.ts
3372
3372
  * Purpose: Runtime validation and JSON Schema generation for Flow configurations
3373
3373
  *
3374
- * The Flow system provides unified configuration across all walkerOS environments.
3374
+ * The Flow system provides unified configuration across all walkerOS flows.
3375
3375
  * These schemas enable:
3376
3376
  * - Runtime validation of config files
3377
3377
  * - Clear error messages for configuration issues
@@ -3389,6 +3389,33 @@ declare namespace source {
3389
3389
  * Used in Setup.variables and Config.env.
3390
3390
  */
3391
3391
  declare const PrimitiveSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
3392
+ /**
3393
+ * Variables schema for interpolation.
3394
+ */
3395
+ declare const VariablesSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
3396
+ /**
3397
+ * Definitions schema for reusable configurations.
3398
+ */
3399
+ declare const DefinitionsSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3400
+ /**
3401
+ * Packages schema for build configuration.
3402
+ */
3403
+ declare const PackagesSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
3404
+ version: z.ZodOptional<z.ZodString>;
3405
+ imports: z.ZodOptional<z.ZodArray<z.ZodString>>;
3406
+ path: z.ZodOptional<z.ZodString>;
3407
+ }, z.core.$strip>>;
3408
+ /**
3409
+ * Web platform configuration schema.
3410
+ */
3411
+ declare const WebSchema: z.ZodObject<{
3412
+ windowCollector: z.ZodOptional<z.ZodString>;
3413
+ windowElb: z.ZodOptional<z.ZodString>;
3414
+ }, z.core.$strip>;
3415
+ /**
3416
+ * Server platform configuration schema.
3417
+ */
3418
+ declare const ServerSchema: z.ZodObject<{}, z.core.$loose>;
3392
3419
  /**
3393
3420
  * Source reference schema.
3394
3421
  *
@@ -3398,9 +3425,12 @@ declare const PrimitiveSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.
3398
3425
  */
3399
3426
  declare const SourceReferenceSchema: z.ZodObject<{
3400
3427
  package: z.ZodString;
3428
+ code: z.ZodOptional<z.ZodString>;
3401
3429
  config: z.ZodOptional<z.ZodUnknown>;
3402
3430
  env: z.ZodOptional<z.ZodUnknown>;
3403
3431
  primary: z.ZodOptional<z.ZodBoolean>;
3432
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
3433
+ definitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3404
3434
  }, z.core.$strip>;
3405
3435
  /**
3406
3436
  * Destination reference schema.
@@ -3411,66 +3441,96 @@ declare const SourceReferenceSchema: z.ZodObject<{
3411
3441
  */
3412
3442
  declare const DestinationReferenceSchema: z.ZodObject<{
3413
3443
  package: z.ZodString;
3444
+ code: z.ZodOptional<z.ZodString>;
3414
3445
  config: z.ZodOptional<z.ZodUnknown>;
3415
3446
  env: z.ZodOptional<z.ZodUnknown>;
3447
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
3448
+ definitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3416
3449
  }, z.core.$strip>;
3417
3450
  /**
3418
- * Flow environment configuration schema.
3451
+ * Single flow configuration schema.
3419
3452
  *
3420
3453
  * @remarks
3421
- * Represents a single deployment environment (e.g., web_prod, server_stage).
3422
- * Uses `.passthrough()` to allow package-specific extensions (build, docker, etc.).
3454
+ * Represents a single deployment target (e.g., web_prod, server_stage).
3455
+ * Platform is determined by presence of `web` or `server` key.
3456
+ * Exactly one must be present.
3423
3457
  */
3424
3458
  declare const ConfigSchema: z.ZodObject<{
3425
- platform: z.ZodEnum<{
3426
- web: "web";
3427
- server: "server";
3428
- }>;
3459
+ web: z.ZodOptional<z.ZodObject<{
3460
+ windowCollector: z.ZodOptional<z.ZodString>;
3461
+ windowElb: z.ZodOptional<z.ZodString>;
3462
+ }, z.core.$strip>>;
3463
+ server: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
3429
3464
  sources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3430
3465
  package: z.ZodString;
3466
+ code: z.ZodOptional<z.ZodString>;
3431
3467
  config: z.ZodOptional<z.ZodUnknown>;
3432
3468
  env: z.ZodOptional<z.ZodUnknown>;
3433
3469
  primary: z.ZodOptional<z.ZodBoolean>;
3470
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
3471
+ definitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3434
3472
  }, z.core.$strip>>>;
3435
3473
  destinations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3436
3474
  package: z.ZodString;
3475
+ code: z.ZodOptional<z.ZodString>;
3437
3476
  config: z.ZodOptional<z.ZodUnknown>;
3438
3477
  env: z.ZodOptional<z.ZodUnknown>;
3478
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
3479
+ definitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3439
3480
  }, z.core.$strip>>>;
3440
3481
  collector: z.ZodOptional<z.ZodUnknown>;
3441
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
3442
- }, z.core.$loose>;
3482
+ packages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3483
+ version: z.ZodOptional<z.ZodString>;
3484
+ imports: z.ZodOptional<z.ZodArray<z.ZodString>>;
3485
+ path: z.ZodOptional<z.ZodString>;
3486
+ }, z.core.$strip>>>;
3487
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
3488
+ definitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3489
+ }, z.core.$strip>;
3443
3490
  /**
3444
3491
  * Flow setup schema - root configuration.
3445
3492
  *
3446
3493
  * @remarks
3447
3494
  * This is the complete schema for walkeros.config.json files.
3448
- * Contains multiple named environments with shared variables and definitions.
3495
+ * Contains multiple named flows with shared variables and definitions.
3449
3496
  */
3450
3497
  declare const SetupSchema: z.ZodObject<{
3451
3498
  version: z.ZodLiteral<1>;
3452
3499
  $schema: z.ZodOptional<z.ZodString>;
3453
3500
  variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
3454
3501
  definitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3455
- environments: z.ZodRecord<z.ZodString, z.ZodObject<{
3456
- platform: z.ZodEnum<{
3457
- web: "web";
3458
- server: "server";
3459
- }>;
3502
+ flows: z.ZodRecord<z.ZodString, z.ZodObject<{
3503
+ web: z.ZodOptional<z.ZodObject<{
3504
+ windowCollector: z.ZodOptional<z.ZodString>;
3505
+ windowElb: z.ZodOptional<z.ZodString>;
3506
+ }, z.core.$strip>>;
3507
+ server: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
3460
3508
  sources: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3461
3509
  package: z.ZodString;
3510
+ code: z.ZodOptional<z.ZodString>;
3462
3511
  config: z.ZodOptional<z.ZodUnknown>;
3463
3512
  env: z.ZodOptional<z.ZodUnknown>;
3464
3513
  primary: z.ZodOptional<z.ZodBoolean>;
3514
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
3515
+ definitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3465
3516
  }, z.core.$strip>>>;
3466
3517
  destinations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3467
3518
  package: z.ZodString;
3519
+ code: z.ZodOptional<z.ZodString>;
3468
3520
  config: z.ZodOptional<z.ZodUnknown>;
3469
3521
  env: z.ZodOptional<z.ZodUnknown>;
3522
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
3523
+ definitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3470
3524
  }, z.core.$strip>>>;
3471
3525
  collector: z.ZodOptional<z.ZodUnknown>;
3472
- env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
3473
- }, z.core.$loose>>;
3526
+ packages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
3527
+ version: z.ZodOptional<z.ZodString>;
3528
+ imports: z.ZodOptional<z.ZodArray<z.ZodString>>;
3529
+ path: z.ZodOptional<z.ZodString>;
3530
+ }, z.core.$strip>>>;
3531
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
3532
+ definitions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
3533
+ }, z.core.$strip>>;
3474
3534
  }, z.core.$strip>;
3475
3535
  /**
3476
3536
  * Parse and validate Flow.Setup configuration.
@@ -3486,7 +3546,7 @@ declare const SetupSchema: z.ZodObject<{
3486
3546
  *
3487
3547
  * const raw = JSON.parse(readFileSync('walkeros.config.json', 'utf8'));
3488
3548
  * const config = parseSetup(raw);
3489
- * console.log(`Found ${Object.keys(config.environments).length} environments`);
3549
+ * console.log(`Found ${Object.keys(config.flows).length} flows`);
3490
3550
  * ```
3491
3551
  */
3492
3552
  declare function parseSetup(data: unknown): z.infer<typeof SetupSchema>;
@@ -3510,31 +3570,48 @@ declare function parseSetup(data: unknown): z.infer<typeof SetupSchema>;
3510
3570
  */
3511
3571
  declare function safeParseSetup(data: unknown): z.ZodSafeParseResult<{
3512
3572
  version: 1;
3513
- environments: Record<string, {
3514
- [x: string]: unknown;
3515
- platform: "web" | "server";
3573
+ flows: Record<string, {
3574
+ web?: {
3575
+ windowCollector?: string | undefined;
3576
+ windowElb?: string | undefined;
3577
+ } | undefined;
3578
+ server?: {
3579
+ [x: string]: unknown;
3580
+ } | undefined;
3516
3581
  sources?: Record<string, {
3517
3582
  package: string;
3583
+ code?: string | undefined;
3518
3584
  config?: unknown;
3519
3585
  env?: unknown;
3520
3586
  primary?: boolean | undefined;
3587
+ variables?: Record<string, string | number | boolean> | undefined;
3588
+ definitions?: Record<string, unknown> | undefined;
3521
3589
  }> | undefined;
3522
3590
  destinations?: Record<string, {
3523
3591
  package: string;
3592
+ code?: string | undefined;
3524
3593
  config?: unknown;
3525
3594
  env?: unknown;
3595
+ variables?: Record<string, string | number | boolean> | undefined;
3596
+ definitions?: Record<string, unknown> | undefined;
3526
3597
  }> | undefined;
3527
3598
  collector?: unknown;
3528
- env?: Record<string, string> | undefined;
3599
+ packages?: Record<string, {
3600
+ version?: string | undefined;
3601
+ imports?: string[] | undefined;
3602
+ path?: string | undefined;
3603
+ }> | undefined;
3604
+ variables?: Record<string, string | number | boolean> | undefined;
3605
+ definitions?: Record<string, unknown> | undefined;
3529
3606
  }>;
3530
3607
  $schema?: string | undefined;
3531
3608
  variables?: Record<string, string | number | boolean> | undefined;
3532
3609
  definitions?: Record<string, unknown> | undefined;
3533
3610
  }>;
3534
3611
  /**
3535
- * Parse and validate Flow.Config (single environment).
3612
+ * Parse and validate Flow.Config (single flow).
3536
3613
  *
3537
- * @param data - Raw JSON data for single environment
3614
+ * @param data - Raw JSON data for single flow
3538
3615
  * @returns Validated Flow.Config object
3539
3616
  * @throws ZodError if validation fails
3540
3617
  *
@@ -3542,33 +3619,50 @@ declare function safeParseSetup(data: unknown): z.ZodSafeParseResult<{
3542
3619
  * ```typescript
3543
3620
  * import { parseConfig } from '@walkeros/core/dev';
3544
3621
  *
3545
- * const envConfig = parseConfig(rawEnvData);
3546
- * console.log(`Platform: ${envConfig.platform}`);
3622
+ * const flowConfig = parseConfig(rawFlowData);
3623
+ * console.log(`Platform: ${flowConfig.web ? 'web' : 'server'}`);
3547
3624
  * ```
3548
3625
  */
3549
3626
  declare function parseConfig(data: unknown): z.infer<typeof ConfigSchema>;
3550
3627
  /**
3551
3628
  * Safely parse Flow.Config without throwing.
3552
3629
  *
3553
- * @param data - Raw JSON data for single environment
3630
+ * @param data - Raw JSON data for single flow
3554
3631
  * @returns Success result with data or error result with issues
3555
3632
  */
3556
3633
  declare function safeParseConfig(data: unknown): z.ZodSafeParseResult<{
3557
- [x: string]: unknown;
3558
- platform: "web" | "server";
3634
+ web?: {
3635
+ windowCollector?: string | undefined;
3636
+ windowElb?: string | undefined;
3637
+ } | undefined;
3638
+ server?: {
3639
+ [x: string]: unknown;
3640
+ } | undefined;
3559
3641
  sources?: Record<string, {
3560
3642
  package: string;
3643
+ code?: string | undefined;
3561
3644
  config?: unknown;
3562
3645
  env?: unknown;
3563
3646
  primary?: boolean | undefined;
3647
+ variables?: Record<string, string | number | boolean> | undefined;
3648
+ definitions?: Record<string, unknown> | undefined;
3564
3649
  }> | undefined;
3565
3650
  destinations?: Record<string, {
3566
3651
  package: string;
3652
+ code?: string | undefined;
3567
3653
  config?: unknown;
3568
3654
  env?: unknown;
3655
+ variables?: Record<string, string | number | boolean> | undefined;
3656
+ definitions?: Record<string, unknown> | undefined;
3569
3657
  }> | undefined;
3570
3658
  collector?: unknown;
3571
- env?: Record<string, string> | undefined;
3659
+ packages?: Record<string, {
3660
+ version?: string | undefined;
3661
+ imports?: string[] | undefined;
3662
+ path?: string | undefined;
3663
+ }> | undefined;
3664
+ variables?: Record<string, string | number | boolean> | undefined;
3665
+ definitions?: Record<string, unknown> | undefined;
3572
3666
  }>;
3573
3667
  /**
3574
3668
  * Generate JSON Schema for Flow.Setup.
@@ -3595,7 +3689,7 @@ declare const setupJsonSchema: z.core.JSONSchema.JSONSchema;
3595
3689
  * Generate JSON Schema for Flow.Config.
3596
3690
  *
3597
3691
  * @remarks
3598
- * Used for validating individual environment configurations.
3692
+ * Used for validating individual flow configurations.
3599
3693
  *
3600
3694
  * @returns JSON Schema (Draft 7) representation of ConfigSchema
3601
3695
  */
@@ -3620,10 +3714,15 @@ declare const sourceReferenceJsonSchema: z.core.JSONSchema.JSONSchema;
3620
3714
  declare const destinationReferenceJsonSchema: z.core.JSONSchema.JSONSchema;
3621
3715
 
3622
3716
  declare const flow_ConfigSchema: typeof ConfigSchema;
3717
+ declare const flow_DefinitionsSchema: typeof DefinitionsSchema;
3623
3718
  declare const flow_DestinationReferenceSchema: typeof DestinationReferenceSchema;
3719
+ declare const flow_PackagesSchema: typeof PackagesSchema;
3624
3720
  declare const flow_PrimitiveSchema: typeof PrimitiveSchema;
3721
+ declare const flow_ServerSchema: typeof ServerSchema;
3625
3722
  declare const flow_SetupSchema: typeof SetupSchema;
3626
3723
  declare const flow_SourceReferenceSchema: typeof SourceReferenceSchema;
3724
+ declare const flow_VariablesSchema: typeof VariablesSchema;
3725
+ declare const flow_WebSchema: typeof WebSchema;
3627
3726
  declare const flow_configJsonSchema: typeof configJsonSchema;
3628
3727
  declare const flow_destinationReferenceJsonSchema: typeof destinationReferenceJsonSchema;
3629
3728
  declare const flow_parseConfig: typeof parseConfig;
@@ -3633,7 +3732,7 @@ declare const flow_safeParseSetup: typeof safeParseSetup;
3633
3732
  declare const flow_setupJsonSchema: typeof setupJsonSchema;
3634
3733
  declare const flow_sourceReferenceJsonSchema: typeof sourceReferenceJsonSchema;
3635
3734
  declare namespace flow {
3636
- export { flow_ConfigSchema as ConfigSchema, flow_DestinationReferenceSchema as DestinationReferenceSchema, flow_PrimitiveSchema as PrimitiveSchema, flow_SetupSchema as SetupSchema, flow_SourceReferenceSchema as SourceReferenceSchema, flow_configJsonSchema as configJsonSchema, flow_destinationReferenceJsonSchema as destinationReferenceJsonSchema, flow_parseConfig as parseConfig, flow_parseSetup as parseSetup, flow_safeParseConfig as safeParseConfig, flow_safeParseSetup as safeParseSetup, flow_setupJsonSchema as setupJsonSchema, flow_sourceReferenceJsonSchema as sourceReferenceJsonSchema };
3735
+ export { flow_ConfigSchema as ConfigSchema, flow_DefinitionsSchema as DefinitionsSchema, flow_DestinationReferenceSchema as DestinationReferenceSchema, flow_PackagesSchema as PackagesSchema, flow_PrimitiveSchema as PrimitiveSchema, flow_ServerSchema as ServerSchema, flow_SetupSchema as SetupSchema, flow_SourceReferenceSchema as SourceReferenceSchema, flow_VariablesSchema as VariablesSchema, flow_WebSchema as WebSchema, flow_configJsonSchema as configJsonSchema, flow_destinationReferenceJsonSchema as destinationReferenceJsonSchema, flow_parseConfig as parseConfig, flow_parseSetup as parseSetup, flow_safeParseConfig as safeParseConfig, flow_safeParseSetup as safeParseSetup, flow_setupJsonSchema as setupJsonSchema, flow_sourceReferenceJsonSchema as sourceReferenceJsonSchema };
3637
3736
  }
3638
3737
 
3639
3738
  /**