avo-inspector 2.2.2-alpha.9 → 3.0.0-alpha.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +36 -5
  2. package/README.md +1 -1
  3. package/bin/avo-inspector.js +8 -10
  4. package/dist/AvoDeduplicator.d.ts +1 -1
  5. package/dist/AvoEncryption.d.ts +19 -5
  6. package/dist/AvoInspector.d.ts +2 -2
  7. package/dist/AvoNetworkCallsHandler.d.ts +4 -1
  8. package/dist/AvoSchemaParser.d.ts +1 -1
  9. package/dist/browser.js.LICENSE.txt +5 -0
  10. package/dist/eventSpec/AvoEventSpecFetchTypes.d.ts +38 -49
  11. package/dist/eventSpec/AvoEventSpecFetcher.d.ts +11 -36
  12. package/dist/eventSpec/AvoGuid.d.ts +3 -0
  13. package/dist/index.js +1 -1
  14. package/dist/index.js.LICENSE.txt +0 -2
  15. package/dist-browser/AvoAnonymousId.d.ts +26 -0
  16. package/dist-browser/AvoBatcher.d.ts +26 -0
  17. package/dist-browser/AvoDeduplicator.d.ts +20 -0
  18. package/dist-browser/AvoEncryption.d.ts +33 -0
  19. package/dist-browser/AvoGuid.d.ts +3 -0
  20. package/dist-browser/AvoInspector.d.ts +78 -0
  21. package/dist-browser/AvoInspectorEnv.d.ts +7 -0
  22. package/dist-browser/AvoNetworkCallsHandler.d.ts +74 -0
  23. package/dist-browser/AvoSchemaParser.d.ts +20 -0
  24. package/dist-browser/AvoStorage.d.ts +22 -0
  25. package/dist-browser/__mocks__/xhr.d.ts +12 -0
  26. package/dist-browser/__mocks__/xhrError.d.ts +12 -0
  27. package/dist-browser/__tests__/AnonymousId_test.d.ts +1 -0
  28. package/dist-browser/__tests__/AvoEncryption_test.d.ts +1 -0
  29. package/dist-browser/__tests__/AvoInspectorEventSpec_test.d.ts +1 -0
  30. package/dist-browser/__tests__/AvoInspector_test.d.ts +1 -0
  31. package/dist-browser/__tests__/BatcherPublic_test.d.ts +1 -0
  32. package/dist-browser/__tests__/Batcher_test.d.ts +1 -0
  33. package/dist-browser/__tests__/Deduplicator_test.d.ts +1 -0
  34. package/dist-browser/__tests__/EncryptedPropertyTracking_test.d.ts +1 -0
  35. package/dist-browser/__tests__/EventSpecCache_test.d.ts +1 -0
  36. package/dist-browser/__tests__/EventSpecFetcher_test.d.ts +1 -0
  37. package/dist-browser/__tests__/EventValidator_test.d.ts +1 -0
  38. package/dist-browser/__tests__/NetworkCallsHandler_test.d.ts +1 -0
  39. package/dist-browser/__tests__/Parsing_test.d.ts +1 -0
  40. package/dist-browser/__tests__/Storage_test.d.ts +1 -0
  41. package/dist-browser/__tests__/ValidationIntegration_test.d.ts +1 -0
  42. package/dist-browser/__tests__/constants.d.ts +36 -0
  43. package/dist-browser/__tests__/helpers/encryptionHelpers.d.ts +13 -0
  44. package/dist-browser/__tests__/helpers/mockFactories.d.ts +49 -0
  45. package/dist-browser/eventSpec/AvoEventSpecCache.d.ts +73 -0
  46. package/dist-browser/eventSpec/AvoEventSpecFetchTypes.d.ts +109 -0
  47. package/dist-browser/eventSpec/AvoEventSpecFetcher.d.ts +55 -0
  48. package/dist-browser/eventSpec/EventValidator.d.ts +90 -0
  49. package/dist-browser/eventSpec/index.d.ts +4 -0
  50. package/dist-browser/index.d.ts +2 -0
  51. package/dist-browser/utils.d.ts +3 -0
  52. package/dist-native/AvoBatcher.d.ts +24 -0
  53. package/dist-native/AvoBatcher.js +82 -0
  54. package/dist-native/AvoDeduplicator.d.ts +36 -0
  55. package/dist-native/AvoDeduplicator.js +142 -0
  56. package/dist-native/AvoGuid.d.ts +3 -0
  57. package/dist-native/AvoGuid.js +14 -0
  58. package/dist-native/AvoInspector.d.ts +52 -0
  59. package/dist-native/AvoInspector.js +220 -0
  60. package/dist-native/AvoInspectorEnv.d.ts +7 -0
  61. package/dist-native/AvoInspectorEnv.js +8 -0
  62. package/dist-native/AvoInstallationId.d.ts +5 -0
  63. package/dist-native/AvoInstallationId.js +36 -0
  64. package/dist-native/AvoNetworkCallsHandler.d.ts +48 -0
  65. package/dist-native/AvoNetworkCallsHandler.js +142 -0
  66. package/dist-native/AvoSchemaParser.d.ts +11 -0
  67. package/dist-native/AvoSchemaParser.js +95 -0
  68. package/dist-native/AvoSessionTracker.d.ts +15 -0
  69. package/dist-native/AvoSessionTracker.js +104 -0
  70. package/dist-native/AvoStorage.d.ts +22 -0
  71. package/dist-native/AvoStorage.js +336 -0
  72. package/dist-native/__mocks__/xhr.d.ts +12 -0
  73. package/dist-native/__mocks__/xhr.js +14 -0
  74. package/dist-native/__mocks__/xhrError.d.ts +12 -0
  75. package/dist-native/__mocks__/xhrError.js +14 -0
  76. package/dist-native/__tests__/AvoInspector.d.ts +1 -0
  77. package/dist-native/__tests__/AvoInspector.js +207 -0
  78. package/dist-native/__tests__/Batcher.d.ts +1 -0
  79. package/dist-native/__tests__/Batcher.js +280 -0
  80. package/dist-native/__tests__/BatcherPublic.d.ts +1 -0
  81. package/dist-native/__tests__/BatcherPublic.js +82 -0
  82. package/dist-native/__tests__/Deduplicator.d.ts +1 -0
  83. package/dist-native/__tests__/Deduplicator.js +111 -0
  84. package/dist-native/__tests__/InstallationId.d.ts +1 -0
  85. package/dist-native/__tests__/InstallationId.js +40 -0
  86. package/dist-native/__tests__/NetworkCallsHandler.d.ts +1 -0
  87. package/dist-native/__tests__/NetworkCallsHandler.js +132 -0
  88. package/dist-native/__tests__/Parsing.d.ts +1 -0
  89. package/dist-native/__tests__/Parsing.js +115 -0
  90. package/dist-native/__tests__/Sessions.d.ts +1 -0
  91. package/dist-native/__tests__/Sessions.js +179 -0
  92. package/dist-native/__tests__/Storage.d.ts +1 -0
  93. package/dist-native/__tests__/Storage.js +173 -0
  94. package/dist-native/__tests__/constants.d.ts +36 -0
  95. package/dist-native/__tests__/constants.js +47 -0
  96. package/dist-native/index.d.ts +2 -0
  97. package/dist-native/index.js +7 -0
  98. package/dist-native/utils.d.ts +3 -0
  99. package/dist-native/utils.js +42 -0
  100. package/jest.config.js +5 -1
  101. package/lib/bs/.bsbuild +5 -0
  102. package/lib/bs/.bsdeps +8 -0
  103. package/lib/bs/.compiler.log +2 -0
  104. package/lib/bs/.ninja_log +7 -0
  105. package/lib/bs/build.ninja +19 -0
  106. package/lib/bs/install.ninja +12 -0
  107. package/lib/bs/rescript/AvoInspector.ast +0 -0
  108. package/lib/bs/rescript/AvoInspector.cmi +0 -0
  109. package/lib/bs/rescript/AvoInspector.cmj +0 -0
  110. package/lib/bs/rescript/AvoInspector.cmt +0 -0
  111. package/lib/bs/rescript/AvoInspector.cmti +0 -0
  112. package/lib/bs/rescript/AvoInspector.d +0 -0
  113. package/lib/bs/rescript/AvoInspector.iast +0 -0
  114. package/lib/ocaml/.compiler.log +2 -0
  115. package/lib/ocaml/.ninja_log +8 -0
  116. package/lib/ocaml/AvoInspector.cmi +0 -0
  117. package/lib/ocaml/AvoInspector.cmj +0 -0
  118. package/lib/ocaml/AvoInspector.cmt +0 -0
  119. package/lib/ocaml/AvoInspector.cmti +0 -0
  120. package/lib/ocaml/AvoInspector.res +25 -0
  121. package/lib/ocaml/AvoInspector.resi +9 -0
  122. package/lib/ocaml/install.stamp +0 -0
  123. package/package.json +2 -2
  124. package/rescript/AvoInspector.mjs +11 -0
  125. package/.claude/settings.local.json +0 -19
  126. package/dist/eventSpec/fetcher.d.ts +0 -52
package/CHANGELOG.md CHANGED
@@ -5,12 +5,47 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.0.0-alpha.1] - 2025-12-09
9
+
10
+ ### Changed
11
+
12
+ - **Encryption Migration**: Migrated encryption implementation from `eciesjs` (secp256k1) to `@noble/curves` + Web Crypto API (prime256v1 / NIST P-256) for browser compatibility
13
+ - Uses `@noble/curves` library for ECDH operations (lightweight, modern, audited - ~20KB)
14
+ - Uses Web Crypto API for AES-256-GCM encryption/decryption
15
+ - Updated curve to prime256v1 (NIST P-256), standard for Web Crypto API
16
+ - Updated CLI tool to use Node.js crypto (Node-only, so crypto module is fine)
17
+ - Maintains same encryption format specification: `[Version(1b)] + [EphemeralPubKey(65b)] + [IV(16b)] + [AuthTag(16b)] + [Ciphertext]`
18
+ - Maintains same key format (Hex strings) for compatibility with other languages
19
+
20
+ ### Breaking Changes
21
+
22
+ - **[Breaking]** `extractSchema()` is now an async function and returns `Promise<EventProperty[]>`
23
+ - All callers must now use `await` when calling `extractSchema()`
24
+ - Example migration:
25
+ ```javascript
26
+ // Before (v2.x)
27
+ const schema = inspector.extractSchema(eventProperties);
28
+
29
+ // After (v3.0)
30
+ const schema = await inspector.extractSchema(eventProperties);
31
+ ```
32
+ - **[Breaking]** `shouldRegisterSchemaFromManually()` in `AvoDeduplicator` is now async. It should not be used in the client code though.
33
+
34
+ ### Removed
35
+
36
+ - Removed `eciesjs` dependency (replaced with `@noble/curves`)
37
+ - Removed `elliptic` dependency (replaced with `@noble/curves`)
38
+
39
+ ### Added
40
+
41
+ - Added `@noble/curves` dependency for browser-compatible ECDH operations (lightweight, modern, audited)
42
+
8
43
  ## [2.2.1-alpha] - 2025-11-24
9
44
 
10
45
  ### Added
11
46
 
12
47
  - **ECC Property Value Encryption**: Optional `publicEncryptionKey` parameter on SDK initialization enables zero-knowledge encryption of property values in dev/staging environments using ECIES (Elliptic Curve Integrated Encryption Scheme). Avo never has access to the private key, ensuring complete data privacy.
13
- - Uses secp256k1 curve with AES-256-GCM for hybrid encryption
48
+ - Uses prime256v1 (NIST P-256) curve with AES-256-GCM for hybrid encryption (standard for Web Crypto API)
14
49
  - Only encrypts in dev/staging environments (production sends schema only)
15
50
  - Adds optional `encryptedPropertyValue` field to event schema
16
51
  - CLI tool for key generation: `npx avo-inspector generate-keys`
@@ -27,10 +62,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
27
62
  - Production environment now optimized: no property values, no encryption, no EventSpec API calls
28
63
  - Dev/Staging environments now support rich debugging with encrypted values and event specs
29
64
 
30
- ### Dependencies
31
-
32
- - Added `eciesjs` ^0.4.11 for ECC/ECIES encryption
33
-
34
65
  ## 2.2.0
35
66
 
36
67
  - Add anonymous ID support to track events without user identification
package/README.md CHANGED
@@ -104,7 +104,7 @@ Inspector supports encrypting property values in development and staging environ
104
104
 
105
105
  ## Key Features
106
106
 
107
- - Uses ECC (Elliptic Curve Cryptography) with secp256k1 for strong security
107
+ - Uses ECC (Elliptic Curve Cryptography) with prime256v1 (NIST P-256) for strong security, standard for Web Crypto API
108
108
  - Zero-knowledge architecture: Avo never has access to your private key
109
109
  - No message size limitations
110
110
  - Only active in dev/staging environments (production is unaffected)
@@ -1,20 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // Use eciesjs directly for ECC key generation
4
- const { PrivateKey } = require('eciesjs');
3
+ // Use Node.js crypto for ECC key generation (prime256v1 / NIST P-256)
4
+ const { createECDH } = require('crypto');
5
5
  const fs = require('fs');
6
6
  const path = require('path');
7
7
 
8
8
  function generateKeyPair() {
9
- // Generate a new random private key (32 bytes / 256 bits)
10
- const privateKey = new PrivateKey();
11
-
12
- // Derive the public key from the private key
13
- const publicKey = privateKey.publicKey;
9
+ // Generate a new random private key (32 bytes) via ECDH on prime256v1
10
+ const ecdh = createECDH('prime256v1');
11
+ ecdh.generateKeys();
14
12
 
15
13
  return {
16
- publicKey: publicKey.toHex(),
17
- privateKey: privateKey.toHex()
14
+ publicKey: ecdh.getPublicKey('hex'),
15
+ privateKey: ecdh.getPrivateKey('hex')
18
16
  };
19
17
  }
20
18
 
@@ -48,7 +46,7 @@ Examples:
48
46
  function generateKeys(writeToFiles = false) {
49
47
  console.log(`
50
48
  ╔═══════════════════════════════════════════════════════════════╗
51
- ║ Generating ECC Key Pair (secp256k1)... ║
49
+ ║ Generating ECC Key Pair (prime256v1 / NIST P-256)... ║
52
50
  ╚═══════════════════════════════════════════════════════════════╝
53
51
  `);
54
52
 
@@ -12,7 +12,7 @@ export declare class AvoDeduplicator {
12
12
  propertyName: string;
13
13
  propertyType: string;
14
14
  children?: any;
15
- }>): boolean;
15
+ }>): Promise<boolean>;
16
16
  private hasSameShapeInAvoFunctionsAs;
17
17
  private lookForEventSchemaIn;
18
18
  private clearOldEvents;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Generates a new ECC key pair for encryption/decryption.
3
- * Uses secp256k1 curve (P-256 family) which provides 128-bit security.
3
+ * Uses P-256 (prime256v1 / NIST P-256) curve which is standard for Web Crypto API.
4
4
  *
5
5
  * @returns An object containing the private and public keys as hex strings
6
6
  */
@@ -18,16 +18,30 @@ export declare function generateKeyPair(): {
18
18
  * - Fast encryption even for large values
19
19
  * - Strong authentication via GCM
20
20
  *
21
+ * SPECIFICATION (Standard Web Crypto Profile):
22
+ * 1. Curve: P-256 (prime256v1 / NIST P-256)
23
+ * 2. Key Derivation (KDF): SHA-256(SharedSecret)
24
+ * 3. Cipher: AES-256-GCM
25
+ * 4. Serialization: [Version(1b)] + [EphemeralPubKey(33 or 65b)] + [IV(16b)] + [AuthTag(16b)] + [Ciphertext]
26
+ * Version 0x00 = Standard Web Profile
27
+ * EphemeralPubKey: 0x04 (uncompressed) + 64 bytes = 65 bytes total, or compressed format (33 bytes)
28
+ *
21
29
  * @param value - The value to encrypt (any type - will be JSON stringified)
22
30
  * @param publicKey - The ECC public key in hex format provided by the client
23
- * @returns Base64-encoded encrypted string that can only be decrypted with the private key
31
+ * @returns Promise resolving to base64-encoded encrypted string that can only be decrypted with the private key
24
32
  */
25
- export declare function encryptValue(value: any, publicKey: string): string;
33
+ export declare function encryptValue(value: any, publicKey: string): Promise<string>;
26
34
  /**
27
35
  * Decrypts a value that was encrypted with encryptValue.
28
36
  *
37
+ * SPECIFICATION (Standard Web Crypto Profile):
38
+ * 1. Curve: P-256 (prime256v1 / NIST P-256)
39
+ * 2. Key Derivation (KDF): SHA-256(SharedSecret)
40
+ * 3. Cipher: AES-256-GCM
41
+ * 4. Deserialization: [Version(1b)] + [EphemeralPubKey(33 or 65b)] + [IV(16b)] + [AuthTag(16b)] + [Ciphertext]
42
+ *
29
43
  * @param encryptedValue - The base64-encoded encrypted string
30
44
  * @param privateKey - The ECC private key in hex format
31
- * @returns The original decrypted value (parsed from JSON)
45
+ * @returns Promise resolving to the original decrypted value (parsed from JSON)
32
46
  */
33
- export declare function decryptValue(encryptedValue: string, privateKey: string): any;
47
+ export declare function decryptValue(encryptedValue: string, privateKey: string): Promise<any>;
@@ -44,12 +44,12 @@ export declare class AvoInspector {
44
44
  }>): Promise<void>;
45
45
  private trackSchemaInternal;
46
46
  enableLogging(enable: boolean): void;
47
- extractSchema(eventProperties: Record<string, any>, shouldLogIfEnabled?: boolean): Array<{
47
+ extractSchema(eventProperties: Record<string, any>, shouldLogIfEnabled?: boolean): Promise<Array<{
48
48
  propertyName: string;
49
49
  propertyType: string;
50
50
  encryptedPropertyValue?: string;
51
51
  children?: any;
52
- }>;
52
+ }>>;
53
53
  setBatchSize(newBatchSize: number): void;
54
54
  setBatchFlushSeconds(newBatchFlushSeconds: number): void;
55
55
  /**
@@ -33,6 +33,8 @@ export interface BaseBody {
33
33
  samplingRate: number;
34
34
  /** Event spec metadata from EventSpecResponse (moved from EventSchemaBody) */
35
35
  eventSpecMetadata?: EventSpecMetadata;
36
+ /** RSA public encryption key - allows Inspector to validate encrypted values against tracking plan */
37
+ publicEncryptionKey?: string;
36
38
  }
37
39
  export interface SessionStartedBody extends BaseBody {
38
40
  type: "sessionStarted";
@@ -55,10 +57,11 @@ export declare class AvoNetworkCallsHandler {
55
57
  private readonly appName;
56
58
  private readonly appVersion;
57
59
  private readonly libVersion;
60
+ private readonly publicEncryptionKey?;
58
61
  private samplingRate;
59
62
  private sending;
60
63
  private static readonly trackingEndpoint;
61
- constructor(apiKey: string, envName: string, appName: string, appVersion: string, libVersion: string);
64
+ constructor(apiKey: string, envName: string, appName: string, appVersion: string, libVersion: string, publicEncryptionKey?: string);
62
65
  callInspectorWithBatchBody(inEvents: Array<SessionStartedBody | EventSchemaBody>, onCompleted: (error: Error | null) => any): void;
63
66
  private fixStreamIds;
64
67
  bodyForSessionStartedCall(): SessionStartedBody;
@@ -10,7 +10,7 @@ export declare class AvoSchemaParser {
10
10
  * Never returns unencrypted values - only encrypted or nothing.
11
11
  */
12
12
  private static getEncryptedPropertyValueIfEnabled;
13
- static extractSchema(eventProperties: Record<string, any>, publicEncryptionKey?: string, env?: string): EventProperty[];
13
+ static extractSchema(eventProperties: Record<string, any>, publicEncryptionKey?: string, env?: string): Promise<EventProperty[]>;
14
14
  private static removeDuplicates;
15
15
  private static getPropValueType;
16
16
  }
@@ -0,0 +1,5 @@
1
+ /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
2
+
3
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
+
5
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
@@ -1,67 +1,54 @@
1
1
  /**
2
- * Wire format - Property constraints from the API.
3
- *
4
- * The API returns constraints in a compact format:
5
- * - `t`: Type - either a string ("string", "int", "float", "boolean") or an object (for nested object types)
6
- * - `r`: Required flag
7
- * - `l`: List flag - true if this is an array/list of the type
8
- * - `v`: Allowed values - array of allowed string values
9
- * - `min`/`max`: Numeric range constraints
10
- *
11
- * For list of objects, `t` is an object containing child property schemas and `l` is true.
2
+ * This file is generated. Internal development changes should be made in the generator
3
+ * and the file should be re-generated. External contributions are welcome to submit
4
+ * changes directly to this file, and we'll apply them to the generator internally.
5
+ */
6
+ /**
7
+ * Wire format - Property constraints with short field names.
8
+ * At most one constraint type will be present per property.
12
9
  */
13
10
  export interface PropertyConstraintsWire {
14
- /**
15
- * Type - either a string type name ("string", "int", "float", "boolean")
16
- * or an object containing nested property schemas (for object/list of objects)
17
- */
18
- t: string | Record<string, PropertyConstraintsWire>;
19
- /** Required flag */
11
+ /** Type name (for reference only, not validated) */
12
+ t: string;
13
+ /** Required flag (for reference only, not validated) */
20
14
  r: boolean;
21
15
  /** List flag - true if this is an array/list of the type */
22
16
  l?: boolean;
23
- /** Allowed values - array of allowed string values */
24
- v?: Array<string>;
25
- /** Minimum value for numeric types */
26
- min?: number;
27
- /** Maximum value for numeric types */
28
- max?: number;
17
+ /** Pinned values: pinnedValue -> eventIds that require this exact value */
18
+ p?: Record<string, Array<string>>;
19
+ /** Allowed values: JSON array string -> eventIds that accept these values */
20
+ v?: Record<string, Array<string>>;
21
+ /** Regex patterns: pattern -> eventIds that require matching this regex */
22
+ rx?: Record<string, Array<string>>;
23
+ /** Min/max ranges: "min,max" -> eventIds that require value in this range */
24
+ minmax?: Record<string, Array<string>>;
25
+ /** Nested property constraints for object properties */
26
+ children?: Record<string, PropertyConstraintsWire>;
29
27
  }
30
28
  /**
31
- * Wire format - Base event from the API.
29
+ * Wire format - Event spec entry with short field names.
30
+ * A single event entry (base event + its variants).
31
+ * Multiple events can match the same name request due to name mapping.
32
32
  */
33
- export interface BaseEventWire {
34
- /** Event name */
35
- name: string;
36
- /** Event ID */
33
+ export interface EventSpecEntryWire {
34
+ /** Branch identifier */
35
+ b: string;
36
+ /** Base event ID */
37
37
  id: string;
38
+ /** Variant IDs (baseEventId + variantIds = complete set) */
39
+ vids: Array<string>;
38
40
  /** Property constraints keyed by property name */
39
- props: Record<string, PropertyConstraintsWire>;
40
- }
41
- /**
42
- * Wire format - Event variant from the API.
43
- */
44
- export interface EventVariantWire {
45
- /** Variant ID */
46
- variantId: string;
47
- /** Name suffix for this variant */
48
- nameSuffix: string;
49
- /** Full event ID (baseEventId.variantId) */
50
- eventId: string;
51
- /** Property constraints for this variant */
52
- props: Record<string, PropertyConstraintsWire>;
41
+ p: Record<string, PropertyConstraintsWire>;
53
42
  }
54
43
  /**
55
44
  * Wire format - Response from getEventSpec endpoint.
56
- * Contains the base event and its variants.
45
+ * Contains array of events that match the requested name (due to name mapping).
57
46
  */
58
47
  export interface EventSpecResponseWire {
59
- /** Branch identifier */
60
- branchId: string;
61
- /** Base event definition */
62
- baseEvent: BaseEventWire;
63
- /** Event variants */
64
- variants: Array<EventVariantWire>;
48
+ /** Array of events matching the requested name */
49
+ events: Array<EventSpecEntryWire>;
50
+ /** Schema metadata (keeps long names - small, one per response) */
51
+ metadata: EventSpecMetadata;
65
52
  }
66
53
  /**
67
54
  * Internal - Property constraints with meaningful field names.
@@ -72,6 +59,8 @@ export interface PropertyConstraints {
72
59
  type: string;
73
60
  /** Required flag (for reference only, not validated) */
74
61
  required: boolean;
62
+ /** List flag - true if this is an array/list of items */
63
+ isList?: boolean;
75
64
  /** Pinned values: pinnedValue -> eventIds that require this exact value */
76
65
  pinnedValues?: Record<string, Array<string>>;
77
66
  /** Allowed values: JSON array string -> eventIds that accept these values */
@@ -80,7 +69,7 @@ export interface PropertyConstraints {
80
69
  regexPatterns?: Record<string, Array<string>>;
81
70
  /** Min/max ranges: "min,max" -> eventIds that require value in this range */
82
71
  minMaxRanges?: Record<string, Array<string>>;
83
- /** Nested property constraints for object properties */
72
+ /** Nested property constraints for object properties (for objects or list of objects) */
84
73
  children?: Record<string, PropertyConstraints>;
85
74
  }
86
75
  /**
@@ -1,3 +1,8 @@
1
+ /**
2
+ * This file is generated. Internal development changes should be made in the generator
3
+ * and the file should be re-generated. External contributions are welcome to submit
4
+ * changes directly to this file, and we'll apply them to the generator internally.
5
+ */
1
6
  import type { EventSpecResponse, FetchEventSpecParams } from "./AvoEventSpecFetchTypes";
2
7
  /**
3
8
  * EventSpecFetcher handles fetching event specifications from the Avo API.
@@ -43,43 +48,13 @@ export declare class AvoEventSpecFetcher {
43
48
  private makeRequest;
44
49
  /**
45
50
  * Basic shape check for wire format - ensures response has the minimum expected structure.
46
- * API returns: { branchId, baseEvent: { name, id, props }, variants: [...] }
51
+ * Uses short field names from wire format.
47
52
  */
48
53
  private hasExpectedShape;
49
- /**
50
- * Parses the wire format response into internal format.
51
- *
52
- * The API returns a single event with its variants. We transform this into
53
- * our internal format which has an array of EventSpecEntry (one entry containing
54
- * the base event ID and all variant IDs, with merged property constraints).
55
- */
54
+ /** Parses the wire format response into internal format with meaningful field names. */
56
55
  private static parseEventSpecResponse;
57
- /**
58
- * Parses and merges property constraints from base event and variants.
59
- *
60
- * For each property, we need to:
61
- * 1. Parse the wire format into internal format
62
- * 2. Convert allowed values array to Record<string, eventIds>
63
- * 3. Convert min/max to Record<string, eventIds>
64
- * 4. Track which event IDs have which constraints
65
- */
66
- private static parseAndMergeProps;
67
- /**
68
- * Merges property constraints from base event and variants into a single PropertyConstraints.
69
- */
70
- private static mergePropertyConstraints;
71
- /**
72
- * Gets the type string from a wire property.
73
- * If `t` is an object (for nested objects), returns "object".
74
- */
75
- private static getTypeString;
76
- /**
77
- * Gets the nested schema from a wire property.
78
- * Returns the nested property schemas if `t` is an object, otherwise undefined.
79
- */
80
- private static getNestedSchema;
81
- /**
82
- * Adds constraints from a wire property to the accumulator maps.
83
- */
84
- private static addConstraintsFromProp;
56
+ /** Parses a single event spec entry from wire format. */
57
+ private static parseEventSpecEntry;
58
+ /** Parses property constraints from wire format. */
59
+ private static parsePropertyConstraints;
85
60
  }
@@ -0,0 +1,3 @@
1
+ export default class AvoGuid {
2
+ static newGuid(): string;
3
+ }