@walkeros/web-destination-api 4.1.0-next-1778668930820 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +206 -0
- package/README.md +17 -165
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.js +4 -42
- package/dist/examples/index.mjs +4 -42
- package/dist/index.browser.js +1 -1
- package/dist/index.es5.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +5 -7
- package/package.json +6 -4
package/dist/examples/index.js
CHANGED
|
@@ -56,50 +56,12 @@ __export(step_exports, {
|
|
|
56
56
|
entityAction: () => entityAction,
|
|
57
57
|
pageView: () => pageView
|
|
58
58
|
});
|
|
59
|
-
|
|
60
|
-
// ../../../core/dist/index.mjs
|
|
61
|
-
var e = Object.defineProperty;
|
|
62
|
-
var s = {};
|
|
63
|
-
((t, n) => {
|
|
64
|
-
for (var r in n) e(t, r, { get: n[r], enumerable: true });
|
|
65
|
-
})(s, { Level: () => c });
|
|
66
|
-
var c = ((e2) => (e2[e2.ERROR = 0] = "ERROR", e2[e2.WARN = 1] = "WARN", e2[e2.INFO = 2] = "INFO", e2[e2.DEBUG = 3] = "DEBUG", e2))(c || {});
|
|
67
|
-
var B = { merge: true, shallow: true, extend: true };
|
|
68
|
-
function J(e2, t = {}, n = {}) {
|
|
69
|
-
n = { ...B, ...n };
|
|
70
|
-
const r = Object.entries(t).reduce((t2, [r2, o]) => {
|
|
71
|
-
const a = e2[r2];
|
|
72
|
-
return n.merge && Array.isArray(a) && Array.isArray(o) ? t2[r2] = o.reduce((e3, t3) => e3.includes(t3) ? e3 : [...e3, t3], [...a]) : (n.extend || r2 in e2) && (t2[r2] = o), t2;
|
|
73
|
-
}, {});
|
|
74
|
-
return n.shallow ? { ...e2, ...r } : (Object.assign(e2, r), e2);
|
|
75
|
-
}
|
|
76
|
-
function ye() {
|
|
77
|
-
let e2 = "";
|
|
78
|
-
for (let t = 0; t < 16; t++) e2 += (16 * Math.random() | 0).toString(16);
|
|
79
|
-
return e2;
|
|
80
|
-
}
|
|
81
|
-
function he(e2 = {}) {
|
|
82
|
-
var _a;
|
|
83
|
-
const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = J({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" } }], consent: { functional: true }, id: e2.id || ye(), trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, source: { type: "collector", schema: "4" } }, e2, { merge: false });
|
|
84
|
-
if (e2.name) {
|
|
85
|
-
const [t2, r] = (_a = e2.name.split(" ")) != null ? _a : [];
|
|
86
|
-
t2 && r && (n.entity = t2, n.action = r);
|
|
87
|
-
}
|
|
88
|
-
return n;
|
|
89
|
-
}
|
|
90
|
-
function ve(e2 = "entity action", t = {}) {
|
|
91
|
-
const n = t.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), r = { data: { id: "ers", name: "Everyday Ruck Snack", color: "black", size: "l", price: 420 } }, o = { data: { id: "cc", name: "Cool Cap", size: "one size", price: 42 } };
|
|
92
|
-
return he({ ...{ "cart view": { data: { currency: "EUR", value: 2 * r.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", data: { ...r.data, quantity: 2 }, context: { shopping: ["cart", 0] }, nested: [] }], trigger: "load" }, "checkout view": { data: { step: "payment", currency: "EUR", value: r.data.price + o.data.price }, context: { shopping: ["checkout", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...r, context: { shopping: ["checkout", 0] }, nested: [] }, { entity: "product", ...o, context: { shopping: ["checkout", 0] }, nested: [] }], trigger: "load" }, "order complete": { data: { id: "0rd3r1d", currency: "EUR", shipping: 5.22, taxes: 73.76, total: 555 }, context: { shopping: ["complete", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...r, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "product", ...o, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "gift", data: { name: "Surprise" }, context: { shopping: ["complete", 0] }, nested: [] }], trigger: "load" }, "page view": { data: { domain: "www.example.com", title: "walkerOS documentation", referrer: "https://www.walkeros.io/", search: "?foo=bar", hash: "#hash", id: "/docs/" }, globals: { pagegroup: "docs" }, trigger: "load" }, "product add": { ...r, context: { shopping: ["intent", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "click" }, "product view": { ...r, context: { shopping: ["detail", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "product visible": { data: { ...r.data, position: 3, promo: true }, context: { shopping: ["discover", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "promotion visible": { data: { name: "Setting up tracking easily", position: "hero" }, context: { ab_test: ["engagement", 0] }, globals: { pagegroup: "homepage" }, trigger: "visible" }, "session start": { data: { id: "s3ss10n", start: n, isNew: true, count: 1, runs: 1, isStart: true, storage: true, referrer: "", device: "c00k13" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n", hash: "h4sh", address: "street number", email: "user@example.com", phone: "+49 123 456 789", userAgent: "Mozilla...", browser: "Chrome", browserVersion: "90", deviceType: "desktop", language: "de-DE", country: "DE", region: "HH", city: "Hamburg", zip: "20354", timezone: "Berlin", os: "walkerOS", osVersion: "1.0", screenSize: "1337x420", ip: "127.0.0.0", internal: true, custom: "value" } } }[e2], ...t, name: e2 });
|
|
93
|
-
}
|
|
94
|
-
var jt = ["code", "package", "before", "next", "cache", "mapping"];
|
|
95
|
-
var kt = /* @__PURE__ */ new Set([...jt, "config", "env", "validate", "variables", "examples", "disabled", "id", "logger", "mock", "chainMocks"]);
|
|
96
|
-
|
|
97
|
-
// src/examples/step.ts
|
|
59
|
+
var import_core = require("@walkeros/core");
|
|
98
60
|
var URL = "https://api.example.com/events";
|
|
99
61
|
var entityAction = {
|
|
100
62
|
title: "Entity action",
|
|
101
63
|
description: "A generic entity action event is forwarded to the configured API endpoint with the mapped data JSON body.",
|
|
102
|
-
in:
|
|
64
|
+
in: (0, import_core.getEvent)("entity action", { timestamp: 1700000500 }),
|
|
103
65
|
mapping: {
|
|
104
66
|
data: "data"
|
|
105
67
|
},
|
|
@@ -120,7 +82,7 @@ var entityAction = {
|
|
|
120
82
|
var pageView = {
|
|
121
83
|
title: "Page view",
|
|
122
84
|
description: "A page view is POSTed to the configured API endpoint with the event data section as the JSON body.",
|
|
123
|
-
in:
|
|
85
|
+
in: (0, import_core.getEvent)("page view", { timestamp: 1700000501 }),
|
|
124
86
|
mapping: {
|
|
125
87
|
data: "data"
|
|
126
88
|
},
|
|
@@ -143,7 +105,7 @@ var pageView = {
|
|
|
143
105
|
var customTransform = {
|
|
144
106
|
title: "Custom payload",
|
|
145
107
|
description: "An order event is reshaped via a data mapping into a custom JSON body for the API endpoint.",
|
|
146
|
-
in:
|
|
108
|
+
in: (0, import_core.getEvent)("order complete", { timestamp: 1700000502 }),
|
|
147
109
|
mapping: {
|
|
148
110
|
data: {
|
|
149
111
|
map: {
|
package/dist/examples/index.mjs
CHANGED
|
@@ -35,50 +35,12 @@ __export(step_exports, {
|
|
|
35
35
|
entityAction: () => entityAction,
|
|
36
36
|
pageView: () => pageView
|
|
37
37
|
});
|
|
38
|
-
|
|
39
|
-
// ../../../core/dist/index.mjs
|
|
40
|
-
var e = Object.defineProperty;
|
|
41
|
-
var s = {};
|
|
42
|
-
((t, n) => {
|
|
43
|
-
for (var r in n) e(t, r, { get: n[r], enumerable: true });
|
|
44
|
-
})(s, { Level: () => c });
|
|
45
|
-
var c = ((e2) => (e2[e2.ERROR = 0] = "ERROR", e2[e2.WARN = 1] = "WARN", e2[e2.INFO = 2] = "INFO", e2[e2.DEBUG = 3] = "DEBUG", e2))(c || {});
|
|
46
|
-
var B = { merge: true, shallow: true, extend: true };
|
|
47
|
-
function J(e2, t = {}, n = {}) {
|
|
48
|
-
n = { ...B, ...n };
|
|
49
|
-
const r = Object.entries(t).reduce((t2, [r2, o]) => {
|
|
50
|
-
const a = e2[r2];
|
|
51
|
-
return n.merge && Array.isArray(a) && Array.isArray(o) ? t2[r2] = o.reduce((e3, t3) => e3.includes(t3) ? e3 : [...e3, t3], [...a]) : (n.extend || r2 in e2) && (t2[r2] = o), t2;
|
|
52
|
-
}, {});
|
|
53
|
-
return n.shallow ? { ...e2, ...r } : (Object.assign(e2, r), e2);
|
|
54
|
-
}
|
|
55
|
-
function ye() {
|
|
56
|
-
let e2 = "";
|
|
57
|
-
for (let t = 0; t < 16; t++) e2 += (16 * Math.random() | 0).toString(16);
|
|
58
|
-
return e2;
|
|
59
|
-
}
|
|
60
|
-
function he(e2 = {}) {
|
|
61
|
-
var _a;
|
|
62
|
-
const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = J({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" } }], consent: { functional: true }, id: e2.id || ye(), trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, source: { type: "collector", schema: "4" } }, e2, { merge: false });
|
|
63
|
-
if (e2.name) {
|
|
64
|
-
const [t2, r] = (_a = e2.name.split(" ")) != null ? _a : [];
|
|
65
|
-
t2 && r && (n.entity = t2, n.action = r);
|
|
66
|
-
}
|
|
67
|
-
return n;
|
|
68
|
-
}
|
|
69
|
-
function ve(e2 = "entity action", t = {}) {
|
|
70
|
-
const n = t.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), r = { data: { id: "ers", name: "Everyday Ruck Snack", color: "black", size: "l", price: 420 } }, o = { data: { id: "cc", name: "Cool Cap", size: "one size", price: 42 } };
|
|
71
|
-
return he({ ...{ "cart view": { data: { currency: "EUR", value: 2 * r.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", data: { ...r.data, quantity: 2 }, context: { shopping: ["cart", 0] }, nested: [] }], trigger: "load" }, "checkout view": { data: { step: "payment", currency: "EUR", value: r.data.price + o.data.price }, context: { shopping: ["checkout", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...r, context: { shopping: ["checkout", 0] }, nested: [] }, { entity: "product", ...o, context: { shopping: ["checkout", 0] }, nested: [] }], trigger: "load" }, "order complete": { data: { id: "0rd3r1d", currency: "EUR", shipping: 5.22, taxes: 73.76, total: 555 }, context: { shopping: ["complete", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...r, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "product", ...o, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "gift", data: { name: "Surprise" }, context: { shopping: ["complete", 0] }, nested: [] }], trigger: "load" }, "page view": { data: { domain: "www.example.com", title: "walkerOS documentation", referrer: "https://www.walkeros.io/", search: "?foo=bar", hash: "#hash", id: "/docs/" }, globals: { pagegroup: "docs" }, trigger: "load" }, "product add": { ...r, context: { shopping: ["intent", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "click" }, "product view": { ...r, context: { shopping: ["detail", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "product visible": { data: { ...r.data, position: 3, promo: true }, context: { shopping: ["discover", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "promotion visible": { data: { name: "Setting up tracking easily", position: "hero" }, context: { ab_test: ["engagement", 0] }, globals: { pagegroup: "homepage" }, trigger: "visible" }, "session start": { data: { id: "s3ss10n", start: n, isNew: true, count: 1, runs: 1, isStart: true, storage: true, referrer: "", device: "c00k13" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n", hash: "h4sh", address: "street number", email: "user@example.com", phone: "+49 123 456 789", userAgent: "Mozilla...", browser: "Chrome", browserVersion: "90", deviceType: "desktop", language: "de-DE", country: "DE", region: "HH", city: "Hamburg", zip: "20354", timezone: "Berlin", os: "walkerOS", osVersion: "1.0", screenSize: "1337x420", ip: "127.0.0.0", internal: true, custom: "value" } } }[e2], ...t, name: e2 });
|
|
72
|
-
}
|
|
73
|
-
var jt = ["code", "package", "before", "next", "cache", "mapping"];
|
|
74
|
-
var kt = /* @__PURE__ */ new Set([...jt, "config", "env", "validate", "variables", "examples", "disabled", "id", "logger", "mock", "chainMocks"]);
|
|
75
|
-
|
|
76
|
-
// src/examples/step.ts
|
|
38
|
+
import { getEvent } from "@walkeros/core";
|
|
77
39
|
var URL = "https://api.example.com/events";
|
|
78
40
|
var entityAction = {
|
|
79
41
|
title: "Entity action",
|
|
80
42
|
description: "A generic entity action event is forwarded to the configured API endpoint with the mapped data JSON body.",
|
|
81
|
-
in:
|
|
43
|
+
in: getEvent("entity action", { timestamp: 1700000500 }),
|
|
82
44
|
mapping: {
|
|
83
45
|
data: "data"
|
|
84
46
|
},
|
|
@@ -99,7 +61,7 @@ var entityAction = {
|
|
|
99
61
|
var pageView = {
|
|
100
62
|
title: "Page view",
|
|
101
63
|
description: "A page view is POSTed to the configured API endpoint with the event data section as the JSON body.",
|
|
102
|
-
in:
|
|
64
|
+
in: getEvent("page view", { timestamp: 1700000501 }),
|
|
103
65
|
mapping: {
|
|
104
66
|
data: "data"
|
|
105
67
|
},
|
|
@@ -122,7 +84,7 @@ var pageView = {
|
|
|
122
84
|
var customTransform = {
|
|
123
85
|
title: "Custom payload",
|
|
124
86
|
description: "An order event is reshaped via a data mapping into a custom JSON body for the API endpoint.",
|
|
125
|
-
in:
|
|
87
|
+
in: getEvent("order complete", { timestamp: 1700000502 }),
|
|
126
88
|
mapping: {
|
|
127
89
|
data: {
|
|
128
90
|
map: {
|
package/dist/index.browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Walkerjs=(()=>{var
|
|
1
|
+
"use strict";var Walkerjs=(()=>{var t=Object.defineProperty,e=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,o={};((e,r)=>{for(var n in r)t(e,n,{get:r[n],enumerable:!0})})(o,{DestinationAPI:()=>v,default:()=>R,destinationAPI:()=>j});var s=Object.defineProperty,a=(t,e)=>{for(var r in e)s(t,r,{get:e[r],enumerable:!0})};function i(t,e){if("collector"===t)return"collector";if(!e)throw new Error(`stepId(${t}) requires an id`);return`${t}.${e}`}a({},{stepId:()=>i});function u(t,e){const r=t.destinations[e];if(!r)throw new Error(`Destination not found: ${e}`);return r}a({},{getDestination:()=>u});a({},{Level:()=>f});var c,f=((c=f||{})[c.ERROR=0]="ERROR",c[c.WARN=1]="WARN",c[c.INFO=2]="INFO",c[c.DEBUG=3]="DEBUG",c);function d(t,e){const r=t.transformers[e];if(!r)throw new Error(`Transformer not found: ${e}`);return r}a({},{getTransformer:()=>d});function l(t,e){const r=t.sources[e];if(!r)throw new Error(`Source not found: ${e}`);return r}a({},{getSource:()=>l});function g(t,e){const r=t.stores[e];if(!r)throw new Error(`Store not found: ${e}`);return r}a({},{getStore:()=>g});var h={merge:!0,shallow:!0,extend:!0};function p(t,e,r){return function(...n){try{return t(...n)}catch(t){if(!e)return;return e(t)}finally{null==r||r()}}}function y(t){return void 0===t||function(t,e){return typeof t==typeof e}(t,"")?t:JSON.stringify(t)}function m(t={}){return function(t,e={},r={}){r={...h,...r};const n=Object.entries(e).reduce((e,[n,o])=>{const s=t[n];return r.merge&&Array.isArray(s)&&Array.isArray(o)?e[n]=o.reduce((t,e)=>t.includes(e)?t:[...t,e],[...s]):(r.extend||n in t)&&(e[n]=o),e},{});return r.shallow?{...t,...n}:(Object.assign(t,n),t)}({"Content-Type":"application/json; charset=utf-8"},t)}function w(t,e,r={transport:"fetch"}){switch(r.transport||"fetch"){case"beacon":return function(t,e){const r=y(e),n=navigator.sendBeacon(t,r);return{ok:n,error:n?void 0:"Failed to send beacon"}}(t,e);case"xhr":return function(t,e,r={}){const n=m(r.headers),o=r.method||"POST",s=y(e);return p(()=>{const e=new XMLHttpRequest;e.open(o,t,!1);for(const t in n)e.setRequestHeader(t,n[t]);e.send(s);const r=e.status>=200&&e.status<300;return{ok:r,data:p(JSON.parse,()=>e.response)(e.response),error:r?void 0:`${e.status} ${e.statusText}`}},t=>({ok:!1,error:t.message}))()}(t,e,r);default:return async function(t,e,r={}){const n=m(r.headers),o=y(e);return function(t,e,r){return async function(...n){try{return await t(...n)}catch(t){if(!e)return;return await e(t)}finally{await(null==r?void 0:r())}}}(async()=>{const e=await fetch(t,{method:r.method||"POST",headers:n,keepalive:!0,credentials:r.credentials||"same-origin",mode:r.noCors?"no-cors":"cors",body:o}),s=r.noCors?"":await e.text();return{ok:e.ok,data:s,error:e.ok?void 0:e.statusText}},t=>({ok:!1,error:t.message}))()}(t,e,r)}}var v={};function O(t,e,r){const{url:n,headers:o,method:s,transport:a="fetch"}=e;r(n,t,{headers:o,method:s,transport:a})}var b,j={type:"api",config:{},init({config:t,logger:e}){const{url:r}=t.settings||{};r||e.throw("Config settings url missing")},push(t,{config:e,rule:r,data:n,env:o,logger:s}){const{settings:a}=e,{url:i,transform:u}=a||{},c=function(t){return void 0!==t}(n)?n:t;O(u?u(c,e,r):JSON.stringify(c),a,o.sendWeb||w)},pushBatch(t,{config:e,rule:r,env:n}){const o=e.settings,{transform:s}=o,a=t.data.length?t.data:t.events,i=s?a.map(t=>s(t,e,r)):a;O(JSON.stringify(i),o,n.sendWeb||w)}},R=j;return b=o,((o,s,a,i)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let u of r(s))n.call(o,u)||u===a||t(o,u,{get:()=>s[u],enumerable:!(i=e(s,u))||i.enumerable});return o})(t({},"__esModule",{value:!0}),b)})();
|
package/dist/index.es5.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _array_like_to_array(e
|
|
1
|
+
"use strict";function _array_like_to_array(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function _array_with_holes(r){if(Array.isArray(r))return r}function _array_without_holes(r){if(Array.isArray(r))return _array_like_to_array(r)}function asyncGeneratorStep(r,e,t,n,o,a,i){try{var u=r[a](i),c=u.value}catch(r){return void t(r)}u.done?e(c):Promise.resolve(c).then(n,o)}function _async_to_generator(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){asyncGeneratorStep(a,n,o,i,u,"next",r)}function u(r){asyncGeneratorStep(a,n,o,i,u,"throw",r)}i(void 0)})}}function _define_property(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function _iterable_to_array(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _iterable_to_array_limit(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a=[],i=!0,u=!1;try{for(t=t.call(r);!(i=(n=t.next()).done)&&(a.push(n.value),!e||a.length!==e);i=!0);}catch(r){u=!0,o=r}finally{try{i||null==t.return||t.return()}finally{if(u)throw o}}return a}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),n.forEach(function(e){_define_property(r,e,t[e])})}return r}function _sliced_to_array(r,e){return _array_with_holes(r)||_iterable_to_array_limit(r,e)||_unsupported_iterable_to_array(r,e)||_non_iterable_rest()}function _to_consumable_array(r){return _array_without_holes(r)||_iterable_to_array(r)||_unsupported_iterable_to_array(r)||_non_iterable_spread()}function _type_of(r){return r&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r}function _unsupported_iterable_to_array(r,e){if(r){if("string"==typeof r)return _array_like_to_array(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_array_like_to_array(r,e):void 0}}function _ts_generator(r,e){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(r,a)}catch(r){u=[6,r],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}var Walkerjs=function(){var r=function(r,e){if("collector"===r)return"collector";if(!e)throw new Error("stepId(".concat(r,") requires an id"));return"".concat(r,".").concat(e)},e=function(r,e){var t=r.destinations[e];if(!t)throw new Error("Destination not found: ".concat(e));return t},t=function(r,e){var t=r.transformers[e];if(!t)throw new Error("Transformer not found: ".concat(e));return t},n=function(r,e){var t=r.sources[e];if(!t)throw new Error("Source not found: ".concat(e));return t},o=function(r,e){var t=r.stores[e];if(!t)throw new Error("Store not found: ".concat(e));return t},a=function(r,e,t){return function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];try{return r.apply(void 0,_to_consumable_array(o))}catch(r){if(!e)return;return e(r)}finally{null==t||t()}}},i=function(r,e,t){return function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return _async_to_generator(function(){var n;return _ts_generator(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,4,6]),[4,r.apply(void 0,_to_consumable_array(o))];case 1:case 3:return[2,a.sent()];case 2:return n=a.sent(),e?[4,e(n)]:[2];case 4:return[4,null==t?void 0:t()];case 5:return a.sent(),[7];case 6:return[2]}})})()}},u=function(r){return void 0===r||function(r,e){return(void 0===r?"undefined":_type_of(r))==(void 0===e?"undefined":_type_of(e))}(r,"")?r:JSON.stringify(r)},c=function(){return function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=_object_spread({},j,t);var n=Object.entries(e).reduce(function(e,n){var o=_sliced_to_array(n,2),a=o[0],i=o[1],u=r[a];return t.merge&&Array.isArray(u)&&Array.isArray(i)?e[a]=i.reduce(function(r,e){return r.includes(e)?r:_to_consumable_array(r).concat([e])},_to_consumable_array(u)):(t.extend||a in r)&&(e[a]=i),e},{});return t.shallow?_object_spread({},r,n):(Object.assign(r,n),r)}({"Content-Type":"application/json; charset=utf-8"},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})},s=function(r,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{transport:"fetch"};switch(t.transport||"fetch"){case"beacon":return f(r,e);case"xhr":return _(r,e,t);default:return l(r,e,t)}},l=function(r,e){return _async_to_generator(function(r,e){var t,n,o,a=arguments;return _ts_generator(this,function(s){return n=c((t=a.length>2&&void 0!==a[2]?a[2]:{}).headers),o=u(e),[2,i(function(){return _async_to_generator(function(){var e,a,i;return _ts_generator(this,function(u){switch(u.label){case 0:return[4,fetch(r,{method:t.method||"POST",headers:n,keepalive:!0,credentials:t.credentials||"same-origin",mode:t.noCors?"no-cors":"cors",body:o})];case 1:return e=u.sent(),t.noCors?(i="",[3,4]):[3,2];case 2:return[4,e.text()];case 3:i=u.sent(),u.label=4;case 4:return a=i,[2,{ok:e.ok,data:a,error:e.ok?void 0:e.statusText}]}})})()},function(r){return{ok:!1,error:r.message}})()]})}).apply(this,arguments)},f=function(r,e){var t=u(e),n=navigator.sendBeacon(r,t);return{ok:n,error:n?void 0:"Failed to send beacon"}},_=function(r,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=c(t.headers),o=t.method||"POST",i=u(e);return a(function(){var e=new XMLHttpRequest;for(var t in e.open(o,r,!1),n)e.setRequestHeader(t,n[t]);e.send(i);var u=e.status>=200&&e.status<300;return{ok:u,data:a(JSON.parse,function(){return e.response})(e.response),error:u?void 0:"".concat(e.status," ").concat(e.statusText)}},function(r){return{ok:!1,error:r.message}})()},y=function(r,e,t){var n=e.url,o=e.headers,a=e.method,i=e.transport;t(n,r,{headers:o,method:a,transport:void 0===i?"fetch":i})},d=Object.defineProperty,p=Object.getOwnPropertyDescriptor,v=Object.getOwnPropertyNames,b=Object.prototype.hasOwnProperty,h={};!function(r,e){for(var t in e)d(r,t,{get:e[t],enumerable:!0})}(h,{DestinationAPI:function(){return A},default:function(){return P},destinationAPI:function(){return k}});var g=Object.defineProperty,m=function(r,e){for(var t in e)g(r,t,{get:e[t],enumerable:!0})};m({},{stepId:function(){return r}});m({},{getDestination:function(){return e}});m({},{Level:function(){return O}});var w,O=((w=O||{})[w.ERROR=0]="ERROR",w[w.WARN=1]="WARN",w[w.INFO=2]="INFO",w[w.DEBUG=3]="DEBUG",w);m({},{getTransformer:function(){return t}});m({},{getSource:function(){return n}});m({},{getStore:function(){return o}});var S,j={merge:!0,shallow:!0,extend:!0},A={},k={type:"api",config:{},init:function(r){var e=r.config,t=r.logger;(e.settings||{}).url||t.throw("Config settings url missing")},push:function(r,e){var t=e.config,n=e.rule,o=e.data,a=e.env,i=(e.logger,t.settings),u=i||{},c=(u.url,u.transform),l=function(r){return void 0!==r}(o)?o:r,f=c?c(l,t,n):JSON.stringify(l);y(f,i,a.sendWeb||s)},pushBatch:function(r,e){var t=e.config,n=e.rule,o=e.env,a=t.settings,i=a.transform,u=r.data.length?r.data:r.events,c=i?u.map(function(r){return i(r,t,n)}):u;y(JSON.stringify(c),a,o.sendWeb||s)}},P=k;return S=h,function(r,e,t,n){if(e&&"object"===(void 0===e?"undefined":_type_of(e))||"function"==typeof e){var o=!0,a=!1,i=void 0;try{for(var u,c=function(){var o=u.value;b.call(r,o)||o===t||d(r,o,{get:function(){return e[o]},enumerable:!(n=p(e,o))||n.enumerable})},s=v(e)[Symbol.iterator]();!(o=(u=s.next()).done);o=!0)c()}catch(r){a=!0,i=r}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}}return r}(d({},"__esModule",{value:!0}),S)}();
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s={};((e,r)=>{for(var n in r)t(e,n,{get:r[n],enumerable:!0})})(s,{DestinationAPI:()=>
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s={};((e,r)=>{for(var n in r)t(e,n,{get:r[n],enumerable:!0})})(s,{DestinationAPI:()=>c,default:()=>l,destinationAPI:()=>g}),module.exports=(e=s,((e,s,i,a)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let c of n(s))o.call(e,c)||c===i||t(e,c,{get:()=>s[c],enumerable:!(a=r(s,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var i=require("@walkeros/core"),a=require("@walkeros/web-core"),c={};function f(e,t,r){const{url:n,headers:o,method:s,transport:i="fetch"}=t;r(n,e,{headers:o,method:s,transport:i})}var g={type:"api",config:{},init({config:e,logger:t}){const{url:r}=e.settings||{};r||t.throw("Config settings url missing")},push(e,{config:t,rule:r,data:n,env:o,logger:s}){const{settings:c}=t,{url:g,transform:l}=c||{},u=(0,i.isDefined)(n)?n:e;f(l?l(u,t,r):JSON.stringify(u),c,o.sendWeb||a.sendWeb)},pushBatch(e,{config:t,rule:r,env:n}){const o=t.settings,{transform:s}=o,i=e.data.length?e.data:e.events,c=s?i.map(e=>s(e,t,r)):i;f(JSON.stringify(c),o,n.sendWeb||a.sendWeb)}},l=g;//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/types/index.ts"],"sourcesContent":["import type { SendDataValue } from '@walkeros/core';\nimport type { Settings, Destination } from './types';\nimport { isDefined } from '@walkeros/core';\nimport { sendWeb } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationAPI from './types';\n\nfunction send(\n body: SendDataValue,\n settings: Settings,\n sendWebFn: typeof sendWeb,\n): void {\n const { url, headers, method, transport = 'fetch' } = settings;\n sendWebFn(url, body, { headers, method, transport });\n}\n\nexport const destinationAPI: Destination = {\n type: 'api',\n\n config: {},\n\n init({ config, logger }) {\n const { url } = config.settings || {};\n if (!url) logger.throw('Config settings url missing');\n },\n\n push(event, { config, rule, data, env, logger }) {\n const { settings } = config;\n const { url, transform } = settings || {};\n\n const eventData = isDefined(data) ? data : event;\n // Transform returns body directly, otherwise stringify\n const body = transform\n ? transform(eventData, config, rule)\n : JSON.stringify(eventData);\n\n send(body, settings as Settings, env.sendWeb || sendWeb);\n },\n\n pushBatch(batch, { config, rule, env }) {\n const settings = config.settings as Settings;\n const { transform } = settings;\n const items = batch.data.length ? batch.data : batch.events;\n\n // Apply transform to each item if defined, then stringify array\n const payload = transform\n ? items.map((item) => transform(item, config, rule))\n : items;\n\n send(JSON.stringify(payload), settings, env.sendWeb || sendWeb);\n },\n};\n\nexport default destinationAPI;\n","import type {\n Mapping as WalkerOSMapping,\n SendDataValue,\n SendHeaders,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationWeb, sendWeb } from '@walkeros/web-core';\nimport type { SendWebTransport } from '@walkeros/web-core';\n\nexport interface Settings {\n url: string;\n headers?: SendHeaders;\n method?: string;\n transform?: Transform;\n transport?: SendWebTransport;\n}\n\n// InitSettings: user input (all optional)\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationWeb.Env {\n sendWeb?: typeof sendWeb;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport type Destination = DestinationWeb.Destination<Types>;\nexport type Config = DestinationWeb.Config<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type Transform = (\n data?: unknown,\n config?: Config,\n mapping?: WalkerOSMapping.Rule<Mapping>,\n) => SendDataValue;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types/index.ts"],"sourcesContent":["import type { SendDataValue } from '@walkeros/core';\nimport type { Settings, Destination } from './types';\nimport { isDefined } from '@walkeros/core';\nimport { sendWeb } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationAPI from './types';\n\nfunction send(\n body: SendDataValue,\n settings: Settings,\n sendWebFn: typeof sendWeb,\n): void {\n const { url, headers, method, transport = 'fetch' } = settings;\n sendWebFn(url, body, { headers, method, transport });\n}\n\nexport const destinationAPI: Destination = {\n type: 'api',\n\n config: {},\n\n init({ config, logger }) {\n const { url } = config.settings || {};\n if (!url) logger.throw('Config settings url missing');\n },\n\n push(event, { config, rule, data, env, logger }) {\n const { settings } = config;\n const { url, transform } = settings || {};\n\n const eventData = isDefined(data) ? data : event;\n // Transform returns body directly, otherwise stringify\n const body = transform\n ? transform(eventData, config, rule)\n : JSON.stringify(eventData);\n\n send(body, settings as Settings, env.sendWeb || sendWeb);\n },\n\n pushBatch(batch, { config, rule, env }) {\n const settings = config.settings as Settings;\n const { transform } = settings;\n const items = batch.data.length ? batch.data : batch.events;\n\n // Apply transform to each item if defined, then stringify array\n const payload = transform\n ? items.map((item) => transform(item, config, rule))\n : items;\n\n send(JSON.stringify(payload), settings, env.sendWeb || sendWeb);\n },\n};\n\nexport default destinationAPI;\n","import type {\n Mapping as WalkerOSMapping,\n SendDataValue,\n SendHeaders,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationWeb, sendWeb } from '@walkeros/web-core';\nimport type { SendWebTransport } from '@walkeros/web-core';\n\nexport interface Settings {\n url: string;\n headers?: SendHeaders;\n method?: string;\n transform?: Transform;\n transport?: SendWebTransport;\n}\n\n// InitSettings: user input (all optional)\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationWeb.Env {\n sendWeb?: typeof sendWeb;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport type Destination = DestinationWeb.Destination<Types>;\nexport type Config = DestinationWeb.Config<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type Transform = (\n data?: unknown,\n config?: Config,\n mapping?: WalkerOSMapping.Rule<Mapping>,\n) => SendDataValue;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAA0B;AAC1B,sBAAwB;;;ACHxB;;;ADQA,SAAS,KACP,MACA,UACA,WACM;AACN,QAAM,EAAE,KAAK,SAAS,QAAQ,YAAY,QAAQ,IAAI;AACtD,YAAU,KAAK,MAAM,EAAE,SAAS,QAAQ,UAAU,CAAC;AACrD;AAEO,IAAM,iBAA8B;AAAA,EACzC,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAQ,OAAO,GAAG;AACvB,UAAM,EAAE,IAAI,IAAI,OAAO,YAAY,CAAC;AACpC,QAAI,CAAC,IAAK,QAAO,MAAM,6BAA6B;AAAA,EACtD;AAAA,EAEA,KAAK,OAAO,EAAE,QAAQ,MAAM,MAAM,KAAK,OAAO,GAAG;AAC/C,UAAM,EAAE,SAAS,IAAI;AACrB,UAAM,EAAE,KAAK,UAAU,IAAI,YAAY,CAAC;AAExC,UAAM,gBAAY,uBAAU,IAAI,IAAI,OAAO;AAE3C,UAAM,OAAO,YACT,UAAU,WAAW,QAAQ,IAAI,IACjC,KAAK,UAAU,SAAS;AAE5B,SAAK,MAAM,UAAsB,IAAI,WAAW,uBAAO;AAAA,EACzD;AAAA,EAEA,UAAU,OAAO,EAAE,QAAQ,MAAM,IAAI,GAAG;AACtC,UAAM,WAAW,OAAO;AACxB,UAAM,EAAE,UAAU,IAAI;AACtB,UAAM,QAAQ,MAAM,KAAK,SAAS,MAAM,OAAO,MAAM;AAGrD,UAAM,UAAU,YACZ,MAAM,IAAI,CAAC,SAAS,UAAU,MAAM,QAAQ,IAAI,CAAC,IACjD;AAEJ,SAAK,KAAK,UAAU,OAAO,GAAG,UAAU,IAAI,WAAW,uBAAO;AAAA,EAChE;AACF;AAEA,IAAO,gBAAQ;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=Object.defineProperty
|
|
1
|
+
var t=Object.defineProperty,r=(r,e)=>{for(var n in e)t(r,n,{get:e[n],enumerable:!0})};function e(t,r){if("collector"===t)return"collector";if(!r)throw new Error(`stepId(${t}) requires an id`);return`${t}.${r}`}r({},{stepId:()=>e});function n(t,r){const e=t.destinations[r];if(!e)throw new Error(`Destination not found: ${r}`);return e}r({},{getDestination:()=>n});r({},{Level:()=>s});var o,s=((o=s||{})[o.ERROR=0]="ERROR",o[o.WARN=1]="WARN",o[o.INFO=2]="INFO",o[o.DEBUG=3]="DEBUG",o);function a(t,r){const e=t.transformers[r];if(!e)throw new Error(`Transformer not found: ${r}`);return e}r({},{getTransformer:()=>a});function i(t,r){const e=t.sources[r];if(!e)throw new Error(`Source not found: ${r}`);return e}r({},{getSource:()=>i});function u(t,r){const e=t.stores[r];if(!e)throw new Error(`Store not found: ${r}`);return e}r({},{getStore:()=>u});var c={merge:!0,shallow:!0,extend:!0};function f(t,r,e){return function(...n){try{return t(...n)}catch(t){if(!r)return;return r(t)}finally{null==e||e()}}}function d(t){return void 0===t||function(t,r){return typeof t==typeof r}(t,"")?t:JSON.stringify(t)}function l(t={}){return function(t,r={},e={}){e={...c,...e};const n=Object.entries(r).reduce((r,[n,o])=>{const s=t[n];return e.merge&&Array.isArray(s)&&Array.isArray(o)?r[n]=o.reduce((t,r)=>t.includes(r)?t:[...t,r],[...s]):(e.extend||n in t)&&(r[n]=o),r},{});return e.shallow?{...t,...n}:(Object.assign(t,n),t)}({"Content-Type":"application/json; charset=utf-8"},t)}function h(t,r,e={transport:"fetch"}){switch(e.transport||"fetch"){case"beacon":return function(t,r){const e=d(r),n=navigator.sendBeacon(t,e);return{ok:n,error:n?void 0:"Failed to send beacon"}}(t,r);case"xhr":return function(t,r,e={}){const n=l(e.headers),o=e.method||"POST",s=d(r);return f(()=>{const r=new XMLHttpRequest;r.open(o,t,!1);for(const t in n)r.setRequestHeader(t,n[t]);r.send(s);const e=r.status>=200&&r.status<300;return{ok:e,data:f(JSON.parse,()=>r.response)(r.response),error:e?void 0:`${r.status} ${r.statusText}`}},t=>({ok:!1,error:t.message}))()}(t,r,e);default:return async function(t,r,e={}){const n=l(e.headers),o=d(r);return function(t,r,e){return async function(...n){try{return await t(...n)}catch(t){if(!r)return;return await r(t)}finally{await(null==e?void 0:e())}}}(async()=>{const r=await fetch(t,{method:e.method||"POST",headers:n,keepalive:!0,credentials:e.credentials||"same-origin",mode:e.noCors?"no-cors":"cors",body:o}),s=e.noCors?"":await r.text();return{ok:r.ok,data:s,error:r.ok?void 0:r.statusText}},t=>({ok:!1,error:t.message}))()}(t,r,e)}}var g={};function p(t,r,e){const{url:n,headers:o,method:s,transport:a="fetch"}=r;e(n,t,{headers:o,method:s,transport:a})}var w={type:"api",config:{},init({config:t,logger:r}){const{url:e}=t.settings||{};e||r.throw("Config settings url missing")},push(t,{config:r,rule:e,data:n,env:o,logger:s}){const{settings:a}=r,{url:i,transform:u}=a||{},c=function(t){return void 0!==t}(n)?n:t;p(u?u(c,r,e):JSON.stringify(c),a,o.sendWeb||h)},pushBatch(t,{config:r,rule:e,env:n}){const o=r.settings,{transform:s}=o,a=t.data.length?t.data:t.events,i=s?a.map(t=>s(t,r,e)):a;p(JSON.stringify(i),o,n.sendWeb||h)}},y=w;export{g as DestinationAPI,y as default,w as destinationAPI};//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/index.ts","../src/index.ts"],"sourcesContent":["import type {\n Mapping as WalkerOSMapping,\n SendDataValue,\n SendHeaders,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationWeb, sendWeb } from '@walkeros/web-core';\nimport type { SendWebTransport } from '@walkeros/web-core';\n\nexport interface Settings {\n url: string;\n headers?: SendHeaders;\n method?: string;\n transform?: Transform;\n transport?: SendWebTransport;\n}\n\n// InitSettings: user input (all optional)\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationWeb.Env {\n sendWeb?: typeof sendWeb;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport type Destination = DestinationWeb.Destination<Types>;\nexport type Config = DestinationWeb.Config<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type Transform = (\n data?: unknown,\n config?: Config,\n mapping?: WalkerOSMapping.Rule<Mapping>,\n) => SendDataValue;\n","import type { SendDataValue } from '@walkeros/core';\nimport type { Settings, Destination } from './types';\nimport { isDefined } from '@walkeros/core';\nimport { sendWeb } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationAPI from './types';\n\nfunction send(\n body: SendDataValue,\n settings: Settings,\n sendWebFn: typeof sendWeb,\n): void {\n const { url, headers, method, transport = 'fetch' } = settings;\n sendWebFn(url, body, { headers, method, transport });\n}\n\nexport const destinationAPI: Destination = {\n type: 'api',\n\n config: {},\n\n init({ config, logger }) {\n const { url } = config.settings || {};\n if (!url) logger.throw('Config settings url missing');\n },\n\n push(event, { config, rule, data, env, logger }) {\n const { settings } = config;\n const { url, transform } = settings || {};\n\n const eventData = isDefined(data) ? data : event;\n // Transform returns body directly, otherwise stringify\n const body = transform\n ? transform(eventData, config, rule)\n : JSON.stringify(eventData);\n\n send(body, settings as Settings, env.sendWeb || sendWeb);\n },\n\n pushBatch(batch, { config, rule, env }) {\n const settings = config.settings as Settings;\n const { transform } = settings;\n const items = batch.data.length ? batch.data : batch.events;\n\n // Apply transform to each item if defined, then stringify array\n const payload = transform\n ? items.map((item) => transform(item, config, rule))\n : items;\n\n send(JSON.stringify(payload), settings, env.sendWeb || sendWeb);\n },\n};\n\nexport default destinationAPI;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/types/index.ts","../src/index.ts"],"sourcesContent":["import type {\n Mapping as WalkerOSMapping,\n SendDataValue,\n SendHeaders,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationWeb, sendWeb } from '@walkeros/web-core';\nimport type { SendWebTransport } from '@walkeros/web-core';\n\nexport interface Settings {\n url: string;\n headers?: SendHeaders;\n method?: string;\n transform?: Transform;\n transport?: SendWebTransport;\n}\n\n// InitSettings: user input (all optional)\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationWeb.Env {\n sendWeb?: typeof sendWeb;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport type Destination = DestinationWeb.Destination<Types>;\nexport type Config = DestinationWeb.Config<Types>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\nexport type Transform = (\n data?: unknown,\n config?: Config,\n mapping?: WalkerOSMapping.Rule<Mapping>,\n) => SendDataValue;\n","import type { SendDataValue } from '@walkeros/core';\nimport type { Settings, Destination } from './types';\nimport { isDefined } from '@walkeros/core';\nimport { sendWeb } from '@walkeros/web-core';\n\n// Types\nexport * as DestinationAPI from './types';\n\nfunction send(\n body: SendDataValue,\n settings: Settings,\n sendWebFn: typeof sendWeb,\n): void {\n const { url, headers, method, transport = 'fetch' } = settings;\n sendWebFn(url, body, { headers, method, transport });\n}\n\nexport const destinationAPI: Destination = {\n type: 'api',\n\n config: {},\n\n init({ config, logger }) {\n const { url } = config.settings || {};\n if (!url) logger.throw('Config settings url missing');\n },\n\n push(event, { config, rule, data, env, logger }) {\n const { settings } = config;\n const { url, transform } = settings || {};\n\n const eventData = isDefined(data) ? data : event;\n // Transform returns body directly, otherwise stringify\n const body = transform\n ? transform(eventData, config, rule)\n : JSON.stringify(eventData);\n\n send(body, settings as Settings, env.sendWeb || sendWeb);\n },\n\n pushBatch(batch, { config, rule, env }) {\n const settings = config.settings as Settings;\n const { transform } = settings;\n const items = batch.data.length ? batch.data : batch.events;\n\n // Apply transform to each item if defined, then stringify array\n const payload = transform\n ? items.map((item) => transform(item, config, rule))\n : items;\n\n send(JSON.stringify(payload), settings, env.sendWeb || sendWeb);\n },\n};\n\nexport default destinationAPI;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;ACQA,SAAS,KACP,MACA,UACA,WACM;AACN,QAAM,EAAE,KAAK,SAAS,QAAQ,YAAY,QAAQ,IAAI;AACtD,YAAU,KAAK,MAAM,EAAE,SAAS,QAAQ,UAAU,CAAC;AACrD;AAEO,IAAM,iBAA8B;AAAA,EACzC,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,KAAK,EAAE,QAAQ,OAAO,GAAG;AACvB,UAAM,EAAE,IAAI,IAAI,OAAO,YAAY,CAAC;AACpC,QAAI,CAAC,IAAK,QAAO,MAAM,6BAA6B;AAAA,EACtD;AAAA,EAEA,KAAK,OAAO,EAAE,QAAQ,MAAM,MAAM,KAAK,OAAO,GAAG;AAC/C,UAAM,EAAE,SAAS,IAAI;AACrB,UAAM,EAAE,KAAK,UAAU,IAAI,YAAY,CAAC;AAExC,UAAM,YAAY,GAAU,IAAI,IAAI,OAAO;AAE3C,UAAM,OAAO,YACT,UAAU,WAAW,QAAQ,IAAI,IACjC,KAAK,UAAU,SAAS;AAE5B,SAAK,MAAM,UAAsB,IAAI,WAAWA,EAAO;AAAA,EACzD;AAAA,EAEA,UAAU,OAAO,EAAE,QAAQ,MAAM,IAAI,GAAG;AACtC,UAAM,WAAW,OAAO;AACxB,UAAM,EAAE,UAAU,IAAI;AACtB,UAAM,QAAQ,MAAM,KAAK,SAAS,MAAM,OAAO,MAAM;AAGrD,UAAM,UAAU,YACZ,MAAM,IAAI,CAAC,SAAS,UAAU,MAAM,QAAQ,IAAI,CAAC,IACjD;AAEJ,SAAK,KAAK,UAAU,OAAO,GAAG,UAAU,IAAI,WAAWA,EAAO;AAAA,EAChE;AACF;AAEA,IAAO,gBAAQ;","names":["S"]}
|
package/dist/walkerOS.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$meta": {
|
|
3
3
|
"package": "@walkeros/web-destination-api",
|
|
4
|
-
"version": "4.1.0
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"type": "destination",
|
|
6
6
|
"platform": [
|
|
7
7
|
"web"
|
|
@@ -55,9 +55,7 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"required": [
|
|
58
|
-
"url"
|
|
59
|
-
"method",
|
|
60
|
-
"transport"
|
|
58
|
+
"url"
|
|
61
59
|
],
|
|
62
60
|
"additionalProperties": false
|
|
63
61
|
}
|
|
@@ -155,7 +153,7 @@
|
|
|
155
153
|
"consent": {
|
|
156
154
|
"functional": true
|
|
157
155
|
},
|
|
158
|
-
"id": "
|
|
156
|
+
"id": "1ae26706c4f99a19",
|
|
159
157
|
"trigger": "load",
|
|
160
158
|
"entity": "order",
|
|
161
159
|
"action": "complete",
|
|
@@ -233,7 +231,7 @@
|
|
|
233
231
|
"consent": {
|
|
234
232
|
"functional": true
|
|
235
233
|
},
|
|
236
|
-
"id": "
|
|
234
|
+
"id": "a4ec3e6754afaacf",
|
|
237
235
|
"trigger": "test",
|
|
238
236
|
"entity": "entity",
|
|
239
237
|
"action": "action",
|
|
@@ -299,7 +297,7 @@
|
|
|
299
297
|
"consent": {
|
|
300
298
|
"functional": true
|
|
301
299
|
},
|
|
302
|
-
"id": "
|
|
300
|
+
"id": "c4196615625f0466",
|
|
303
301
|
"trigger": "load",
|
|
304
302
|
"entity": "page",
|
|
305
303
|
"action": "view",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/web-destination-api",
|
|
3
3
|
"description": "Web API destination for walkerOS",
|
|
4
|
-
"version": "4.1.0
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"./walkerOS.json": "./dist/walkerOS.json"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
-
"dist/**"
|
|
28
|
+
"dist/**",
|
|
29
|
+
"CHANGELOG.md"
|
|
29
30
|
],
|
|
30
31
|
"scripts": {
|
|
31
32
|
"build": "tsup --silent",
|
|
@@ -37,10 +38,11 @@
|
|
|
37
38
|
"update": "npx npm-check-updates -u && npm update"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@walkeros/
|
|
41
|
+
"@walkeros/core": "4.1.0",
|
|
42
|
+
"@walkeros/web-core": "4.1.0"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
|
-
"@walkeros/collector": "4.1.0
|
|
45
|
+
"@walkeros/collector": "4.1.0"
|
|
44
46
|
},
|
|
45
47
|
"repository": {
|
|
46
48
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|