@m1212e/rumble 0.16.17 → 0.16.19

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/out/index.cjs CHANGED
@@ -31,6 +31,7 @@ const require_generate = require('./generate-9zSO5f7n.cjs');
31
31
  let graphql = require("graphql");
32
32
  let _escape_tech_graphql_armor = require("@escape.tech/graphql-armor");
33
33
  let _graphql_yoga_plugin_disable_introspection = require("@graphql-yoga/plugin-disable-introspection");
34
+ let _opentelemetry_api = require("@opentelemetry/api");
34
35
  let _pothos_tracing_opentelemetry = require("@pothos/tracing-opentelemetry");
35
36
  let es_toolkit = require("es-toolkit");
36
37
  let graphql_yoga = require("graphql-yoga");
@@ -215,6 +216,10 @@ function mapNullFieldsToUndefined(obj) {
215
216
  return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, value === null ? void 0 : value]));
216
217
  }
217
218
 
219
+ //#endregion
220
+ //#region package.json
221
+ var version = "0.16.19";
222
+
218
223
  //#endregion
219
224
  //#region lib/helpers/mergeFilters.ts
220
225
  function mergeFilters(filterA, filterB) {
@@ -544,7 +549,7 @@ const createAbilityBuilder = ({ db, actions, defaultLimit, otel }) => {
544
549
  span?.setAttribute("abilities.status", "applied");
545
550
  return transformToResponse(mergedFilters);
546
551
  };
547
- if (otel?.tracer) return otel.tracer.startActiveSpan(`prepare_query_abilities_${action}`, (span) => {
552
+ if (otel?.enabled && otel.tracer) return otel.tracer.startActiveSpan(`prepare_query_abilities_${action}`, (span) => {
548
553
  try {
549
554
  return assembleAbilities(span);
550
555
  } finally {
@@ -1457,8 +1462,10 @@ const applyFilters = async ({ filters, entities, context }) => {
1457
1462
  const applyFiltersKey = "applyFilters";
1458
1463
  var RuntimeFiltersPlugin = class extends _pothos_core.BasePlugin {
1459
1464
  tracer;
1465
+ tracerEnabled;
1460
1466
  onTypeConfig(typeConfig) {
1461
- this.tracer = this.builder.options.otelTracer;
1467
+ this.tracer = this.builder.options.otel?.tracer;
1468
+ this.tracerEnabled = this.builder.options.otel?.enabled;
1462
1469
  return typeConfig;
1463
1470
  }
1464
1471
  wrapResolve(resolver, fieldConfig) {
@@ -1485,9 +1492,9 @@ var RuntimeFiltersPlugin = class extends _pothos_core.BasePlugin {
1485
1492
  if (Array.isArray(resolved)) return allowed;
1486
1493
  return allowed[0] ?? null;
1487
1494
  };
1488
- if (this.tracer) return this.tracer.startActiveSpan(`apply_filters_${fieldConfig.name}`, async (span) => {
1495
+ if (this.tracer && this.tracerEnabled) return this.tracer.startActiveSpan(`apply_filters_${fieldConfig.name}`, async (span) => {
1489
1496
  try {
1490
- return await runFilters();
1497
+ return await runFilters(span);
1491
1498
  } finally {
1492
1499
  span.end();
1493
1500
  }
@@ -1507,7 +1514,7 @@ function registerRuntimeFiltersPlugin() {
1507
1514
  //#endregion
1508
1515
  //#region lib/schemaBuilder.ts
1509
1516
  const createSchemaBuilder = ({ db, disableDefaultObjects, pubsub, pothosConfig, otel }) => {
1510
- const createSpan = otel?.tracer ? (0, _pothos_tracing_opentelemetry.createOpenTelemetryWrapper)(otel.tracer, otel.options) : void 0;
1517
+ const createSpan = otel?.enabled && otel.tracer ? (0, _pothos_tracing_opentelemetry.createOpenTelemetryWrapper)(otel.tracer, otel.options) : void 0;
1511
1518
  registerRuntimeFiltersPlugin();
1512
1519
  const schemaBuilder = new _pothos_core.default({
1513
1520
  ...pothosConfig,
@@ -1533,10 +1540,10 @@ const createSchemaBuilder = ({ db, disableDefaultObjects, pubsub, pothosConfig,
1533
1540
  }) },
1534
1541
  defaultFieldNullability: false,
1535
1542
  tracing: {
1536
- default: otel?.tracer ? (config) => (0, _pothos_plugin_tracing.isRootField)(config) : () => false,
1543
+ default: otel?.enabled ? (config) => (0, _pothos_plugin_tracing.isRootField)(config) : () => false,
1537
1544
  wrap: createSpan ? (resolver, options) => createSpan(resolver, options) : (resolver) => resolver
1538
1545
  },
1539
- otelTracer: otel?.tracer
1546
+ otel
1540
1547
  });
1541
1548
  schemaBuilder.addScalarType("JSON", graphql_scalars.JSONResolver);
1542
1549
  schemaBuilder.addScalarType("Date", graphql_scalars.DateResolver);
@@ -1584,6 +1591,7 @@ export const db = drizzle(
1584
1591
  ];
1585
1592
  if (rumbleInput.defaultLimit === void 0) rumbleInput.defaultLimit = 100;
1586
1593
  if (rumbleInput.search?.enabled) initSearchIfApplicable(rumbleInput);
1594
+ if (rumbleInput.otel?.enabled && !rumbleInput.otel.tracer) rumbleInput.otel.tracer = _opentelemetry_api.trace.getTracer("@m1212e/rumble", version);
1587
1595
  const abilityBuilder = createAbilityBuilder(rumbleInput);
1588
1596
  const context = createContextFunction({
1589
1597
  ...rumbleInput,
@@ -1638,7 +1646,7 @@ export const db = drizzle(
1638
1646
  plugins: [
1639
1647
  ...args?.plugins ?? [],
1640
1648
  ...enableApiDocs ? [] : [(0, _graphql_yoga_plugin_disable_introspection.useDisableIntrospection)(), (0, _escape_tech_graphql_armor.EnvelopArmorPlugin)()],
1641
- rumbleInput.otel?.tracer ? { onExecute: ({ setExecuteFn, executeFn }) => {
1649
+ rumbleInput.otel?.enabled ? { onExecute: ({ setExecuteFn, executeFn }) => {
1642
1650
  setExecuteFn((options) => rumbleInput.otel.tracer.startActiveSpan(_pothos_tracing_opentelemetry.SpanNames.EXECUTE, { attributes: { [_pothos_tracing_opentelemetry.AttributeNames.OPERATION_NAME]: options.operationName ?? "anonymous" } }, async (span) => {
1643
1651
  try {
1644
1652
  return await executeFn(options);