@walkeros/core 3.4.0 → 3.4.1

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/dev.mjs CHANGED
@@ -1 +1 @@
1
- var e=Object.defineProperty,n=(n,i)=>{for(var t in i)e(n,t,{get:i[t],enumerable:!0})},i={};n(i,{BaseContextConfig:()=>q,BatchConfig:()=>U,CacheRuleSchema:()=>$e,CacheSchema:()=>Ve,CacheSchemas:()=>Ae,ClickIdEntrySchema:()=>Ai,CodeSchema:()=>Ui,CollectorSchemas:()=>hn,ConsentSchema:()=>Q,ContractActionsSchema:()=>yi,ContractSchema:()=>Ci,ContractSchemaEntry:()=>Si,Counter:()=>d,DeepPartialEventSchema:()=>oe,DestinationReferenceSchema:()=>hi,DestinationSchemas:()=>Me,DestinationsMapConfig:()=>A,EntitiesSchema:()=>ne,EntitySchema:()=>ee,EventSchema:()=>ie,FlowConfigSchema:()=>ji,FlowSchemas:()=>ii,FlowSettingsSchema:()=>xi,GenericEnvConfig:()=>D,GenericSettingsConfig:()=>I,HandlersConfig:()=>j,HintSchema:()=>Wi,HintsSchema:()=>Bi,IdConfig:()=>P,Identifier:()=>c,InitConfig:()=>J,LoopSchema:()=>ge,MapSchema:()=>ve,MappingResultSchema:()=>xe,MappingSchemas:()=>me,MatchExpressionSchema:()=>qe,MatcherSchemas:()=>Te,NextRuleSchema:()=>Be,OptionalPrimitiveValue:()=>m,OrderedPropertiesSchema:()=>_,PartialEventSchema:()=>te,PolicySchema:()=>ye,PrimaryConfig:()=>O,PrimitiveSchema:()=>ti,PrimitiveValue:()=>u,ProcessingControlConfig:()=>W,PropertiesSchema:()=>G,PropertySchema:()=>F,PropertyTypeSchema:()=>H,QueueConfig:()=>R,RequiredBoolean:()=>s,RequiredNumber:()=>a,RequiredString:()=>r,RoutableNextSchema:()=>We,RuleSchema:()=>we,RulesSchema:()=>ke,RuntimeInstanceConfig:()=>z,SetSchema:()=>he,SourceReferenceSchema:()=>fi,SourceSchema:()=>Z,SourceSchemas:()=>Dn,SourceTypeSchema:()=>K,SourcesMapConfig:()=>B,StoreReferenceSchema:()=>vi,StoreSchemas:()=>Xn,TaggingVersion:()=>p,Timestamp:()=>l,TransformerReferenceSchema:()=>gi,TransformerSchemas:()=>Fn,UserSchema:()=>X,UtilitySchemas:()=>b,ValueConfigSchema:()=>Se,ValueSchema:()=>be,ValuesSchema:()=>fe,VerboseConfig:()=>E,VersionSchema:()=>Y,WalkerOSSchemas:()=>$,configJsonSchema:()=>Oi,consentJsonSchema:()=>ue,contractEntryJsonSchema:()=>Li,contractJsonSchema:()=>zi,createArraySchema:()=>Zi,createConsentConfig:()=>L,createDataTransformationConfig:()=>N,createEnumSchema:()=>et,createMappingRulesConfig:()=>M,createObjectSchema:()=>Xi,createPolicyConfig:()=>T,createTupleSchema:()=>nt,destinationReferenceJsonSchema:()=>Ni,entityJsonSchema:()=>de,eventJsonSchema:()=>re,loopJsonSchema:()=>Re,mapJsonSchema:()=>Je,orderedPropertiesJsonSchema:()=>le,parseConfig:()=>Ei,parseSettings:()=>Pi,partialEventJsonSchema:()=>ae,policyJsonSchema:()=>Oe,propertiesJsonSchema:()=>ce,ruleJsonSchema:()=>Ie,rulesJsonSchema:()=>De,safeParseConfig:()=>Ri,safeParseSettings:()=>Ji,setJsonSchema:()=>Pe,settingsJsonSchema:()=>Ii,sourceReferenceJsonSchema:()=>Di,sourceTypeJsonSchema:()=>pe,storeReferenceJsonSchema:()=>Ti,transformerReferenceJsonSchema:()=>Mi,userJsonSchema:()=>se,validateFlowConfig:()=>$i,valueConfigJsonSchema:()=>Ee,valueJsonSchema:()=>je,z:()=>t,zodToSchema:()=>it});import{z as t}from"zod";function o(e,n,i="draft-7"){return t.toJSONSchema(e,{target:i})}var r=t.string(),a=t.number(),s=t.boolean(),c=t.string().min(1),l=t.number().int().positive(),d=t.number().int().nonnegative(),p=t.number().describe("Tagging version number"),u=t.union([t.string(),t.number(),t.boolean()]),m=u.optional(),b={};n(b,{ErrorHandlerSchema:()=>h,HandlerSchema:()=>S,LogHandlerSchema:()=>v,StorageSchema:()=>g,StorageTypeSchema:()=>f,errorHandlerJsonSchema:()=>k,handlerJsonSchema:()=>x,logHandlerJsonSchema:()=>C,storageJsonSchema:()=>w,storageTypeJsonSchema:()=>y});var f=t.enum(["local","session","cookie"]).describe("Storage mechanism: local, session, or cookie"),g=t.object({Local:t.literal("local"),Session:t.literal("session"),Cookie:t.literal("cookie")}).describe("Storage type constants for type-safe references"),h=t.any().describe("Error handler function: (error, state?) => void"),v=t.any().describe("Log handler function: (message, verbose?) => void"),S=t.object({Error:h.describe("Error handler function"),Log:v.describe("Log handler function")}).describe("Handler interface with error and log functions"),y=o(f),w=o(g),k=o(h),C=o(v),x=o(S),j=t.object({onError:h.optional().describe("Error handler function: (error, state?) => void"),onLog:v.optional().describe("Log handler function: (message, verbose?) => void")}).partial(),E=t.object({verbose:t.boolean().describe("Enable verbose logging for debugging").optional()}).partial(),R=t.object({queue:t.boolean().describe("Whether to queue events when consent is not granted").optional()}).partial(),P=t.object({}).partial(),J=t.object({init:t.boolean().describe("Whether to initialize immediately").optional(),loadScript:t.boolean().describe("Whether to load external script (for web destinations)").optional()}).partial(),O=t.object({primary:t.boolean().describe("Mark as primary (only one can be primary)").optional()}).partial(),I=t.object({settings:t.any().optional().describe("Implementation-specific configuration")}).partial(),D=t.object({env:t.any().optional().describe("Environment dependencies (platform-specific)")}).partial();function N(e,n){return t.object({data:t.union([e,n]).optional().describe("Data transformation rules")}).partial()}function M(e){return t.object({mapping:e.optional().describe("Event mapping rules")}).partial()}function T(e){return t.object({policy:e.optional().describe("Pre-processing policy rules")}).partial()}function L(e){return t.object({consent:e.optional().describe("Required consent states")}).partial()}var z=t.object({type:t.string().optional().describe("Instance type identifier"),config:t.unknown().describe("Instance configuration")}).partial(),q=t.object({collector:t.unknown().describe("Collector instance (runtime object)"),config:t.unknown().describe("Configuration"),env:t.unknown().describe("Environment dependencies")}).partial(),U=t.object({batch:t.number().optional().describe("Batch size: bundle N events for batch processing"),batched:t.unknown().optional().describe("Batch of events to be processed")}).partial(),W=t.object({ignore:t.boolean().describe("Set to true to skip processing").optional(),condition:t.string().optional().describe("Condition function: return true to process")}).partial(),B=t.object({sources:t.record(t.string(),t.unknown()).describe("Map of source instances")}).partial(),A=t.object({destinations:t.record(t.string(),t.unknown()).describe("Map of destination instances")}).partial(),$={};n($,{ConsentSchema:()=>Q,DeepPartialEventSchema:()=>oe,EntitiesSchema:()=>ne,EntitySchema:()=>ee,EventSchema:()=>ie,OrderedPropertiesSchema:()=>_,PartialEventSchema:()=>te,PropertiesSchema:()=>G,PropertySchema:()=>F,PropertyTypeSchema:()=>H,SourceSchema:()=>Z,SourceTypeSchema:()=>K,UserSchema:()=>X,VersionSchema:()=>Y,consentJsonSchema:()=>ue,entityJsonSchema:()=>de,eventJsonSchema:()=>re,orderedPropertiesJsonSchema:()=>le,partialEventJsonSchema:()=>ae,propertiesJsonSchema:()=>ce,sourceTypeJsonSchema:()=>pe,userJsonSchema:()=>se});var V,H=t.lazy(()=>t.union([t.boolean(),t.string(),t.number(),t.record(t.string(),F)])),F=t.lazy(()=>t.union([H,t.array(H)])),G=t.record(t.string(),F.optional()).describe("Flexible property collection with optional values"),_=t.record(t.string(),t.tuple([F,t.number()]).optional()).describe("Ordered properties with [value, order] tuples for priority control"),K=t.union([t.enum(["web","server","app","other"]),t.string()]).describe("Source type: web, server, app, other, or custom"),Q=t.record(t.string(),t.boolean()).meta({id:"WalkerOSConsent",title:"WalkerOS.Consent",description:"Consent state mapping. Keys are consent groups (e.g. marketing, functional), values are booleans for granted/denied."}).describe("Consent requirement mapping (group name to state)"),X=G.and(t.object({id:t.string().optional().describe("User identifier"),device:t.string().optional().describe("Device identifier"),session:t.string().optional().describe("Session identifier"),hash:t.string().optional().describe("Hashed identifier"),address:t.string().optional().describe("User address"),email:t.string().email().optional().describe("User email address"),phone:t.string().optional().describe("User phone number"),userAgent:t.string().optional().describe("Browser user agent string"),browser:t.string().optional().describe("Browser name"),browserVersion:t.string().optional().describe("Browser version"),deviceType:t.string().optional().describe("Device type (mobile, desktop, tablet)"),os:t.string().optional().describe("Operating system"),osVersion:t.string().optional().describe("Operating system version"),screenSize:t.string().optional().describe("Screen dimensions"),language:t.string().optional().describe("User language"),country:t.string().optional().describe("User country"),region:t.string().optional().describe("User region/state"),city:t.string().optional().describe("User city"),zip:t.string().optional().describe("User postal code"),timezone:t.string().optional().describe("User timezone"),ip:t.string().optional().describe("User IP address"),internal:t.boolean().optional().describe("Internal user flag (employee, test user)")})).describe("User identification and properties"),Y=G.and(t.object({source:r.describe('Walker implementation version (e.g., "2.0.0")'),tagging:p})).describe("Walker version information"),Z=G.and(t.object({type:K.describe("Source type identifier"),id:r.describe("Source identifier (typically URL on web)"),previous_id:r.describe("Previous source identifier (typically referrer on web)")})).describe("Event source information"),ee=t.lazy(()=>t.object({entity:t.string().describe("Entity name"),data:G.describe("Entity-specific properties"),nested:t.array(ee).describe("Nested child entities"),context:_.describe("Entity context data")})).describe("Nested entity structure with recursive nesting support"),ne=t.array(ee).describe("Array of nested entities"),ie=t.object({name:t.string().describe('Event name in "entity action" format (e.g., "page view", "product add")'),data:G.describe("Event-specific properties"),context:_.describe("Ordered context properties with priorities"),globals:G.describe("Global properties shared across events"),custom:G.describe("Custom implementation-specific properties"),user:X.describe("User identification and attributes"),nested:ne.describe("Related nested entities"),consent:Q.describe("Consent states at event time"),id:c.describe("Unique event identifier (timestamp-based)"),trigger:r.describe("Event trigger identifier"),entity:r.describe("Parsed entity from event name"),action:r.describe("Parsed action from event name"),timestamp:l.describe("Unix timestamp in milliseconds since epoch"),timing:a.describe("Event processing timing information"),group:r.describe("Event grouping identifier"),count:d.describe("Event count in session"),version:Y.describe("Walker version information"),source:Z.describe("Event source information")}).describe("Complete walkerOS event structure"),te=ie.partial().describe("Partial event structure with all fields optional"),oe=ie.partial().describe("Partial event structure with all top-level fields optional"),re=o(ie),ae=o(te),se=o(X),ce=o(G),le=o(_),de=o(ee),pe=o(K),ue=o(Q),me={};n(me,{ConfigSchema:()=>Ce,LoopSchema:()=>ge,MapSchema:()=>ve,PolicySchema:()=>ye,ResultSchema:()=>xe,RuleSchema:()=>we,RulesSchema:()=>ke,SetSchema:()=>he,ValueConfigSchema:()=>Se,ValueSchema:()=>be,ValuesSchema:()=>fe,configJsonSchema:()=>Ne,loopJsonSchema:()=>Re,mapJsonSchema:()=>Je,policyJsonSchema:()=>Oe,ruleJsonSchema:()=>Ie,rulesJsonSchema:()=>De,setJsonSchema:()=>Pe,valueConfigJsonSchema:()=>Ee,valueJsonSchema:()=>je});var be=t.lazy(()=>t.union([t.string().describe('String value or property path (e.g., "data.id")'),t.number().describe("Numeric value"),t.boolean().describe("Boolean value"),t.lazy(()=>V),t.array(be).describe("Array of values")])).meta({id:"MappingValue",title:"Mapping.Value",description:"Polymorphic transform primitive used in every mapping field. A string path, constant, operator object (map/loop/set/condition/consent), or array of values."}),fe=t.array(be).describe("Array of transformation values"),ge=t.lazy(()=>t.tuple([be,be]).describe("Loop transformation: [source, transform] tuple for array processing")),he=t.lazy(()=>t.array(be).describe("Set: Array of values for selection or combination")),ve=t.lazy(()=>t.record(t.string(),be).describe("Map: Object mapping keys to transformation values")),Se=V=t.object({key:t.string().optional().describe('Property path to extract from event (e.g., "data.id", "user.email")'),value:t.union([t.string(),t.number(),t.boolean()]).optional().describe("Static primitive value"),fn:t.string().optional().describe("Custom transformation function as string (serialized)"),map:ve.optional().describe("Object mapping: transform event data to structured output"),loop:ge.optional().describe("Loop transformation: [source, transform] for array processing"),set:he.optional().describe("Set of values: combine or select from multiple values"),consent:Q.optional().describe("Required consent states to include this value"),condition:t.string().optional().describe("Condition function as string: return true to include value"),validate:t.string().optional().describe("Validation function as string: return true if value is valid")}).refine(e=>Object.keys(e).length>0,{message:"ValueConfig must have at least one property"}).describe("Value transformation configuration with multiple strategies"),ye=t.record(t.string(),be).describe("Policy rules for event pre-processing (key → value mapping)"),we=t.object({name:t.string().optional().describe('Custom event name override (e.g., "view_item" for "product view")'),data:t.union([be,fe]).optional().describe("Data transformation rules for event"),settings:t.any().optional().describe("Destination-specific settings for this event mapping"),condition:t.string().optional().describe("Condition function as string: return true to process event"),consent:Q.optional().describe("Required consent states to process this event"),policy:ye.optional().describe("Event-level policy overrides (applied after config-level policy)"),batch:t.number().optional().describe("Batch size: bundle N events for batch processing"),include:t.array(t.string()).optional().describe('Event sections (e.g. ["context", "globals"]) flattened into context.data'),ignore:t.boolean().optional().describe("Skip the event entirely. No push, no side effects. Use for suppression."),skip:t.boolean().optional().describe("Run side effects (settings.identify, ...) but skip the default push call.")}).meta({id:"MappingRule",title:"Mapping.Rule",description:"Configuration for transforming a single event at one stage of the flow (source or destination)."}).describe("Mapping rule for specific entity-action combination"),ke=t.record(t.string(),t.record(t.string(),t.union([we,t.array(we)])).optional()).describe('Event mapping rules: entity → action → Rule. Keys match event name split by space. Use "*" as wildcard for entity or action. Priority: exact > entity wildcard > action wildcard > global wildcard (*→*).'),Ce=t.object({consent:Q.optional().describe("Required consent states to process any events"),data:t.union([be,fe]).optional().describe("Global data transformation applied to all events"),include:t.array(t.string()).optional().describe("Event sections to flatten into context.data"),mapping:ke.optional().describe("Entity-action specific mapping rules"),policy:ye.optional().describe("Pre-processing policy rules applied before mapping")}).describe("Shared mapping configuration for sources and destinations"),xe=t.object({eventMapping:we.optional().describe("Resolved mapping rule for event"),mappingKey:t.string().optional().describe('Mapping key used (e.g., "product.view")')}).describe("Mapping resolution result"),je=o(be),Ee=o(Se),Re=o(ge),Pe=o(he),Je=o(ve),Oe=o(ye),Ie=o(we),De=o(ke),Ne=o(Ce),Me={};n(Me,{BatchSchema:()=>Ze,ConfigSchema:()=>He,ContextSchema:()=>_e,DLQSchema:()=>ln,DataSchema:()=>en,DestinationPolicySchema:()=>Ge,DestinationsSchema:()=>rn,InitDestinationsSchema:()=>on,InitSchema:()=>tn,InstanceSchema:()=>nn,PartialConfigSchema:()=>Fe,PushBatchContextSchema:()=>Qe,PushContextSchema:()=>Ke,PushEventSchema:()=>Xe,PushEventsSchema:()=>Ye,PushResultSchema:()=>sn,RefSchema:()=>an,ResultSchema:()=>cn,batchJsonSchema:()=>bn,configJsonSchema:()=>dn,contextJsonSchema:()=>un,instanceJsonSchema:()=>fn,partialConfigJsonSchema:()=>pn,pushContextJsonSchema:()=>mn,resultJsonSchema:()=>gn});var Te={};n(Te,{MatchExpressionSchema:()=>qe,NextRuleSchema:()=>Be,RoutableNextSchema:()=>We});var Le=t.enum(["eq","contains","prefix","suffix","regex","gt","lt","exists"]),ze=t.object({key:t.string(),operator:Le,value:t.string(),not:t.boolean().optional()}),qe=t.union([ze,t.object({and:t.array(t.lazy(()=>qe))}),t.object({or:t.array(t.lazy(()=>qe))})]),Ue=t.union([qe,t.literal("*")]),We=t.union([t.string(),t.array(t.string()),t.array(t.object({match:Ue,next:t.lazy(()=>We)}))]),Be=t.object({match:Ue,next:t.lazy(()=>We)}),Ae={};n(Ae,{CacheRuleSchema:()=>$e,CacheSchema:()=>Ve});var $e=t.object({match:t.union([qe,t.literal("*")]).describe("Match expression or wildcard to determine when this rule applies"),key:t.array(t.string()).min(1).describe("Dot-path fields used to build the cache key"),ttl:t.number().positive().describe("Time-to-live in seconds for cached entries"),update:t.record(t.string(),be).optional().describe("Response mutations applied on cache hit (key → Value mapping)")}),Ve=t.object({full:t.boolean().optional().describe("Stop flow on cache HIT (default: false). When true, skip remaining steps and return cached value."),store:t.string().optional().describe("Store ID for persistent caching (references a configured store)"),rules:t.array($e).min(1).describe("Cache rules — at least one required")}),He=t.object({consent:Q.optional().describe("Required consent states to send events to this destination"),settings:t.any().describe("Implementation-specific configuration").optional(),data:t.union([be,fe]).optional().describe("Global data transformation applied to all events for this destination"),include:t.array(t.string()).optional().describe("Event sections to flatten into context.data"),env:t.any().describe("Environment dependencies (platform-specific)").optional(),id:c.describe("Destination instance identifier (defaults to destination key)").optional(),init:t.boolean().describe("Whether to initialize immediately").optional(),loadScript:t.boolean().describe("Whether to load external script (for web destinations)").optional(),mapping:ke.optional().describe("Entity-action specific mapping rules for this destination"),policy:ye.optional().describe("Pre-processing policy rules applied before event mapping"),queue:t.boolean().describe("Whether to queue events when consent is not granted").optional(),require:t.array(t.string()).optional().describe('Defer destination initialization until these collector events fire (e.g., ["consent"])'),logger:t.object({level:t.union([t.number(),t.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:t.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),before:We.optional().describe("Post-collector transformer chain applied before this destination receives the event"),next:We.optional().describe("Post-push transformer chain. Runs after destination push completes; push response is available at ingest._response"),cache:Ve.optional().describe("Cache configuration for deduplication; skip push on cache HIT"),disabled:t.boolean().describe("Completely skip this destination (no init, no push, no queue)").optional(),mock:t.unknown().optional().describe("Return this value instead of calling push(). Dev/testing only.")}).describe("Destination configuration"),Fe=He.partial().describe("Partial destination configuration with all fields optional"),Ge=ye.describe("Destination policy rules for event pre-processing"),_e=t.object({collector:t.unknown().describe("Collector instance (runtime object)"),config:He.describe("Destination configuration"),data:t.union([t.unknown(),t.array(t.unknown())]).optional().describe("Transformed event data"),env:t.unknown().describe("Environment dependencies")}).describe("Destination context for init and push functions"),Ke=_e.extend({mapping:we.optional().describe("Resolved mapping rule for this specific event")}).describe("Push context with event-specific mapping"),Qe=Ke.describe("Batch push context with event-specific mapping"),Xe=t.object({event:ie.describe("The event to process"),mapping:we.optional().describe("Mapping rule for this event")}).describe("Event with optional mapping for batch processing"),Ye=t.array(Xe).describe("Array of events with mappings"),Ze=t.object({key:t.string().describe('Batch key (usually mapping key like "product.view")'),events:t.array(ie).describe("Array of events in batch"),data:t.array(t.union([t.unknown(),t.array(t.unknown())]).optional()).describe("Transformed data for each event"),mapping:we.optional().describe("Shared mapping rule for batch")}).describe("Batch of events grouped by mapping key"),en=t.union([t.unknown(),t.array(t.unknown())]).optional().describe("Transformed event data (Property, undefined, or array)"),nn=t.object({config:He.describe("Destination configuration"),queue:t.array(ie).optional().describe("Queued events awaiting consent"),dlq:t.array(t.tuple([ie,t.unknown()])).optional().describe("Dead letter queue (failed events with errors)"),type:t.string().optional().describe("Destination type identifier"),env:t.unknown().optional().describe("Environment dependencies"),init:t.unknown().optional().describe("Initialization function"),push:t.unknown().describe("Push function for single events"),pushBatch:t.unknown().optional().describe("Batch push function"),on:t.unknown().optional().describe("Event lifecycle hook function")}).describe("Destination instance (runtime object with functions)"),tn=t.object({code:nn.describe("Destination instance with implementation"),config:Fe.optional().describe("Partial configuration overrides"),env:t.unknown().optional().describe("Partial environment overrides")}).describe("Destination initialization configuration"),on=t.record(t.string(),tn).describe("Map of destination IDs to initialization configurations"),rn=t.record(t.string(),nn).describe("Map of destination IDs to runtime instances"),an=t.object({type:t.string().describe('Destination type ("gtag", "meta", "bigquery")'),data:t.unknown().optional().describe("Response from push()"),error:t.unknown().optional().describe("Error if failed")}).describe("Destination reference with type and response data"),sn=t.object({queue:t.array(ie).optional().describe("Events queued (awaiting consent)"),error:t.unknown().optional().describe("Error if push failed")}).describe("Push operation result"),cn=t.object({ok:t.boolean().describe("True if nothing failed"),event:t.unknown().optional().describe("The processed event"),done:t.record(t.string(),an).optional().describe("Destinations that processed successfully"),queued:t.record(t.string(),an).optional().describe("Destinations that queued events"),failed:t.record(t.string(),an).optional().describe("Destinations that failed to process")}).describe("Push result with destination outcomes"),ln=t.array(t.tuple([ie,t.unknown()])).describe("Dead letter queue: [(event, error), ...]"),dn=o(He),pn=o(Fe),un=o(_e),mn=o(Ke),bn=o(Ze),fn=o(nn),gn=o(cn),hn={};n(hn,{CommandTypeSchema:()=>vn,ConfigSchema:()=>Sn,DestinationsSchema:()=>xn,InitConfigSchema:()=>wn,InstanceSchema:()=>jn,PushContextSchema:()=>kn,SessionDataSchema:()=>yn,SourcesSchema:()=>Cn,commandTypeJsonSchema:()=>En,configJsonSchema:()=>Rn,initConfigJsonSchema:()=>Jn,instanceJsonSchema:()=>In,pushContextJsonSchema:()=>On,sessionDataJsonSchema:()=>Pn});var vn=t.union([t.enum(["action","config","consent","context","destination","elb","globals","hook","init","link","run","user","walker"]),t.string()]).describe("Collector command type: standard commands or custom string for extensions"),Sn=t.object({run:t.boolean().describe("Whether to run collector automatically on initialization").optional(),tagging:p,globalsStatic:G.describe("Static global properties that persist across collector runs"),sessionStatic:t.record(t.string(),t.unknown()).describe("Static session data that persists across collector runs"),logger:t.object({level:t.union([t.number(),t.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:t.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler)")}).describe("Core collector configuration"),yn=G.and(t.object({isStart:t.boolean().describe("Whether this is a new session start"),storage:t.boolean().describe("Whether storage is available"),id:c.describe("Session identifier").optional(),start:l.describe("Session start timestamp").optional(),marketing:t.literal(!0).optional().describe("Marketing attribution flag"),updated:l.describe("Last update timestamp").optional(),isNew:t.boolean().describe("Whether this is a new session").optional(),device:c.describe("Device identifier").optional(),count:d.describe("Event count in session").optional(),runs:d.describe("Number of runs").optional()})).describe("Session state and tracking data"),wn=Sn.partial().extend({consent:Q.optional().describe("Initial consent state"),user:X.optional().describe("Initial user data"),globals:G.optional().describe("Initial global properties"),sources:t.unknown().optional().describe("Source configurations"),destinations:t.unknown().optional().describe("Destination configurations"),transformers:t.unknown().optional().describe("Transformer configurations"),stores:t.unknown().optional().describe("Store configurations"),custom:G.optional().describe("Initial custom implementation-specific properties"),hooks:t.unknown().optional().describe("Pipeline observation hooks")}).describe("Collector initialization configuration with initial state"),kn=t.object({mapping:Ce.optional().describe("Source-level mapping configuration")}).describe("Push context with optional source mapping"),Cn=t.record(t.string(),t.unknown()).describe("Map of source IDs to source instances"),xn=t.record(t.string(),t.unknown()).describe("Map of destination IDs to destination instances"),jn=t.object({push:t.unknown().describe("Push function for processing events"),command:t.unknown().describe("Command function for walker commands"),allowed:t.boolean().describe("Whether event processing is allowed"),config:Sn.describe("Current collector configuration"),consent:Q.describe("Current consent state"),count:t.number().describe("Event count (increments with each event)"),custom:G.describe("Custom implementation-specific properties"),sources:Cn.describe("Registered source instances"),destinations:xn.describe("Registered destination instances"),globals:G.describe("Current global properties"),group:t.string().describe("Event grouping identifier"),hooks:t.unknown().describe("Lifecycle hook functions"),on:t.unknown().describe("Event lifecycle configuration"),queue:t.array(ie).describe("Queued events awaiting processing"),round:t.number().describe("Collector run count (increments with each run)"),session:t.union([yn]).describe("Current session state"),timing:t.number().describe("Event processing timing information"),user:X.describe("Current user data"),version:t.string().describe("Walker implementation version")}).describe("Collector instance with state and methods"),En=o(vn),Rn=o(Sn),Pn=o(yn),Jn=o(wn),On=o(kn),In=o(jn),Dn={};n(Dn,{BaseEnvSchema:()=>Nn,ConfigSchema:()=>Mn,InitSchema:()=>zn,InitSourceSchema:()=>qn,InitSourcesSchema:()=>Un,InstanceSchema:()=>Ln,PartialConfigSchema:()=>Tn,baseEnvJsonSchema:()=>Wn,configJsonSchema:()=>Bn,initSourceJsonSchema:()=>Vn,initSourcesJsonSchema:()=>Hn,instanceJsonSchema:()=>$n,partialConfigJsonSchema:()=>An});var Nn=t.object({push:t.unknown().describe("Collector push function"),command:t.unknown().describe("Collector command function"),sources:t.unknown().optional().describe("Map of registered source instances"),elb:t.unknown().describe("Public API function (alias for collector.push)")}).catchall(t.unknown()).describe("Base environment for dependency injection - platform-specific sources extend this"),Mn=Ce.extend({settings:t.any().describe("Implementation-specific configuration").optional(),env:Nn.optional().describe("Environment dependencies (platform-specific)"),id:c.describe("Source identifier (defaults to source key)").optional(),primary:t.boolean().describe("Mark as primary (only one can be primary)").optional(),require:t.array(t.string()).optional().describe('Defer source initialization until these collector events fire (e.g., ["consent"])'),logger:t.object({level:t.union([t.number(),t.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:t.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),ingest:t.union([be,fe]).optional().describe("Ingest metadata extraction mapping. Extracts values from raw request objects (Express req, Lambda event) using mapping syntax."),disabled:t.boolean().describe("Completely skip this source (no init, no event capture)").optional()}).describe("Source configuration with mapping and environment"),Tn=Mn.partial().describe("Partial source configuration with all fields optional"),Ln=t.object({type:t.string().describe('Source type identifier (e.g., "browser", "dataLayer")'),config:Mn.describe("Current source configuration"),push:t.any().describe("Push function - THE HANDLER (flexible signature for platform compatibility)"),destroy:t.any().optional().describe("Cleanup function called when source is removed"),on:t.unknown().optional().describe("Lifecycle hook function for event types")}).describe("Source instance with push handler and lifecycle methods"),zn=t.any().describe("Source initialization function: (config, env) => Instance | Promise<Instance>"),qn=t.object({code:zn.describe("Source initialization function"),config:Tn.optional().describe("Partial configuration overrides"),env:Nn.partial().optional().describe("Partial environment overrides"),primary:t.boolean().optional().describe("Mark as primary source (only one can be primary)")}).describe("Source initialization configuration"),Un=t.record(t.string(),qn).describe("Map of source IDs to initialization configurations"),Wn=o(Nn),Bn=o(Mn),An=o(Tn),$n=o(Ln),Vn=o(qn),Hn=o(Un),Fn={};n(Fn,{ConfigSchema:()=>Gn,PartialConfigSchema:()=>_n,configJsonSchema:()=>Kn,partialConfigJsonSchema:()=>Qn});var Gn=t.object({settings:t.any().describe("Implementation-specific configuration").optional(),env:t.any().describe("Environment dependencies (platform-specific)").optional(),id:c.describe("Transformer instance identifier (defaults to transformer key)").optional(),logger:t.object({level:t.union([t.number(),t.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:t.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),before:We.optional().describe("Pre-transformer chain that runs before this transformer pushes"),next:We.optional().describe("Graph wiring to the next transformer in the chain"),cache:Ve.optional().describe("Step-level cache configuration for this transformer"),init:t.boolean().describe("Whether to initialize immediately").optional(),disabled:t.boolean().describe("Completely skip this transformer in chains").optional(),mock:t.unknown().optional().describe("Return this value instead of calling push(). Global mock for all chains. Dev/testing only."),chainMocks:t.record(t.string(),t.unknown()).optional().describe("Path-specific mock values keyed by chain path. Takes precedence over global mock. Dev/testing only.")}).describe("Transformer configuration"),_n=Gn.partial().describe("Partial transformer configuration with all fields optional"),Kn=o(Gn),Qn=o(_n),Xn={};n(Xn,{ConfigSchema:()=>Yn,PartialConfigSchema:()=>Zn,configJsonSchema:()=>ei,partialConfigJsonSchema:()=>ni});var Yn=t.object({settings:t.any().describe("Implementation-specific configuration").optional(),env:t.any().describe("Environment dependencies (platform-specific)").optional(),id:c.describe("Store instance identifier (defaults to store key)").optional(),logger:t.object({level:t.union([t.number(),t.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:t.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults")}).describe("Store configuration"),Zn=Yn.partial().describe("Partial store configuration with all fields optional"),ei=o(Yn),ni=o(Zn),ii={};n(ii,{BundleSchema:()=>li,ConfigSchema:()=>ji,ContractActionsSchema:()=>yi,ContractEntrySchema:()=>ki,ContractEventsSchema:()=>wi,ContractSchema:()=>Ci,ContractSchemaEntry:()=>Si,DefinitionsSchema:()=>ri,DestinationReferenceSchema:()=>hi,InlineCodeSchema:()=>ui,OverridesSchema:()=>ci,PackagesSchema:()=>si,PrimitiveSchema:()=>ti,ServerSchema:()=>pi,SettingsSchema:()=>xi,SourceReferenceSchema:()=>fi,StepExampleSchema:()=>mi,StepExamplesSchema:()=>bi,StoreReferenceSchema:()=>vi,TransformerReferenceSchema:()=>gi,VariablesSchema:()=>oi,WebSchema:()=>di,configJsonSchema:()=>Oi,contractEntryJsonSchema:()=>Li,contractJsonSchema:()=>zi,destinationReferenceJsonSchema:()=>Ni,parseConfig:()=>Ei,parseSettings:()=>Pi,safeParseConfig:()=>Ri,safeParseSettings:()=>Ji,settingsJsonSchema:()=>Ii,sourceReferenceJsonSchema:()=>Di,storeReferenceJsonSchema:()=>Ti,transformerReferenceJsonSchema:()=>Mi});var ti=t.union([t.string(),t.number(),t.boolean()]).describe("Primitive value: string, number, or boolean"),oi=t.record(t.string(),ti).describe("Variables for interpolation"),ri=t.record(t.string(),t.unknown()).describe("Reusable configuration definitions"),ai=/^(@[a-z0-9\-~][a-z0-9\-._~]*\/)?[a-z0-9\-~][a-z0-9\-._~]*$/,si=t.record(t.string().regex(ai,"Invalid npm package name"),t.object({version:t.string().optional(),imports:t.array(t.string()).optional(),path:t.string().optional()})).describe("NPM packages to bundle"),ci=t.record(t.string().regex(ai,"Invalid npm package name"),t.string().min(1,"Override version cannot be empty")).describe("Transitive dependency version overrides"),li=t.object({packages:si.optional().describe("NPM packages to bundle"),overrides:ci.optional().describe("Transitive dependency overrides")}).strict().describe("Bundle configuration (packages + overrides)"),di=t.object({windowCollector:t.string().default("collector").optional().describe('Window property name for the collector instance (default: "collector")'),windowElb:t.string().default("elb").optional().describe('Window property name for the elb command queue (default: "elb")')}).describe("Web platform configuration"),pi=t.object({}).passthrough().describe("Server platform configuration (reserved for future options)"),ui=t.object({push:t.string().min(1,"Push function cannot be empty").describe('JavaScript function for processing events. Must start with "$code:" prefix. Example: "$code:(event) => { console.log(event); }"'),type:t.string().optional().describe("Optional type identifier for the inline instance"),init:t.string().optional().describe("Optional initialization function. Use $code: prefix for inline JavaScript.")}).describe("Inline code for custom sources/transformers/destinations"),mi=t.object({description:t.string().optional().describe("Human-readable description"),in:t.unknown().optional().describe("Input to the step"),trigger:t.object({type:t.string().optional().describe("Trigger mechanism (e.g., click, POST, load)"),options:t.unknown().optional().describe("Mechanism-specific options")}).optional().describe("Source trigger metadata"),mapping:t.unknown().optional().describe("Mapping configuration"),out:t.unknown().optional().describe("Expected output from the step"),command:t.enum(["config","consent","user","run"]).optional().describe("Invoke elb('walker <command>', in) instead of pushing in as an event")}).describe("Named example with input/output pair"),bi=t.record(t.string(),mi).describe("Named step examples for testing and documentation"),fi=t.object({package:t.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-source-browser@2.0.0")'),code:t.union([t.string(),ui]).optional().describe('Either a named export string (e.g., "sourceExpress") or an inline code object with push function'),config:t.unknown().optional().describe("Source-specific configuration object"),env:t.unknown().optional().describe("Source environment configuration"),primary:t.boolean().optional().describe("Mark as primary source (provides main elb). Only one source should be primary."),variables:oi.optional().describe("Source-level variables (highest priority in cascade)"),definitions:ri.optional().describe("Source-level definitions (highest priority in cascade)"),next:We.optional().describe("Pre-collector transformer chain. String, string[], or NextRule[] for conditional routing based on ingest data."),before:We.optional().describe("Pre-source transformer chain (consent-exempt). Handles transport-level preprocessing."),examples:bi.optional().describe("Named step examples for testing and documentation (stripped during bundling)"),cache:Ve.optional().describe("Cache configuration for this source (match → key → ttl rules)")}).describe("Source package reference with configuration"),gi=t.object({package:t.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/transformer-enricher@1.0.0")'),code:t.union([t.string(),ui]).optional().describe('Either a named export string (e.g., "transformerEnricher") or an inline code object with push function'),config:t.unknown().optional().describe("Transformer-specific configuration object"),env:t.unknown().optional().describe("Transformer environment configuration"),before:We.optional().describe("Pre-transformer chain. Runs before this transformer push function."),next:We.optional().describe("Next transformer in chain. String, string[], or NextRule[] for conditional routing."),variables:oi.optional().describe("Transformer-level variables (highest priority in cascade)"),definitions:ri.optional().describe("Transformer-level definitions (highest priority in cascade)"),examples:bi.optional().describe("Named step examples for testing and documentation (stripped during bundling)"),cache:Ve.optional().describe("Cache configuration for this transformer (match → key → ttl rules)")}).describe("Transformer package reference with configuration"),hi=t.object({package:t.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-destination-gtag@2.0.0")'),code:t.union([t.string(),ui]).optional().describe('Either a named export string (e.g., "destinationAnalytics") or an inline code object with push function'),config:t.unknown().optional().describe("Destination-specific configuration object"),env:t.unknown().optional().describe("Destination environment configuration"),variables:oi.optional().describe("Destination-level variables (highest priority in cascade)"),definitions:ri.optional().describe("Destination-level definitions (highest priority in cascade)"),before:We.optional().describe("Post-collector transformer chain. String, string[], or NextRule[] for conditional routing."),next:We.optional().describe("Post-push transformer chain. Push response available at context.ingest._response."),examples:bi.optional().describe("Named step examples for testing and documentation (stripped during bundling)"),cache:Ve.optional().describe("Cache configuration for this destination (match → key → ttl rules)")}).describe("Destination package reference with configuration"),vi=t.object({package:t.string().min(1,"Package name cannot be empty").optional().describe("Store package specifier with optional version"),code:t.union([t.string(),ui]).optional().describe("Named export string or inline code definition"),config:t.unknown().optional().describe("Store-specific configuration object"),env:t.unknown().optional().describe("Store environment configuration"),variables:oi.optional().describe("Store-level variables (highest priority in cascade)"),definitions:ri.optional().describe("Store-level definitions (highest priority in cascade)"),examples:bi.optional().describe("Named step examples for testing and documentation (stripped during bundling)")}).describe("Store package reference with configuration"),Si=t.record(t.string(),t.unknown()).describe("JSON Schema object for event validation with description/examples annotations"),yi=t.record(t.string(),Si).describe("Action-level contract entries"),wi=t.record(t.string(),yi).describe("Entity-action event schemas"),ki=t.object({extends:t.string().optional().describe("Inherit from another named contract"),tagging:t.number().int().min(0).optional().describe("Contract version number"),description:t.string().optional().describe("Human-readable description"),globals:Si.optional().describe("JSON Schema for event.globals"),context:Si.optional().describe("JSON Schema for event.context"),custom:Si.optional().describe("JSON Schema for event.custom"),user:Si.optional().describe("JSON Schema for event.user"),consent:Si.optional().describe("JSON Schema for event.consent"),events:wi.optional().describe("Entity-action event schemas")}).describe("Named contract entry with optional sections and events"),Ci=t.record(t.string(),ki).describe("Named contracts with optional extends inheritance"),xi=t.object({web:di.optional().describe("Web platform configuration (browser-based tracking). Mutually exclusive with server."),server:pi.optional().describe("Server platform configuration (Node.js). Mutually exclusive with web."),sources:t.record(t.string(),fi).optional().describe("Source configurations (data capture) keyed by unique identifier"),destinations:t.record(t.string(),hi).optional().describe("Destination configurations (data output) keyed by unique identifier"),transformers:t.record(t.string(),gi).optional().describe("Transformer configurations (event transformation) keyed by unique identifier"),stores:t.record(t.string(),vi).optional().describe("Store configurations (key-value storage) keyed by unique identifier"),collector:t.unknown().optional().describe("Collector configuration for event processing (uses Collector.InitConfig)"),bundle:li.optional().describe("Build-time configuration (packages + overrides)"),packages:t.unknown().optional().refine(e=>void 0===e,{message:"`packages` must live under `bundle.packages`. Move your packages block to `flow.<name>.bundle.packages`. This is a breaking change — see CHANGELOG migration guide."}).describe("Legacy top-level packages (moved to bundle.packages)"),variables:oi.optional().describe("Flow-level variables (override Config.variables, overridden by source/destination variables)"),definitions:ri.optional().describe("Flow-level definitions (extend Config.definitions, overridden by source/destination definitions)")}).refine(e=>{const n=void 0!==e.web,i=void 0!==e.server;return(n||i)&&!(n&&i)},{message:'Exactly one of "web" or "server" must be present'}).describe("Single flow settings for one deployment target"),ji=t.object({$schema:t.string().url("Schema URL must be a valid URL").optional().describe('JSON Schema reference for IDE validation (e.g., "https://walkeros.io/schema/flow/v2.json")'),include:t.array(t.string()).optional().describe("Folders to include in the bundle output"),variables:oi.optional().describe("Shared variables for interpolation across all flows (use $var.name syntax)"),definitions:ri.optional().describe("Reusable configuration definitions (use $def.name syntax)"),flows:t.record(t.string(),xi).refine(e=>Object.keys(e).length>0,{message:"At least one flow is required"}).describe("Named flow configurations (e.g., production, staging, development)")}).extend({version:t.literal(3).describe("Configuration schema version"),contract:Ci.optional().describe("Named contracts with extends inheritance and dot-path references")}).describe("walkerOS flow configuration (walkeros.config.json)");function Ei(e){return ji.parse(e)}function Ri(e){return ji.safeParse(e)}function Pi(e){return xi.parse(e)}function Ji(e){return xi.safeParse(e)}var Oi=t.toJSONSchema(ji,{target:"draft-7"}),Ii=o(xi),Di=o(fi),Ni=o(hi),Mi=o(gi),Ti=o(vi),Li=o(ki),zi=o(Ci);import{z as qi}from"zod";var Ui=qi.object({lang:qi.string().optional().describe("Language identifier (e.g. json, sql, bash, typescript)"),code:qi.string().describe("Code snippet")}),Wi=qi.object({text:qi.string().describe("Short actionable hint text focused on walkerOS usage"),code:qi.array(Ui).optional().describe("Optional code snippets")}),Bi=qi.record(qi.string(),Wi).describe("Keyed hints for AI consumption — lightweight context beyond schemas and examples"),Ai=t.object({param:t.string().describe("Lowercase URL parameter name. Match is case-insensitive on lookup."),platform:t.string().describe("Canonical platform identifier (lowercase, kebab-case).")});function $i(e){let n;try{n=JSON.parse(e)}catch(n){const{line:i,column:t}=function(e,n){if(e instanceof SyntaxError){const i=e.message.match(/position\s+(\d+)/);if(i){return Vi(n,parseInt(i[1],10))}const t=e.message.match(/line\s+(\d+)\s+column\s+(\d+)/);if(t)return{line:parseInt(t[1],10),column:parseInt(t[2],10)}}return{line:1,column:1}}(n,e);return{valid:!1,errors:[{message:n instanceof Error?n.message:"Invalid JSON",severity:"error",line:i,column:t}],warnings:[]}}const i=[],t=[],o=ji.safeParse(n);if(!o.success)for(const n of o.error.issues){const t=n.path.join("."),o=Fi(e,n.path);i.push({message:n.message,severity:"error",path:t||"root",...o})}const r=function(e){if(!(Gi(e)&&"version"in e&&"flows"in e&&Gi(e.flows)))return;const n={},i={},t=[],o=[],r=[],a=[],s=[];let c;Ki(n,e.variables),Qi(i,e.definitions),function(e,n){if(!Gi(n))return;for(const[,i]of Object.entries(n)){if(!Gi(i))continue;const n=i.events;if(Gi(n))for(const[i,t]of Object.entries(n)){if(!Gi(t))continue;const n=e.find(e=>e.entity===i),o=Object.keys(t);if(n)for(const e of o)n.actions.includes(e)||n.actions.push(e);else e.push({entity:i,actions:o})}}}(s,e.contract);for(const s of Object.values(e.flows))if(Gi(s)){c||("web"in s?c="web":"server"in s&&(c="server")),Ki(n,s.variables),Qi(i,s.definitions);for(const e of["sources","destinations","transformers"]){const l="sources"===e?"source":"destinations"===e?"destination":"transformer",d="sources"===e?t:"destinations"===e?o:r;if(Gi(s[e]))for(const[t,o]of Object.entries(s[e]))d.push(t),Gi(o)&&(Ki(n,o.variables),Qi(i,o.definitions),"string"==typeof o.package&&a.push({package:o.package,shortName:t,type:l,platform:c||"web"}))}}const l={variables:n,definitions:i,stepNames:{sources:t,destinations:o,transformers:r}};c&&(l.platform=c);a.length>0&&(l.packages=a);s.length>0&&(l.contract=s);return l}(n);if(r){const n=function(e,n){const i=[];if(n.variables){const t=/\$var\.(\w+)/g;let o;for(;null!==(o=t.exec(e));)if(!(o[1]in n.variables)){const t=Hi(e,o.index,o[0].length);i.push({message:`Unknown variable "$var.${o[1]}". Defined: ${Object.keys(n.variables).join(", ")||"none"}`,severity:"warning",path:`$var.${o[1]}`,...t})}}if(n.definitions){const t=/\$def\.(\w+)/g;let o;for(;null!==(o=t.exec(e));)if(!(o[1]in n.definitions)){const t=Hi(e,o.index,o[0].length);i.push({message:`Unknown definition "$def.${o[1]}". Defined: ${Object.keys(n.definitions).join(", ")||"none"}`,severity:"warning",path:`$def.${o[1]}`,...t})}}return i}(e,r);t.push(...n)}return{valid:0===i.length,errors:i,warnings:t,context:r}}function Vi(e,n){let i=1,t=1;for(let o=0;o<n&&o<e.length;o++)"\n"===e[o]?(i++,t=1):t++;return{line:i,column:t}}function Hi(e,n,i){const t=Vi(e,n),o=Vi(e,n+i);return{line:t.line,column:t.column,endLine:o.line,endColumn:o.column}}function Fi(e,n){if(0===n.length)return{line:1,column:1};const i=n[n.length-1];if("string"==typeof i){const n=`"${i}"`,t=e.lastIndexOf(n);if(-1!==t)return Vi(e,t)}return{line:1,column:1}}function Gi(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function _i(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e}function Ki(e,n){if(Gi(n))for(const[i,t]of Object.entries(n))_i(t)&&(e[i]=t)}function Qi(e,n){if(Gi(n))for(const[i,t]of Object.entries(n))e[i]=t}function Xi(e,n){const i=[],t={};for(const[n,o]of Object.entries(e)){o.required&&i.push(n);const e={type:o.type};if(o.description&&(e.description=o.description),o.pattern&&(e.pattern=o.pattern),void 0!==o.minLength&&(e.minLength=o.minLength),void 0!==o.maxLength&&(e.maxLength=o.maxLength),void 0!==o.minimum&&(e.minimum=o.minimum),void 0!==o.maximum&&(e.maximum=o.maximum),o.enum&&(e.enum=[...o.enum]),void 0!==o.default&&(e.default=o.default),"object"===o.type&&o.properties){const n={};for(const[e,i]of Object.entries(o.properties))n[e]=Yi(i);e.properties=n}"array"===o.type&&o.items&&(e.items=Yi(o.items)),t[n]=e}const o={type:"object",properties:t};return n&&(o.title=n),i.length>0&&(o.required=i),o}function Yi(e){const n={type:e.type};if(e.description&&(n.description=e.description),e.pattern&&(n.pattern=e.pattern),void 0!==e.minLength&&(n.minLength=e.minLength),void 0!==e.maxLength&&(n.maxLength=e.maxLength),void 0!==e.minimum&&(n.minimum=e.minimum),void 0!==e.maximum&&(n.maximum=e.maximum),e.enum&&(n.enum=[...e.enum]),void 0!==e.default&&(n.default=e.default),"object"===e.type&&e.properties){const i={};for(const[n,t]of Object.entries(e.properties))i[n]=Yi(t);n.properties=i}return"array"===e.type&&e.items&&(n.items=Yi(e.items)),n}function Zi(e,n){const i={type:"array",items:Yi(e)};return void 0!==n?.minItems&&(i.minItems=n.minItems),void 0!==n?.maxItems&&(i.maxItems=n.maxItems),n?.description&&(i.description=n.description),n?.title&&(i.title=n.title),i}function et(e,n="string",i){const t={type:n,enum:[...e]};return i?.description&&(t.description=i.description),i?.title&&(t.title=i.title),t}function nt(e,n,i){return Zi({type:"object"},{minItems:2,maxItems:2,description:i||"Tuple with exactly 2 elements [source, transform]"})}function it(e){return t.toJSONSchema(e,{target:"draft-7"})}var tt=new Set(["env","onError","onLog","primary"]),ot={source:Dn.configJsonSchema,destination:Me.configJsonSchema};function rt(e,n){const i=ot[e];if(!i||!i.properties){return{type:"object",properties:{settings:n.settings?at(n.settings):{description:"Implementation-specific configuration"}}}}const t=JSON.parse(JSON.stringify(i)),o=t.properties;for(const e of tt)delete o[e];return n.settings&&(o.settings=at(n.settings)),t}function at(e){const{$schema:n,...i}=e;return i}function st(e){return 0===e.length?"// no output":e.map(ct).join(";\n\n")}function ct(e){const[n,...i]=e,t=i.map(lt).join(", ");return"return"===n?t?`return ${t}`:"return":`${n}(${t})`}function lt(e){return void 0===e?"undefined":null===e?"null":"function"==typeof e?"[Function]":JSON.stringify(e,null,2)}export{Ai as ClickIdEntrySchema,st as formatOut,rt as mergeConfigSchema,i as schemas,t as z,it as zodToSchema};//# sourceMappingURL=dev.mjs.map
1
+ var e=Object.defineProperty,n=(n,i)=>{for(var t in i)e(n,t,{get:i[t],enumerable:!0})},i={};n(i,{BaseContextConfig:()=>q,BatchConfig:()=>U,CacheRuleSchema:()=>$e,CacheSchema:()=>Ve,CacheSchemas:()=>Ae,ClickIdEntrySchema:()=>Ai,CodeSchema:()=>Ui,CollectorSchemas:()=>hn,ConsentSchema:()=>Q,ContractActionsSchema:()=>yi,ContractSchema:()=>Ci,ContractSchemaEntry:()=>Si,Counter:()=>d,DeepPartialEventSchema:()=>oe,DestinationReferenceSchema:()=>hi,DestinationSchemas:()=>Me,DestinationsMapConfig:()=>A,EntitiesSchema:()=>ne,EntitySchema:()=>ee,EventSchema:()=>ie,FlowConfigSchema:()=>ji,FlowSchemas:()=>ii,FlowSettingsSchema:()=>xi,GenericEnvConfig:()=>D,GenericSettingsConfig:()=>O,HandlersConfig:()=>j,HintSchema:()=>Wi,HintsSchema:()=>Bi,IdConfig:()=>P,Identifier:()=>c,InitConfig:()=>J,LoopSchema:()=>ge,MapSchema:()=>ve,MappingResultSchema:()=>xe,MappingSchemas:()=>me,MatchExpressionSchema:()=>qe,MatcherSchemas:()=>Te,NextRuleSchema:()=>Be,OptionalPrimitiveValue:()=>m,OrderedPropertiesSchema:()=>_,PartialEventSchema:()=>te,PolicySchema:()=>ye,PrimaryConfig:()=>I,PrimitiveSchema:()=>ti,PrimitiveValue:()=>u,ProcessingControlConfig:()=>W,PropertiesSchema:()=>G,PropertySchema:()=>F,PropertyTypeSchema:()=>H,QueueConfig:()=>R,RequiredBoolean:()=>s,RequiredNumber:()=>a,RequiredString:()=>r,RoutableNextSchema:()=>We,RuleSchema:()=>we,RulesSchema:()=>ke,RuntimeInstanceConfig:()=>z,SetSchema:()=>he,SourceReferenceSchema:()=>fi,SourceSchema:()=>Z,SourceSchemas:()=>Dn,SourceTypeSchema:()=>K,SourcesMapConfig:()=>B,StoreReferenceSchema:()=>vi,StoreSchemas:()=>Xn,TaggingVersion:()=>p,Timestamp:()=>l,TransformerReferenceSchema:()=>gi,TransformerSchemas:()=>Fn,UserSchema:()=>X,UtilitySchemas:()=>b,ValueConfigSchema:()=>Se,ValueSchema:()=>be,ValuesSchema:()=>fe,VerboseConfig:()=>E,VersionSchema:()=>Y,WalkerOSSchemas:()=>$,configJsonSchema:()=>Ii,consentJsonSchema:()=>ue,contractEntryJsonSchema:()=>Li,contractJsonSchema:()=>zi,createArraySchema:()=>Zi,createConsentConfig:()=>L,createDataTransformationConfig:()=>N,createEnumSchema:()=>et,createMappingRulesConfig:()=>M,createObjectSchema:()=>Xi,createPolicyConfig:()=>T,createTupleSchema:()=>nt,destinationReferenceJsonSchema:()=>Ni,entityJsonSchema:()=>de,eventJsonSchema:()=>re,loopJsonSchema:()=>Re,mapJsonSchema:()=>Je,orderedPropertiesJsonSchema:()=>le,parseConfig:()=>Ei,parseSettings:()=>Pi,partialEventJsonSchema:()=>ae,policyJsonSchema:()=>Ie,propertiesJsonSchema:()=>ce,ruleJsonSchema:()=>Oe,rulesJsonSchema:()=>De,safeParseConfig:()=>Ri,safeParseSettings:()=>Ji,setJsonSchema:()=>Pe,settingsJsonSchema:()=>Oi,sourceReferenceJsonSchema:()=>Di,sourceTypeJsonSchema:()=>pe,storeReferenceJsonSchema:()=>Ti,transformerReferenceJsonSchema:()=>Mi,userJsonSchema:()=>se,validateFlowConfig:()=>$i,valueConfigJsonSchema:()=>Ee,valueJsonSchema:()=>je,z:()=>t,zodToSchema:()=>it});import{z as t}from"zod";function o(e,n,i="draft-7"){return t.toJSONSchema(e,{target:i})}var r=t.string(),a=t.number(),s=t.boolean(),c=t.string().min(1),l=t.number().int().positive(),d=t.number().int().nonnegative(),p=t.number().describe("Tagging version number"),u=t.union([t.string(),t.number(),t.boolean()]),m=u.optional(),b={};n(b,{ErrorHandlerSchema:()=>h,HandlerSchema:()=>S,LogHandlerSchema:()=>v,StorageSchema:()=>g,StorageTypeSchema:()=>f,errorHandlerJsonSchema:()=>k,handlerJsonSchema:()=>x,logHandlerJsonSchema:()=>C,storageJsonSchema:()=>w,storageTypeJsonSchema:()=>y});var f=t.enum(["local","session","cookie"]).describe("Storage mechanism: local, session, or cookie"),g=t.object({Local:t.literal("local"),Session:t.literal("session"),Cookie:t.literal("cookie")}).describe("Storage type constants for type-safe references"),h=t.any().describe("Error handler function: (error, state?) => void"),v=t.any().describe("Log handler function: (message, verbose?) => void"),S=t.object({Error:h.describe("Error handler function"),Log:v.describe("Log handler function")}).describe("Handler interface with error and log functions"),y=o(f),w=o(g),k=o(h),C=o(v),x=o(S),j=t.object({onError:h.optional().describe("Error handler function: (error, state?) => void"),onLog:v.optional().describe("Log handler function: (message, verbose?) => void")}).partial(),E=t.object({verbose:t.boolean().describe("Enable verbose logging for debugging").optional()}).partial(),R=t.object({queue:t.boolean().describe("Whether to queue events when consent is not granted").optional()}).partial(),P=t.object({}).partial(),J=t.object({init:t.boolean().describe("Whether to initialize immediately").optional(),loadScript:t.boolean().describe("Whether to load external script (for web destinations)").optional()}).partial(),I=t.object({primary:t.boolean().describe("Mark as primary (only one can be primary)").optional()}).partial(),O=t.object({settings:t.any().optional().describe("Implementation-specific configuration")}).partial(),D=t.object({env:t.any().optional().describe("Environment dependencies (platform-specific)")}).partial();function N(e,n){return t.object({data:t.union([e,n]).optional().describe("Data transformation rules")}).partial()}function M(e){return t.object({mapping:e.optional().describe("Event mapping rules")}).partial()}function T(e){return t.object({policy:e.optional().describe("Pre-processing policy rules")}).partial()}function L(e){return t.object({consent:e.optional().describe("Required consent states")}).partial()}var z=t.object({type:t.string().optional().describe("Instance type identifier"),config:t.unknown().describe("Instance configuration")}).partial(),q=t.object({collector:t.unknown().describe("Collector instance (runtime object)"),config:t.unknown().describe("Configuration"),env:t.unknown().describe("Environment dependencies")}).partial(),U=t.object({batch:t.number().optional().describe("Batch size: bundle N events for batch processing"),batched:t.unknown().optional().describe("Batch of events to be processed")}).partial(),W=t.object({ignore:t.boolean().describe("Set to true to skip processing").optional(),condition:t.string().optional().describe("Condition function: return true to process")}).partial(),B=t.object({sources:t.record(t.string(),t.unknown()).describe("Map of source instances")}).partial(),A=t.object({destinations:t.record(t.string(),t.unknown()).describe("Map of destination instances")}).partial(),$={};n($,{ConsentSchema:()=>Q,DeepPartialEventSchema:()=>oe,EntitiesSchema:()=>ne,EntitySchema:()=>ee,EventSchema:()=>ie,OrderedPropertiesSchema:()=>_,PartialEventSchema:()=>te,PropertiesSchema:()=>G,PropertySchema:()=>F,PropertyTypeSchema:()=>H,SourceSchema:()=>Z,SourceTypeSchema:()=>K,UserSchema:()=>X,VersionSchema:()=>Y,consentJsonSchema:()=>ue,entityJsonSchema:()=>de,eventJsonSchema:()=>re,orderedPropertiesJsonSchema:()=>le,partialEventJsonSchema:()=>ae,propertiesJsonSchema:()=>ce,sourceTypeJsonSchema:()=>pe,userJsonSchema:()=>se});var V,H=t.lazy(()=>t.union([t.boolean(),t.string(),t.number(),t.record(t.string(),F)])),F=t.lazy(()=>t.union([H,t.array(H)])),G=t.record(t.string(),F.optional()).describe("Flexible property collection with optional values"),_=t.record(t.string(),t.tuple([F,t.number()]).optional()).describe("Ordered properties with [value, order] tuples for priority control"),K=t.union([t.enum(["web","server","app","other"]),t.string()]).describe("Source type: web, server, app, other, or custom"),Q=t.record(t.string(),t.boolean()).meta({id:"WalkerOSConsent",title:"WalkerOS.Consent",description:"Consent state mapping. Keys are consent groups (e.g. marketing, functional), values are booleans for granted/denied."}).describe("Consent requirement mapping (group name to state)"),X=G.and(t.object({id:t.string().optional().describe("User identifier"),device:t.string().optional().describe("Device identifier"),session:t.string().optional().describe("Session identifier"),hash:t.string().optional().describe("Hashed identifier"),address:t.string().optional().describe("User address"),email:t.string().email().optional().describe("User email address"),phone:t.string().optional().describe("User phone number"),userAgent:t.string().optional().describe("Browser user agent string"),browser:t.string().optional().describe("Browser name"),browserVersion:t.string().optional().describe("Browser version"),deviceType:t.string().optional().describe("Device type (mobile, desktop, tablet)"),os:t.string().optional().describe("Operating system"),osVersion:t.string().optional().describe("Operating system version"),screenSize:t.string().optional().describe("Screen dimensions"),language:t.string().optional().describe("User language"),country:t.string().optional().describe("User country"),region:t.string().optional().describe("User region/state"),city:t.string().optional().describe("User city"),zip:t.string().optional().describe("User postal code"),timezone:t.string().optional().describe("User timezone"),ip:t.string().optional().describe("User IP address"),internal:t.boolean().optional().describe("Internal user flag (employee, test user)")})).describe("User identification and properties"),Y=G.and(t.object({source:r.describe('Walker implementation version (e.g., "2.0.0")'),tagging:p})).describe("Walker version information"),Z=G.and(t.object({type:K.describe("Source type identifier"),id:r.describe("Source identifier (typically URL on web)"),previous_id:r.describe("Previous source identifier (typically referrer on web)")})).describe("Event source information"),ee=t.lazy(()=>t.object({entity:t.string().describe("Entity name"),data:G.describe("Entity-specific properties"),nested:t.array(ee).describe("Nested child entities"),context:_.describe("Entity context data")})).describe("Nested entity structure with recursive nesting support"),ne=t.array(ee).describe("Array of nested entities"),ie=t.object({name:t.string().describe('Event name in "entity action" format (e.g., "page view", "product add")'),data:G.describe("Event-specific properties"),context:_.describe("Ordered context properties with priorities"),globals:G.describe("Global properties shared across events"),custom:G.describe("Custom implementation-specific properties"),user:X.describe("User identification and attributes"),nested:ne.describe("Related nested entities"),consent:Q.describe("Consent states at event time"),id:c.describe("Unique event identifier (timestamp-based)"),trigger:r.describe("Event trigger identifier"),entity:r.describe("Parsed entity from event name"),action:r.describe("Parsed action from event name"),timestamp:l.describe("Unix timestamp in milliseconds since epoch"),timing:a.describe("Event processing timing information"),group:r.describe("Event grouping identifier"),count:d.describe("Event count in session"),version:Y.describe("Walker version information"),source:Z.describe("Event source information")}).describe("Complete walkerOS event structure"),te=ie.partial().describe("Partial event structure with all fields optional"),oe=ie.partial().describe("Partial event structure with all top-level fields optional"),re=o(ie),ae=o(te),se=o(X),ce=o(G),le=o(_),de=o(ee),pe=o(K),ue=o(Q),me={};n(me,{ConfigSchema:()=>Ce,LoopSchema:()=>ge,MapSchema:()=>ve,PolicySchema:()=>ye,ResultSchema:()=>xe,RuleSchema:()=>we,RulesSchema:()=>ke,SetSchema:()=>he,ValueConfigSchema:()=>Se,ValueSchema:()=>be,ValuesSchema:()=>fe,configJsonSchema:()=>Ne,loopJsonSchema:()=>Re,mapJsonSchema:()=>Je,policyJsonSchema:()=>Ie,ruleJsonSchema:()=>Oe,rulesJsonSchema:()=>De,setJsonSchema:()=>Pe,valueConfigJsonSchema:()=>Ee,valueJsonSchema:()=>je});var be=t.lazy(()=>t.union([t.string().describe('String value or property path (e.g., "data.id")'),t.number().describe("Numeric value"),t.boolean().describe("Boolean value"),t.lazy(()=>V),t.array(be).describe("Array of values")])).meta({id:"MappingValue",title:"Mapping.Value",description:"Polymorphic transform primitive used in every mapping field. A string path, constant, operator object (map/loop/set/condition/consent), or array of values."}),fe=t.array(be).describe("Array of transformation values"),ge=t.lazy(()=>t.tuple([be,be]).describe("Loop transformation: [source, transform] tuple for array processing")),he=t.lazy(()=>t.array(be).describe("Set: Array of values for selection or combination")),ve=t.lazy(()=>t.record(t.string(),be).describe("Map: Object mapping keys to transformation values")),Se=V=t.object({key:t.string().optional().describe('Property path to extract from event (e.g., "data.id", "user.email")'),value:t.union([t.string(),t.number(),t.boolean()]).optional().describe("Static primitive value"),fn:t.string().optional().describe("Custom transformation function as string (serialized)"),map:ve.optional().describe("Object mapping: transform event data to structured output"),loop:ge.optional().describe("Loop transformation: [source, transform] for array processing"),set:he.optional().describe("Set of values: combine or select from multiple values"),consent:Q.optional().describe("Required consent states to include this value"),condition:t.string().optional().describe("Condition function as string: return true to include value"),validate:t.string().optional().describe("Validation function as string: return true if value is valid")}).refine(e=>Object.keys(e).length>0,{message:"ValueConfig must have at least one property"}).describe("Value transformation configuration with multiple strategies"),ye=t.record(t.string(),be).describe("Policy rules for event pre-processing (key → value mapping)"),we=t.object({name:t.string().optional().describe('Custom event name override (e.g., "view_item" for "product view")'),data:t.union([be,fe]).optional().describe("Data transformation rules for event"),settings:t.any().optional().describe("Destination-specific settings for this event mapping"),condition:t.string().optional().describe("Condition function as string: return true to process event"),consent:Q.optional().describe("Required consent states to process this event"),policy:ye.optional().describe("Event-level policy overrides (applied after config-level policy)"),batch:t.number().optional().describe("Batch size: bundle N events for batch processing"),include:t.array(t.string()).optional().describe('Event sections (e.g. ["context", "globals"]) flattened into context.data'),ignore:t.boolean().optional().describe("Skip the event entirely. No push, no side effects. Use for suppression."),skip:t.boolean().optional().describe("Run side effects (settings.identify, ...) but skip the default push call.")}).meta({id:"MappingRule",title:"Mapping.Rule",description:"Configuration for transforming a single event at one stage of the flow (source or destination)."}).describe("Mapping rule for specific entity-action combination"),ke=t.record(t.string(),t.record(t.string(),t.union([we,t.array(we)])).optional()).describe('Event mapping rules: entity → action → Rule. Keys match event name split by space. Use "*" as wildcard for entity or action. Priority: exact > entity wildcard > action wildcard > global wildcard (*→*).'),Ce=t.object({consent:Q.optional().describe("Required consent states to process any events"),data:t.union([be,fe]).optional().describe("Global data transformation applied to all events"),include:t.array(t.string()).optional().describe("Event sections to flatten into context.data"),mapping:ke.optional().describe("Entity-action specific mapping rules"),policy:ye.optional().describe("Pre-processing policy rules applied before mapping")}).describe("Shared mapping configuration for sources and destinations"),xe=t.object({eventMapping:we.optional().describe("Resolved mapping rule for event"),mappingKey:t.string().optional().describe('Mapping key used (e.g., "product.view")')}).describe("Mapping resolution result"),je=o(be),Ee=o(Se),Re=o(ge),Pe=o(he),Je=o(ve),Ie=o(ye),Oe=o(we),De=o(ke),Ne=o(Ce),Me={};n(Me,{BatchSchema:()=>Ze,ConfigSchema:()=>He,ContextSchema:()=>_e,DLQSchema:()=>ln,DataSchema:()=>en,DestinationPolicySchema:()=>Ge,DestinationsSchema:()=>rn,InitDestinationsSchema:()=>on,InitSchema:()=>tn,InstanceSchema:()=>nn,PartialConfigSchema:()=>Fe,PushBatchContextSchema:()=>Qe,PushContextSchema:()=>Ke,PushEventSchema:()=>Xe,PushEventsSchema:()=>Ye,PushResultSchema:()=>sn,RefSchema:()=>an,ResultSchema:()=>cn,batchJsonSchema:()=>bn,configJsonSchema:()=>dn,contextJsonSchema:()=>un,instanceJsonSchema:()=>fn,partialConfigJsonSchema:()=>pn,pushContextJsonSchema:()=>mn,resultJsonSchema:()=>gn});var Te={};n(Te,{MatchExpressionSchema:()=>qe,NextRuleSchema:()=>Be,RoutableNextSchema:()=>We});var Le=t.enum(["eq","contains","prefix","suffix","regex","gt","lt","exists"]),ze=t.object({key:t.string(),operator:Le,value:t.string(),not:t.boolean().optional()}),qe=t.union([ze,t.object({and:t.array(t.lazy(()=>qe))}),t.object({or:t.array(t.lazy(()=>qe))})]),Ue=t.union([qe,t.literal("*")]),We=t.union([t.string(),t.array(t.string()),t.array(t.object({match:Ue,next:t.lazy(()=>We)}))]),Be=t.object({match:Ue,next:t.lazy(()=>We)}),Ae={};n(Ae,{CacheRuleSchema:()=>$e,CacheSchema:()=>Ve});var $e=t.object({match:t.union([qe,t.literal("*")]).describe("Match expression or wildcard to determine when this rule applies"),key:t.array(t.string()).min(1).describe("Dot-path fields used to build the cache key"),ttl:t.number().positive().describe("Time-to-live in seconds for cached entries"),update:t.record(t.string(),be).optional().describe("Response mutations applied on cache hit (key → Value mapping)")}),Ve=t.object({full:t.boolean().optional().describe("Stop flow on cache HIT (default: false). When true, skip remaining steps and return cached value."),store:t.string().optional().describe("Store ID for persistent caching (references a configured store)"),rules:t.array($e).min(1).describe("Cache rules — at least one required")}),He=t.object({consent:Q.optional().describe("Required consent states to send events to this destination"),settings:t.any().describe("Implementation-specific configuration").optional(),data:t.union([be,fe]).optional().describe("Global data transformation applied to all events for this destination"),include:t.array(t.string()).optional().describe("Event sections to flatten into context.data"),env:t.any().describe("Environment dependencies (platform-specific)").optional(),id:c.describe("Destination instance identifier (defaults to destination key)").optional(),init:t.boolean().describe("Whether to initialize immediately").optional(),loadScript:t.boolean().describe("Whether to load external script (for web destinations)").optional(),mapping:ke.optional().describe("Entity-action specific mapping rules for this destination"),policy:ye.optional().describe("Pre-processing policy rules applied before event mapping"),queue:t.boolean().describe("Whether to queue events when consent is not granted").optional(),require:t.array(t.string()).optional().describe('Defer destination initialization until these collector events fire (e.g., ["consent"])'),logger:t.object({level:t.union([t.number(),t.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:t.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),before:We.optional().describe("Post-collector transformer chain applied before this destination receives the event"),next:We.optional().describe("Post-push transformer chain. Runs after destination push completes; push response is available at ingest._response"),cache:Ve.optional().describe("Cache configuration for deduplication; skip push on cache HIT"),disabled:t.boolean().describe("Completely skip this destination (no init, no push, no queue)").optional(),mock:t.unknown().optional().describe("Return this value instead of calling push(). Dev/testing only.")}).describe("Destination configuration"),Fe=He.partial().describe("Partial destination configuration with all fields optional"),Ge=ye.describe("Destination policy rules for event pre-processing"),_e=t.object({collector:t.unknown().describe("Collector instance (runtime object)"),config:He.describe("Destination configuration"),data:t.union([t.unknown(),t.array(t.unknown())]).optional().describe("Transformed event data"),env:t.unknown().describe("Environment dependencies")}).describe("Destination context for init and push functions"),Ke=_e.extend({mapping:we.optional().describe("Resolved mapping rule for this specific event")}).describe("Push context with event-specific mapping"),Qe=Ke.describe("Batch push context with event-specific mapping"),Xe=t.object({event:ie.describe("The event to process"),mapping:we.optional().describe("Mapping rule for this event")}).describe("Event with optional mapping for batch processing"),Ye=t.array(Xe).describe("Array of events with mappings"),Ze=t.object({key:t.string().describe('Batch key (usually mapping key like "product.view")'),events:t.array(ie).describe("Array of events in batch"),data:t.array(t.union([t.unknown(),t.array(t.unknown())]).optional()).describe("Transformed data for each event"),mapping:we.optional().describe("Shared mapping rule for batch")}).describe("Batch of events grouped by mapping key"),en=t.union([t.unknown(),t.array(t.unknown())]).optional().describe("Transformed event data (Property, undefined, or array)"),nn=t.object({config:He.describe("Destination configuration"),queue:t.array(ie).optional().describe("Queued events awaiting consent"),dlq:t.array(t.tuple([ie,t.unknown()])).optional().describe("Dead letter queue (failed events with errors)"),type:t.string().optional().describe("Destination type identifier"),env:t.unknown().optional().describe("Environment dependencies"),init:t.unknown().optional().describe("Initialization function"),push:t.unknown().describe("Push function for single events"),pushBatch:t.unknown().optional().describe("Batch push function"),on:t.unknown().optional().describe("Event lifecycle hook function")}).describe("Destination instance (runtime object with functions)"),tn=t.object({code:nn.describe("Destination instance with implementation"),config:Fe.optional().describe("Partial configuration overrides"),env:t.unknown().optional().describe("Partial environment overrides")}).describe("Destination initialization configuration"),on=t.record(t.string(),tn).describe("Map of destination IDs to initialization configurations"),rn=t.record(t.string(),nn).describe("Map of destination IDs to runtime instances"),an=t.object({type:t.string().describe('Destination type ("gtag", "meta", "bigquery")'),data:t.unknown().optional().describe("Response from push()"),error:t.unknown().optional().describe("Error if failed")}).describe("Destination reference with type and response data"),sn=t.object({queue:t.array(ie).optional().describe("Events queued (awaiting consent)"),error:t.unknown().optional().describe("Error if push failed")}).describe("Push operation result"),cn=t.object({ok:t.boolean().describe("True if nothing failed"),event:t.unknown().optional().describe("The processed event"),done:t.record(t.string(),an).optional().describe("Destinations that processed successfully"),queued:t.record(t.string(),an).optional().describe("Destinations that queued events"),failed:t.record(t.string(),an).optional().describe("Destinations that failed to process")}).describe("Push result with destination outcomes"),ln=t.array(t.tuple([ie,t.unknown()])).describe("Dead letter queue: [(event, error), ...]"),dn=o(He),pn=o(Fe),un=o(_e),mn=o(Ke),bn=o(Ze),fn=o(nn),gn=o(cn),hn={};n(hn,{CommandTypeSchema:()=>vn,ConfigSchema:()=>Sn,DestinationsSchema:()=>xn,InitConfigSchema:()=>wn,InstanceSchema:()=>jn,PushContextSchema:()=>kn,SessionDataSchema:()=>yn,SourcesSchema:()=>Cn,commandTypeJsonSchema:()=>En,configJsonSchema:()=>Rn,initConfigJsonSchema:()=>Jn,instanceJsonSchema:()=>On,pushContextJsonSchema:()=>In,sessionDataJsonSchema:()=>Pn});var vn=t.union([t.enum(["action","config","consent","context","destination","elb","globals","hook","init","link","run","user","walker"]),t.string()]).describe("Collector command type: standard commands or custom string for extensions"),Sn=t.object({run:t.boolean().describe("Whether to run collector automatically on initialization").optional(),tagging:p,globalsStatic:G.describe("Static global properties that persist across collector runs"),sessionStatic:t.record(t.string(),t.unknown()).describe("Static session data that persists across collector runs"),logger:t.object({level:t.union([t.number(),t.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:t.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler)")}).describe("Core collector configuration"),yn=G.and(t.object({isStart:t.boolean().describe("Whether this is a new session start"),storage:t.boolean().describe("Whether storage is available"),id:c.describe("Session identifier").optional(),start:l.describe("Session start timestamp").optional(),marketing:t.literal(!0).optional().describe("Marketing attribution flag"),updated:l.describe("Last update timestamp").optional(),isNew:t.boolean().describe("Whether this is a new session").optional(),device:c.describe("Device identifier").optional(),count:d.describe("Event count in session").optional(),runs:d.describe("Number of runs").optional()})).describe("Session state and tracking data"),wn=Sn.partial().extend({consent:Q.optional().describe("Initial consent state"),user:X.optional().describe("Initial user data"),globals:G.optional().describe("Initial global properties"),sources:t.unknown().optional().describe("Source configurations"),destinations:t.unknown().optional().describe("Destination configurations"),transformers:t.unknown().optional().describe("Transformer configurations"),stores:t.unknown().optional().describe("Store configurations"),custom:G.optional().describe("Initial custom implementation-specific properties"),hooks:t.unknown().optional().describe("Pipeline observation hooks")}).describe("Collector initialization configuration with initial state"),kn=t.object({mapping:Ce.optional().describe("Source-level mapping configuration")}).describe("Push context with optional source mapping"),Cn=t.record(t.string(),t.unknown()).describe("Map of source IDs to source instances"),xn=t.record(t.string(),t.unknown()).describe("Map of destination IDs to destination instances"),jn=t.object({push:t.unknown().describe("Push function for processing events"),command:t.unknown().describe("Command function for walker commands"),allowed:t.boolean().describe("Whether event processing is allowed"),config:Sn.describe("Current collector configuration"),consent:Q.describe("Current consent state"),count:t.number().describe("Event count (increments with each event)"),custom:G.describe("Custom implementation-specific properties"),sources:Cn.describe("Registered source instances"),destinations:xn.describe("Registered destination instances"),globals:G.describe("Current global properties"),group:t.string().describe("Event grouping identifier"),hooks:t.unknown().describe("Lifecycle hook functions"),on:t.unknown().describe("Event lifecycle configuration"),queue:t.array(ie).describe("Queued events awaiting processing"),round:t.number().describe("Collector run count (increments with each run)"),session:t.union([yn]).describe("Current session state"),timing:t.number().describe("Event processing timing information"),user:X.describe("Current user data"),version:t.string().describe("Walker implementation version")}).describe("Collector instance with state and methods"),En=o(vn),Rn=o(Sn),Pn=o(yn),Jn=o(wn),In=o(kn),On=o(jn),Dn={};n(Dn,{BaseEnvSchema:()=>Nn,ConfigSchema:()=>Mn,InitSchema:()=>zn,InitSourceSchema:()=>qn,InitSourcesSchema:()=>Un,InstanceSchema:()=>Ln,PartialConfigSchema:()=>Tn,baseEnvJsonSchema:()=>Wn,configJsonSchema:()=>Bn,initSourceJsonSchema:()=>Vn,initSourcesJsonSchema:()=>Hn,instanceJsonSchema:()=>$n,partialConfigJsonSchema:()=>An});var Nn=t.object({push:t.unknown().describe("Collector push function"),command:t.unknown().describe("Collector command function"),sources:t.unknown().optional().describe("Map of registered source instances"),elb:t.unknown().describe("Public API function (alias for collector.push)")}).catchall(t.unknown()).describe("Base environment for dependency injection - platform-specific sources extend this"),Mn=Ce.extend({settings:t.any().describe("Implementation-specific configuration").optional(),env:Nn.optional().describe("Environment dependencies (platform-specific)"),id:c.describe("Source identifier (defaults to source key)").optional(),primary:t.boolean().describe("Mark as primary (only one can be primary)").optional(),require:t.array(t.string()).optional().describe('Defer source initialization until these collector events fire (e.g., ["consent"])'),logger:t.object({level:t.union([t.number(),t.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:t.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),ingest:t.union([be,fe]).optional().describe("Ingest metadata extraction mapping. Extracts values from raw request objects (Express req, Lambda event) using mapping syntax."),disabled:t.boolean().describe("Completely skip this source (no init, no event capture)").optional()}).describe("Source configuration with mapping and environment"),Tn=Mn.partial().describe("Partial source configuration with all fields optional"),Ln=t.object({type:t.string().describe('Source type identifier (e.g., "browser", "dataLayer")'),config:Mn.describe("Current source configuration"),push:t.any().describe("Push function - THE HANDLER (flexible signature for platform compatibility)"),destroy:t.any().optional().describe("Cleanup function called when source is removed"),on:t.unknown().optional().describe("Lifecycle hook function for event types")}).describe("Source instance with push handler and lifecycle methods"),zn=t.any().describe("Source initialization function: (config, env) => Instance | Promise<Instance>"),qn=t.object({code:zn.describe("Source initialization function"),config:Tn.optional().describe("Partial configuration overrides"),env:Nn.partial().optional().describe("Partial environment overrides"),primary:t.boolean().optional().describe("Mark as primary source (only one can be primary)")}).describe("Source initialization configuration"),Un=t.record(t.string(),qn).describe("Map of source IDs to initialization configurations"),Wn=o(Nn),Bn=o(Mn),An=o(Tn),$n=o(Ln),Vn=o(qn),Hn=o(Un),Fn={};n(Fn,{ConfigSchema:()=>Gn,PartialConfigSchema:()=>_n,configJsonSchema:()=>Kn,partialConfigJsonSchema:()=>Qn});var Gn=t.object({settings:t.any().describe("Implementation-specific configuration").optional(),env:t.any().describe("Environment dependencies (platform-specific)").optional(),id:c.describe("Transformer instance identifier (defaults to transformer key)").optional(),logger:t.object({level:t.union([t.number(),t.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:t.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults"),before:We.optional().describe("Pre-transformer chain that runs before this transformer pushes"),next:We.optional().describe("Graph wiring to the next transformer in the chain"),cache:Ve.optional().describe("Step-level cache configuration for this transformer"),init:t.boolean().describe("Whether to initialize immediately").optional(),disabled:t.boolean().describe("Completely skip this transformer in chains").optional(),mock:t.unknown().optional().describe("Return this value instead of calling push(). Global mock for all chains. Dev/testing only."),chainMocks:t.record(t.string(),t.unknown()).optional().describe("Path-specific mock values keyed by chain path. Takes precedence over global mock. Dev/testing only.")}).describe("Transformer configuration"),_n=Gn.partial().describe("Partial transformer configuration with all fields optional"),Kn=o(Gn),Qn=o(_n),Xn={};n(Xn,{ConfigSchema:()=>Yn,PartialConfigSchema:()=>Zn,configJsonSchema:()=>ei,partialConfigJsonSchema:()=>ni});var Yn=t.object({settings:t.any().describe("Implementation-specific configuration").optional(),env:t.any().describe("Environment dependencies (platform-specific)").optional(),id:c.describe("Store instance identifier (defaults to store key)").optional(),logger:t.object({level:t.union([t.number(),t.enum(["ERROR","WARN","INFO","DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"),handler:t.any().optional().describe("Custom log handler function")}).optional().describe("Logger configuration (level, handler) to override the collector defaults")}).describe("Store configuration"),Zn=Yn.partial().describe("Partial store configuration with all fields optional"),ei=o(Yn),ni=o(Zn),ii={};n(ii,{BundleSchema:()=>li,ConfigSchema:()=>ji,ContractActionsSchema:()=>yi,ContractEntrySchema:()=>ki,ContractEventsSchema:()=>wi,ContractSchema:()=>Ci,ContractSchemaEntry:()=>Si,DefinitionsSchema:()=>ri,DestinationReferenceSchema:()=>hi,InlineCodeSchema:()=>ui,OverridesSchema:()=>ci,PackagesSchema:()=>si,PrimitiveSchema:()=>ti,ServerSchema:()=>pi,SettingsSchema:()=>xi,SourceReferenceSchema:()=>fi,StepExampleSchema:()=>mi,StepExamplesSchema:()=>bi,StoreReferenceSchema:()=>vi,TransformerReferenceSchema:()=>gi,VariablesSchema:()=>oi,WebSchema:()=>di,configJsonSchema:()=>Ii,contractEntryJsonSchema:()=>Li,contractJsonSchema:()=>zi,destinationReferenceJsonSchema:()=>Ni,parseConfig:()=>Ei,parseSettings:()=>Pi,safeParseConfig:()=>Ri,safeParseSettings:()=>Ji,settingsJsonSchema:()=>Oi,sourceReferenceJsonSchema:()=>Di,storeReferenceJsonSchema:()=>Ti,transformerReferenceJsonSchema:()=>Mi});var ti=t.union([t.string(),t.number(),t.boolean()]).describe("Primitive value: string, number, or boolean"),oi=t.record(t.string(),ti).describe("Variables for interpolation"),ri=t.record(t.string(),t.unknown()).describe("Reusable configuration definitions"),ai=/^(@[a-z0-9\-~][a-z0-9\-._~]*\/)?[a-z0-9\-~][a-z0-9\-._~]*$/,si=t.record(t.string().regex(ai,"Invalid npm package name"),t.object({version:t.string().optional(),imports:t.array(t.string()).optional(),path:t.string().optional()})).describe("NPM packages to bundle"),ci=t.record(t.string().regex(ai,"Invalid npm package name"),t.string().min(1,"Override version cannot be empty")).describe("Transitive dependency version overrides"),li=t.object({packages:si.optional().describe("NPM packages to bundle"),overrides:ci.optional().describe("Transitive dependency overrides")}).strict().describe("Bundle configuration (packages + overrides)"),di=t.object({windowCollector:t.string().default("collector").optional().describe('Window property name for the collector instance (default: "collector")'),windowElb:t.string().default("elb").optional().describe('Window property name for the elb command queue (default: "elb")')}).describe("Web platform configuration"),pi=t.object({}).passthrough().describe("Server platform configuration (reserved for future options)"),ui=t.object({push:t.string().min(1,"Push function cannot be empty").describe('JavaScript function for processing events. Must start with "$code:" prefix. Example: "$code:(event) => { console.log(event); }"'),type:t.string().optional().describe("Optional type identifier for the inline instance"),init:t.string().optional().describe("Optional initialization function. Use $code: prefix for inline JavaScript.")}).describe("Inline code for custom sources/transformers/destinations"),mi=t.object({title:t.string().optional().describe("Human-readable title (overrides default heading)"),description:t.string().optional().describe("Human-readable description"),public:t.boolean().optional().describe("Whether this example is shown in docs/UI/MCP default output (default: true). Set false for test-only fixtures."),in:t.unknown().optional().describe("Input to the step"),trigger:t.object({type:t.string().optional().describe("Trigger mechanism (e.g., click, POST, load)"),options:t.unknown().optional().describe("Mechanism-specific options")}).optional().describe("Source trigger metadata"),mapping:t.unknown().optional().describe("Mapping configuration"),out:t.unknown().optional().describe("Expected output from the step"),command:t.enum(["config","consent","user","run"]).optional().describe("Invoke elb('walker <command>', in) instead of pushing in as an event")}).describe("Named example with input/output pair"),bi=t.record(t.string(),mi).describe("Named step examples for testing and documentation"),fi=t.object({package:t.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-source-browser@2.0.0")'),code:t.union([t.string(),ui]).optional().describe('Either a named export string (e.g., "sourceExpress") or an inline code object with push function'),config:t.unknown().optional().describe("Source-specific configuration object"),env:t.unknown().optional().describe("Source environment configuration"),primary:t.boolean().optional().describe("Mark as primary source (provides main elb). Only one source should be primary."),variables:oi.optional().describe("Source-level variables (highest priority in cascade)"),definitions:ri.optional().describe("Source-level definitions (highest priority in cascade)"),next:We.optional().describe("Pre-collector transformer chain. String, string[], or NextRule[] for conditional routing based on ingest data."),before:We.optional().describe("Pre-source transformer chain (consent-exempt). Handles transport-level preprocessing."),examples:bi.optional().describe("Named step examples for testing and documentation (stripped during bundling)"),cache:Ve.optional().describe("Cache configuration for this source (match → key → ttl rules)")}).describe("Source package reference with configuration"),gi=t.object({package:t.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/transformer-enricher@1.0.0")'),code:t.union([t.string(),ui]).optional().describe('Either a named export string (e.g., "transformerEnricher") or an inline code object with push function'),config:t.unknown().optional().describe("Transformer-specific configuration object"),env:t.unknown().optional().describe("Transformer environment configuration"),before:We.optional().describe("Pre-transformer chain. Runs before this transformer push function."),next:We.optional().describe("Next transformer in chain. String, string[], or NextRule[] for conditional routing."),variables:oi.optional().describe("Transformer-level variables (highest priority in cascade)"),definitions:ri.optional().describe("Transformer-level definitions (highest priority in cascade)"),examples:bi.optional().describe("Named step examples for testing and documentation (stripped during bundling)"),cache:Ve.optional().describe("Cache configuration for this transformer (match → key → ttl rules)")}).describe("Transformer package reference with configuration"),hi=t.object({package:t.string().min(1,"Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-destination-gtag@2.0.0")'),code:t.union([t.string(),ui]).optional().describe('Either a named export string (e.g., "destinationAnalytics") or an inline code object with push function'),config:t.unknown().optional().describe("Destination-specific configuration object"),env:t.unknown().optional().describe("Destination environment configuration"),variables:oi.optional().describe("Destination-level variables (highest priority in cascade)"),definitions:ri.optional().describe("Destination-level definitions (highest priority in cascade)"),before:We.optional().describe("Post-collector transformer chain. String, string[], or NextRule[] for conditional routing."),next:We.optional().describe("Post-push transformer chain. Push response available at context.ingest._response."),examples:bi.optional().describe("Named step examples for testing and documentation (stripped during bundling)"),cache:Ve.optional().describe("Cache configuration for this destination (match → key → ttl rules)")}).describe("Destination package reference with configuration"),vi=t.object({package:t.string().min(1,"Package name cannot be empty").optional().describe("Store package specifier with optional version"),code:t.union([t.string(),ui]).optional().describe("Named export string or inline code definition"),config:t.unknown().optional().describe("Store-specific configuration object"),env:t.unknown().optional().describe("Store environment configuration"),variables:oi.optional().describe("Store-level variables (highest priority in cascade)"),definitions:ri.optional().describe("Store-level definitions (highest priority in cascade)"),examples:bi.optional().describe("Named step examples for testing and documentation (stripped during bundling)")}).describe("Store package reference with configuration"),Si=t.record(t.string(),t.unknown()).describe("JSON Schema object for event validation with description/examples annotations"),yi=t.record(t.string(),Si).describe("Action-level contract entries"),wi=t.record(t.string(),yi).describe("Entity-action event schemas"),ki=t.object({extends:t.string().optional().describe("Inherit from another named contract"),tagging:t.number().int().min(0).optional().describe("Contract version number"),description:t.string().optional().describe("Human-readable description"),globals:Si.optional().describe("JSON Schema for event.globals"),context:Si.optional().describe("JSON Schema for event.context"),custom:Si.optional().describe("JSON Schema for event.custom"),user:Si.optional().describe("JSON Schema for event.user"),consent:Si.optional().describe("JSON Schema for event.consent"),events:wi.optional().describe("Entity-action event schemas")}).describe("Named contract entry with optional sections and events"),Ci=t.record(t.string(),ki).describe("Named contracts with optional extends inheritance"),xi=t.object({web:di.optional().describe("Web platform configuration (browser-based tracking). Mutually exclusive with server."),server:pi.optional().describe("Server platform configuration (Node.js). Mutually exclusive with web."),sources:t.record(t.string(),fi).optional().describe("Source configurations (data capture) keyed by unique identifier"),destinations:t.record(t.string(),hi).optional().describe("Destination configurations (data output) keyed by unique identifier"),transformers:t.record(t.string(),gi).optional().describe("Transformer configurations (event transformation) keyed by unique identifier"),stores:t.record(t.string(),vi).optional().describe("Store configurations (key-value storage) keyed by unique identifier"),collector:t.unknown().optional().describe("Collector configuration for event processing (uses Collector.InitConfig)"),bundle:li.optional().describe("Build-time configuration (packages + overrides)"),packages:t.unknown().optional().refine(e=>void 0===e,{message:"`packages` must live under `bundle.packages`. Move your packages block to `flow.<name>.bundle.packages`. This is a breaking change — see CHANGELOG migration guide."}).describe("Legacy top-level packages (moved to bundle.packages)"),variables:oi.optional().describe("Flow-level variables (override Config.variables, overridden by source/destination variables)"),definitions:ri.optional().describe("Flow-level definitions (extend Config.definitions, overridden by source/destination definitions)")}).refine(e=>{const n=void 0!==e.web,i=void 0!==e.server;return(n||i)&&!(n&&i)},{message:'Exactly one of "web" or "server" must be present'}).describe("Single flow settings for one deployment target"),ji=t.object({$schema:t.string().url("Schema URL must be a valid URL").optional().describe('JSON Schema reference for IDE validation (e.g., "https://walkeros.io/schema/flow/v2.json")'),include:t.array(t.string()).optional().describe("Folders to include in the bundle output"),variables:oi.optional().describe("Shared variables for interpolation across all flows (use $var.name syntax)"),definitions:ri.optional().describe("Reusable configuration definitions (use $def.name syntax)"),flows:t.record(t.string(),xi).refine(e=>Object.keys(e).length>0,{message:"At least one flow is required"}).describe("Named flow configurations (e.g., production, staging, development)")}).extend({version:t.literal(3).describe("Configuration schema version"),contract:Ci.optional().describe("Named contracts with extends inheritance and dot-path references")}).describe("walkerOS flow configuration (walkeros.config.json)");function Ei(e){return ji.parse(e)}function Ri(e){return ji.safeParse(e)}function Pi(e){return xi.parse(e)}function Ji(e){return xi.safeParse(e)}var Ii=t.toJSONSchema(ji,{target:"draft-7"}),Oi=o(xi),Di=o(fi),Ni=o(hi),Mi=o(gi),Ti=o(vi),Li=o(ki),zi=o(Ci);import{z as qi}from"zod";var Ui=qi.object({lang:qi.string().optional().describe("Language identifier (e.g. json, sql, bash, typescript)"),code:qi.string().describe("Code snippet")}),Wi=qi.object({text:qi.string().describe("Short actionable hint text focused on walkerOS usage"),code:qi.array(Ui).optional().describe("Optional code snippets")}),Bi=qi.record(qi.string(),Wi).describe("Keyed hints for AI consumption — lightweight context beyond schemas and examples"),Ai=t.object({param:t.string().describe("Lowercase URL parameter name. Match is case-insensitive on lookup."),platform:t.string().describe("Canonical platform identifier (lowercase, kebab-case).")});function $i(e){let n;try{n=JSON.parse(e)}catch(n){const{line:i,column:t}=function(e,n){if(e instanceof SyntaxError){const i=e.message.match(/position\s+(\d+)/);if(i){return Vi(n,parseInt(i[1],10))}const t=e.message.match(/line\s+(\d+)\s+column\s+(\d+)/);if(t)return{line:parseInt(t[1],10),column:parseInt(t[2],10)}}return{line:1,column:1}}(n,e);return{valid:!1,errors:[{message:n instanceof Error?n.message:"Invalid JSON",severity:"error",line:i,column:t}],warnings:[]}}const i=[],t=[],o=ji.safeParse(n);if(!o.success)for(const n of o.error.issues){const t=n.path.join("."),o=Fi(e,n.path);i.push({message:n.message,severity:"error",path:t||"root",...o})}const r=function(e){if(!(Gi(e)&&"version"in e&&"flows"in e&&Gi(e.flows)))return;const n={},i={},t=[],o=[],r=[],a=[],s=[];let c;Ki(n,e.variables),Qi(i,e.definitions),function(e,n){if(!Gi(n))return;for(const[,i]of Object.entries(n)){if(!Gi(i))continue;const n=i.events;if(Gi(n))for(const[i,t]of Object.entries(n)){if(!Gi(t))continue;const n=e.find(e=>e.entity===i),o=Object.keys(t);if(n)for(const e of o)n.actions.includes(e)||n.actions.push(e);else e.push({entity:i,actions:o})}}}(s,e.contract);for(const s of Object.values(e.flows))if(Gi(s)){c||("web"in s?c="web":"server"in s&&(c="server")),Ki(n,s.variables),Qi(i,s.definitions);for(const e of["sources","destinations","transformers"]){const l="sources"===e?"source":"destinations"===e?"destination":"transformer",d="sources"===e?t:"destinations"===e?o:r;if(Gi(s[e]))for(const[t,o]of Object.entries(s[e]))d.push(t),Gi(o)&&(Ki(n,o.variables),Qi(i,o.definitions),"string"==typeof o.package&&a.push({package:o.package,shortName:t,type:l,platform:c||"web"}))}}const l={variables:n,definitions:i,stepNames:{sources:t,destinations:o,transformers:r}};c&&(l.platform=c);a.length>0&&(l.packages=a);s.length>0&&(l.contract=s);return l}(n);if(r){const n=function(e,n){const i=[];if(n.variables){const t=/\$var\.(\w+)/g;let o;for(;null!==(o=t.exec(e));)if(!(o[1]in n.variables)){const t=Hi(e,o.index,o[0].length);i.push({message:`Unknown variable "$var.${o[1]}". Defined: ${Object.keys(n.variables).join(", ")||"none"}`,severity:"warning",path:`$var.${o[1]}`,...t})}}if(n.definitions){const t=/\$def\.(\w+)/g;let o;for(;null!==(o=t.exec(e));)if(!(o[1]in n.definitions)){const t=Hi(e,o.index,o[0].length);i.push({message:`Unknown definition "$def.${o[1]}". Defined: ${Object.keys(n.definitions).join(", ")||"none"}`,severity:"warning",path:`$def.${o[1]}`,...t})}}return i}(e,r);t.push(...n)}return{valid:0===i.length,errors:i,warnings:t,context:r}}function Vi(e,n){let i=1,t=1;for(let o=0;o<n&&o<e.length;o++)"\n"===e[o]?(i++,t=1):t++;return{line:i,column:t}}function Hi(e,n,i){const t=Vi(e,n),o=Vi(e,n+i);return{line:t.line,column:t.column,endLine:o.line,endColumn:o.column}}function Fi(e,n){if(0===n.length)return{line:1,column:1};const i=n[n.length-1];if("string"==typeof i){const n=`"${i}"`,t=e.lastIndexOf(n);if(-1!==t)return Vi(e,t)}return{line:1,column:1}}function Gi(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function _i(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e}function Ki(e,n){if(Gi(n))for(const[i,t]of Object.entries(n))_i(t)&&(e[i]=t)}function Qi(e,n){if(Gi(n))for(const[i,t]of Object.entries(n))e[i]=t}function Xi(e,n){const i=[],t={};for(const[n,o]of Object.entries(e)){o.required&&i.push(n);const e={type:o.type};if(o.description&&(e.description=o.description),o.pattern&&(e.pattern=o.pattern),void 0!==o.minLength&&(e.minLength=o.minLength),void 0!==o.maxLength&&(e.maxLength=o.maxLength),void 0!==o.minimum&&(e.minimum=o.minimum),void 0!==o.maximum&&(e.maximum=o.maximum),o.enum&&(e.enum=[...o.enum]),void 0!==o.default&&(e.default=o.default),"object"===o.type&&o.properties){const n={};for(const[e,i]of Object.entries(o.properties))n[e]=Yi(i);e.properties=n}"array"===o.type&&o.items&&(e.items=Yi(o.items)),t[n]=e}const o={type:"object",properties:t};return n&&(o.title=n),i.length>0&&(o.required=i),o}function Yi(e){const n={type:e.type};if(e.description&&(n.description=e.description),e.pattern&&(n.pattern=e.pattern),void 0!==e.minLength&&(n.minLength=e.minLength),void 0!==e.maxLength&&(n.maxLength=e.maxLength),void 0!==e.minimum&&(n.minimum=e.minimum),void 0!==e.maximum&&(n.maximum=e.maximum),e.enum&&(n.enum=[...e.enum]),void 0!==e.default&&(n.default=e.default),"object"===e.type&&e.properties){const i={};for(const[n,t]of Object.entries(e.properties))i[n]=Yi(t);n.properties=i}return"array"===e.type&&e.items&&(n.items=Yi(e.items)),n}function Zi(e,n){const i={type:"array",items:Yi(e)};return void 0!==n?.minItems&&(i.minItems=n.minItems),void 0!==n?.maxItems&&(i.maxItems=n.maxItems),n?.description&&(i.description=n.description),n?.title&&(i.title=n.title),i}function et(e,n="string",i){const t={type:n,enum:[...e]};return i?.description&&(t.description=i.description),i?.title&&(t.title=i.title),t}function nt(e,n,i){return Zi({type:"object"},{minItems:2,maxItems:2,description:i||"Tuple with exactly 2 elements [source, transform]"})}function it(e){return t.toJSONSchema(e,{target:"draft-7"})}var tt=new Set(["env","onError","onLog","primary"]),ot={source:Dn.configJsonSchema,destination:Me.configJsonSchema};function rt(e,n){const i=ot[e];if(!i||!i.properties){return{type:"object",properties:{settings:n.settings?at(n.settings):{description:"Implementation-specific configuration"}}}}const t=JSON.parse(JSON.stringify(i)),o=t.properties;for(const e of tt)delete o[e];return n.settings&&(o.settings=at(n.settings)),t}function at(e){const{$schema:n,...i}=e;return i}function st(e){return 0===e.length?"// no output":e.map(ct).join(";\n\n")}function ct(e){const[n,...i]=e,t=i.map(lt).join(", ");return"return"===n?t?`return ${t}`:"return":`${n}(${t})`}function lt(e){return void 0===e?"undefined":null===e?"null":"function"==typeof e?"[Function]":JSON.stringify(e,null,2)}export{Ai as ClickIdEntrySchema,st as formatOut,rt as mergeConfigSchema,i as schemas,t as z,it as zodToSchema};//# sourceMappingURL=dev.mjs.map