@classytic/arc 2.18.3 → 2.18.4

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.
@@ -256,7 +256,7 @@ async function registerArcPlugins(fastify, config, trackPlugin, modules) {
256
256
  }
257
257
  if (config.arcPlugins?.sse) if (config.arcPlugins?.events === false) fastify.log.warn("SSE plugin requires events plugin (arcPlugins.events). SSE disabled.");
258
258
  else {
259
- const { default: ssePlugin } = await import("./sse-Xq8UtuQx.mjs").then((n) => n.r);
259
+ const { default: ssePlugin } = await import("./sse-BrY1W6U8.mjs").then((n) => n.r);
260
260
  const opts = config.arcPlugins.sse === true ? {} : config.arcPlugins.sse;
261
261
  await fastify.register(ssePlugin, opts);
262
262
  trackPlugin("arc-sse", opts);
@@ -1,5 +1,5 @@
1
1
  import { n as preloadResourcesAsync, t as preloadResources } from "../preloadResources-B-j-iqo-.mjs";
2
- import { a as edgePreset, c as testingPreset, i as developmentPreset, n as createApp, o as getPreset, s as productionPreset, t as ArcFactory } from "../createApp-DLuUGVZQ.mjs";
2
+ import { a as edgePreset, c as testingPreset, i as developmentPreset, n as createApp, o as getPreset, s as productionPreset, t as ArcFactory } from "../createApp-J1iPXY9p.mjs";
3
3
  import { t as loadResources } from "../loadResources-CwXt9MCh.mjs";
4
4
  //#region src/factory/edge.ts
5
5
  /**
package/dist/index.mjs CHANGED
@@ -5,6 +5,6 @@ import { C as requireAuth, D as when, F as applyFieldWritePermissions, I as fiel
5
5
  import { a as defineResource, i as defineResourceVariants, o as ResourceDefinition, s as defineAction, u as defineAggregation } from "./core-C88uIwd3.mjs";
6
6
  import { c as getControllerScope } from "./pipeline-D4sqiokR.mjs";
7
7
  //#region src/index.ts
8
- const version = "2.18.3";
8
+ const version = "2.18.4";
9
9
  //#endregion
10
10
  export { ArcError, BaseController, BaseCrudController, BulkMixin, CRUD_OPERATIONS, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, ForbiddenError, HOOK_OPERATIONS, HOOK_PHASES, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, NotFoundError, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, SlugMixin, SoftDeleteMixin, TreeMixin, UnauthorizedError, ValidationError, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, createDomainError, createDynamicPermissionMatrix, createOrgPermissions, defineAction, defineAggregation, defineResource, defineResourceVariants, denyAll, fields, fullPublic, getControllerScope, ownerWithAdminBypass, presets_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, version, when };
@@ -4,7 +4,7 @@ const eventGatewayPluginImpl = async (fastify, opts = {}) => {
4
4
  const { auth = true, orgScoped = false, roomPolicy, maxMessageBytes, maxSubscriptionsPerClient, authenticate } = opts;
5
5
  if (auth && !authenticate && !fastify.hasDecorator("authenticate")) throw new Error("[arc-event-gateway] auth is true but fastify.authenticate is not registered. Register an auth plugin first, provide a custom authenticate function, or set auth: false.");
6
6
  if (opts.sse !== false) {
7
- const { default: ssePlugin } = await import("../sse-Xq8UtuQx.mjs").then((n) => n.r);
7
+ const { default: ssePlugin } = await import("../sse-BrY1W6U8.mjs").then((n) => n.r);
8
8
  await fastify.register(ssePlugin, {
9
9
  path: opts.sse?.path ?? "/events/stream",
10
10
  requireAuth: auth,
@@ -8,7 +8,7 @@ import { n as caching_default, t as cachingPlugin } from "../caching-C0DdKiYB.mj
8
8
  import { n as errorHandlerPlugin, t as defaultIsDuplicateKeyError } from "../errorHandler-Bua97SEt.mjs";
9
9
  import { n as metrics_default, t as metricsPlugin } from "../metrics-Da2EUPi9.mjs";
10
10
  import { t as replyHelpersPlugin } from "../replyHelpers-DXHVxrrj.mjs";
11
- import { n as sse_default, t as ssePlugin } from "../sse-Xq8UtuQx.mjs";
11
+ import { n as sse_default, t as ssePlugin } from "../sse-BrY1W6U8.mjs";
12
12
  import { n as versioning_default, t as versioningPlugin } from "../versioning-C0K8KQLx.mjs";
13
13
  import { randomUUID } from "node:crypto";
14
14
  import fp from "fastify-plugin";
@@ -58,7 +58,7 @@ try {
58
58
  function createTracerProvider(options) {
59
59
  if (!isAvailable || !NodeTracerProvider || !BatchSpanProcessor || !OTLPTraceExporter) return null;
60
60
  const { serviceName = "@classytic/arc", serviceVersion, exporterUrl = "http://localhost:4318/v1/traces" } = options;
61
- const resolvedVersion = serviceVersion ?? "2.18.3";
61
+ const resolvedVersion = serviceVersion ?? "2.18.4";
62
62
  const exporter = new OTLPTraceExporter({ url: exporterUrl });
63
63
  const provider = new NodeTracerProvider({ resource: { attributes: {
64
64
  "service.name": serviceName,
@@ -79,8 +79,17 @@ const ssePlugin = async (fastify, opts = {}) => {
79
79
  }
80
80
  };
81
81
  if (requireAuth) {
82
- if (!fastify.hasDecorator("authenticate")) throw new Error("[arc-sse] requireAuth is true but fastify.authenticate is not registered. Register an auth plugin before SSE, or set requireAuth: false.");
83
- routeOpts.preHandler = fastify.authenticate;
82
+ routeOpts.preHandler = (request, reply) => {
83
+ const authenticate = fastify.authenticate;
84
+ if (typeof authenticate !== "function") {
85
+ reply.code(401).send({ error: "Unauthorized" });
86
+ return Promise.resolve();
87
+ }
88
+ return authenticate(request, reply);
89
+ };
90
+ fastify.addHook("onReady", async () => {
91
+ if (!fastify.hasDecorator("authenticate")) throw new Error("[arc-sse] requireAuth is true but no `authenticate` decorator was registered by the time the app was ready. Register an auth plugin, or set requireAuth: false.");
92
+ });
84
93
  }
85
94
  fastify.route(routeOpts);
86
95
  fastify.addHook("onClose", async () => {
@@ -1046,7 +1046,7 @@ function pickDefaultAuth(authMode, callerAuth) {
1046
1046
  };
1047
1047
  }
1048
1048
  async function createTestApp(options = {}) {
1049
- const { createApp } = await import("../createApp-DLuUGVZQ.mjs").then((n) => n.r);
1049
+ const { createApp } = await import("../createApp-J1iPXY9p.mjs").then((n) => n.r);
1050
1050
  const { resources = [], db = "in-memory", connectMongoose = false, authMode = "jwt", defaultOrgId, plugins, auth: callerAuth, ...appOptions } = options;
1051
1051
  let dbHandle;
1052
1052
  let dbUri;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/arc",
3
- "version": "2.18.3",
3
+ "version": "2.18.4",
4
4
  "description": "Resource-oriented backend framework for Fastify - clean, minimal, powerful, tree-shakable",
5
5
  "type": "module",
6
6
  "exports": {