@budibase/backend-core 3.39.15 → 3.39.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +15 -15
- package/dist/index.js.map +3 -3
- package/dist/package.json +3 -3
- package/dist/plugins.js.map +2 -2
- package/dist/src/db/lucene.d.ts +1 -0
- package/dist/src/db/lucene.js +28 -1
- package/dist/src/db/lucene.js.map +1 -1
- package/dist/src/events/processors/index.d.ts +0 -2
- package/dist/src/events/processors/index.js +1 -4
- package/dist/src/events/processors/index.js.map +1 -1
- package/dist/tests/core/utilities/mocks/events.js +0 -2
- package/dist/tests/core/utilities/mocks/events.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/events/processors/AnalyticsProcessor.d.ts +0 -11
- package/dist/src/events/processors/AnalyticsProcessor.js +0 -105
- package/dist/src/events/processors/AnalyticsProcessor.js.map +0 -1
- package/dist/src/events/processors/posthog/PosthogProcessor.d.ts +0 -12
- package/dist/src/events/processors/posthog/PosthogProcessor.js +0 -155
- package/dist/src/events/processors/posthog/PosthogProcessor.js.map +0 -1
- package/dist/src/events/processors/posthog/index.d.ts +0 -2
- package/dist/src/events/processors/posthog/index.js +0 -8
- package/dist/src/events/processors/posthog/index.js.map +0 -1
- package/dist/src/events/processors/posthog/rateLimiting.d.ts +0 -7
- package/dist/src/events/processors/posthog/rateLimiting.js +0 -129
- package/dist/src/events/processors/posthog/rateLimiting.js.map +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const PosthogProcessor_1 = __importDefault(require("./PosthogProcessor"));
|
|
7
|
-
exports.default = PosthogProcessor_1.default;
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/events/processors/posthog/index.ts"],"names":[],"mappings":";;;;;AAAA,0EAAiD;AAEjD,kBAAe,0BAAgB,CAAA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Event } from "@budibase/types";
|
|
2
|
-
/**
|
|
3
|
-
* Check if this event should be sent right now
|
|
4
|
-
* Return false to signal the event SHOULD be sent
|
|
5
|
-
* Return true to signal the event should NOT be sent
|
|
6
|
-
*/
|
|
7
|
-
export declare const limited: (event: Event) => Promise<boolean>;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.limited = void 0;
|
|
46
|
-
const types_1 = require("@budibase/types");
|
|
47
|
-
const cache = __importStar(require("../../../cache/generic"));
|
|
48
|
-
const generic_1 = require("../../../cache/generic");
|
|
49
|
-
const context = __importStar(require("../../../context"));
|
|
50
|
-
const isRateLimited = (event) => {
|
|
51
|
-
return (event === types_1.Event.SERVED_BUILDER ||
|
|
52
|
-
event === types_1.Event.SERVED_APP_PREVIEW ||
|
|
53
|
-
event === types_1.Event.SERVED_APP);
|
|
54
|
-
};
|
|
55
|
-
const isPerApp = (event) => {
|
|
56
|
-
return event === types_1.Event.SERVED_APP_PREVIEW || event === types_1.Event.SERVED_APP;
|
|
57
|
-
};
|
|
58
|
-
var RateLimit;
|
|
59
|
-
(function (RateLimit) {
|
|
60
|
-
RateLimit["CALENDAR_DAY"] = "calendarDay";
|
|
61
|
-
})(RateLimit || (RateLimit = {}));
|
|
62
|
-
const RATE_LIMITS = {
|
|
63
|
-
[types_1.Event.SERVED_APP]: RateLimit.CALENDAR_DAY,
|
|
64
|
-
[types_1.Event.SERVED_APP_PREVIEW]: RateLimit.CALENDAR_DAY,
|
|
65
|
-
[types_1.Event.SERVED_BUILDER]: RateLimit.CALENDAR_DAY,
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Check if this event should be sent right now
|
|
69
|
-
* Return false to signal the event SHOULD be sent
|
|
70
|
-
* Return true to signal the event should NOT be sent
|
|
71
|
-
*/
|
|
72
|
-
const limited = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
-
// not a rate limited event -- send
|
|
74
|
-
if (!isRateLimited(event)) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
const cachedEvent = yield readEvent(event);
|
|
78
|
-
if (cachedEvent) {
|
|
79
|
-
const timestamp = new Date(cachedEvent.timestamp);
|
|
80
|
-
const limit = RATE_LIMITS[event];
|
|
81
|
-
switch (limit) {
|
|
82
|
-
case RateLimit.CALENDAR_DAY: {
|
|
83
|
-
// get midnight at the start of the next day for the timestamp
|
|
84
|
-
timestamp.setDate(timestamp.getDate() + 1);
|
|
85
|
-
timestamp.setHours(0, 0, 0, 0);
|
|
86
|
-
// if we have passed the threshold into the next day
|
|
87
|
-
if (Date.now() > timestamp.getTime()) {
|
|
88
|
-
// update the timestamp in the event -- send
|
|
89
|
-
yield recordEvent(event, { timestamp: Date.now() });
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
// still within the limited period -- don't send
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
// no event present i.e. expired -- send
|
|
101
|
-
yield recordEvent(event, { timestamp: Date.now() });
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
exports.limited = limited;
|
|
106
|
-
const eventKey = (event) => {
|
|
107
|
-
let key = `${generic_1.CacheKey.EVENTS_RATE_LIMIT}:${event}`;
|
|
108
|
-
if (isPerApp(event)) {
|
|
109
|
-
key = key + ":" + context.getWorkspaceId();
|
|
110
|
-
}
|
|
111
|
-
return key;
|
|
112
|
-
};
|
|
113
|
-
const readEvent = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
114
|
-
const key = eventKey(event);
|
|
115
|
-
const result = yield cache.get(key);
|
|
116
|
-
return result;
|
|
117
|
-
});
|
|
118
|
-
const recordEvent = (event, properties) => __awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
-
const key = eventKey(event);
|
|
120
|
-
const limit = RATE_LIMITS[event];
|
|
121
|
-
let ttl;
|
|
122
|
-
switch (limit) {
|
|
123
|
-
case RateLimit.CALENDAR_DAY: {
|
|
124
|
-
ttl = generic_1.TTL.ONE_DAY;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
yield cache.store(key, properties, ttl);
|
|
128
|
-
});
|
|
129
|
-
//# sourceMappingURL=rateLimiting.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rateLimiting.js","sourceRoot":"","sources":["../../../../../src/events/processors/posthog/rateLimiting.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAuC;AACvC,8DAA+C;AAC/C,oDAAsD;AACtD,0DAA2C;AAO3C,MAAM,aAAa,GAAG,CAAC,KAAY,EAA6B,EAAE;IAChE,OAAO,CACL,KAAK,KAAK,aAAK,CAAC,cAAc;QAC9B,KAAK,KAAK,aAAK,CAAC,kBAAkB;QAClC,KAAK,KAAK,aAAK,CAAC,UAAU,CAC3B,CAAA;AACH,CAAC,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,KAAuB,EAAE,EAAE;IAC3C,OAAO,KAAK,KAAK,aAAK,CAAC,kBAAkB,IAAI,KAAK,KAAK,aAAK,CAAC,UAA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