appos 0.4.1-0 → 0.4.2-0

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.
@@ -2,7 +2,7 @@ import { t as defineAppContext } from "../app-context-DoFRTUi5.mjs";
2
2
  import { _ as defineAuthSchema, a as loadWorkflows, c as generatePreview, d as dbChangeInputSchema, f as dbChangesEvent, g as defineRedisClient, h as loadEvents, i as defineWorkflow, l as generateImageVariant, m as defineEventBus, n as defineQueue, o as purgeAttachment, p as defineEvent, r as defineScheduledWorkflow, t as sendEmail, u as extractBlobMetadata } from "../send-email-Do8SjZL7.mjs";
3
3
  import { f as PUBLIC_DIR, l as LOCALES_DIR } from "../constants-DbBfpyC3.mjs";
4
4
  import { _ as defineMigrationOpts, a as generateOpenAPIDocument, c as scanAPIRoutes, d as loadMiddleware, f as ui_default$2, g as defineDatabase, h as dbChanges, i as defineTypedResponses, l as writeOpenAPISpecs, m as ui_default, n as defineOpenAPIConfig, o as loadAndRegisterAPIRoutes, p as ui_default$1, r as defineOpenAPIEndpoint, s as registerRoutes, t as defineOpenAPI, u as defineMiddleware, v as defineTestDatabase, y as migrationsSchema } from "../openapi-C7QT3gNU.mjs";
5
- import { t as instrumentation_exports } from "../instrumentation-CTl5Q8ky.mjs";
5
+ import { t as instrumentation_exports } from "../instrumentation-DrvjMp7J.mjs";
6
6
  import { _ as pgTable, c as orm_exports, t as index, w as unique } from "../orm-BYSfGzG0.mjs";
7
7
  import { passkey } from "@better-auth/passkey";
8
8
  import { sso } from "@better-auth/sso";
@@ -32,7 +32,7 @@ import { DriveManager } from "flydrive";
32
32
  import { FSDriver } from "flydrive/drivers/fs";
33
33
  import { S3Driver } from "flydrive/drivers/s3";
34
34
 
35
- //#region src/web/auth.ts
35
+ //#region src/web/client/auth.ts
36
36
  /**
37
37
  * Default base path for auth routes.
38
38
  */
@@ -2,9 +2,9 @@ import "../app-context-DoFRTUi5.mjs";
2
2
  import { a as loadWorkflows, h as loadEvents } from "../send-email-Do8SjZL7.mjs";
3
3
  import { a as DATABASES_DIR, c as FIXTURES_DIR, h as WEB_DIR, i as COMMANDS_DIR, m as TEST_EXTENSIONS, n as BUILD_DIR, s as FILE_EXT, t as APPOS_DIR, u as MAIN_ENTRY } from "../constants-DbBfpyC3.mjs";
4
4
  import { _ as defineMigrationOpts } from "../openapi-C7QT3gNU.mjs";
5
- import "../instrumentation-CTl5Q8ky.mjs";
6
- import { t as defineServer } from "../server-6XZo256O.mjs";
7
- import "../ssr-CVebWWYi.mjs";
5
+ import "../instrumentation-DrvjMp7J.mjs";
6
+ import { t as defineServer } from "../server-lUTkWRNL.mjs";
7
+ import "../ssr-C4ZXh5DE.mjs";
8
8
  import { createRequire } from "node:module";
9
9
  import { z } from "zod";
10
10
  import path, { dirname, join } from "node:path";
@@ -221,74 +221,82 @@ function defineCommand(def) {
221
221
  //#endregion
222
222
  //#region src/cli/commands/build.ts
223
223
  /**
224
- * Runtime externals - needed in production Docker.
225
- */
226
- const RUNTIME_EXACT = [
227
- "canvas",
228
- "pino",
229
- "sharp",
230
- "thread-stream",
231
- "ultimate-express",
232
- "uWebSockets.js"
233
- ];
234
- /**
235
- * Runtime externals with prefixes.
236
- */
237
- const RUNTIME_PREFIXES = [
238
- "@aws-sdk/",
239
- "@dbos-inc/",
240
- "@img/",
241
- "@opentelemetry/",
242
- "@smithy/"
243
- ];
244
- /**
245
- * Build-time externals - only needed during build.
246
- */
247
- const BUILD_EXACT = [
248
- "esbuild",
249
- "lightningcss",
250
- "tailwindcss",
251
- "tsgo",
252
- "vite",
253
- "vitest",
254
- "youch"
255
- ];
256
- /**
257
- * Build-time externals with prefixes.
258
- */
259
- const BUILD_PREFIXES = ["@esbuild/", "@tailwindcss/"];
260
- /**
261
- * Optional externals - database drivers, only included if app uses them.
224
+ * Build externals configuration.
225
+ *
226
+ * - runtime: Packages collected to build/node_modules/ for production Docker.
227
+ * - esbuildOnly: Marked external during bundling but NOT collected (build tools, optional drivers).
228
+ * - skip: Excluded when collecting transitive dependencies.
262
229
  */
263
- const OPTIONAL_EXACT = [
264
- "@duckdb/node-api",
265
- "@electric-sql/pglite",
266
- "@libsql/client",
267
- "@neondatabase/serverless",
268
- "@planetscale/database",
269
- "@sqlitecloud/drivers",
270
- "@tursodatabase/database",
271
- "@vercel/postgres",
272
- "better-sqlite3",
273
- "postgres",
274
- "bun"
275
- ];
276
- const OPTIONAL_PREFIXES = ["mysql2"];
230
+ const EXTERNALS = {
231
+ runtime: [
232
+ "canvas",
233
+ "sharp",
234
+ "@img/*",
235
+ "pino",
236
+ "thread-stream",
237
+ "ultimate-express",
238
+ "uWebSockets.js",
239
+ "@aws-sdk/*",
240
+ "@dbos-inc/*",
241
+ "@opentelemetry/*",
242
+ "@smithy/*"
243
+ ],
244
+ esbuildOnly: [
245
+ "esbuild",
246
+ "@esbuild/*",
247
+ "lightningcss",
248
+ "tailwindcss",
249
+ "@tailwindcss/*",
250
+ "tsgo",
251
+ "vite",
252
+ "vitest",
253
+ "youch",
254
+ "@duckdb/node-api",
255
+ "@electric-sql/pglite",
256
+ "@libsql/client",
257
+ "@neondatabase/serverless",
258
+ "@planetscale/database",
259
+ "@sqlitecloud/drivers",
260
+ "@tursodatabase/database",
261
+ "@vercel/postgres",
262
+ "better-sqlite3",
263
+ "bun",
264
+ "mysql2*",
265
+ "postgres"
266
+ ],
267
+ skip: [
268
+ "@babel",
269
+ "@rollup",
270
+ "@types",
271
+ "biome",
272
+ "prettier",
273
+ "rollup",
274
+ "@grpc",
275
+ "node-fetch",
276
+ "web-streams-polyfill",
277
+ "fetch-blob",
278
+ "formdata-polyfill",
279
+ "data-uri-to-buffer",
280
+ "@opentelemetry/auto-instrumentations-node"
281
+ ]
282
+ };
283
+ /** Check if a package matches an external pattern (supports * suffix for prefix matching). */
284
+ function matchesPattern(name, pattern) {
285
+ return pattern.endsWith("*") ? name.startsWith(pattern.slice(0, -1)) : name === pattern;
286
+ }
287
+ /** Check if a package is a runtime external (should be collected). */
288
+ function isRuntimeExternal(name) {
289
+ return EXTERNALS.runtime.some((p$1) => matchesPattern(name, p$1));
290
+ }
291
+ /** Check if a package should be skipped during collection. */
292
+ function shouldSkip(name) {
293
+ return EXTERNALS.skip.some((p$1) => name.startsWith(p$1));
294
+ }
277
295
  /**
278
296
  * Get all externals for esbuild bundling.
279
297
  */
280
298
  function getEsbuildExternals() {
281
- const allExact = [
282
- ...RUNTIME_EXACT,
283
- ...BUILD_EXACT,
284
- ...OPTIONAL_EXACT
285
- ];
286
- const allPrefixes = [
287
- ...RUNTIME_PREFIXES,
288
- ...BUILD_PREFIXES,
289
- ...OPTIONAL_PREFIXES
290
- ];
291
- return [...allExact, ...allPrefixes.map((p$1) => `${p$1}*`)];
299
+ return [...EXTERNALS.runtime, ...EXTERNALS.esbuildOnly];
292
300
  }
293
301
  /**
294
302
  * Find a binary in node_modules/.bin by traversing up from cwd.
@@ -324,22 +332,6 @@ async function collectEntryPoints() {
324
332
  return entryPoints;
325
333
  }
326
334
  /**
327
- * Prefixes of packages to skip when collecting runtime dependencies.
328
- */
329
- const SKIP_PREFIXES = [
330
- "@babel",
331
- "@esbuild",
332
- "@rollup",
333
- "@tailwindcss",
334
- "@types",
335
- "biome",
336
- "esbuild",
337
- "prettier",
338
- "rollup",
339
- "tailwindcss",
340
- "vite"
341
- ];
342
- /**
343
335
  * Collect runtime dependencies to build/node_modules/.
344
336
  *
345
337
  * Algorithm:
@@ -391,7 +383,7 @@ async function collectRuntimeDeps() {
391
383
  * 3. Recursively collect dependencies and non-optional peerDependencies
392
384
  */
393
385
  async function collectPackage(name) {
394
- if (collected.has(name) || SKIP_PREFIXES.some((p$1) => name.startsWith(p$1))) return;
386
+ if (collected.has(name) || shouldSkip(name)) return;
395
387
  collected.add(name);
396
388
  const pkgPath = await findPackageJson(name);
397
389
  if (!pkgPath) return;
@@ -404,11 +396,7 @@ async function collectRuntimeDeps() {
404
396
  dereference: true
405
397
  });
406
398
  if (name === "appos") {
407
- for (const dep of Object.keys(pkgJson.dependencies || {})) {
408
- const isRuntimeExact = RUNTIME_EXACT.includes(dep);
409
- const isRuntimePrefix = RUNTIME_PREFIXES.some((p$1) => dep.startsWith(p$1));
410
- if (isRuntimeExact || isRuntimePrefix) await collectPackage(dep);
411
- }
399
+ for (const dep of Object.keys(pkgJson.dependencies || {})) if (isRuntimeExternal(dep)) await collectPackage(dep);
412
400
  return;
413
401
  }
414
402
  for (const dep of Object.keys(pkgJson.dependencies || {})) await collectPackage(dep);
@@ -416,16 +404,7 @@ async function collectRuntimeDeps() {
416
404
  for (const dep of Object.keys(pkgJson.peerDependencies || {})) if (!peerMeta[dep]?.optional) await collectPackage(dep);
417
405
  }
418
406
  await mkdir(targetDir, { recursive: true });
419
- for (const pkg of RUNTIME_EXACT) await collectPackage(pkg);
420
- const apposPkgPath = await findPackageJson("appos");
421
- if (apposPkgPath) {
422
- const apposPkgJson = JSON.parse(await readFile(apposPkgPath, "utf8"));
423
- for (const dep of Object.keys(apposPkgJson.dependencies || {})) {
424
- const isRuntimeExact = RUNTIME_EXACT.includes(dep);
425
- const isRuntimePrefix = RUNTIME_PREFIXES.some((p$1) => dep.startsWith(p$1));
426
- if (isRuntimeExact || isRuntimePrefix) await collectPackage(dep);
427
- }
428
- }
407
+ await collectPackage("appos");
429
408
  const arch = process.arch === "x64" ? "x64" : process.arch;
430
409
  const platform = process.platform;
431
410
  const nodeAbi = process.versions.modules;
@@ -1425,7 +1404,7 @@ var preview_default = defineCommand({
1425
1404
 
1426
1405
  //#endregion
1427
1406
  //#region package.json
1428
- var version = "0.4.1-0";
1407
+ var version = "0.4.2-0";
1429
1408
 
1430
1409
  //#endregion
1431
1410
  //#region src/cli/commands/repl.ts
@@ -7,9 +7,12 @@ __reExport(instrumentation_exports, import__opentelemetry_api);
7
7
  const importFlag = "import=appos/instrumentation";
8
8
  if (process.execArgv.some((arg) => arg.includes(importFlag)) || (process.env.NODE_OPTIONS ?? "").includes(importFlag)) {
9
9
  const { register } = await import("node:module");
10
- const { getNodeAutoInstrumentations } = await import("@opentelemetry/auto-instrumentations-node");
11
10
  const { OTLPTraceExporter } = await import("@opentelemetry/exporter-trace-otlp-http");
11
+ const { ExpressInstrumentation } = await import("@opentelemetry/instrumentation-express");
12
+ const { HttpInstrumentation } = await import("@opentelemetry/instrumentation-http");
13
+ const { PgInstrumentation } = await import("@opentelemetry/instrumentation-pg");
12
14
  const { PinoInstrumentation } = await import("@opentelemetry/instrumentation-pino");
15
+ const { UndiciInstrumentation } = await import("@opentelemetry/instrumentation-undici");
13
16
  const { resourceFromAttributes } = await import("@opentelemetry/resources");
14
17
  const { NodeSDK } = await import("@opentelemetry/sdk-node");
15
18
  const { BatchSpanProcessor } = await import("@opentelemetry/sdk-trace-node");
@@ -28,12 +31,15 @@ if (process.execArgv.some((arg) => arg.includes(importFlag)) || (process.env.NOD
28
31
  url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || "http://localhost:4318/v1/traces",
29
32
  headers: process.env.OTEL_EXPORTER_OTLP_HEADERS ? JSON.parse(process.env.OTEL_EXPORTER_OTLP_HEADERS) : void 0
30
33
  }))],
31
- instrumentations: [getNodeAutoInstrumentations({
32
- "@opentelemetry/instrumentation-fs": { enabled: false },
33
- "@opentelemetry/instrumentation-dns": { enabled: false }
34
- }), new PinoInstrumentation({ logHook: (_span, record) => {
35
- record["service.name"] = service.name;
36
- } })]
34
+ instrumentations: [
35
+ new HttpInstrumentation(),
36
+ new ExpressInstrumentation(),
37
+ new PgInstrumentation(),
38
+ new UndiciInstrumentation(),
39
+ new PinoInstrumentation({ logHook: (_span, record) => {
40
+ record["service.name"] = service.name;
41
+ } })
42
+ ]
37
43
  }).start();
38
44
  }
39
45
 
@@ -1,4 +1,4 @@
1
- import "./instrumentation-CTl5Q8ky.mjs";
1
+ import "./instrumentation-DrvjMp7J.mjs";
2
2
 
3
3
  export * from "@opentelemetry/api"
4
4
 
@@ -1,7 +1,7 @@
1
1
  import { d as MIDDLEWARE_DIR, f as PUBLIC_DIR, h as WEB_DIR, r as BUILD_OUTPUT_DIR, t as APPOS_DIR } from "./constants-DbBfpyC3.mjs";
2
2
  import { d as loadMiddleware, f as ui_default$2, m as ui_default, o as loadAndRegisterAPIRoutes, p as ui_default$1 } from "./openapi-C7QT3gNU.mjs";
3
- import { t as instrumentation_exports } from "./instrumentation-CTl5Q8ky.mjs";
4
- import { n as appLoadContext } from "./ssr-CVebWWYi.mjs";
3
+ import { t as instrumentation_exports } from "./instrumentation-DrvjMp7J.mjs";
4
+ import { d as appLoadContext } from "./ssr-C4ZXh5DE.mjs";
5
5
  import { toNodeHandler } from "better-auth/node";
6
6
  import { createClient } from "redis";
7
7
  import { join, resolve } from "node:path";
@@ -1,6 +1,6 @@
1
1
  import { dirname, join } from "node:path";
2
- import { remixRoutesOptionAdapter as remixRoutesOptionAdapter$1 } from "@react-router/remix-routes-option-adapter";
3
- import { flatRoutes as flatRoutes$1 } from "remix-flat-routes";
2
+ import { remixRoutesOptionAdapter, remixRoutesOptionAdapter as remixRoutesOptionAdapter$1 } from "@react-router/remix-routes-option-adapter";
3
+ import { flatRoutes, flatRoutes as flatRoutes$1 } from "remix-flat-routes";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { RouterContextProvider as RouterContextProvider$1, createContext, redirect } from "react-router";
6
6
  import { createReadableStreamFromReadable } from "@react-router/node";
@@ -8,6 +8,16 @@ import { isbot } from "isbot";
8
8
  import { renderToPipeableStream } from "react-dom/server";
9
9
  import { layout, route } from "@react-router/dev/routes";
10
10
 
11
+ //#region src/web/server/context.ts
12
+ /**
13
+ * Server-side context utilities for React Router.
14
+ */
15
+ /**
16
+ * The typed context for accessing AppContext in React Router loaders/actions.
17
+ */
18
+ const appLoadContext = createContext();
19
+
20
+ //#endregion
11
21
  //#region src/web/routes/auth/utils.ts
12
22
  /**
13
23
  * Authentication route configuration utilities.
@@ -145,19 +155,41 @@ function definePostAuthRedirect(requestUrl, fallbackPath = "/") {
145
155
  }
146
156
 
147
157
  //#endregion
148
- //#region src/web/ssr.ts
158
+ //#region src/web/server/routes.ts
149
159
  /**
150
- * React Router SSR utilities.
160
+ * Creates flat routes configuration for React Router v7.
151
161
  *
152
- * Used in:
153
- * - routes.ts (build-time route configuration)
154
- * - entry.server.tsx (SSR rendering)
155
- * - api/main.ts (express request handler)
156
- */
157
- /**
158
- * The typed context for accessing AppContext in React Router loaders/actions.
162
+ * Encapsulates the remix-flat-routes setup with sensible defaults:
163
+ * - Ignores dotfiles and test files by default
164
+ * - Returns empty array during production build (routes are pre-resolved)
165
+ * - Uses remix-flat-routes for file-based routing
166
+ *
167
+ * @param options - Configuration options
168
+ * @returns Route configuration entries to spread in routes.ts default export
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * import { defineAuthRoutes, defineFlatRoutes } from "appos/web/ssr";
173
+ * import { authConfig } from "#isomorphic/auth.ts";
174
+ * import config from "#react-router.config.ts";
175
+ *
176
+ * export const authRoutes = defineAuthRoutes({ config: authConfig });
177
+ *
178
+ * export default [
179
+ * ...await defineFlatRoutes({ config }),
180
+ * ...authRoutes.routes,
181
+ * ];
182
+ * ```
159
183
  */
160
- const appLoadContext = createContext();
184
+ async function defineFlatRoutes(options) {
185
+ if (import.meta.url.endsWith(".js")) return [];
186
+ const { config, routesDir = "routes", ignoredRouteFiles = [] } = options;
187
+ const defaultIgnored = ["**/.*", "**/*.{spec,test}.{ts,tsx}"];
188
+ return remixRoutesOptionAdapter((defineRoutes) => flatRoutes(routesDir, defineRoutes, {
189
+ appDir: config.appDirectory,
190
+ ignoredRouteFiles: [...defaultIgnored, ...ignoredRouteFiles]
191
+ }));
192
+ }
161
193
 
162
194
  //#endregion
163
- export { isbot as a, defineAuthRoutes as c, flatRoutes$1 as i, defineLoginRedirect as l, appLoadContext as n, remixRoutesOptionAdapter$1 as o, createReadableStreamFromReadable as r, renderToPipeableStream as s, RouterContextProvider$1 as t, definePostAuthRedirect as u };
195
+ export { defineLoginRedirect as a, createReadableStreamFromReadable as c, appLoadContext as d, defineAuthRoutes as i, isbot as l, flatRoutes$1 as n, definePostAuthRedirect as o, remixRoutesOptionAdapter$1 as r, RouterContextProvider$1 as s, defineFlatRoutes as t, renderToPipeableStream as u };
@@ -1,9 +1,9 @@
1
1
  import "../app-context-DoFRTUi5.mjs";
2
2
  import "../constants-DbBfpyC3.mjs";
3
3
  import { v as defineTestDatabase } from "../openapi-C7QT3gNU.mjs";
4
- import "../instrumentation-CTl5Q8ky.mjs";
5
- import { t as defineServer } from "../server-6XZo256O.mjs";
6
- import "../ssr-CVebWWYi.mjs";
4
+ import "../instrumentation-DrvjMp7J.mjs";
5
+ import { t as defineServer } from "../server-lUTkWRNL.mjs";
6
+ import "../ssr-C4ZXh5DE.mjs";
7
7
  import { t as mock_exports } from "../mock-CURQkGUm.mjs";
8
8
  import { join } from "node:path";
9
9
  import { mkdirSync, mkdtempSync } from "node:fs";