@walkeros/collector 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/dev.d.mts +8 -4
  2. package/dist/dev.d.ts +8 -4
  3. package/dist/dev.js +1 -1
  4. package/dist/dev.js.map +1 -1
  5. package/dist/dev.mjs +1 -1
  6. package/dist/dev.mjs.map +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +1 -1
  10. package/dist/index.mjs.map +1 -1
  11. package/package.json +2 -2
  12. package/dist/__tests__/auto-run.test.d.ts +0 -2
  13. package/dist/__tests__/auto-run.test.d.ts.map +0 -1
  14. package/dist/__tests__/auto-run.test.js +0 -105
  15. package/dist/__tests__/auto-run.test.js.map +0 -1
  16. package/dist/__tests__/consent.test.d.ts +0 -2
  17. package/dist/__tests__/consent.test.d.ts.map +0 -1
  18. package/dist/__tests__/consent.test.js +0 -21
  19. package/dist/__tests__/consent.test.js.map +0 -1
  20. package/dist/__tests__/create-flow.test.d.ts +0 -2
  21. package/dist/__tests__/create-flow.test.d.ts.map +0 -1
  22. package/dist/__tests__/create-flow.test.js +0 -69
  23. package/dist/__tests__/create-flow.test.js.map +0 -1
  24. package/dist/__tests__/destination.test.d.ts +0 -2
  25. package/dist/__tests__/destination.test.d.ts.map +0 -1
  26. package/dist/__tests__/destination.test.js +0 -242
  27. package/dist/__tests__/destination.test.js.map +0 -1
  28. package/dist/__tests__/handle.test.d.ts +0 -2
  29. package/dist/__tests__/handle.test.d.ts.map +0 -1
  30. package/dist/__tests__/handle.test.js +0 -78
  31. package/dist/__tests__/handle.test.js.map +0 -1
  32. package/dist/__tests__/mapping.test.d.ts +0 -2
  33. package/dist/__tests__/mapping.test.d.ts.map +0 -1
  34. package/dist/__tests__/mapping.test.js +0 -310
  35. package/dist/__tests__/mapping.test.js.map +0 -1
  36. package/dist/__tests__/source.test.d.ts +0 -2
  37. package/dist/__tests__/source.test.d.ts.map +0 -1
  38. package/dist/__tests__/source.test.js +0 -306
  39. package/dist/__tests__/source.test.js.map +0 -1
  40. package/dist/__tests__/start-flow.test.d.ts +0 -2
  41. package/dist/__tests__/start-flow.test.d.ts.map +0 -1
  42. package/dist/__tests__/start-flow.test.js +0 -167
  43. package/dist/__tests__/start-flow.test.js.map +0 -1
  44. package/dist/__tests__/walker-entity.test.d.ts +0 -2
  45. package/dist/__tests__/walker-entity.test.d.ts.map +0 -1
  46. package/dist/__tests__/walker-entity.test.js +0 -52
  47. package/dist/__tests__/walker-entity.test.js.map +0 -1
  48. package/dist/collector.d.ts +0 -3
  49. package/dist/collector.d.ts.map +0 -1
  50. package/dist/collector.js +0 -59
  51. package/dist/collector.js.map +0 -1
  52. package/dist/command.d.ts +0 -12
  53. package/dist/command.d.ts.map +0 -1
  54. package/dist/command.js +0 -20
  55. package/dist/command.js.map +0 -1
  56. package/dist/consent.d.ts +0 -10
  57. package/dist/consent.d.ts.map +0 -1
  58. package/dist/consent.js +0 -30
  59. package/dist/consent.js.map +0 -1
  60. package/dist/constants.d.ts +0 -13
  61. package/dist/constants.d.ts.map +0 -1
  62. package/dist/constants.js +0 -35
  63. package/dist/constants.js.map +0 -1
  64. package/dist/destination.d.ts +0 -56
  65. package/dist/destination.d.ts.map +0 -1
  66. package/dist/destination.js +0 -289
  67. package/dist/destination.js.map +0 -1
  68. package/dist/dev.d.ts.map +0 -1
  69. package/dist/elb.d.ts +0 -11
  70. package/dist/elb.d.ts.map +0 -1
  71. package/dist/elb.js +0 -60
  72. package/dist/elb.js.map +0 -1
  73. package/dist/flow.d.ts +0 -4
  74. package/dist/flow.d.ts.map +0 -1
  75. package/dist/flow.js +0 -44
  76. package/dist/flow.js.map +0 -1
  77. package/dist/handle.d.ts +0 -29
  78. package/dist/handle.d.ts.map +0 -1
  79. package/dist/handle.js +0 -161
  80. package/dist/handle.js.map +0 -1
  81. package/dist/index.d.ts.map +0 -1
  82. package/dist/on.d.ts +0 -19
  83. package/dist/on.d.ts.map +0 -1
  84. package/dist/on.js +0 -116
  85. package/dist/on.js.map +0 -1
  86. package/dist/push.d.ts +0 -11
  87. package/dist/push.d.ts.map +0 -1
  88. package/dist/push.js +0 -43
  89. package/dist/push.js.map +0 -1
  90. package/dist/schemas.d.ts +0 -6
  91. package/dist/schemas.d.ts.map +0 -1
  92. package/dist/schemas.js +0 -37
  93. package/dist/schemas.js.map +0 -1
  94. package/dist/source.d.ts +0 -10
  95. package/dist/source.d.ts.map +0 -1
  96. package/dist/source.js +0 -40
  97. package/dist/source.js.map +0 -1
  98. package/dist/types/collector.d.ts +0 -19
  99. package/dist/types/collector.d.ts.map +0 -1
  100. package/dist/types/collector.js +0 -2
  101. package/dist/types/collector.js.map +0 -1
  102. package/dist/types/index.d.ts +0 -2
  103. package/dist/types/index.d.ts.map +0 -1
  104. package/dist/types/index.js +0 -2
  105. package/dist/types/index.js.map +0 -1
package/dist/elb.js DELETED
@@ -1,60 +0,0 @@
1
- /**
2
- * Creates the default ELB source.
3
- * Routes between collector.push and collector.command based on input.
4
- * Provides backward-compatible flexible argument interface.
5
- *
6
- * @param collector - The walkerOS collector instance
7
- * @returns ELB source instance
8
- */
9
- export function createElbSource(collector) {
10
- return {
11
- type: 'elb',
12
- config: {},
13
- // The push function is the elb() interface users interact with
14
- push: async (eventOrCommand, data, options, context, nested, custom) => {
15
- // Detect walker commands
16
- if (typeof eventOrCommand === 'string' &&
17
- eventOrCommand.startsWith('walker ')) {
18
- const command = eventOrCommand.replace('walker ', '');
19
- return collector.command(command, data, options);
20
- }
21
- // Build event object
22
- let event;
23
- if (typeof eventOrCommand === 'string') {
24
- // Convert string to object: elb('page view', { title: 'Home' })
25
- event = { name: eventOrCommand };
26
- if (data && typeof data === 'object' && !Array.isArray(data)) {
27
- event.data = data;
28
- }
29
- }
30
- else if (eventOrCommand && typeof eventOrCommand === 'object') {
31
- // Use object directly: elb({ name: 'page view', data: {...} })
32
- event = eventOrCommand;
33
- // Merge additional data if provided
34
- if (data && typeof data === 'object' && !Array.isArray(data)) {
35
- event.data = {
36
- ...(event.data || {}),
37
- ...data,
38
- };
39
- }
40
- }
41
- else {
42
- // Invalid input
43
- return { ok: false, successful: [], queued: [], failed: [] };
44
- }
45
- // Add optional properties if provided
46
- if (context && typeof context === 'object') {
47
- event.context = context;
48
- }
49
- if (nested && Array.isArray(nested)) {
50
- event.nested = nested;
51
- }
52
- if (custom && typeof custom === 'object') {
53
- event.custom = custom;
54
- }
55
- // Call collector.push with event object
56
- return collector.push(event);
57
- },
58
- };
59
- }
60
- //# sourceMappingURL=elb.js.map
package/dist/elb.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"elb.js","sourceRoot":"","sources":["../src/elb.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,SAA6B;IAE7B,OAAO;QACL,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,EAAE;QAEV,+DAA+D;QAC/D,IAAI,EAAE,KAAK,EACT,cAAwB,EACxB,IAAc,EACd,OAAiB,EACjB,OAAiB,EACjB,MAA0B,EAC1B,MAA4B,EACH,EAAE;YAC3B,yBAAyB;YACzB,IACE,OAAO,cAAc,KAAK,QAAQ;gBAClC,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC,EACpC,CAAC;gBACD,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;gBACtD,OAAO,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YACnD,CAAC;YAED,qBAAqB;YACrB,IAAI,KAAgC,CAAC;YAErC,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;gBACvC,gEAAgE;gBAChE,KAAK,GAAG,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;gBACjC,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,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
- export declare function startFlow<ElbPush extends Elb.Fn = Elb.Fn>(initConfig?: Collector.InitConfig): Promise<StartFlow<ElbPush>>;
4
- //# sourceMappingURL=flow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,wBAAsB,SAAS,CAAC,OAAO,SAAS,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,EAC7D,UAAU,CAAC,EAAE,SAAS,CAAC,UAAU,GAChC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAkD7B"}
package/dist/flow.js DELETED
@@ -1,44 +0,0 @@
1
- import { collector } from './collector';
2
- import { createElbSource } from './elb';
3
- import { initSources } from './source';
4
- export async function startFlow(initConfig) {
5
- initConfig = initConfig || {};
6
- const instance = await collector(initConfig);
7
- // Create and register ELB source first
8
- const elbSource = createElbSource(instance);
9
- instance.sources.elb = elbSource;
10
- // Now initialize other sources with ELB source available
11
- const additionalSources = await initSources(instance, initConfig.sources || {});
12
- Object.assign(instance.sources, additionalSources);
13
- const { consent, user, globals, custom } = initConfig;
14
- if (consent)
15
- await instance.command('consent', consent);
16
- if (user)
17
- await instance.command('user', user);
18
- if (globals)
19
- Object.assign(instance.globals, globals);
20
- if (custom)
21
- Object.assign(instance.custom, custom);
22
- if (instance.config.run)
23
- await instance.command('run');
24
- // Determine the primary elb:
25
- // 1. Use explicitly marked primary source
26
- // 2. Use first non-elb source if any exist
27
- // 3. Fallback to ELB source
28
- let primaryElb = elbSource.push;
29
- const sources = Object.values(instance.sources).filter((source) => source.type !== 'elb');
30
- // First, check for explicitly marked primary source
31
- const markedPrimary = sources.find((source) => source.config.primary);
32
- if (markedPrimary) {
33
- primaryElb = markedPrimary.push;
34
- }
35
- else if (sources.length > 0) {
36
- // Use first source as default
37
- primaryElb = sources[0].push;
38
- }
39
- return {
40
- collector: instance,
41
- elb: primaryElb,
42
- };
43
- }
44
- //# sourceMappingURL=flow.js.map
package/dist/flow.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"flow.js","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,UAAiC;IAEjC,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,CAAC;IAE7C,uCAAuC;IACvC,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,QAAQ,CAAC,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC;IAEjC,yDAAyD;IACzD,MAAM,iBAAiB,GAAG,MAAM,WAAW,CACzC,QAAQ,EACR,UAAU,CAAC,OAAO,IAAI,EAAE,CACzB,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAEnD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IAEtD,IAAI,OAAO;QAAE,MAAM,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxD,IAAI,IAAI;QAAE,MAAM,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/C,IAAI,OAAO;QAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,MAAM;QAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEnD,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG;QAAE,MAAM,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAEvD,6BAA6B;IAC7B,0CAA0C;IAC1C,2CAA2C;IAC3C,4BAA4B;IAC5B,IAAI,UAAU,GAAW,SAAS,CAAC,IAAc,CAAC;IAElD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,CACpD,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,CAClC,CAAC;IAEF,oDAAoD;IACpD,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAChC,CAAC,MAAM,EAAE,EAAE,CAAE,MAAM,CAAC,MAAgC,CAAC,OAAO,CAC7D,CAAC;IAEF,IAAI,aAAa,EAAE,CAAC;QAClB,UAAU,GAAG,aAAa,CAAC,IAAc,CAAC;IAC5C,CAAC;SAAM,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,8BAA8B;QAC9B,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,IAAc,CAAC;IACzC,CAAC;IAED,OAAO;QACL,SAAS,EAAE,QAAQ;QACnB,GAAG,EAAE,UAAqB;KAC3B,CAAC;AACJ,CAAC"}
package/dist/handle.d.ts DELETED
@@ -1,29 +0,0 @@
1
- import type { Collector, WalkerOS, Elb } from '@walkeros/core';
2
- import type { RunState } from './types/collector';
3
- /**
4
- * Handles common commands.
5
- *
6
- * @param collector The walkerOS collector instance.
7
- * @param action The action to handle.
8
- * @param data The data to handle.
9
- * @param options The options to handle.
10
- * @returns A promise that resolves with the push result or undefined.
11
- */
12
- export declare function commonHandleCommand(collector: Collector.Instance, action: string, data?: unknown, options?: unknown): Promise<Elb.PushResult>;
13
- /**
14
- * Creates a full event from a partial event.
15
- *
16
- * @param collector The walkerOS collector instance.
17
- * @param partialEvent The partial event to transform.
18
- * @returns The full event.
19
- */
20
- export declare function createEvent(collector: Collector.Instance, partialEvent: WalkerOS.PartialEvent): WalkerOS.Event;
21
- /**
22
- * Runs the collector by setting it to allowed state and processing queued events.
23
- *
24
- * @param collector The walkerOS collector instance.
25
- * @param state Optional state to merge with the collector (user, globals, consent, custom).
26
- * @returns A promise that resolves with the push result.
27
- */
28
- export declare function runCollector(collector: Collector.Instance, state?: RunState): Promise<Elb.PushResult>;
29
- //# sourceMappingURL=handle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAe,GAAG,EAAM,MAAM,gBAAgB,CAAC;AAOhF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,SAAS,CAAC,QAAQ,EAC7B,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAkFzB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,SAAS,CAAC,QAAQ,EAC7B,YAAY,EAAE,QAAQ,CAAC,YAAY,GAClC,QAAQ,CAAC,KAAK,CAuDhB;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,SAAS,EAAE,SAAS,CAAC,QAAQ,EAC7B,KAAK,CAAC,EAAE,QAAQ,GACf,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAuDzB"}
package/dist/handle.js DELETED
@@ -1,161 +0,0 @@
1
- import { Const } from './constants';
2
- import { addDestination, pushToDestinations } from './destination';
3
- import { assign, getId, isFunction, isString } from '@walkeros/core';
4
- import { isObject } from '@walkeros/core';
5
- import { setConsent } from './consent';
6
- import { on, onApply } from './on';
7
- /**
8
- * Handles common commands.
9
- *
10
- * @param collector The walkerOS collector instance.
11
- * @param action The action to handle.
12
- * @param data The data to handle.
13
- * @param options The options to handle.
14
- * @returns A promise that resolves with the push result or undefined.
15
- */
16
- export async function commonHandleCommand(collector, action, data, options) {
17
- let result;
18
- switch (action) {
19
- case Const.Commands.Config:
20
- if (isObject(data)) {
21
- assign(collector.config, data, {
22
- shallow: false,
23
- });
24
- }
25
- break;
26
- case Const.Commands.Consent:
27
- if (isObject(data)) {
28
- result = await setConsent(collector, data);
29
- }
30
- break;
31
- case Const.Commands.Custom:
32
- if (isObject(data)) {
33
- collector.custom = assign(collector.custom, data);
34
- }
35
- break;
36
- case Const.Commands.Destination:
37
- if (isObject(data) && isFunction(data.push)) {
38
- result = await addDestination(collector, { code: data }, options);
39
- }
40
- break;
41
- case Const.Commands.Globals:
42
- if (isObject(data)) {
43
- collector.globals = assign(collector.globals, data);
44
- }
45
- break;
46
- case Const.Commands.On:
47
- if (isString(data)) {
48
- on(collector, data, options);
49
- }
50
- break;
51
- case Const.Commands.Ready:
52
- onApply(collector, 'ready');
53
- break;
54
- case Const.Commands.Run:
55
- result = await runCollector(collector, data);
56
- break;
57
- case Const.Commands.Session:
58
- onApply(collector, 'session');
59
- break;
60
- case Const.Commands.User:
61
- if (isObject(data)) {
62
- assign(collector.user, data, { shallow: false });
63
- }
64
- break;
65
- }
66
- return (result || {
67
- ok: true,
68
- successful: [],
69
- queued: [],
70
- failed: [],
71
- });
72
- }
73
- /**
74
- * Creates a full event from a partial event.
75
- *
76
- * @param collector The walkerOS collector instance.
77
- * @param partialEvent The partial event to transform.
78
- * @returns The full event.
79
- */
80
- export function createEvent(collector, partialEvent) {
81
- if (!partialEvent.name)
82
- throw new Error('Event name is required');
83
- const [entityValue, actionValue] = partialEvent.name.split(' ');
84
- if (!entityValue || !actionValue)
85
- throw new Error('Event name is invalid');
86
- ++collector.count;
87
- const { timestamp = Date.now(), group = collector.group, count = collector.count, } = partialEvent;
88
- const { name = `${entityValue} ${actionValue}`, data = {}, context = {}, globals = collector.globals, custom = {}, user = collector.user, nested = [], consent = collector.consent, id = `${timestamp}-${group}-${count}`, trigger = '', entity = entityValue, action = actionValue, timing = 0, version = {
89
- source: collector.version,
90
- tagging: collector.config.tagging || 0,
91
- }, source = { type: 'collector', id: '', previous_id: '' }, } = partialEvent;
92
- return {
93
- name,
94
- data,
95
- context,
96
- globals,
97
- custom,
98
- user,
99
- nested,
100
- consent,
101
- id,
102
- trigger,
103
- entity,
104
- action,
105
- timestamp,
106
- timing,
107
- group,
108
- count,
109
- version,
110
- source,
111
- };
112
- }
113
- /**
114
- * Runs the collector by setting it to allowed state and processing queued events.
115
- *
116
- * @param collector The walkerOS collector instance.
117
- * @param state Optional state to merge with the collector (user, globals, consent, custom).
118
- * @returns A promise that resolves with the push result.
119
- */
120
- export async function runCollector(collector, state) {
121
- // Set the collector to allowed state
122
- collector.allowed = true;
123
- // Reset count and generate new group ID
124
- collector.count = 0;
125
- collector.group = getId();
126
- // Update timing for this run
127
- collector.timing = Date.now();
128
- // Update collector state if provided
129
- if (state) {
130
- // Update consent if provided
131
- if (state.consent) {
132
- collector.consent = assign(collector.consent, state.consent);
133
- }
134
- // Update user if provided
135
- if (state.user) {
136
- collector.user = assign(collector.user, state.user);
137
- }
138
- // Update globals if provided
139
- if (state.globals) {
140
- collector.globals = assign(collector.config.globalsStatic || {}, state.globals);
141
- }
142
- // Update custom if provided
143
- if (state.custom) {
144
- collector.custom = assign(collector.custom, state.custom);
145
- }
146
- }
147
- // Reset destination queues
148
- Object.values(collector.destinations).forEach((destination) => {
149
- destination.queue = [];
150
- });
151
- // Reset collector queue for this run
152
- collector.queue = [];
153
- // Increase round counter
154
- collector.round++;
155
- // Process any queued events now that the collector is allowed
156
- const result = await pushToDestinations(collector);
157
- // Call the predefined run events
158
- onApply(collector, 'run');
159
- return result;
160
- }
161
- //# sourceMappingURL=handle.js.map
@@ -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C,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;QAC5D,WAAW,CAAC,KAAK,GAAG,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,qCAAqC;IACrC,SAAS,CAAC,KAAK,GAAG,EAAE,CAAC;IAErB,yBAAyB;IACzB,SAAS,CAAC,KAAK,EAAE,CAAC;IAElB,8DAA8D;IAC9D,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAEnD,iCAAiC;IACjC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAE1B,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,aAAa,CAAC;AAE5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC;AACrB,cAAc,UAAU,CAAC"}
package/dist/on.d.ts DELETED
@@ -1,19 +0,0 @@
1
- import type { Collector, On, WalkerOS } from '@walkeros/core';
2
- /**
3
- * Registers a callback for a specific event type.
4
- *
5
- * @param collector The walkerOS collector instance.
6
- * @param type The type of the event to listen for.
7
- * @param option The callback function or an array of callback functions.
8
- */
9
- export declare function on(collector: Collector.Instance, type: On.Types, option: WalkerOS.SingleOrArray<On.Options>): void;
10
- /**
11
- * Applies all registered callbacks for a specific event type.
12
- *
13
- * @param collector The walkerOS collector instance.
14
- * @param type The type of the event to apply the callbacks for.
15
- * @param options The options for the callbacks.
16
- * @param config The consent configuration.
17
- */
18
- export declare function onApply(collector: Collector.Instance, type: On.Types, options?: Array<On.Options>, config?: WalkerOS.Consent): void;
19
- //# sourceMappingURL=on.d.ts.map
package/dist/on.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"on.d.ts","sourceRoot":"","sources":["../src/on.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK9D;;;;;;GAMG;AACH,wBAAgB,EAAE,CAChB,SAAS,EAAE,SAAS,CAAC,QAAQ,EAC7B,IAAI,EAAE,EAAE,CAAC,KAAK,EACd,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,CAAC,QAe3C;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,SAAS,EAAE,SAAS,CAAC,QAAQ,EAC7B,IAAI,EAAE,EAAE,CAAC,KAAK,EACd,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,EAC3B,MAAM,CAAC,EAAE,QAAQ,CAAC,OAAO,QA2D1B"}
package/dist/on.js DELETED
@@ -1,116 +0,0 @@
1
- import { isArray } from '@walkeros/core';
2
- import { Const } from './constants';
3
- import { tryCatch } from '@walkeros/core';
4
- /**
5
- * Registers a callback for a specific event type.
6
- *
7
- * @param collector The walkerOS collector instance.
8
- * @param type The type of the event to listen for.
9
- * @param option The callback function or an array of callback functions.
10
- */
11
- export function on(collector, type, option) {
12
- const on = collector.on;
13
- const onType = on[type] || [];
14
- const options = isArray(option) ? option : [option];
15
- options.forEach((option) => {
16
- onType.push(option);
17
- });
18
- // Update collector on state
19
- on[type] = onType;
20
- // Execute the on function directly
21
- onApply(collector, type, options);
22
- }
23
- /**
24
- * Applies all registered callbacks for a specific event type.
25
- *
26
- * @param collector The walkerOS collector instance.
27
- * @param type The type of the event to apply the callbacks for.
28
- * @param options The options for the callbacks.
29
- * @param config The consent configuration.
30
- */
31
- export function onApply(collector, type, options, config) {
32
- // Use the optionally provided options
33
- let onConfig = options || [];
34
- if (!options) {
35
- // Get the collector on events
36
- onConfig = collector.on[type] || [];
37
- }
38
- // Calculate context data once for all sources and destinations
39
- let contextData;
40
- switch (type) {
41
- case Const.Commands.Consent:
42
- contextData = config || collector.consent;
43
- break;
44
- case Const.Commands.Session:
45
- contextData = collector.session;
46
- break;
47
- case Const.Commands.Ready:
48
- case Const.Commands.Run:
49
- default:
50
- contextData = undefined;
51
- break;
52
- }
53
- Object.values(collector.sources).forEach((source) => {
54
- if (source.on) {
55
- tryCatch(source.on)(type, contextData);
56
- }
57
- });
58
- Object.values(collector.destinations).forEach((destination) => {
59
- if (destination.on) {
60
- // Cast to runtime-compatible version for type safety
61
- const onFn = destination.on;
62
- tryCatch(onFn)(type, contextData);
63
- }
64
- });
65
- if (!onConfig.length)
66
- return; // No on-events registered, nothing to do
67
- switch (type) {
68
- case Const.Commands.Consent:
69
- onConsent(collector, onConfig, config);
70
- break;
71
- case Const.Commands.Ready:
72
- onReady(collector, onConfig);
73
- break;
74
- case Const.Commands.Run:
75
- onRun(collector, onConfig);
76
- break;
77
- case Const.Commands.Session:
78
- onSession(collector, onConfig);
79
- break;
80
- default:
81
- break;
82
- }
83
- }
84
- function onConsent(collector, onConfig, currentConsent) {
85
- const consentState = currentConsent || collector.consent;
86
- onConfig.forEach((consentConfig) => {
87
- // Collect functions whose consent keys match the rule keys directly
88
- // Directly execute functions whose consent keys match the rule keys
89
- Object.keys(consentState) // consent keys
90
- .filter((consent) => consent in consentConfig) // check for matching rule keys
91
- .forEach((consent) => {
92
- // Execute the function
93
- tryCatch(consentConfig[consent])(collector, consentState);
94
- });
95
- });
96
- }
97
- function onReady(collector, onConfig) {
98
- if (collector.allowed)
99
- onConfig.forEach((func) => {
100
- tryCatch(func)(collector);
101
- });
102
- }
103
- function onRun(collector, onConfig) {
104
- if (collector.allowed)
105
- onConfig.forEach((func) => {
106
- tryCatch(func)(collector);
107
- });
108
- }
109
- function onSession(collector, onConfig) {
110
- if (!collector.session)
111
- return;
112
- onConfig.forEach((func) => {
113
- tryCatch(func)(collector, collector.session);
114
- });
115
- }
116
- //# sourceMappingURL=on.js.map
package/dist/on.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"on.js","sourceRoot":"","sources":["../src/on.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,EAAE,CAChB,SAA6B,EAC7B,IAAc,EACd,MAA0C;IAE1C,MAAM,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC;IACxB,MAAM,MAAM,GAAsB,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAEpD,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACzB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,4BAA4B;IAC3B,EAAE,CAAC,IAAI,CAAmB,GAAG,MAAM,CAAC;IAErC,mCAAmC;IACnC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CACrB,SAA6B,EAC7B,IAAc,EACd,OAA2B,EAC3B,MAAyB;IAEzB,sCAAsC;IACtC,IAAI,QAAQ,GAAG,OAAO,IAAI,EAAE,CAAC;IAE7B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,8BAA8B;QAC9B,QAAQ,GAAG,SAAS,CAAC,E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,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACxB,QAAQ,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,SAAS,CAChB,SAA6B,EAC7B,QAAiC;IAEjC,IAAI,CAAC,SAAS,CAAC,OAAO;QAAE,OAAO;IAE/B,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,QAAQ,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/push.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { Collector, WalkerOS } from '@walkeros/core';
2
- /**
3
- * Creates the push function for the collector.
4
- * Handles source mapping, event creation, and routing to destinations.
5
- *
6
- * @param collector - The walkerOS collector instance
7
- * @param prepareEvent - Function to enrich partial events
8
- * @returns The push function
9
- */
10
- export declare function createPush<T extends Collector.Instance>(collector: T, prepareEvent: (event: WalkerOS.DeepPartialEvent) => WalkerOS.PartialEvent): Collector.PushFn;
11
- //# sourceMappingURL=push.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../src/push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAO,MAAM,gBAAgB,CAAC;AAU/D;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,SAAS,CAAC,QAAQ,EACrD,SAAS,EAAE,CAAC,EACZ,YAAY,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,gBAAgB,KAAK,QAAQ,CAAC,YAAY,GACxE,SAAS,CAAC,MAAM,CAwDlB"}
package/dist/push.js DELETED
@@ -1,43 +0,0 @@
1
- import { getGrantedConsent, processEventMapping, tryCatchAsync, useHooks, } from '@walkeros/core';
2
- import { createEvent } from './handle';
3
- import { pushToDestinations, createPushResult } from './destination';
4
- /**
5
- * Creates the push function for the collector.
6
- * Handles source mapping, event creation, and routing to destinations.
7
- *
8
- * @param collector - The walkerOS collector instance
9
- * @param prepareEvent - Function to enrich partial events
10
- * @returns The push function
11
- */
12
- export function createPush(collector, prepareEvent) {
13
- return useHooks(async (event, context = {}) => {
14
- return await tryCatchAsync(async () => {
15
- let partialEvent = event;
16
- // Apply source mapping if provided in context
17
- if (context.mapping) {
18
- const processed = await processEventMapping(partialEvent, context.mapping, collector);
19
- // Check ignore flag
20
- if (processed.ignore) {
21
- return createPushResult({ ok: true });
22
- }
23
- // Check consent requirements
24
- if (context.mapping.consent) {
25
- const grantedConsent = getGrantedConsent(context.mapping.consent, collector.consent, processed.event.consent);
26
- if (!grantedConsent) {
27
- return createPushResult({ ok: true });
28
- }
29
- }
30
- partialEvent = processed.event;
31
- }
32
- // Prepare event (add timing, source info)
33
- const enrichedEvent = prepareEvent(partialEvent);
34
- // Create full event
35
- const fullEvent = createEvent(collector, enrichedEvent);
36
- // Push to destinations
37
- return await pushToDestinations(collector, fullEvent);
38
- }, () => {
39
- return createPushResult({ ok: false });
40
- })();
41
- }, 'Push', collector.hooks);
42
- }
43
- //# sourceMappingURL=push.js.map
package/dist/push.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"push.js","sourceRoot":"","sources":["../src/push.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,QAAQ,GACT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CACxB,SAAY,EACZ,YAAyE;IAEzE,OAAO,QAAQ,CACb,KAAK,EACH,KAAgC,EAChC,UAAiC,EAAE,EACV,EAAE;QAC3B,OAAO,MAAM,aAAa,CACxB,KAAK,IAA6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f/utils';
2
- export declare const settingsSchema: RJSFSchema;
3
- export declare const schemas: {
4
- settings: RJSFSchema;
5
- };
6
- //# sourceMappingURL=schemas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,cAAc,EAAE,UAmC5B,CAAC;AAEF,eAAO,MAAM,OAAO;;CAEnB,CAAC"}
package/dist/schemas.js DELETED
@@ -1,37 +0,0 @@
1
- export const settingsSchema = {
2
- type: 'object',
3
- properties: {
4
- run: {
5
- type: 'boolean',
6
- description: 'Automatically start the collector pipeline on initialization',
7
- },
8
- sources: {
9
- type: 'object',
10
- description: 'Configurations for sources providing events to the collector',
11
- },
12
- destinations: {
13
- type: 'object',
14
- description: 'Configurations for destinations receiving processed events',
15
- },
16
- consent: {
17
- type: 'object',
18
- description: 'Initial consent state to control routing of events',
19
- },
20
- verbose: {
21
- type: 'boolean',
22
- description: 'Enable verbose logging for debugging',
23
- },
24
- onError: {
25
- type: 'string',
26
- description: 'Error handler triggered when the collector encounters failures',
27
- },
28
- onLog: {
29
- type: 'string',
30
- description: 'Custom log handler for collector messages',
31
- },
32
- },
33
- };
34
- export const schemas = {
35
- settings: settingsSchema,
36
- };
37
- //# sourceMappingURL=schemas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,GAAG,EAAE;YACH,IAAI,EAAE,SAAS;YACf,WAAW,EACT,8DAA8D;SACjE;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,8DAA8D;SACjE;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4DAA4D;SAC1E;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,oDAAoD;SAClE;QACD,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,sCAAsC;SACpD;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,gEAAgE;SACnE;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,2CAA2C;SACzD;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,QAAQ,EAAE,cAAc;CACzB,CAAC"}
package/dist/source.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { Collector, Source } from '@walkeros/core';
2
- /**
3
- * Initialize sources using the code/config/env pattern
4
- *
5
- * @param collector - The WalkerOS collector instance
6
- * @param sources - Map of source definitions with code/config/env
7
- * @returns Initialized sources
8
- */
9
- export declare function initSources(collector: Collector.Instance, sources?: Source.InitSources): Promise<Collector.Sources>;
10
- //# sourceMappingURL=source.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAY,MAAM,gBAAgB,CAAC;AAGlE;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,SAAS,CAAC,QAAQ,EAC7B,OAAO,GAAE,MAAM,CAAC,WAAgB,GAC/B,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAwC5B"}