@genn-inc/cluebase-frontend-sdk 0.0.3 → 0.0.8
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/README.md +21 -0
- package/dist/_generated/correlation-attribute-keys.d.ts +3 -0
- package/dist/_generated/correlation-attribute-keys.js +34 -0
- package/dist/_generated/diagnostic-codes.d.ts +4 -0
- package/dist/_generated/diagnostic-codes.js +48 -0
- package/dist/_generated/drop-reasons.d.ts +2 -0
- package/dist/_generated/drop-reasons.js +25 -0
- package/dist/_generated/{identity-pii-policy.d.ts → identity-pii-policy-text-contains.d.ts} +1 -1
- package/dist/_generated/{identity-pii-policy.js → identity-pii-policy-text-contains.js} +1 -1
- package/dist/_generated/identity-pii-policy-whole-value.d.ts +37 -0
- package/dist/_generated/identity-pii-policy-whole-value.js +106 -0
- package/dist/_generated/ingest-routes.d.ts +5 -0
- package/dist/_generated/ingest-routes.js +12 -0
- package/dist/_generated/otel-span-conversion.js +1 -9
- package/dist/context/browser-storage.js +1 -2
- package/dist/context/environment.js +5 -3
- package/dist/context/identity.js +5 -9
- package/dist/context/organization.d.ts +1 -1
- package/dist/context/organization.js +6 -8
- package/dist/context/session.js +6 -8
- package/dist/context/tab.js +8 -12
- package/dist/context/trace.js +4 -5
- package/dist/exporter/batch.d.ts +26 -27
- package/dist/exporter/batch.js +248 -294
- package/dist/exporter/browser-outbox-records.d.ts +8 -25
- package/dist/exporter/browser-outbox-records.js +21 -100
- package/dist/exporter/browser-outbox.d.ts +23 -25
- package/dist/exporter/browser-outbox.js +106 -181
- package/dist/exporter/client.d.ts +25 -35
- package/dist/exporter/client.js +107 -335
- package/dist/exporter/delivery-pipeline.d.ts +71 -0
- package/dist/exporter/delivery-pipeline.js +196 -0
- package/dist/exporter/delivery-response-contract.d.ts +1 -81
- package/dist/exporter/delivery-response-contract.js +0 -118
- package/dist/exporter/delivery-response.d.ts +9 -4
- package/dist/exporter/delivery-response.js +59 -122
- package/dist/exporter/diagnostics.d.ts +3 -2
- package/dist/exporter/diagnostics.js +5 -26
- package/dist/exporter/event-id.d.ts +1 -0
- package/dist/exporter/event-id.js +4 -3
- package/dist/exporter/frontend-resource.js +5 -4
- package/dist/exporter/observation-source-event-exporter.d.ts +2 -1
- package/dist/exporter/observation-source-event-exporter.js +7 -4
- package/dist/exporter/path-template.js +3 -1
- package/dist/exporter/raw-event-to-source-signal.js +4 -2
- package/dist/exporter/sanitize.d.ts +3 -2
- package/dist/exporter/sanitize.js +4 -3
- package/dist/exporter/sdk-core-delivery.d.ts +225 -0
- package/dist/exporter/sdk-core-delivery.js +97 -0
- package/dist/exporter/sdk-core-wasm.d.ts +11 -0
- package/dist/exporter/sdk-core-wasm.js +39 -0
- package/dist/exporter/source-event.d.ts +3 -0
- package/dist/exporter/source-event.js +17 -0
- package/dist/exporter/span-to-source-signal.d.ts +2 -2
- package/dist/exporter/span-to-source-signal.js +45 -125
- package/dist/index.d.ts +5 -4
- package/dist/index.js +18 -6
- package/dist/instrumentation/action.js +9 -8
- package/dist/instrumentation/dom.js +13 -21
- package/dist/instrumentation/drag.js +0 -3
- package/dist/instrumentation/error.js +3 -1
- package/dist/instrumentation/form.js +5 -6
- package/dist/instrumentation/input.js +4 -8
- package/dist/instrumentation/location.js +3 -1
- package/dist/instrumentation/network-request.js +1 -1
- package/dist/instrumentation/network-span-attributes.js +2 -2
- package/dist/instrumentation/network.d.ts +1 -1
- package/dist/instrumentation/network.js +24 -3
- package/dist/instrumentation/performance.js +1 -2
- package/dist/internal/internal-log.js +2 -1
- package/dist/provider/_version.d.ts +1 -1
- package/dist/provider/_version.js +1 -1
- package/dist/provider/config.js +16 -4
- package/dist/provider/constants.d.ts +1 -1
- package/dist/provider/constants.js +0 -2
- package/dist/provider/lifecycle-event-dedup.d.ts +7 -0
- package/dist/provider/lifecycle-event-dedup.js +31 -0
- package/dist/provider/sdk-event-pipeline.d.ts +3 -4
- package/dist/provider/sdk-event-pipeline.js +5 -17
- package/dist/provider/sdk-input-normalization.js +2 -2
- package/dist/provider/sdk-otel-pipeline.d.ts +2 -1
- package/dist/provider/sdk-otel-pipeline.js +7 -15
- package/dist/provider/sdk-runtime-surfaces.d.ts +17 -13
- package/dist/provider/sdk-runtime-surfaces.js +15 -13
- package/dist/provider/sdk.js +137 -48
- package/dist/provider/types.d.ts +18 -24
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm.d.ts +44 -0
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm.js +355 -0
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm_bg.wasm +0 -0
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm_bg.wasm.d.ts +11 -0
- package/dist/wasm/pkg-web/package.json +15 -0
- package/package.json +62 -53
- package/dist/provider/usage-governor.d.ts +0 -7
- package/dist/provider/usage-governor.js +0 -114
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
/* @ts-self-types="./cluebase_sdk_core_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} request_json
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
export function deliveryCommandJson(request_json) {
|
|
8
|
+
let deferred3_0;
|
|
9
|
+
let deferred3_1;
|
|
10
|
+
try {
|
|
11
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
12
|
+
const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
13
|
+
const len0 = WASM_VECTOR_LEN;
|
|
14
|
+
wasm.deliveryCommandJson(retptr, ptr0, len0);
|
|
15
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
16
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
17
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
18
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
19
|
+
var ptr2 = r0;
|
|
20
|
+
var len2 = r1;
|
|
21
|
+
if (r3) {
|
|
22
|
+
ptr2 = 0; len2 = 0;
|
|
23
|
+
throw takeObject(r2);
|
|
24
|
+
}
|
|
25
|
+
deferred3_0 = ptr2;
|
|
26
|
+
deferred3_1 = len2;
|
|
27
|
+
return getStringFromWasm0(ptr2, len2);
|
|
28
|
+
} finally {
|
|
29
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
30
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} span_json
|
|
36
|
+
* @param {string} options_json
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*/
|
|
39
|
+
export function spanToObservationSourceEventJson(span_json, options_json) {
|
|
40
|
+
let deferred4_0;
|
|
41
|
+
let deferred4_1;
|
|
42
|
+
try {
|
|
43
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
44
|
+
const ptr0 = passStringToWasm0(span_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
45
|
+
const len0 = WASM_VECTOR_LEN;
|
|
46
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
47
|
+
const len1 = WASM_VECTOR_LEN;
|
|
48
|
+
wasm.spanToObservationSourceEventJson(retptr, ptr0, len0, ptr1, len1);
|
|
49
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
50
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
51
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
52
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
53
|
+
var ptr3 = r0;
|
|
54
|
+
var len3 = r1;
|
|
55
|
+
if (r3) {
|
|
56
|
+
ptr3 = 0; len3 = 0;
|
|
57
|
+
throw takeObject(r2);
|
|
58
|
+
}
|
|
59
|
+
deferred4_0 = ptr3;
|
|
60
|
+
deferred4_1 = len3;
|
|
61
|
+
return getStringFromWasm0(ptr3, len3);
|
|
62
|
+
} finally {
|
|
63
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
64
|
+
wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {string} span_json
|
|
70
|
+
* @param {string} options_json
|
|
71
|
+
* @returns {string}
|
|
72
|
+
*/
|
|
73
|
+
export function spanToSdkSignalJson(span_json, options_json) {
|
|
74
|
+
let deferred4_0;
|
|
75
|
+
let deferred4_1;
|
|
76
|
+
try {
|
|
77
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
78
|
+
const ptr0 = passStringToWasm0(span_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
79
|
+
const len0 = WASM_VECTOR_LEN;
|
|
80
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
81
|
+
const len1 = WASM_VECTOR_LEN;
|
|
82
|
+
wasm.spanToSdkSignalJson(retptr, ptr0, len0, ptr1, len1);
|
|
83
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
84
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
85
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
86
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
87
|
+
var ptr3 = r0;
|
|
88
|
+
var len3 = r1;
|
|
89
|
+
if (r3) {
|
|
90
|
+
ptr3 = 0; len3 = 0;
|
|
91
|
+
throw takeObject(r2);
|
|
92
|
+
}
|
|
93
|
+
deferred4_0 = ptr3;
|
|
94
|
+
deferred4_1 = len3;
|
|
95
|
+
return getStringFromWasm0(ptr3, len3);
|
|
96
|
+
} finally {
|
|
97
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
98
|
+
wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function __wbg_get_imports() {
|
|
102
|
+
const import0 = {
|
|
103
|
+
__proto__: null,
|
|
104
|
+
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
105
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
106
|
+
},
|
|
107
|
+
__wbg_getRandomValues_a608c4436c19407a: function() { return handleError(function (arg0, arg1) {
|
|
108
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
109
|
+
}, arguments); },
|
|
110
|
+
__wbg_getTime_f5a55efff2585d5d: function(arg0) {
|
|
111
|
+
const ret = getObject(arg0).getTime();
|
|
112
|
+
return ret;
|
|
113
|
+
},
|
|
114
|
+
__wbg_new_0_72d020f0c63443d4: function() {
|
|
115
|
+
const ret = new Date();
|
|
116
|
+
return addHeapObject(ret);
|
|
117
|
+
},
|
|
118
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
119
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
120
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
121
|
+
return addHeapObject(ret);
|
|
122
|
+
},
|
|
123
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
124
|
+
takeObject(arg0);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
return {
|
|
128
|
+
__proto__: null,
|
|
129
|
+
"./cluebase_sdk_core_wasm_bg.js": import0,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function addHeapObject(obj) {
|
|
134
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
135
|
+
const idx = heap_next;
|
|
136
|
+
heap_next = heap[idx];
|
|
137
|
+
|
|
138
|
+
heap[idx] = obj;
|
|
139
|
+
return idx;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function dropObject(idx) {
|
|
143
|
+
if (idx < 1028) return;
|
|
144
|
+
heap[idx] = heap_next;
|
|
145
|
+
heap_next = idx;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
149
|
+
ptr = ptr >>> 0;
|
|
150
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let cachedDataViewMemory0 = null;
|
|
154
|
+
function getDataViewMemory0() {
|
|
155
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
156
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
157
|
+
}
|
|
158
|
+
return cachedDataViewMemory0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function getStringFromWasm0(ptr, len) {
|
|
162
|
+
return decodeText(ptr >>> 0, len);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
let cachedUint8ArrayMemory0 = null;
|
|
166
|
+
function getUint8ArrayMemory0() {
|
|
167
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
168
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
169
|
+
}
|
|
170
|
+
return cachedUint8ArrayMemory0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function getObject(idx) { return heap[idx]; }
|
|
174
|
+
|
|
175
|
+
function handleError(f, args) {
|
|
176
|
+
try {
|
|
177
|
+
return f.apply(this, args);
|
|
178
|
+
} catch (e) {
|
|
179
|
+
wasm.__wbindgen_export(addHeapObject(e));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
let heap = new Array(1024).fill(undefined);
|
|
184
|
+
heap.push(undefined, null, true, false);
|
|
185
|
+
|
|
186
|
+
let heap_next = heap.length;
|
|
187
|
+
|
|
188
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
189
|
+
if (realloc === undefined) {
|
|
190
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
191
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
192
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
193
|
+
WASM_VECTOR_LEN = buf.length;
|
|
194
|
+
return ptr;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
let len = arg.length;
|
|
198
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
199
|
+
|
|
200
|
+
const mem = getUint8ArrayMemory0();
|
|
201
|
+
|
|
202
|
+
let offset = 0;
|
|
203
|
+
|
|
204
|
+
for (; offset < len; offset++) {
|
|
205
|
+
const code = arg.charCodeAt(offset);
|
|
206
|
+
if (code > 0x7F) break;
|
|
207
|
+
mem[ptr + offset] = code;
|
|
208
|
+
}
|
|
209
|
+
if (offset !== len) {
|
|
210
|
+
if (offset !== 0) {
|
|
211
|
+
arg = arg.slice(offset);
|
|
212
|
+
}
|
|
213
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
214
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
215
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
216
|
+
|
|
217
|
+
offset += ret.written;
|
|
218
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
WASM_VECTOR_LEN = offset;
|
|
222
|
+
return ptr;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function takeObject(idx) {
|
|
226
|
+
const ret = getObject(idx);
|
|
227
|
+
dropObject(idx);
|
|
228
|
+
return ret;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
232
|
+
cachedTextDecoder.decode();
|
|
233
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
234
|
+
let numBytesDecoded = 0;
|
|
235
|
+
function decodeText(ptr, len) {
|
|
236
|
+
numBytesDecoded += len;
|
|
237
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
238
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
239
|
+
cachedTextDecoder.decode();
|
|
240
|
+
numBytesDecoded = len;
|
|
241
|
+
}
|
|
242
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const cachedTextEncoder = new TextEncoder();
|
|
246
|
+
|
|
247
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
248
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
249
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
250
|
+
view.set(buf);
|
|
251
|
+
return {
|
|
252
|
+
read: arg.length,
|
|
253
|
+
written: buf.length
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
let WASM_VECTOR_LEN = 0;
|
|
259
|
+
|
|
260
|
+
let wasmModule, wasmInstance, wasm;
|
|
261
|
+
function __wbg_finalize_init(instance, module) {
|
|
262
|
+
wasmInstance = instance;
|
|
263
|
+
wasm = instance.exports;
|
|
264
|
+
wasmModule = module;
|
|
265
|
+
cachedDataViewMemory0 = null;
|
|
266
|
+
cachedUint8ArrayMemory0 = null;
|
|
267
|
+
return wasm;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
async function __wbg_load(module, imports) {
|
|
271
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
272
|
+
if (!module.ok) {
|
|
273
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
277
|
+
try {
|
|
278
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
279
|
+
} catch (e) {
|
|
280
|
+
const validResponse = expectedResponseType(module.type);
|
|
281
|
+
|
|
282
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
283
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
284
|
+
|
|
285
|
+
} else { throw e; }
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const bytes = await module.arrayBuffer();
|
|
290
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
291
|
+
} else {
|
|
292
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
293
|
+
|
|
294
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
295
|
+
return { instance, module };
|
|
296
|
+
} else {
|
|
297
|
+
return instance;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function expectedResponseType(type) {
|
|
302
|
+
switch (type) {
|
|
303
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
304
|
+
}
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function initSync(module) {
|
|
310
|
+
if (wasm !== undefined) return wasm;
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
if (module !== undefined) {
|
|
314
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
315
|
+
({module} = module)
|
|
316
|
+
} else {
|
|
317
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const imports = __wbg_get_imports();
|
|
322
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
323
|
+
module = new WebAssembly.Module(module);
|
|
324
|
+
}
|
|
325
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
326
|
+
return __wbg_finalize_init(instance, module);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
async function __wbg_init(module_or_path) {
|
|
330
|
+
if (wasm !== undefined) return wasm;
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
if (module_or_path !== undefined) {
|
|
334
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
335
|
+
({module_or_path} = module_or_path)
|
|
336
|
+
} else {
|
|
337
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (module_or_path === undefined) {
|
|
342
|
+
module_or_path = new URL('cluebase_sdk_core_wasm_bg.wasm', import.meta.url);
|
|
343
|
+
}
|
|
344
|
+
const imports = __wbg_get_imports();
|
|
345
|
+
|
|
346
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
347
|
+
module_or_path = fetch(module_or_path);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
351
|
+
|
|
352
|
+
return __wbg_finalize_init(instance, module);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const deliveryCommandJson: (a: number, b: number, c: number) => void;
|
|
5
|
+
export const spanToObservationSourceEventJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
6
|
+
export const spanToSdkSignalJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
7
|
+
export const __wbindgen_export: (a: number) => void;
|
|
8
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
9
|
+
export const __wbindgen_export2: (a: number, b: number) => number;
|
|
10
|
+
export const __wbindgen_export3: (a: number, b: number, c: number, d: number) => number;
|
|
11
|
+
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cluebase-sdk-core-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"files": [
|
|
6
|
+
"cluebase_sdk_core_wasm_bg.wasm",
|
|
7
|
+
"cluebase_sdk_core_wasm.js",
|
|
8
|
+
"cluebase_sdk_core_wasm.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"main": "cluebase_sdk_core_wasm.js",
|
|
11
|
+
"types": "cluebase_sdk_core_wasm.d.ts",
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"./snippets/*"
|
|
14
|
+
]
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,54 +1,63 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
2
|
+
"name": "@genn-inc/cluebase-frontend-sdk",
|
|
3
|
+
"version": "0.0.8",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/genn-inc/cluebase.git"
|
|
7
|
+
},
|
|
8
|
+
"description": "Cluebase Frontend SDK — OTel-based observation-source event capture for frontend apps",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"browser": "./dist/index.js",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build:wasm": "node ../../../scripts/build-sdk-core-wasm.mjs --target web --dest src/wasm/pkg-web",
|
|
25
|
+
"build": "node ./scripts/clean-dist.mjs && node ../../../scripts/generate-shared-contract-tables.mjs && node ./scripts/generate-version-module.mjs && pnpm build:wasm && tsc -p tsconfig.build.json && node ./scripts/fix-esm-relative-imports.mjs && node ../../../scripts/copy-directory.mjs --from src/wasm --to dist/wasm",
|
|
26
|
+
"prepack": "pnpm build",
|
|
27
|
+
"prepublishOnly": "pnpm lint && pnpm test:cov && pnpm typecheck && pnpm test:package-import",
|
|
28
|
+
"lint": "pnpm exec biome lint src",
|
|
29
|
+
"test:package-import": "pnpm build && node ../../../tests/distribution/frontend-sdk/check-package-import.mjs",
|
|
30
|
+
"pretypecheck": "pnpm build:wasm",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.typecheck.json",
|
|
32
|
+
"pretest": "pnpm build:wasm",
|
|
33
|
+
"test": "vitest run --config ../../../tests/config/vitest/frontend-sdk.config.ts",
|
|
34
|
+
"pretest:cov": "pnpm build:wasm",
|
|
35
|
+
"test:cov": "vitest run --config ../../../tests/config/vitest/frontend-sdk.config.ts --coverage"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@cluebase/schema": "workspace:*",
|
|
39
|
+
"@cluebase/shared": "workspace:*",
|
|
40
|
+
"@opentelemetry/api": "1.10.0",
|
|
41
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
42
|
+
"jsdom": "^26.1.0",
|
|
43
|
+
"typescript": "^5.9.3",
|
|
44
|
+
"vitest": "^3.2.7"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@noble/hashes": "1.8.0",
|
|
48
|
+
"@opentelemetry/api-logs": ">=0.218.0 <1.0.0",
|
|
49
|
+
"@opentelemetry/browser-instrumentation": ">=0.5.2 <1.0.0",
|
|
50
|
+
"@opentelemetry/core": ">=2.7.1 <3.0.0",
|
|
51
|
+
"@opentelemetry/instrumentation-document-load": ">=0.63.0 <1.0.0",
|
|
52
|
+
"@opentelemetry/instrumentation-fetch": ">=0.218.0 <1.0.0",
|
|
53
|
+
"@opentelemetry/instrumentation-xml-http-request": ">=0.218.0 <1.0.0",
|
|
54
|
+
"@opentelemetry/resources": ">=2.7.1 <3.0.0",
|
|
55
|
+
"@opentelemetry/sdk-trace-base": ">=2.7.1 <3.0.0",
|
|
56
|
+
"@opentelemetry/sdk-trace-web": ">=2.7.1 <3.0.0",
|
|
57
|
+
"json-canonicalize": "2.0.0",
|
|
58
|
+
"zod": "^4.4.3"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@opentelemetry/api": ">=1.10.0 <1.11.0"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { CostCapability, IngestUsageGovernorFeedback } from "./types.js";
|
|
2
|
-
export declare const DEFAULT_INGEST_USAGE_GOVERNOR_FEEDBACK: IngestUsageGovernorFeedback;
|
|
3
|
-
export declare const normalizeIngestUsageGovernorFeedback: (feedback?: Partial<IngestUsageGovernorFeedback> | null) => IngestUsageGovernorFeedback;
|
|
4
|
-
export declare const mergeIngestUsageGovernorFeedback: (current: IngestUsageGovernorFeedback | null, incoming: IngestUsageGovernorFeedback | null) => IngestUsageGovernorFeedback | null;
|
|
5
|
-
export declare const parseGovernorFeedbackEnvelope: (value: unknown) => IngestUsageGovernorFeedback | null;
|
|
6
|
-
export declare const isCostCapabilityDisabled: (feedback: Pick<IngestUsageGovernorFeedback, "disabledCapabilities">, capability: CostCapability) => boolean;
|
|
7
|
-
export declare const hasUsageGovernorFeedbackChanged: (current: IngestUsageGovernorFeedback, next: IngestUsageGovernorFeedback) => boolean;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { COST_CAPABILITIES as GENERATED_COST_CAPABILITIES, LIMIT_KINDS as GENERATED_LIMIT_KINDS, THRESHOLD_STAGES as GENERATED_THRESHOLD_STAGES, } from "../_generated/usage-governor-tables.js";
|
|
2
|
-
export const DEFAULT_INGEST_USAGE_GOVERNOR_FEEDBACK = {
|
|
3
|
-
disabledCapabilities: [],
|
|
4
|
-
limitReasons: [],
|
|
5
|
-
retryAfterAt: null,
|
|
6
|
-
};
|
|
7
|
-
const COST_CAPABILITIES = new Set(GENERATED_COST_CAPABILITIES);
|
|
8
|
-
const LIMIT_KINDS = new Set(GENERATED_LIMIT_KINDS);
|
|
9
|
-
const THRESHOLD_STAGES = new Set(GENERATED_THRESHOLD_STAGES);
|
|
10
|
-
const asObject = (value) => {
|
|
11
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
12
|
-
return value;
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
};
|
|
16
|
-
const asCostCapability = (value) => {
|
|
17
|
-
return typeof value === "string" &&
|
|
18
|
-
COST_CAPABILITIES.has(value)
|
|
19
|
-
? value
|
|
20
|
-
: null;
|
|
21
|
-
};
|
|
22
|
-
const asLimitKind = (value) => {
|
|
23
|
-
return typeof value === "string" && LIMIT_KINDS.has(value)
|
|
24
|
-
? value
|
|
25
|
-
: null;
|
|
26
|
-
};
|
|
27
|
-
const asThresholdStage = (value) => {
|
|
28
|
-
return typeof value === "string" &&
|
|
29
|
-
THRESHOLD_STAGES.has(value)
|
|
30
|
-
? value
|
|
31
|
-
: null;
|
|
32
|
-
};
|
|
33
|
-
const asNonNegativeNumber = (value) => {
|
|
34
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0
|
|
35
|
-
? value
|
|
36
|
-
: null;
|
|
37
|
-
};
|
|
38
|
-
const asNullableString = (value) => {
|
|
39
|
-
return typeof value === "string" ? value : null;
|
|
40
|
-
};
|
|
41
|
-
const parseLimitReason = (value) => {
|
|
42
|
-
const record = asObject(value);
|
|
43
|
-
if (!record) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
const limitKind = asLimitKind(record.limitKind);
|
|
47
|
-
const thresholdStage = asThresholdStage(record.thresholdStage);
|
|
48
|
-
const currentValue = asNonNegativeNumber(record.currentValue);
|
|
49
|
-
const limitValue = asNonNegativeNumber(record.limitValue);
|
|
50
|
-
const retryAfterAt = record.retryAfterAt === null ? null : asNullableString(record.retryAfterAt);
|
|
51
|
-
if (!limitKind ||
|
|
52
|
-
typeof record.meterKey !== "string" ||
|
|
53
|
-
!thresholdStage ||
|
|
54
|
-
currentValue === null ||
|
|
55
|
-
limitValue === null ||
|
|
56
|
-
retryAfterAt === undefined) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
limitKind,
|
|
61
|
-
meterKey: record.meterKey,
|
|
62
|
-
thresholdStage,
|
|
63
|
-
currentValue,
|
|
64
|
-
limitValue,
|
|
65
|
-
retryAfterAt,
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
const uniqueCapabilities = (capabilities) => [...new Set(capabilities)];
|
|
69
|
-
export const normalizeIngestUsageGovernorFeedback = (feedback) => {
|
|
70
|
-
const disabledCapabilities = Array.isArray(feedback?.disabledCapabilities)
|
|
71
|
-
? feedback.disabledCapabilities
|
|
72
|
-
.map(asCostCapability)
|
|
73
|
-
.filter((capability) => capability !== null)
|
|
74
|
-
: [];
|
|
75
|
-
const limitReasons = Array.isArray(feedback?.limitReasons)
|
|
76
|
-
? feedback.limitReasons
|
|
77
|
-
.map(parseLimitReason)
|
|
78
|
-
.filter((reason) => reason !== null)
|
|
79
|
-
: [];
|
|
80
|
-
return {
|
|
81
|
-
disabledCapabilities: uniqueCapabilities(disabledCapabilities),
|
|
82
|
-
limitReasons,
|
|
83
|
-
retryAfterAt: typeof feedback?.retryAfterAt === "string" ? feedback.retryAfterAt : null,
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
export const mergeIngestUsageGovernorFeedback = (current, incoming) => {
|
|
87
|
-
if (!current) {
|
|
88
|
-
return incoming;
|
|
89
|
-
}
|
|
90
|
-
if (!incoming) {
|
|
91
|
-
return current;
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
disabledCapabilities: uniqueCapabilities([
|
|
95
|
-
...current.disabledCapabilities,
|
|
96
|
-
...incoming.disabledCapabilities,
|
|
97
|
-
]),
|
|
98
|
-
limitReasons: [...current.limitReasons, ...incoming.limitReasons],
|
|
99
|
-
retryAfterAt: current.retryAfterAt ?? incoming.retryAfterAt,
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
export const parseGovernorFeedbackEnvelope = (value) => {
|
|
103
|
-
const payload = asObject(value);
|
|
104
|
-
const governor = asObject(payload?.governor);
|
|
105
|
-
if (!governor) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
return normalizeIngestUsageGovernorFeedback(governor);
|
|
109
|
-
};
|
|
110
|
-
export const isCostCapabilityDisabled = (feedback, capability) => feedback.disabledCapabilities.includes(capability);
|
|
111
|
-
export const hasUsageGovernorFeedbackChanged = (current, next) => current.retryAfterAt !== next.retryAfterAt ||
|
|
112
|
-
current.disabledCapabilities.join("|") !==
|
|
113
|
-
next.disabledCapabilities.join("|") ||
|
|
114
|
-
JSON.stringify(current.limitReasons) !== JSON.stringify(next.limitReasons);
|