@genn-inc/cluebase-frontend-sdk 0.0.6 → 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.
Files changed (62) hide show
  1. package/dist/_generated/correlation-attribute-keys.d.ts +3 -0
  2. package/dist/_generated/correlation-attribute-keys.js +34 -0
  3. package/dist/_generated/diagnostic-codes.d.ts +4 -0
  4. package/dist/_generated/diagnostic-codes.js +48 -0
  5. package/dist/_generated/drop-reasons.d.ts +2 -0
  6. package/dist/_generated/drop-reasons.js +25 -0
  7. package/dist/_generated/ingest-routes.d.ts +5 -0
  8. package/dist/_generated/ingest-routes.js +12 -0
  9. package/dist/context/trace.js +2 -4
  10. package/dist/exporter/batch.d.ts +23 -26
  11. package/dist/exporter/batch.js +247 -289
  12. package/dist/exporter/browser-outbox-records.d.ts +7 -24
  13. package/dist/exporter/browser-outbox-records.js +6 -94
  14. package/dist/exporter/browser-outbox.d.ts +23 -28
  15. package/dist/exporter/browser-outbox.js +99 -211
  16. package/dist/exporter/client.d.ts +24 -34
  17. package/dist/exporter/client.js +105 -318
  18. package/dist/exporter/delivery-pipeline.d.ts +71 -0
  19. package/dist/exporter/delivery-pipeline.js +196 -0
  20. package/dist/exporter/delivery-response-contract.d.ts +1 -81
  21. package/dist/exporter/delivery-response-contract.js +0 -168
  22. package/dist/exporter/delivery-response.d.ts +7 -4
  23. package/dist/exporter/delivery-response.js +59 -133
  24. package/dist/exporter/diagnostics.d.ts +2 -1
  25. package/dist/exporter/diagnostics.js +1 -25
  26. package/dist/exporter/event-id.d.ts +1 -0
  27. package/dist/exporter/event-id.js +3 -0
  28. package/dist/exporter/observation-source-event-exporter.d.ts +1 -1
  29. package/dist/exporter/observation-source-event-exporter.js +2 -2
  30. package/dist/exporter/sdk-core-delivery.d.ts +225 -0
  31. package/dist/exporter/sdk-core-delivery.js +97 -0
  32. package/dist/exporter/sdk-core-wasm.d.ts +7 -1
  33. package/dist/exporter/sdk-core-wasm.js +24 -3
  34. package/dist/exporter/source-event.d.ts +2 -0
  35. package/dist/exporter/source-event.js +17 -0
  36. package/dist/exporter/span-to-source-signal.d.ts +1 -1
  37. package/dist/exporter/span-to-source-signal.js +20 -140
  38. package/dist/index.d.ts +3 -3
  39. package/dist/index.js +5 -3
  40. package/dist/instrumentation/network.d.ts +1 -1
  41. package/dist/instrumentation/network.js +17 -0
  42. package/dist/provider/_version.d.ts +1 -1
  43. package/dist/provider/_version.js +1 -1
  44. package/dist/provider/config.js +16 -3
  45. package/dist/provider/constants.js +0 -1
  46. package/dist/provider/lifecycle-event-dedup.d.ts +7 -0
  47. package/dist/provider/lifecycle-event-dedup.js +31 -0
  48. package/dist/provider/sdk-event-pipeline.d.ts +1 -3
  49. package/dist/provider/sdk-event-pipeline.js +0 -15
  50. package/dist/provider/sdk-otel-pipeline.d.ts +2 -1
  51. package/dist/provider/sdk-otel-pipeline.js +2 -11
  52. package/dist/provider/sdk-runtime-surfaces.d.ts +3 -2
  53. package/dist/provider/sdk-runtime-surfaces.js +7 -6
  54. package/dist/provider/sdk.js +88 -54
  55. package/dist/provider/types.d.ts +12 -19
  56. package/dist/wasm/pkg-web/cluebase_sdk_core_wasm.d.ts +12 -9
  57. package/dist/wasm/pkg-web/cluebase_sdk_core_wasm.js +117 -29
  58. package/dist/wasm/pkg-web/cluebase_sdk_core_wasm_bg.wasm +0 -0
  59. package/dist/wasm/pkg-web/cluebase_sdk_core_wasm_bg.wasm.d.ts +8 -9
  60. package/package.json +1 -1
  61. package/dist/provider/usage-governor.d.ts +0 -7
  62. package/dist/provider/usage-governor.js +0 -114
@@ -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);