@customerio/cdp-analytics-node 0.0.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/LICENSE.MD +22 -0
- package/README.md +20 -0
- package/dist/cjs/app/analytics-node.js +170 -0
- package/dist/cjs/app/analytics-node.js.map +1 -0
- package/dist/cjs/app/context.js +13 -0
- package/dist/cjs/app/context.js.map +1 -0
- package/dist/cjs/app/dispatch-emit.js +37 -0
- package/dist/cjs/app/dispatch-emit.js.map +1 -0
- package/dist/cjs/app/emitter.js +8 -0
- package/dist/cjs/app/emitter.js.map +1 -0
- package/dist/cjs/app/event-factory.js +12 -0
- package/dist/cjs/app/event-factory.js.map +1 -0
- package/dist/cjs/app/event-queue.js +24 -0
- package/dist/cjs/app/event-queue.js.map +1 -0
- package/dist/cjs/app/settings.js +11 -0
- package/dist/cjs/app/settings.js.map +1 -0
- package/dist/cjs/app/types/event.js +3 -0
- package/dist/cjs/app/types/event.js.map +1 -0
- package/dist/cjs/app/types/index.js +7 -0
- package/dist/cjs/app/types/index.js.map +1 -0
- package/dist/cjs/app/types/params.js +3 -0
- package/dist/cjs/app/types/params.js.map +1 -0
- package/dist/cjs/app/types/plugin.js +3 -0
- package/dist/cjs/app/types/plugin.js.map +1 -0
- package/dist/cjs/generated/version.js +6 -0
- package/dist/cjs/generated/version.js.map +1 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/abort.js +77 -0
- package/dist/cjs/lib/abort.js.map +1 -0
- package/dist/cjs/lib/base-64-encode.js +19 -0
- package/dist/cjs/lib/base-64-encode.js.map +1 -0
- package/dist/cjs/lib/create-url.js +15 -0
- package/dist/cjs/lib/create-url.js.map +1 -0
- package/dist/cjs/lib/env.js +25 -0
- package/dist/cjs/lib/env.js.map +1 -0
- package/dist/cjs/lib/extract-promise-parts.js +21 -0
- package/dist/cjs/lib/extract-promise-parts.js.map +1 -0
- package/dist/cjs/lib/fetch.js +7 -0
- package/dist/cjs/lib/fetch.js.map +1 -0
- package/dist/cjs/lib/get-message-id.js +14 -0
- package/dist/cjs/lib/get-message-id.js.map +1 -0
- package/dist/cjs/lib/uuid.js +6 -0
- package/dist/cjs/lib/uuid.js.map +1 -0
- package/dist/cjs/plugins/customerio/context-batch.js +55 -0
- package/dist/cjs/plugins/customerio/context-batch.js.map +1 -0
- package/dist/cjs/plugins/customerio/index.js +44 -0
- package/dist/cjs/plugins/customerio/index.js.map +1 -0
- package/dist/cjs/plugins/customerio/publisher.js +189 -0
- package/dist/cjs/plugins/customerio/publisher.js.map +1 -0
- package/dist/esm/app/analytics-node.js +166 -0
- package/dist/esm/app/analytics-node.js.map +1 -0
- package/dist/esm/app/context.js +9 -0
- package/dist/esm/app/context.js.map +1 -0
- package/dist/esm/app/dispatch-emit.js +33 -0
- package/dist/esm/app/dispatch-emit.js.map +1 -0
- package/dist/esm/app/emitter.js +4 -0
- package/dist/esm/app/emitter.js.map +1 -0
- package/dist/esm/app/event-factory.js +8 -0
- package/dist/esm/app/event-factory.js.map +1 -0
- package/dist/esm/app/event-queue.js +20 -0
- package/dist/esm/app/event-queue.js.map +1 -0
- package/dist/esm/app/settings.js +7 -0
- package/dist/esm/app/settings.js.map +1 -0
- package/dist/esm/app/types/event.js +2 -0
- package/dist/esm/app/types/event.js.map +1 -0
- package/dist/esm/app/types/index.js +4 -0
- package/dist/esm/app/types/index.js.map +1 -0
- package/dist/esm/app/types/params.js +2 -0
- package/dist/esm/app/types/params.js.map +1 -0
- package/dist/esm/app/types/plugin.js +2 -0
- package/dist/esm/app/types/plugin.js.map +1 -0
- package/dist/esm/generated/version.js +3 -0
- package/dist/esm/generated/version.js.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/abort.js +73 -0
- package/dist/esm/lib/abort.js.map +1 -0
- package/dist/esm/lib/base-64-encode.js +15 -0
- package/dist/esm/lib/base-64-encode.js.map +1 -0
- package/dist/esm/lib/create-url.js +11 -0
- package/dist/esm/lib/create-url.js.map +1 -0
- package/dist/esm/lib/env.js +21 -0
- package/dist/esm/lib/env.js.map +1 -0
- package/dist/esm/lib/extract-promise-parts.js +17 -0
- package/dist/esm/lib/extract-promise-parts.js.map +1 -0
- package/dist/esm/lib/fetch.js +3 -0
- package/dist/esm/lib/fetch.js.map +1 -0
- package/dist/esm/lib/get-message-id.js +10 -0
- package/dist/esm/lib/get-message-id.js.map +1 -0
- package/dist/esm/lib/uuid.js +2 -0
- package/dist/esm/lib/uuid.js.map +1 -0
- package/dist/esm/plugins/customerio/context-batch.js +51 -0
- package/dist/esm/plugins/customerio/context-batch.js.map +1 -0
- package/dist/esm/plugins/customerio/index.js +39 -0
- package/dist/esm/plugins/customerio/index.js.map +1 -0
- package/dist/esm/plugins/customerio/publisher.js +185 -0
- package/dist/esm/plugins/customerio/publisher.js.map +1 -0
- package/dist/types/app/analytics-node.d.ts +62 -0
- package/dist/types/app/analytics-node.d.ts.map +1 -0
- package/dist/types/app/context.d.ts +6 -0
- package/dist/types/app/context.d.ts.map +1 -0
- package/dist/types/app/dispatch-emit.d.ts +7 -0
- package/dist/types/app/dispatch-emit.d.ts.map +1 -0
- package/dist/types/app/emitter.d.ts +23 -0
- package/dist/types/app/emitter.d.ts.map +1 -0
- package/dist/types/app/event-factory.d.ts +14 -0
- package/dist/types/app/event-factory.d.ts.map +1 -0
- package/dist/types/app/event-queue.d.ts +7 -0
- package/dist/types/app/event-queue.d.ts.map +1 -0
- package/dist/types/app/settings.d.ts +33 -0
- package/dist/types/app/settings.d.ts.map +1 -0
- package/dist/types/app/types/event.d.ts +7 -0
- package/dist/types/app/types/event.d.ts.map +1 -0
- package/dist/types/app/types/index.d.ts +4 -0
- package/dist/types/app/types/index.d.ts.map +1 -0
- package/dist/types/app/types/params.d.ts +60 -0
- package/dist/types/app/types/params.d.ts.map +1 -0
- package/dist/types/app/types/plugin.d.ts +6 -0
- package/dist/types/app/types/plugin.d.ts.map +1 -0
- package/dist/types/generated/version.d.ts +2 -0
- package/dist/types/generated/version.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/abort.d.ts +6 -0
- package/dist/types/lib/abort.d.ts.map +1 -0
- package/dist/types/lib/base-64-encode.d.ts +5 -0
- package/dist/types/lib/base-64-encode.d.ts.map +1 -0
- package/dist/types/lib/create-url.d.ts +8 -0
- package/dist/types/lib/create-url.d.ts.map +1 -0
- package/dist/types/lib/env.d.ts +3 -0
- package/dist/types/lib/env.d.ts.map +1 -0
- package/dist/types/lib/extract-promise-parts.d.ts +9 -0
- package/dist/types/lib/extract-promise-parts.d.ts.map +1 -0
- package/dist/types/lib/fetch.d.ts +2 -0
- package/dist/types/lib/fetch.d.ts.map +1 -0
- package/dist/types/lib/get-message-id.d.ts +7 -0
- package/dist/types/lib/get-message-id.d.ts.map +1 -0
- package/dist/types/lib/uuid.d.ts +2 -0
- package/dist/types/lib/uuid.d.ts.map +1 -0
- package/dist/types/plugins/customerio/context-batch.d.ts +26 -0
- package/dist/types/plugins/customerio/context-batch.d.ts.map +1 -0
- package/dist/types/plugins/customerio/index.d.ts +13 -0
- package/dist/types/plugins/customerio/index.d.ts.map +1 -0
- package/dist/types/plugins/customerio/publisher.d.ts +38 -0
- package/dist/types/plugins/customerio/publisher.d.ts.map +1 -0
- package/package.json +43 -0
- package/src/app/analytics-node.ts +295 -0
- package/src/app/context.ts +11 -0
- package/src/app/dispatch-emit.ts +42 -0
- package/src/app/emitter.ts +23 -0
- package/src/app/event-factory.ts +20 -0
- package/src/app/event-queue.ts +23 -0
- package/src/app/settings.ts +39 -0
- package/src/app/types/event.ts +7 -0
- package/src/app/types/index.ts +3 -0
- package/src/app/types/params.ts +74 -0
- package/src/app/types/plugin.ts +5 -0
- package/src/generated/version.ts +2 -0
- package/src/index.ts +17 -0
- package/src/lib/abort.ts +77 -0
- package/src/lib/base-64-encode.ts +14 -0
- package/src/lib/create-url.ts +11 -0
- package/src/lib/env.ts +32 -0
- package/src/lib/extract-promise-parts.ts +21 -0
- package/src/lib/fetch.ts +3 -0
- package/src/lib/get-message-id.ts +10 -0
- package/src/lib/uuid.ts +1 -0
- package/src/plugins/customerio/context-batch.ts +71 -0
- package/src/plugins/customerio/index.ts +65 -0
- package/src/plugins/customerio/publisher.ts +258 -0
package/LICENSE.MD
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2021 Segment
|
|
4
|
+
Copyright © 2023 Customer.io
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Customer.io Data Pipelines analytics client for Node.js.
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install @customerio/cdp-analytics-node
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Analytics } from '@customerio/cdp-analytics-node'
|
|
13
|
+
|
|
14
|
+
// instantiation
|
|
15
|
+
const analytics = new Analytics({ writeKey: '<MY_WRITE_KEY>' })
|
|
16
|
+
|
|
17
|
+
analytics.identify({
|
|
18
|
+
userId: '4'
|
|
19
|
+
});
|
|
20
|
+
```
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Analytics = void 0;
|
|
4
|
+
const cdp_analytics_core_1 = require("@customerio/cdp-analytics-core");
|
|
5
|
+
const settings_1 = require("./settings");
|
|
6
|
+
const version_1 = require("../generated/version");
|
|
7
|
+
const customerio_1 = require("../plugins/customerio");
|
|
8
|
+
const event_factory_1 = require("./event-factory");
|
|
9
|
+
const dispatch_emit_1 = require("./dispatch-emit");
|
|
10
|
+
const emitter_1 = require("./emitter");
|
|
11
|
+
const context_1 = require("./context");
|
|
12
|
+
const event_queue_1 = require("./event-queue");
|
|
13
|
+
class Analytics extends emitter_1.NodeEmitter {
|
|
14
|
+
constructor(settings) {
|
|
15
|
+
super();
|
|
16
|
+
this._isClosed = false;
|
|
17
|
+
this._pendingEvents = 0;
|
|
18
|
+
(0, settings_1.validateSettings)(settings);
|
|
19
|
+
this._eventFactory = new event_factory_1.NodeEventFactory();
|
|
20
|
+
this._queue = new event_queue_1.NodeEventQueue();
|
|
21
|
+
const flushInterval = settings.flushInterval ?? 10000;
|
|
22
|
+
this._closeAndFlushDefaultTimeout = flushInterval * 1.25; // add arbitrary multiplier in case an event is in a plugin.
|
|
23
|
+
const { plugin, publisher } = (0, customerio_1.createConfiguredNodePlugin)({
|
|
24
|
+
writeKey: settings.writeKey,
|
|
25
|
+
host: settings.host,
|
|
26
|
+
path: settings.path,
|
|
27
|
+
maxRetries: settings.maxRetries ?? 3,
|
|
28
|
+
maxEventsInBatch: settings.maxEventsInBatch ?? 15,
|
|
29
|
+
httpRequestTimeout: settings.httpRequestTimeout,
|
|
30
|
+
flushInterval,
|
|
31
|
+
}, this);
|
|
32
|
+
this._publisher = publisher;
|
|
33
|
+
this.ready = this.register(plugin).then(() => undefined);
|
|
34
|
+
this.emit('initialize', settings);
|
|
35
|
+
(0, cdp_analytics_core_1.bindAll)(this);
|
|
36
|
+
}
|
|
37
|
+
get VERSION() {
|
|
38
|
+
return version_1.version;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Call this method to stop collecting new events and flush all existing events.
|
|
42
|
+
* This method also waits for any event method-specific callbacks to be triggered,
|
|
43
|
+
* and any of their subsequent promises to be resolved/rejected.
|
|
44
|
+
*/
|
|
45
|
+
closeAndFlush({ timeout = this._closeAndFlushDefaultTimeout, } = {}) {
|
|
46
|
+
this._publisher.flushAfterClose(this._pendingEvents);
|
|
47
|
+
this._isClosed = true;
|
|
48
|
+
const promise = new Promise((resolve) => {
|
|
49
|
+
if (!this._pendingEvents) {
|
|
50
|
+
resolve();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.once('drained', () => resolve());
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return timeout ? (0, cdp_analytics_core_1.pTimeout)(promise, timeout).catch(() => undefined) : promise;
|
|
57
|
+
}
|
|
58
|
+
_dispatch(CustomerioEvent, callback) {
|
|
59
|
+
if (this._isClosed) {
|
|
60
|
+
this.emit('call_after_close', CustomerioEvent);
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
this._pendingEvents++;
|
|
64
|
+
(0, dispatch_emit_1.dispatchAndEmit)(CustomerioEvent, this._queue, this, callback)
|
|
65
|
+
.catch((ctx) => ctx)
|
|
66
|
+
.finally(() => {
|
|
67
|
+
this._pendingEvents--;
|
|
68
|
+
if (!this._pendingEvents) {
|
|
69
|
+
this.emit('drained');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Combines two unassociated user identities.
|
|
75
|
+
*/
|
|
76
|
+
alias({ userId, previousId, context, timestamp, integrations }, callback) {
|
|
77
|
+
const CustomerioEvent = this._eventFactory.alias(userId, previousId, {
|
|
78
|
+
context,
|
|
79
|
+
integrations,
|
|
80
|
+
timestamp,
|
|
81
|
+
});
|
|
82
|
+
this._dispatch(CustomerioEvent, callback);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Associates an identified user with a collective.
|
|
86
|
+
*/
|
|
87
|
+
group({ timestamp, groupId, userId, anonymousId, traits = {}, context, integrations, }, callback) {
|
|
88
|
+
const CustomerioEvent = this._eventFactory.group(groupId, traits, {
|
|
89
|
+
context,
|
|
90
|
+
anonymousId,
|
|
91
|
+
userId,
|
|
92
|
+
timestamp,
|
|
93
|
+
integrations,
|
|
94
|
+
});
|
|
95
|
+
this._dispatch(CustomerioEvent, callback);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Includes a unique userId and (maybe anonymousId) and any optional traits you know about them.
|
|
99
|
+
*/
|
|
100
|
+
identify({ userId, anonymousId, traits = {}, context, timestamp, integrations, }, callback) {
|
|
101
|
+
const CustomerioEvent = this._eventFactory.identify(userId, traits, {
|
|
102
|
+
context,
|
|
103
|
+
anonymousId,
|
|
104
|
+
userId,
|
|
105
|
+
timestamp,
|
|
106
|
+
integrations,
|
|
107
|
+
});
|
|
108
|
+
this._dispatch(CustomerioEvent, callback);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The page method lets you record page views on your website, along with optional extra information about the page being viewed.
|
|
112
|
+
*/
|
|
113
|
+
page({ userId, anonymousId, category, name, properties, context, timestamp, integrations, }, callback) {
|
|
114
|
+
const CustomerioEvent = this._eventFactory.page(category ?? null, name ?? null, properties, { context, anonymousId, userId, timestamp, integrations });
|
|
115
|
+
this._dispatch(CustomerioEvent, callback);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Records screen views on your app, along with optional extra information
|
|
119
|
+
* about the screen viewed by the user.
|
|
120
|
+
*/
|
|
121
|
+
screen({ userId, anonymousId, category, name, properties, context, timestamp, integrations, }, callback) {
|
|
122
|
+
const CustomerioEvent = this._eventFactory.screen(category ?? null, name ?? null, properties, { context, anonymousId, userId, timestamp, integrations });
|
|
123
|
+
this._dispatch(CustomerioEvent, callback);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Records actions your users perform.
|
|
127
|
+
*/
|
|
128
|
+
track({ userId, anonymousId, event, properties, context, timestamp, integrations, }, callback) {
|
|
129
|
+
const CustomerioEvent = this._eventFactory.track(event, properties, {
|
|
130
|
+
context,
|
|
131
|
+
userId,
|
|
132
|
+
anonymousId,
|
|
133
|
+
timestamp,
|
|
134
|
+
integrations,
|
|
135
|
+
});
|
|
136
|
+
this._dispatch(CustomerioEvent, callback);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Registers one or more plugins to augment Analytics functionality.
|
|
140
|
+
* @param plugins
|
|
141
|
+
*/
|
|
142
|
+
register(...plugins) {
|
|
143
|
+
return this._queue.criticalTasks.run(async () => {
|
|
144
|
+
const ctx = context_1.Context.system();
|
|
145
|
+
const registrations = plugins.map((xt) => this._queue.register(ctx, xt, this));
|
|
146
|
+
await Promise.all(registrations);
|
|
147
|
+
this.emit('register', plugins.map((el) => el.name));
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Deregisters one or more plugins based on their names.
|
|
152
|
+
* @param pluginNames - The names of one or more plugins to deregister.
|
|
153
|
+
*/
|
|
154
|
+
async deregister(...pluginNames) {
|
|
155
|
+
const ctx = context_1.Context.system();
|
|
156
|
+
const deregistrations = pluginNames.map((pl) => {
|
|
157
|
+
const plugin = this._queue.plugins.find((p) => p.name === pl);
|
|
158
|
+
if (plugin) {
|
|
159
|
+
return this._queue.deregister(ctx, plugin, this);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
ctx.log('warn', `plugin ${pl} not found`);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
await Promise.all(deregistrations);
|
|
166
|
+
this.emit('deregister', pluginNames);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.Analytics = Analytics;
|
|
170
|
+
//# sourceMappingURL=analytics-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics-node.js","sourceRoot":"","sources":["../../../src/app/analytics-node.ts"],"names":[],"mappings":";;;AAAA,uEAIuC;AACvC,yCAAgE;AAChE,kDAA8C;AAC9C,sDAAkE;AAClE,mDAAkD;AAClD,mDAA2D;AAC3D,uCAAuC;AAUvC,uCAAmC;AACnC,+CAA8C;AAE9C,MAAa,SAAU,SAAQ,qBAAW;IAaxC,YAAY,QAA2B;QACrC,KAAK,EAAE,CAAA;QAZD,cAAS,GAAG,KAAK,CAAA;QACjB,mBAAc,GAAG,CAAC,CAAA;QAYxB,IAAA,2BAAgB,EAAC,QAAQ,CAAC,CAAA;QAE1B,IAAI,CAAC,aAAa,GAAG,IAAI,gCAAgB,EAAE,CAAA;QAC3C,IAAI,CAAC,MAAM,GAAG,IAAI,4BAAc,EAAE,CAAA;QAElC,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,IAAI,KAAK,CAAA;QAErD,IAAI,CAAC,4BAA4B,GAAG,aAAa,GAAG,IAAI,CAAA,CAAC,4DAA4D;QAErH,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,uCAA0B,EACtD;YACE,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,CA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UAAU,EAAE,YAAY,CAAC,CAAA;aAC1C;QACH,CAAC,CAAC,CAAA;QAEF,MAAM,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;QAClC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAA;IACtC,CAAC;CACF;AA/QD,8BA+QC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// create a derived class since we may want to add node specific things to Context later
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Context = void 0;
|
|
5
|
+
const cdp_analytics_core_1 = require("@customerio/cdp-analytics-core");
|
|
6
|
+
// While this is not a type, it is a definition
|
|
7
|
+
class Context extends cdp_analytics_core_1.CoreContext {
|
|
8
|
+
static system() {
|
|
9
|
+
return new this({ type: 'track', event: 'system' });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.Context = Context;
|
|
13
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/app/context.ts"],"names":[],"mappings":";AAAA,wFAAwF;;;AAExF,uEAA4D;AAG5D,+CAA+C;AAC/C,MAAa,OAAQ,SAAQ,gCAA4B;IACvD,MAAM,CAAU,MAAM;QACpB,OAAO,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;IACrD,CAAC;CACF;AAJD,0BAIC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dispatchAndEmit = void 0;
|
|
4
|
+
const cdp_analytics_core_1 = require("@customerio/cdp-analytics-core");
|
|
5
|
+
const context_1 = require("./context");
|
|
6
|
+
const normalizeDispatchCb = (cb) => (ctx) => {
|
|
7
|
+
const failedDelivery = ctx.failedDelivery();
|
|
8
|
+
return failedDelivery ? cb(failedDelivery.reason, ctx) : cb(undefined, ctx);
|
|
9
|
+
};
|
|
10
|
+
/* Dispatch function, but swallow promise rejections and use event emitter instead */
|
|
11
|
+
const dispatchAndEmit = async (event, queue, emitter, callback) => {
|
|
12
|
+
try {
|
|
13
|
+
const context = new context_1.Context(event);
|
|
14
|
+
const ctx = await (0, cdp_analytics_core_1.dispatch)(context, queue, emitter, {
|
|
15
|
+
...(callback ? { callback: normalizeDispatchCb(callback) } : {}),
|
|
16
|
+
});
|
|
17
|
+
const failedDelivery = ctx.failedDelivery();
|
|
18
|
+
if (failedDelivery) {
|
|
19
|
+
emitter.emit('error', {
|
|
20
|
+
code: 'delivery_failure',
|
|
21
|
+
reason: failedDelivery.reason,
|
|
22
|
+
ctx: ctx,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
emitter.emit(event.type, ctx);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
emitter.emit('error', {
|
|
31
|
+
code: 'unknown',
|
|
32
|
+
reason: err,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.dispatchAndEmit = dispatchAndEmit;
|
|
37
|
+
//# sourceMappingURL=dispatch-emit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch-emit.js","sourceRoot":"","sources":["../../../src/app/dispatch-emit.ts"],"names":[],"mappings":";;;AAAA,uEAAyD;AAEzD,uCAAmC;AAMnC,MAAM,mBAAmB,GAAG,CAAC,EAAY,EAAE,EAAE,CAAC,CAAC,GAAY,EAAE,EAAE;IAC7D,MAAM,cAAc,GAAG,GAAG,CAAC,cAAc,EAAE,CAAA;IAC3C,OAAO,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;AAC7E,CAAC,CAAA;AAED,qFAAqF;AAC9E,MAAM,eAAe,GAAG,KAAK,EAClC,KAAsB,EACtB,KAAqB,EACrB,OAAoB,EACpB,QAAmB,EACJ,EAAE;IACjB,IAAI;QACF,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,KAAK,CAAC,CAAA;QAClC,MAAM,GAAG,GAAG,MAAM,IAAA,6BAAQ,EAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YAClD,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACjE,CAAC,CAAA;QACF,MAAM,cAAc,GAAG,GAAG,CAAC,cAAc,EAAE,CAAA;QAC3C,IAAI,cAAc,EAAE;YAClB,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE;gBACpB,IAAI,EAAE,kBAAkB;gBACxB,MAAM,EAAE,cAAc,CAAC,MAAM;gBAC7B,GAAG,EAAE,GAAG;aACT,CAAC,CAAA;SACH;aAAM;YACL,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;SAC9B;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE;YACpB,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,GAAG;SACZ,CAAC,CAAA;KACH;AACH,CAAC,CAAA;AA3BY,QAAA,eAAe,mBA2B3B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeEmitter = void 0;
|
|
4
|
+
const cdp_analytics_core_1 = require("@customerio/cdp-analytics-core");
|
|
5
|
+
class NodeEmitter extends cdp_analytics_core_1.Emitter {
|
|
6
|
+
}
|
|
7
|
+
exports.NodeEmitter = NodeEmitter;
|
|
8
|
+
//# sourceMappingURL=emitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../../src/app/emitter.ts"],"names":[],"mappings":";;;AAAA,uEAA6E;AAsB7E,MAAa,WAAY,SAAQ,4BAA0B;CAAI;AAA/D,kCAA+D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeEventFactory = void 0;
|
|
4
|
+
const cdp_analytics_core_1 = require("@customerio/cdp-analytics-core");
|
|
5
|
+
const get_message_id_1 = require("../lib/get-message-id");
|
|
6
|
+
class NodeEventFactory extends cdp_analytics_core_1.EventFactory {
|
|
7
|
+
constructor() {
|
|
8
|
+
super({ createMessageId: get_message_id_1.createMessageId });
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.NodeEventFactory = NodeEventFactory;
|
|
12
|
+
//# sourceMappingURL=event-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-factory.js","sourceRoot":"","sources":["../../../src/app/event-factory.ts"],"names":[],"mappings":";;;AAAA,uEAA6D;AAC7D,0DAAuD;AAcvD,MAAa,gBAAiB,SAAQ,iCAAY;IAChD;QACE,KAAK,CAAC,EAAE,eAAe,EAAf,gCAAe,EAAE,CAAC,CAAA;IAC5B,CAAC;CACF;AAJD,4CAIC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeEventQueue = void 0;
|
|
4
|
+
const cdp_analytics_core_1 = require("@customerio/cdp-analytics-core");
|
|
5
|
+
class NodePriorityQueue extends cdp_analytics_core_1.PriorityQueue {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(1, []);
|
|
8
|
+
}
|
|
9
|
+
// do not use an internal "seen" map
|
|
10
|
+
getAttempts(ctx) {
|
|
11
|
+
return ctx.attempts ?? 0;
|
|
12
|
+
}
|
|
13
|
+
updateAttempts(ctx) {
|
|
14
|
+
ctx.attempts = this.getAttempts(ctx) + 1;
|
|
15
|
+
return this.getAttempts(ctx);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
class NodeEventQueue extends cdp_analytics_core_1.CoreEventQueue {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(new NodePriorityQueue());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.NodeEventQueue = NodeEventQueue;
|
|
24
|
+
//# sourceMappingURL=event-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-queue.js","sourceRoot":"","sources":["../../../src/app/event-queue.ts"],"names":[],"mappings":";;;AAAA,uEAA8E;AAI9E,MAAM,iBAAkB,SAAQ,kCAAsB;IACpD;QACE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACd,CAAC;IACD,oCAAoC;IACpC,WAAW,CAAC,GAAY;QACtB,OAAO,GAAG,CAAC,QAAQ,IAAI,CAAC,CAAA;IAC1B,CAAC;IACD,cAAc,CAAC,GAAY;QACzB,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACxC,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAC9B,CAAC;CACF;AAED,MAAa,cAAe,SAAQ,mCAA+B;IACjE;QACE,KAAK,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAA;IAChC,CAAC;CACF;AAJD,wCAIC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateSettings = void 0;
|
|
4
|
+
const cdp_analytics_core_1 = require("@customerio/cdp-analytics-core");
|
|
5
|
+
const validateSettings = (settings) => {
|
|
6
|
+
if (!settings.writeKey) {
|
|
7
|
+
throw new cdp_analytics_core_1.ValidationError('writeKey', 'writeKey is missing.');
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
exports.validateSettings = validateSettings;
|
|
11
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../src/app/settings.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;AAkCzD,MAAM,gBAAgB,GAAG,CAAC,QAA2B,EAAE,EAAE;IAC9D,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;QACtB,MAAM,IAAI,oCAAe,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAA;KAC9D;AACH,CAAC,CAAA;AAJY,QAAA,gBAAgB,oBAI5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../../src/app/types/event.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./params"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./event"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./plugin"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app/types/index.ts"],"names":[],"mappings":";;;AAAA,mDAAwB;AACxB,kDAAuB;AACvB,mDAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../../../src/app/types/params.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../src/app/types/plugin.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/generated/version.ts"],"names":[],"mappings":";;;AAAA,0BAA0B;AACb,QAAA,OAAO,GAAG,eAAe,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Context = exports.Analytics = void 0;
|
|
4
|
+
var analytics_node_1 = require("./app/analytics-node");
|
|
5
|
+
Object.defineProperty(exports, "Analytics", { enumerable: true, get: function () { return analytics_node_1.Analytics; } });
|
|
6
|
+
var context_1 = require("./app/context");
|
|
7
|
+
Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return context_1.Context; } });
|
|
8
|
+
// export Analytics as both a named export and a default export (for backwards-compat. reasons)
|
|
9
|
+
const analytics_node_2 = require("./app/analytics-node");
|
|
10
|
+
exports.default = analytics_node_2.Analytics;
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAAvC,2GAAA,SAAS,OAAA;AAClB,yCAAuC;AAA9B,kGAAA,OAAO,OAAA;AAahB,+FAA+F;AAC/F,yDAAgD;AAChD,kBAAe,0BAAS,CAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.abortSignalAfterTimeout = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* use non-native event emitter for the benefit of non-node runtimes like CF workers.
|
|
6
|
+
*/
|
|
7
|
+
const cdp_analytics_core_1 = require("@customerio/cdp-analytics-core");
|
|
8
|
+
const env_1 = require("./env");
|
|
9
|
+
/**
|
|
10
|
+
* adapted from: https://www.npmjs.com/package/node-abort-controller
|
|
11
|
+
*/
|
|
12
|
+
class AbortSignal {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.onabort = null;
|
|
15
|
+
this.aborted = false;
|
|
16
|
+
this.eventEmitter = new cdp_analytics_core_1.Emitter();
|
|
17
|
+
}
|
|
18
|
+
toString() {
|
|
19
|
+
return '[object AbortSignal]';
|
|
20
|
+
}
|
|
21
|
+
get [Symbol.toStringTag]() {
|
|
22
|
+
return 'AbortSignal';
|
|
23
|
+
}
|
|
24
|
+
removeEventListener(...args) {
|
|
25
|
+
this.eventEmitter.off(...args);
|
|
26
|
+
}
|
|
27
|
+
addEventListener(...args) {
|
|
28
|
+
this.eventEmitter.on(...args);
|
|
29
|
+
}
|
|
30
|
+
dispatchEvent(type) {
|
|
31
|
+
const event = { type, target: this };
|
|
32
|
+
const handlerName = `on${type}`;
|
|
33
|
+
if (typeof this[handlerName] === 'function') {
|
|
34
|
+
;
|
|
35
|
+
this[handlerName](event);
|
|
36
|
+
}
|
|
37
|
+
this.eventEmitter.emit(type, event);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* This polyfill is only neccessary to support versions of node < 14.17.
|
|
42
|
+
* Can be removed once node 14 support is dropped.
|
|
43
|
+
*/
|
|
44
|
+
class AbortController {
|
|
45
|
+
constructor() {
|
|
46
|
+
this.signal = new AbortSignal();
|
|
47
|
+
}
|
|
48
|
+
abort() {
|
|
49
|
+
if (this.signal.aborted)
|
|
50
|
+
return;
|
|
51
|
+
this.signal.aborted = true;
|
|
52
|
+
this.signal.dispatchEvent('abort');
|
|
53
|
+
}
|
|
54
|
+
toString() {
|
|
55
|
+
return '[object AbortController]';
|
|
56
|
+
}
|
|
57
|
+
get [Symbol.toStringTag]() {
|
|
58
|
+
return 'AbortController';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @param timeoutMs - Set a request timeout, after which the request is cancelled.
|
|
63
|
+
*/
|
|
64
|
+
const abortSignalAfterTimeout = (timeoutMs) => {
|
|
65
|
+
if ((0, env_1.detectRuntime)() === 'cloudflare-worker') {
|
|
66
|
+
return []; // TODO: this is broken in cloudflare workers, otherwise results in "A hanging Promise was canceled..." error.
|
|
67
|
+
}
|
|
68
|
+
const ac = new (global.AbortController || AbortController)();
|
|
69
|
+
const timeoutId = setTimeout(() => {
|
|
70
|
+
ac.abort();
|
|
71
|
+
}, timeoutMs);
|
|
72
|
+
// Allow Node.js processes to exit early if only the timeout is running
|
|
73
|
+
timeoutId?.unref?.();
|
|
74
|
+
return [ac.signal, timeoutId];
|
|
75
|
+
};
|
|
76
|
+
exports.abortSignalAfterTimeout = abortSignalAfterTimeout;
|
|
77
|
+
//# sourceMappingURL=abort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../../../src/lib/abort.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,uEAAwD;AACxD,+BAAqC;AAErC;;GAEG;AACH,MAAM,WAAW;IAAjB;QACE,YAAO,GAAsC,IAAI,CAAA;QACjD,YAAO,GAAG,KAAK,CAAA;QACf,iBAAY,GAAG,IAAI,4BAAO,EAAE,CAAA;IAyB9B,CAAC;IAvBC,QAAQ;QACN,OAAO,sBAAsB,CAAA;IAC/B,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,aAAa,CAAA;IACtB,CAAC;IACD,mBAAmB,CAAC,GAAG,IAAgC;QACrD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;IAChC,CAAC;IACD,gBAAgB,CAAC,GAAG,IAA+B;QACjD,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA;IAC/B,CAAC;IACD,aAAa,CAAC,IAAY;QACxB,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;QAEpC,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE,CAAA;QAE/B,IAAI,OAAQ,IAAY,CAAC,WAAW,CAAC,KAAK,UAAU,EA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|
4
|
+
/**
|
|
5
|
+
* Base64 encoder that works in browser, worker, node runtimes.
|
|
6
|
+
*/
|
|
7
|
+
const b64encode = (str) => {
|
|
8
|
+
if (
|
|
9
|
+
// in node env
|
|
10
|
+
typeof Buffer !== 'undefined') {
|
|
11
|
+
return Buffer.from(str).toString('base64');
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
// in worker env
|
|
15
|
+
return btoa(str);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.b64encode = b64encode;
|
|
19
|
+
//# sourceMappingURL=base-64-encode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-64-encode.js","sourceRoot":"","sources":["../../../src/lib/base-64-encode.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACI,MAAM,SAAS,GAAG,CAAC,GAAW,EAAU,EAAE;IAC/C;IACE,cAAc;IACd,OAAO,MAAM,KAAK,WAAW,EAC7B;QACA,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;KAC3C;SAAM;QACL,gBAAgB;QAChB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;KACjB;AACH,CAAC,CAAA;AAVY,QAAA,SAAS,aAUrB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tryCreateFormattedUrl = void 0;
|
|
4
|
+
const stripTrailingSlash = (str) => str.replace(/\/$/, '');
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param host e.g. "http://foo.com"
|
|
8
|
+
* @param path e.g. "/bar"
|
|
9
|
+
* @returns "e.g." "http://foo.com/bar"
|
|
10
|
+
*/
|
|
11
|
+
const tryCreateFormattedUrl = (host, path) => {
|
|
12
|
+
return stripTrailingSlash(new URL(path || '', host).href);
|
|
13
|
+
};
|
|
14
|
+
exports.tryCreateFormattedUrl = tryCreateFormattedUrl;
|
|
15
|
+
//# sourceMappingURL=create-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-url.js","sourceRoot":"","sources":["../../../src/lib/create-url.ts"],"names":[],"mappings":";;;AAAA,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AAElE;;;;;GAKG;AACI,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,IAAa,EAAE,EAAE;IACnE,OAAO,kBAAkB,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAA;AAC3D,CAAC,CAAA;AAFY,QAAA,qBAAqB,yBAEjC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectRuntime = void 0;
|
|
4
|
+
const detectRuntime = () => {
|
|
5
|
+
if (typeof process === 'object' && process && process.env) {
|
|
6
|
+
return 'node';
|
|
7
|
+
}
|
|
8
|
+
if (typeof window === 'object') {
|
|
9
|
+
return 'browser';
|
|
10
|
+
}
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
if (typeof WebSocketPair !== 'undefined') {
|
|
13
|
+
return 'cloudflare-worker';
|
|
14
|
+
}
|
|
15
|
+
if (
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
typeof importScripts === 'function') {
|
|
20
|
+
return 'web-worker';
|
|
21
|
+
}
|
|
22
|
+
return 'unknown';
|
|
23
|
+
};
|
|
24
|
+
exports.detectRuntime = detectRuntime;
|
|
25
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/lib/env.ts"],"names":[],"mappings":";;;AAOO,MAAM,aAAa,GAAG,GAAe,EAAE;IAC5C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE;QACzD,OAAO,MAAM,CAAA;KACd;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,SAAS,CAAA;KACjB;IAED,aAAa;IACb,IAAI,OAAO,aAAa,KAAK,WAAW,EAAE;QACxC,OAAO,mBAAmB,CAAA;KAC3B;IAED;IACE,aAAa;IACb,OAAO,iBAAiB,KAAK,WAAW;QACxC,aAAa;QACb,OAAO,aAAa,KAAK,UAAU,EACnC;QACA,OAAO,YAAY,CAAA;KACpB;IAED,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAxBY,QAAA,aAAa,iBAwBzB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractPromiseParts = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a promise and its associated `resolve` and `reject` methods.
|
|
6
|
+
*/
|
|
7
|
+
function extractPromiseParts() {
|
|
8
|
+
let resolver;
|
|
9
|
+
let rejecter;
|
|
10
|
+
const promise = new Promise((resolve, reject) => {
|
|
11
|
+
resolver = resolve;
|
|
12
|
+
rejecter = reject;
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
promise,
|
|
16
|
+
resolve: resolver,
|
|
17
|
+
reject: rejecter,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.extractPromiseParts = extractPromiseParts;
|
|
21
|
+
//# sourceMappingURL=extract-promise-parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-promise-parts.js","sourceRoot":"","sources":["../../../src/lib/extract-promise-parts.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,mBAAmB;IAKjC,IAAI,QAA4B,CAAA;IAChC,IAAI,QAAoC,CAAA;IACxC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACjD,QAAQ,GAAG,OAAO,CAAA;QAClB,QAAQ,GAAG,MAAM,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,OAAO;QACP,OAAO,EAAE,QAAS;QAClB,MAAM,EAAE,QAAS;KAClB,CAAA;AACH,CAAC;AAjBD,kDAiBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetch = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
6
|
+
exports.fetch = globalThis.fetch || node_fetch_1.default;
|
|
7
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":";;;;AAAA,oEAA8C;AAEjC,QAAA,KAAK,GAAG,UAAU,CAAC,KAAK,IAAI,oBAAM,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMessageId = void 0;
|
|
4
|
+
const uuid_1 = require("./uuid");
|
|
5
|
+
/**
|
|
6
|
+
* get a unique messageId with a very low chance of collisions
|
|
7
|
+
* using @lukeed/uuid/secure uses the node crypto module, which is the fastest
|
|
8
|
+
* @example "node-next-1668208232027-743be593-7789-4b74-8078-cbcc8894c586"
|
|
9
|
+
*/
|
|
10
|
+
const createMessageId = () => {
|
|
11
|
+
return `node-next-${Date.now()}-${(0, uuid_1.uuid)()}`;
|
|
12
|
+
};
|
|
13
|
+
exports.createMessageId = createMessageId;
|
|
14
|
+
//# sourceMappingURL=get-message-id.js.map
|