@geekmidas/constructs 10.0.0-alpha.3 → 10.0.0-alpha.5

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 (92) hide show
  1. package/dist/{Cron-ByxdOfpE.d.mts → Cron-B2OFsfDM.d.cts} +4 -4
  2. package/dist/{Cron-ByxdOfpE.d.mts.map → Cron-B2OFsfDM.d.cts.map} +1 -1
  3. package/dist/{Cron-Wqh464aO.d.cts → Cron-CqEbBbwH.d.mts} +4 -4
  4. package/dist/{Cron-Wqh464aO.d.cts.map → Cron-CqEbBbwH.d.mts.map} +1 -1
  5. package/dist/{CronBuilder-BL0AP6fs.d.mts → CronBuilder-Bg-9h2cc.d.mts} +3 -3
  6. package/dist/{CronBuilder-BL0AP6fs.d.mts.map → CronBuilder-Bg-9h2cc.d.mts.map} +1 -1
  7. package/dist/{CronBuilder-BmABazzH.mjs → CronBuilder-CdibiHNB.mjs} +2 -2
  8. package/dist/{CronBuilder-BmABazzH.mjs.map → CronBuilder-CdibiHNB.mjs.map} +1 -1
  9. package/dist/{CronBuilder-CkXPJiGO.cjs → CronBuilder-DyUr6nYz.cjs} +2 -2
  10. package/dist/{CronBuilder-CkXPJiGO.cjs.map → CronBuilder-DyUr6nYz.cjs.map} +1 -1
  11. package/dist/{CronBuilder-BqpEzMPQ.d.cts → CronBuilder-LSJMfqnq.d.cts} +3 -3
  12. package/dist/{CronBuilder-BqpEzMPQ.d.cts.map → CronBuilder-LSJMfqnq.d.cts.map} +1 -1
  13. package/dist/{Endpoint-BiaaMEn_.cjs → Endpoint-DODn1RhN.cjs} +2 -2
  14. package/dist/{Endpoint-BiaaMEn_.cjs.map → Endpoint-DODn1RhN.cjs.map} +1 -1
  15. package/dist/{Endpoint-2Wg7T7Cq.d.mts → Endpoint-Dem2XyCu.d.mts} +2 -2
  16. package/dist/{Endpoint-2Wg7T7Cq.d.mts.map → Endpoint-Dem2XyCu.d.mts.map} +1 -1
  17. package/dist/{Endpoint-VIOpSo0S.mjs → Endpoint-Dij_wOcc.mjs} +2 -2
  18. package/dist/{Endpoint-VIOpSo0S.mjs.map → Endpoint-Dij_wOcc.mjs.map} +1 -1
  19. package/dist/{Endpoint-CH9Fn1AD.d.cts → Endpoint-DrD8a1yH.d.cts} +2 -2
  20. package/dist/Endpoint-DrD8a1yH.d.cts.map +1 -0
  21. package/dist/{EndpointFactory-ChxLZllA.cjs → EndpointFactory-BHFMmFkV.cjs} +3 -3
  22. package/dist/{EndpointFactory-ChxLZllA.cjs.map → EndpointFactory-BHFMmFkV.cjs.map} +1 -1
  23. package/dist/{EndpointFactory-DTTCkGEL.mjs → EndpointFactory-b4ituq-s.mjs} +3 -3
  24. package/dist/{EndpointFactory-DTTCkGEL.mjs.map → EndpointFactory-b4ituq-s.mjs.map} +1 -1
  25. package/dist/{HonoEndpointAdaptor-NKQQQbBY.mjs → HonoEndpointAdaptor-BM2jbWht.mjs} +2 -2
  26. package/dist/{HonoEndpointAdaptor-NKQQQbBY.mjs.map → HonoEndpointAdaptor-BM2jbWht.mjs.map} +1 -1
  27. package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs → HonoEndpointAdaptor-De6IlBZe.cjs} +2 -2
  28. package/dist/{HonoEndpointAdaptor-D233Jvpk.cjs.map → HonoEndpointAdaptor-De6IlBZe.cjs.map} +1 -1
  29. package/dist/adaptors/aws.cjs +2 -2
  30. package/dist/adaptors/aws.d.cts +3 -3
  31. package/dist/adaptors/aws.d.mts +3 -3
  32. package/dist/adaptors/aws.mjs +2 -2
  33. package/dist/adaptors/hono.cjs +3 -3
  34. package/dist/adaptors/hono.d.cts +2 -2
  35. package/dist/adaptors/hono.d.cts.map +1 -1
  36. package/dist/adaptors/hono.d.mts +4 -4
  37. package/dist/adaptors/hono.d.mts.map +1 -1
  38. package/dist/adaptors/hono.mjs +3 -3
  39. package/dist/adaptors/testing.cjs +3 -3
  40. package/dist/adaptors/testing.d.cts +2 -2
  41. package/dist/adaptors/testing.d.mts +2 -2
  42. package/dist/adaptors/testing.mjs +3 -3
  43. package/dist/auth.cjs +1 -1
  44. package/dist/auth.cjs.map +1 -1
  45. package/dist/auth.d.cts.map +1 -1
  46. package/dist/auth.d.mts.map +1 -1
  47. package/dist/auth.mjs +1 -1
  48. package/dist/auth.mjs.map +1 -1
  49. package/dist/crons/index.cjs +2 -2
  50. package/dist/crons/index.d.cts +7 -7
  51. package/dist/crons/index.d.cts.map +1 -1
  52. package/dist/crons/index.d.mts +7 -7
  53. package/dist/crons/index.mjs +2 -2
  54. package/dist/endpoints/index.cjs +3 -3
  55. package/dist/endpoints/index.d.cts +3 -3
  56. package/dist/endpoints/index.d.mts +3 -3
  57. package/dist/endpoints/index.mjs +3 -3
  58. package/dist/functions/index.cjs +1 -1
  59. package/dist/functions/index.d.cts +1 -1
  60. package/dist/functions/index.d.mts +1 -1
  61. package/dist/functions/index.mjs +1 -1
  62. package/dist/{functions-Cxbo-pEd.mjs → functions-Ck21Uyq0.mjs} +4 -3
  63. package/dist/{functions-Cxbo-pEd.mjs.map → functions-Ck21Uyq0.mjs.map} +1 -1
  64. package/dist/{functions-Bd3TPxid.cjs → functions-DJJA7VGc.cjs} +4 -3
  65. package/dist/{functions-Bd3TPxid.cjs.map → functions-DJJA7VGc.cjs.map} +1 -1
  66. package/dist/{index-JSf9xNIJ.d.cts → index-AIfVzkhi.d.cts} +5 -5
  67. package/dist/{index-JSf9xNIJ.d.cts.map → index-AIfVzkhi.d.cts.map} +1 -1
  68. package/dist/{index-V2nksZIJ.d.cts → index-B8g8POkr.d.cts} +3 -3
  69. package/dist/{index-BxHDdy6a.d.mts.map → index-B8g8POkr.d.cts.map} +1 -1
  70. package/dist/{index-CubPzHd9.d.mts → index-D3zjrwjr.d.mts} +11 -12
  71. package/dist/index-D3zjrwjr.d.mts.map +1 -0
  72. package/dist/{index-BxHDdy6a.d.mts → index-DbKmfl-q.d.mts} +3 -3
  73. package/dist/{index-V2nksZIJ.d.cts.map → index-DbKmfl-q.d.mts.map} +1 -1
  74. package/dist/queue/index.d.cts +2 -2
  75. package/dist/queue/index.d.cts.map +1 -1
  76. package/dist/queue/index.d.mts +2 -2
  77. package/dist/rest-api.cjs +3 -3
  78. package/dist/rest-api.d.cts +3 -3
  79. package/dist/rest-api.d.mts +9 -9
  80. package/dist/rest-api.d.mts.map +1 -1
  81. package/dist/rest-api.mjs +3 -3
  82. package/dist/subscribers/index.d.cts +2 -2
  83. package/dist/subscribers/index.d.cts.map +1 -1
  84. package/dist/subscribers/index.d.mts +2 -2
  85. package/dist/worker.cjs +2 -2
  86. package/dist/worker.d.cts +9 -9
  87. package/dist/worker.d.mts +8 -9
  88. package/dist/worker.d.mts.map +1 -1
  89. package/dist/worker.mjs +2 -2
  90. package/package.json +45 -45
  91. package/dist/Endpoint-CH9Fn1AD.d.cts.map +0 -1
  92. package/dist/index-CubPzHd9.d.mts.map +0 -1
package/dist/auth.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"auth.mjs","names":["id: ConstructName<TName>","config: BetterAuthConfig<TDatabase>","options: ServiceRegisterOptions","value: string","as: { owner?: boolean }","configured: BetterAuthOptions"],"sources":["../src/auth.ts"],"sourcesContent":["/**\n * `BetterAuth` — a declared auth server.\n *\n * It is three things at once, which is what makes it the construct that\n * exercises most of the model: a consumer of a database, a producer of an\n * authorizer, and a set of endpoints. This lands the first two.\n *\n * Its tables live in a schema tenant it is *given* — `orders.schema('AuthDb')`\n * — rather than one it invents. The tenant declares the schema and the role;\n * this declares the one thing left, the signing secret, and reads back the keys\n * it needs.\n *\n * :::caution\n * The isolation that arrangement is *for* — the application's own role holding\n * no grant on these tables, so a compromised handler cannot read sessions — does\n * **not hold yet**. No target creates the per-schema role: both connect as the\n * database owner, so today the tenant is a `search_path`, which is a namespace\n * and not a privilege boundary. See \"Roles are declared and never created\" in\n * `docs/design/constructs-outstanding.md`.\n * :::\n *\n * It declares its own surface, so where it answers, who may call it, and the\n * domain its cookies are scoped to all arrive as environment resolved by the\n * target — none of them guessed from a port, and none of them listed by hand in\n * application config.\n */\n\nimport {\n\ttype AppSpec,\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tenvironmentCase,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { betterAuth } from 'better-auth';\nimport type { Hono } from 'hono';\nimport type { Kysely } from 'kysely';\nimport { type Construct, type Consumable, edgeTo } from './construct-interface';\n\n/** The server better-auth hands back. */\nexport type AuthServer = ReturnType<typeof betterAuth>;\n\n/** Everything better-auth takes, minus what the construct owns. */\nexport type BetterAuthOptions = Omit<\n\tParameters<typeof betterAuth>[0],\n\t'database' | 'secret' | 'basePath' | 'baseURL'\n>;\n\nexport interface BetterAuthConfig<TDatabase extends Consumable> {\n\t/**\n\t * The schema tenant its tables live in.\n\t *\n\t * A construct rather than a URL: the tenant already declares its schema and\n\t * its role, and taking the declaration is what puts the edge in the graph\n\t * instead of a connection string in two places.\n\t */\n\tdatabase: TDatabase;\n\t/**\n\t * Where the auth routes are mounted, e.g. `/api/auth`.\n\t *\n\t * Structural — it is part of the URL every client calls, so it cannot differ\n\t * between stages the way the host can.\n\t */\n\tbasePath?: string;\n\t/**\n\t * The app that serves this auth server — its own container.\n\t *\n\t * An auth server holds the session secret and reaches the identity tables.\n\t * Its own process is the default because sharing one means the surface it\n\t * shares with can read both.\n\t */\n\tapp?: AppSpec;\n\t/**\n\t * The rest of better-auth's options: providers, plugins, email settings.\n\t *\n\t * A function when they need another construct — a magic-link plugin has to\n\t * *send* the link, and the thing that sends mail is a construct whose client\n\t * has to be registered. It is handed the same `ServiceRegisterOptions` this\n\t * construct was, so the env parser flows through the graph rather than being\n\t * imported out of application config.\n\t */\n\toptions?:\n\t\t| BetterAuthOptions\n\t\t| ((\n\t\t\t\toptions: ServiceRegisterOptions,\n\t\t ) => BetterAuthOptions | Promise<BetterAuthOptions>);\n}\n\nconst DEFAULT_BASE_PATH = '/api/auth';\n\nexport class BetterAuth<\n\tTName extends string = string,\n\tTDatabase extends Consumable = Consumable,\n> implements Construct<TName, AuthServer>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, AuthServer>;\n\treadonly basePath: string;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the keys the\n\t * target publishes and the keys the server reads cannot drift.\n\t */\n\tprivate readonly keys: {\n\t\tsecretId: string;\n\t\tsecret: string;\n\t\turl: string;\n\t\ttrustedOrigins: string;\n\t\tcookieDomain: string;\n\t};\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: BetterAuthConfig<TDatabase>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.basePath = config.basePath ?? DEFAULT_BASE_PATH;\n\n\t\t// A secret's name is its key: `Auth` signs with `AUTH_SECRET`, which is\n\t\t// also what better-auth's own tooling looks for.\n\t\tconst secretId = `${canonical}Secret`;\n\t\tthis.keys = {\n\t\t\tsecretId,\n\t\t\tsecret: environmentCase(secretId),\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\ttrustedOrigins: provideKey(canonical, 'trustedOrigins'),\n\t\t\tcookieDomain: provideKey(canonical, 'cookieDomain'),\n\t\t};\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\t/**\n\t * A signing secret and a surface.\n\t *\n\t * The database is *not* declared here — the tenant that was passed in\n\t * declares it, and declaring it twice is the duplication the whole model\n\t * removes. What is declared is what this construct owns: the key it signs\n\t * with, and the routes it answers on.\n\t *\n\t * One endpoint, wildcarded. Better Auth routes internally and the set of\n\t * paths depends on which capabilities are enabled, so enumerating them here\n\t * would be a copy of its router that goes stale on its next release. The\n\t * surface's job is to send everything under `basePath` to one handler, which\n\t * is exactly what the declaration says.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'secret',\n\t\t\t\tid: this.keys.secretId,\n\t\t\t\tprovides: [this.keys.secret],\n\t\t\t},\n\t\t\t{\n\t\t\t\tkind: 'rest-api',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.config.app ? { app: this.config.app } : {}),\n\t\t\t\tprovides: [\n\t\t\t\t\tthis.keys.url,\n\t\t\t\t\tthis.keys.trustedOrigins,\n\t\t\t\t\tthis.keys.cookieDomain,\n\t\t\t\t],\n\t\t\t\tendpoints: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${this.id}Handler`,\n\t\t\t\t\t\thandler: `${this.id}.handler`,\n\t\t\t\t\t\tmethod: 'ANY',\n\t\t\t\t\t\tpath: `${this.basePath}/*`,\n\t\t\t\t\t\t// Read off the tenant rather than written down: this\n\t\t\t\t\t\t// construct takes whatever database it is given, and a\n\t\t\t\t\t\t// hardcoded kind is a second statement of a fact the\n\t\t\t\t\t\t// tenant already makes.\n\t\t\t\t\t\tdependencies: [edgeTo(this.config.database)],\n\t\t\t\t\t\trequires: [this.keys.secret],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Better Auth's own migrations, for the app's migrate step.\n\t *\n\t * It brings its own schema — users, sessions, accounts, verifications — so\n\t * the app never writes those tables and never gets to drift from them.\n\t */\n\tasync migrations(\n\t\toptions: ServiceRegisterOptions,\n\t): Promise<() => Promise<void>> {\n\t\t// As the owner, not the runtime role. Creating tables is DDL, and the\n\t\t// whole point of the split is that a handler's role cannot do it — so a\n\t\t// migrator that connected the way a handler does would fail on the first\n\t\t// `CREATE TABLE` rather than working by accident.\n\t\tconst auth = await this.connect(options, { owner: true });\n\t\tconst { getMigrations } = await import('better-auth/db');\n\t\tconst { runMigrations } = await getMigrations(auth.options);\n\n\t\treturn runMigrations;\n\t}\n\n\t/**\n\t * The server this surface runs as, built from its own declaration.\n\t *\n\t * A surface is a deploy unit, so something has to serve it, and the thing\n\t * that knows how is the construct — not a generator writing a mount into\n\t * somebody else's entry point. That is how the auth server came to be\n\t * mounted by a hook in the application it was supposed to be separate from,\n\t * and then to be served by nothing at all when the hook was deleted.\n\t *\n\t * The routes come from {@link declare}: one wildcard under `basePath`, read\n\t * off the same declaration the manifest carries, so the surface the graph\n\t * describes and the surface that answers requests cannot disagree.\n\t *\n\t * ```ts\n\t * // .gkm/server/app.ts — the whole generated entry\n\t * import { auth } from '@acme/constructs/auth.js';\n\t * export const { app } = await auth.server({ envParser });\n\t * ```\n\t */\n\tasync server(options: ServiceRegisterOptions): Promise<{ app: Hono }> {\n\t\tconst { Hono } = await import('hono');\n\t\tconst { cors } = await import('hono/cors');\n\t\tconst app = new Hono();\n\t\tconst server = await this.connect(options);\n\n\t\t// Who may call this surface, read off the graph. The same list Better\n\t\t// Auth checks for CSRF — it arrives as `<ID>_TRUSTED_ORIGINS`, composed\n\t\t// by the target from whatever declared an edge to this construct, so a\n\t\t// site that depends on the auth server is allowed to reach it and\n\t\t// nothing else is. Nobody writes an origin down.\n\t\tconst { origins } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\torigins: get(this.keys.trustedOrigins)\n\t\t\t\t\t.string()\n\t\t\t\t\t.default('')\n\t\t\t\t\t.transform((value: string) =>\n\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t.split(',')\n\t\t\t\t\t\t\t.map((origin) => origin.trim())\n\t\t\t\t\t\t\t.filter(Boolean),\n\t\t\t\t\t),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\tapp.use('*', cors({ origin: origins, credentials: true, maxAge: 3600 }));\n\n\t\t// Read off the declaration rather than restated here. `ANY` is every\n\t\t// method Better Auth routes internally, which is the reason the\n\t\t// declaration wildcards rather than enumerating.\n\t\tconst [surface] = this.declare().filter(\n\t\t\t(d): d is Extract<Declaration, { kind: 'rest-api' }> =>\n\t\t\t\td.kind === 'rest-api',\n\t\t);\n\n\t\tfor (const endpoint of surface?.endpoints ?? []) {\n\t\t\tconst methods =\n\t\t\t\tendpoint.method === 'ANY'\n\t\t\t\t\t? (['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'] as const)\n\t\t\t\t\t: ([endpoint.method] as const);\n\n\t\t\tapp.on([...methods], endpoint.path, (c) => server.handler(c.req.raw));\n\t\t}\n\n\t\treturn { app };\n\t}\n\n\tprivate async connect(\n\t\toptions: ServiceRegisterOptions,\n\t\tas: { owner?: boolean } = {},\n\t): Promise<AuthServer> {\n\t\tconst { secret, baseUrl, trustedOrigins, cookieDomain } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\tsecret: get(this.keys.secret).string(),\n\t\t\t\t// The surface's own URL, resolved by the target — not guessed from\n\t\t\t\t// a port, which was wrong the moment the server moved to 3001.\n\t\t\t\tbaseUrl: get(this.keys.url).string(),\n\t\t\t\t// Better Auth's CSRF check applies to every caller, not just\n\t\t\t\t// browsers, so an API calling the auth server is rejected unless\n\t\t\t\t// its origin is trusted. The list is derived from the graph and\n\t\t\t\t// arrives as one comma-separated value, for the same reason every\n\t\t\t\t// other derived value arrives as a string: it crosses a process\n\t\t\t\t// boundary as env.\n\t\t\t\ttrustedOrigins: get(this.keys.trustedOrigins)\n\t\t\t\t\t.string()\n\t\t\t\t\t.default('')\n\t\t\t\t\t.transform((value) =>\n\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t.split(',')\n\t\t\t\t\t\t\t.map((origin) => origin.trim())\n\t\t\t\t\t\t\t.filter(Boolean),\n\t\t\t\t\t),\n\t\t\t\t// The domain a session cookie has to carry to be readable by a\n\t\t\t\t// frontend on a sibling host. Optional because there is often\n\t\t\t\t// nothing to widen to: locally everything shares `localhost`,\n\t\t\t\t// where cookies ignore the port and a `Domain` would only be a\n\t\t\t\t// value the browser refuses.\n\t\t\t\tcookieDomain: get(this.keys.cookieDomain).string().optional(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\t// The tenant's own client: one construct, one connection, so what auth\n\t\t// writes and what the browser inspects cannot be two different databases.\n\t\t// A migration asks the tenant for its owner connection, which the tenant\n\t\t// exposes as a `Service` and not as anything `.dependsOn()` would take.\n\t\tconst tenant = this.config.database as Consumable & {\n\t\t\towner?: Service<string, unknown>;\n\t\t};\n\t\tconst source = as.owner && tenant.owner ? tenant.owner : tenant.service;\n\n\t\tconst db = (await source.register(options)) as Kysely<\n\t\t\tRecord<string, never>\n\t\t>;\n\n\t\t// Hoisted: narrowing a property of `this` is not preserved across the\n\t\t// await, and the false branch is the plain-object form.\n\t\tconst configure = this.config.options;\n\t\tconst configured: BetterAuthOptions =\n\t\t\ttypeof configure === 'function'\n\t\t\t\t? await configure(options)\n\t\t\t\t: (configure ?? {});\n\n\t\treturn betterAuth({\n\t\t\t...configured,\n\t\t\tsecret,\n\t\t\tbaseURL: baseUrl,\n\t\t\tbasePath: this.basePath,\n\t\t\tdatabase: { db, type: 'postgres' },\n\t\t\t// Whatever the app added wins over the derived list rather than\n\t\t\t// replacing it: an origin nobody declared is still sometimes real.\n\t\t\ttrustedOrigins: [\n\t\t\t\t...trustedOrigins,\n\t\t\t\t...(configured.trustedOrigins &&\n\t\t\t\tArray.isArray(configured.trustedOrigins)\n\t\t\t\t\t? configured.trustedOrigins\n\t\t\t\t\t: []),\n\t\t\t],\n\t\t\tadvanced: {\n\t\t\t\t...configured.advanced,\n\t\t\t\t// Only when a domain was derived. Better Auth reads the presence\n\t\t\t\t// of this block as intent, so enabling it with no domain would\n\t\t\t\t// widen the cookie to whatever host happened to set it — and the\n\t\t\t\t// case with nothing to widen to is the common one, not an error.\n\t\t\t\t...(cookieDomain\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcrossSubDomainCookies: {\n\t\t\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\t\t\tdomain: cookieDomain,\n\t\t\t\t\t\t\t\t...configured.advanced?.crossSubDomainCookies,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t},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,CACR,QAAQ,GAAG,CACX,UAAU,CAAC,UACX,MACE,MAAM,IAAI,CACV,IAAI,CAAC,WAAW,OAAO,MAAM,CAAC,CAC9B,OAAO,QAAQ,CACjB;GAMF,cAAc,IAAI,KAAK,KAAK,aAAa,CAAC,QAAQ,CAAC,UAAU;EAC7D,GAAE,CACF,OAAO;EAMT,MAAM,SAAS,KAAK,OAAO;EAG3B,MAAM,SAAS,GAAG,SAAS,OAAO,QAAQ,OAAO,QAAQ,OAAO;EAEhE,MAAM,KAAM,MAAM,OAAO,SAAS,QAAQ;EAM1C,MAAM,YAAY,KAAK,OAAO;EAC9B,MAAMC,oBACE,cAAc,aAClB,MAAM,UAAU,QAAQ,GACvB,aAAa,CAAE;AAEpB,SAAO,WAAW;GACjB,GAAG;GACH;GACA,SAAS;GACT,UAAU,KAAK;GACf,UAAU;IAAE;IAAI,MAAM;GAAY;GAGlC,gBAAgB,CACf,GAAG,gBACH,GAAI,WAAW,kBACf,MAAM,QAAQ,WAAW,eAAe,GACrC,WAAW,iBACX,CAAE,CACL;GACD,UAAU;IACT,GAAG,WAAW;IAKd,GAAI,eACD,EACA,uBAAuB;KACtB,SAAS;KACT,QAAQ;KACR,GAAG,WAAW,UAAU;IACxB,EACD,IACA,CAAE;GACL;EACD,EAAC;CACF;AACD"}
1
+ {"version":3,"file":"auth.mjs","names":["id: ConstructName<TName>","config: BetterAuthConfig<TDatabase>","options: ServiceRegisterOptions","value: string","as: { owner?: boolean }","configured: BetterAuthOptions"],"sources":["../src/auth.ts"],"sourcesContent":["/**\n * `BetterAuth` — a declared auth server.\n *\n * It is three things at once, which is what makes it the construct that\n * exercises most of the model: a consumer of a database, a producer of an\n * authorizer, and a set of endpoints. This lands the first two.\n *\n * Its tables live in a schema tenant it is *given* — `orders.schema('AuthDb')`\n * — rather than one it invents. The tenant declares the schema and the role;\n * this declares the one thing left, the signing secret, and reads back the keys\n * it needs.\n *\n * :::caution\n * The isolation that arrangement is *for* — the application's own role holding\n * no grant on these tables, so a compromised handler cannot read sessions — does\n * **not hold yet**. No target creates the per-schema role: both connect as the\n * database owner, so today the tenant is a `search_path`, which is a namespace\n * and not a privilege boundary. See \"Roles are declared and never created\" in\n * `docs/design/constructs-outstanding.md`.\n * :::\n *\n * It declares its own surface, so where it answers, who may call it, and the\n * domain its cookies are scoped to all arrive as environment resolved by the\n * target — none of them guessed from a port, and none of them listed by hand in\n * application config.\n */\n\nimport {\n\ttype AppSpec,\n\ttype ConstructName,\n\tcanonicalId,\n\ttype Declaration,\n\tenvironmentCase,\n\tprovideKey,\n\tserviceKey,\n} from '@geekmidas/manifest';\nimport type { Service, ServiceRegisterOptions } from '@geekmidas/services';\nimport { betterAuth } from 'better-auth';\nimport type { Hono } from 'hono';\nimport type { Kysely } from 'kysely';\nimport { type Construct, type Consumable, edgeTo } from './construct-interface';\n\n/** The server better-auth hands back. */\nexport type AuthServer = ReturnType<typeof betterAuth>;\n\n/** Everything better-auth takes, minus what the construct owns. */\nexport type BetterAuthOptions = Omit<\n\tParameters<typeof betterAuth>[0],\n\t'database' | 'secret' | 'basePath' | 'baseURL'\n>;\n\nexport interface BetterAuthConfig<TDatabase extends Consumable> {\n\t/**\n\t * The schema tenant its tables live in.\n\t *\n\t * A construct rather than a URL: the tenant already declares its schema and\n\t * its role, and taking the declaration is what puts the edge in the graph\n\t * instead of a connection string in two places.\n\t */\n\tdatabase: TDatabase;\n\t/**\n\t * Where the auth routes are mounted, e.g. `/api/auth`.\n\t *\n\t * Structural — it is part of the URL every client calls, so it cannot differ\n\t * between stages the way the host can.\n\t */\n\tbasePath?: string;\n\t/**\n\t * The app that serves this auth server — its own container.\n\t *\n\t * An auth server holds the session secret and reaches the identity tables.\n\t * Its own process is the default because sharing one means the surface it\n\t * shares with can read both.\n\t */\n\tapp?: AppSpec;\n\t/**\n\t * The rest of better-auth's options: providers, plugins, email settings.\n\t *\n\t * A function when they need another construct — a magic-link plugin has to\n\t * *send* the link, and the thing that sends mail is a construct whose client\n\t * has to be registered. It is handed the same `ServiceRegisterOptions` this\n\t * construct was, so the env parser flows through the graph rather than being\n\t * imported out of application config.\n\t */\n\toptions?:\n\t\t| BetterAuthOptions\n\t\t| ((\n\t\t\t\toptions: ServiceRegisterOptions,\n\t\t ) => BetterAuthOptions | Promise<BetterAuthOptions>);\n}\n\nconst DEFAULT_BASE_PATH = '/api/auth';\n\nexport class BetterAuth<\n\tTName extends string = string,\n\tTDatabase extends Consumable = Consumable,\n> implements Construct<TName, AuthServer>\n{\n\treadonly id: TName;\n\treadonly service: Service<Uncapitalize<TName>, AuthServer>;\n\treadonly basePath: string;\n\n\t/**\n\t * Declared once and read by both `declare()` and `connect()`, so the keys the\n\t * target publishes and the keys the server reads cannot drift.\n\t */\n\tprivate readonly keys: {\n\t\tsecretId: string;\n\t\tsecret: string;\n\t\turl: string;\n\t\ttrustedOrigins: string;\n\t\tcookieDomain: string;\n\t};\n\n\tconstructor(\n\t\tid: ConstructName<TName>,\n\t\tprivate readonly config: BetterAuthConfig<TDatabase>,\n\t) {\n\t\tconst canonical = canonicalId(id as string);\n\n\t\tthis.id = canonical as TName;\n\t\tthis.basePath = config.basePath ?? DEFAULT_BASE_PATH;\n\n\t\t// A secret's name is its key: `Auth` signs with `AUTH_SECRET`, which is\n\t\t// also what better-auth's own tooling looks for.\n\t\tconst secretId = `${canonical}Secret`;\n\t\tthis.keys = {\n\t\t\tsecretId,\n\t\t\tsecret: environmentCase(secretId),\n\t\t\turl: provideKey(canonical, 'url'),\n\t\t\ttrustedOrigins: provideKey(canonical, 'trustedOrigins'),\n\t\t\tcookieDomain: provideKey(canonical, 'cookieDomain'),\n\t\t};\n\n\t\t// A field, not a getter: consumers cache services by object identity.\n\t\tthis.service = {\n\t\t\tserviceName: serviceKey(canonical) as Uncapitalize<TName>,\n\t\t\tregister: (options) => this.connect(options),\n\t\t};\n\t}\n\n\t/**\n\t * A signing secret and a surface.\n\t *\n\t * The database is *not* declared here — the tenant that was passed in\n\t * declares it, and declaring it twice is the duplication the whole model\n\t * removes. What is declared is what this construct owns: the key it signs\n\t * with, and the routes it answers on.\n\t *\n\t * One endpoint, wildcarded. Better Auth routes internally and the set of\n\t * paths depends on which capabilities are enabled, so enumerating them here\n\t * would be a copy of its router that goes stale on its next release. The\n\t * surface's job is to send everything under `basePath` to one handler, which\n\t * is exactly what the declaration says.\n\t */\n\tdeclare(): Declaration[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tkind: 'secret',\n\t\t\t\tid: this.keys.secretId,\n\t\t\t\tprovides: [this.keys.secret],\n\t\t\t},\n\t\t\t{\n\t\t\t\tkind: 'rest-api',\n\t\t\t\tid: this.id,\n\t\t\t\t...(this.config.app ? { app: this.config.app } : {}),\n\t\t\t\tprovides: [\n\t\t\t\t\tthis.keys.url,\n\t\t\t\t\tthis.keys.trustedOrigins,\n\t\t\t\t\tthis.keys.cookieDomain,\n\t\t\t\t],\n\t\t\t\tendpoints: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${this.id}Handler`,\n\t\t\t\t\t\thandler: `${this.id}.handler`,\n\t\t\t\t\t\tmethod: 'ANY',\n\t\t\t\t\t\tpath: `${this.basePath}/*`,\n\t\t\t\t\t\t// Read off the tenant rather than written down: this\n\t\t\t\t\t\t// construct takes whatever database it is given, and a\n\t\t\t\t\t\t// hardcoded kind is a second statement of a fact the\n\t\t\t\t\t\t// tenant already makes.\n\t\t\t\t\t\tdependencies: [edgeTo(this.config.database)],\n\t\t\t\t\t\trequires: [this.keys.secret],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t];\n\t}\n\n\t/**\n\t * Better Auth's own migrations, for the app's migrate step.\n\t *\n\t * It brings its own schema — users, sessions, accounts, verifications — so\n\t * the app never writes those tables and never gets to drift from them.\n\t */\n\tasync migrations(\n\t\toptions: ServiceRegisterOptions,\n\t): Promise<() => Promise<void>> {\n\t\t// As the owner, not the runtime role. Creating tables is DDL, and the\n\t\t// whole point of the split is that a handler's role cannot do it — so a\n\t\t// migrator that connected the way a handler does would fail on the first\n\t\t// `CREATE TABLE` rather than working by accident.\n\t\tconst auth = await this.connect(options, { owner: true });\n\t\t// better-auth 1.7 split the migration builder out of `better-auth/db`\n\t\t// into its own entry, so importing it no longer drags the whole db layer\n\t\t// in behind it.\n\t\tconst { getMigrations } = await import('better-auth/db/migration');\n\t\tconst { runMigrations } = await getMigrations(auth.options);\n\n\t\treturn runMigrations;\n\t}\n\n\t/**\n\t * The server this surface runs as, built from its own declaration.\n\t *\n\t * A surface is a deploy unit, so something has to serve it, and the thing\n\t * that knows how is the construct — not a generator writing a mount into\n\t * somebody else's entry point. That is how the auth server came to be\n\t * mounted by a hook in the application it was supposed to be separate from,\n\t * and then to be served by nothing at all when the hook was deleted.\n\t *\n\t * The routes come from {@link declare}: one wildcard under `basePath`, read\n\t * off the same declaration the manifest carries, so the surface the graph\n\t * describes and the surface that answers requests cannot disagree.\n\t *\n\t * ```ts\n\t * // .gkm/server/app.ts — the whole generated entry\n\t * import { auth } from '@acme/constructs/auth.js';\n\t * export const { app } = await auth.server({ envParser });\n\t * ```\n\t */\n\tasync server(options: ServiceRegisterOptions): Promise<{ app: Hono }> {\n\t\tconst { Hono } = await import('hono');\n\t\tconst { cors } = await import('hono/cors');\n\t\tconst app = new Hono();\n\t\tconst server = await this.connect(options);\n\n\t\t// Who may call this surface, read off the graph. The same list Better\n\t\t// Auth checks for CSRF — it arrives as `<ID>_TRUSTED_ORIGINS`, composed\n\t\t// by the target from whatever declared an edge to this construct, so a\n\t\t// site that depends on the auth server is allowed to reach it and\n\t\t// nothing else is. Nobody writes an origin down.\n\t\tconst { origins } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\torigins: get(this.keys.trustedOrigins)\n\t\t\t\t\t.string()\n\t\t\t\t\t.default('')\n\t\t\t\t\t.transform((value: string) =>\n\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t.split(',')\n\t\t\t\t\t\t\t.map((origin) => origin.trim())\n\t\t\t\t\t\t\t.filter(Boolean),\n\t\t\t\t\t),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\tapp.use('*', cors({ origin: origins, credentials: true, maxAge: 3600 }));\n\n\t\t// Read off the declaration rather than restated here. `ANY` is every\n\t\t// method Better Auth routes internally, which is the reason the\n\t\t// declaration wildcards rather than enumerating.\n\t\tconst [surface] = this.declare().filter(\n\t\t\t(d): d is Extract<Declaration, { kind: 'rest-api' }> =>\n\t\t\t\td.kind === 'rest-api',\n\t\t);\n\n\t\tfor (const endpoint of surface?.endpoints ?? []) {\n\t\t\tconst methods =\n\t\t\t\tendpoint.method === 'ANY'\n\t\t\t\t\t? (['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'] as const)\n\t\t\t\t\t: ([endpoint.method] as const);\n\n\t\t\tapp.on([...methods], endpoint.path, (c) => server.handler(c.req.raw));\n\t\t}\n\n\t\treturn { app };\n\t}\n\n\tprivate async connect(\n\t\toptions: ServiceRegisterOptions,\n\t\tas: { owner?: boolean } = {},\n\t): Promise<AuthServer> {\n\t\tconst { secret, baseUrl, trustedOrigins, cookieDomain } = options.envParser\n\t\t\t.create((get) => ({\n\t\t\t\tsecret: get(this.keys.secret).string(),\n\t\t\t\t// The surface's own URL, resolved by the target — not guessed from\n\t\t\t\t// a port, which was wrong the moment the server moved to 3001.\n\t\t\t\tbaseUrl: get(this.keys.url).string(),\n\t\t\t\t// Better Auth's CSRF check applies to every caller, not just\n\t\t\t\t// browsers, so an API calling the auth server is rejected unless\n\t\t\t\t// its origin is trusted. The list is derived from the graph and\n\t\t\t\t// arrives as one comma-separated value, for the same reason every\n\t\t\t\t// other derived value arrives as a string: it crosses a process\n\t\t\t\t// boundary as env.\n\t\t\t\ttrustedOrigins: get(this.keys.trustedOrigins)\n\t\t\t\t\t.string()\n\t\t\t\t\t.default('')\n\t\t\t\t\t.transform((value) =>\n\t\t\t\t\t\tvalue\n\t\t\t\t\t\t\t.split(',')\n\t\t\t\t\t\t\t.map((origin) => origin.trim())\n\t\t\t\t\t\t\t.filter(Boolean),\n\t\t\t\t\t),\n\t\t\t\t// The domain a session cookie has to carry to be readable by a\n\t\t\t\t// frontend on a sibling host. Optional because there is often\n\t\t\t\t// nothing to widen to: locally everything shares `localhost`,\n\t\t\t\t// where cookies ignore the port and a `Domain` would only be a\n\t\t\t\t// value the browser refuses.\n\t\t\t\tcookieDomain: get(this.keys.cookieDomain).string().optional(),\n\t\t\t}))\n\t\t\t.parse();\n\n\t\t// The tenant's own client: one construct, one connection, so what auth\n\t\t// writes and what the browser inspects cannot be two different databases.\n\t\t// A migration asks the tenant for its owner connection, which the tenant\n\t\t// exposes as a `Service` and not as anything `.dependsOn()` would take.\n\t\tconst tenant = this.config.database as Consumable & {\n\t\t\towner?: Service<string, unknown>;\n\t\t};\n\t\tconst source = as.owner && tenant.owner ? tenant.owner : tenant.service;\n\n\t\tconst db = (await source.register(options)) as Kysely<\n\t\t\tRecord<string, never>\n\t\t>;\n\n\t\t// Hoisted: narrowing a property of `this` is not preserved across the\n\t\t// await, and the false branch is the plain-object form.\n\t\tconst configure = this.config.options;\n\t\tconst configured: BetterAuthOptions =\n\t\t\ttypeof configure === 'function'\n\t\t\t\t? await configure(options)\n\t\t\t\t: (configure ?? {});\n\n\t\t// `Auth<O>` is invariant in its options in better-auth 1.7, so the value\n\t\t// built from a concrete literal is not assignable to the `AuthServer`\n\t\t// alias, which names the constraint. The runtime object is the same one\n\t\t// either way; the assertion keeps the variance where it happens instead\n\t\t// of spreading a generic through the construct's public type.\n\t\treturn betterAuth({\n\t\t\t...configured,\n\t\t\tsecret,\n\t\t\tbaseURL: baseUrl,\n\t\t\tbasePath: this.basePath,\n\t\t\tdatabase: { db, type: 'postgres' },\n\t\t\t// Whatever the app added wins over the derived list rather than\n\t\t\t// replacing it: an origin nobody declared is still sometimes real.\n\t\t\ttrustedOrigins: [\n\t\t\t\t...trustedOrigins,\n\t\t\t\t...(configured.trustedOrigins &&\n\t\t\t\tArray.isArray(configured.trustedOrigins)\n\t\t\t\t\t? configured.trustedOrigins\n\t\t\t\t\t: []),\n\t\t\t],\n\t\t\tadvanced: {\n\t\t\t\t...configured.advanced,\n\t\t\t\t// Only when a domain was derived. Better Auth reads the presence\n\t\t\t\t// of this block as intent, so enabling it with no domain would\n\t\t\t\t// widen the cookie to whatever host happened to set it — and the\n\t\t\t\t// case with nothing to widen to is the common one, not an error.\n\t\t\t\t...(cookieDomain\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcrossSubDomainCookies: {\n\t\t\t\t\t\t\t\tenabled: true,\n\t\t\t\t\t\t\t\tdomain: cookieDomain,\n\t\t\t\t\t\t\t\t...configured.advanced?.crossSubDomainCookies,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t}) as AuthServer;\n\t}\n}\n"],"mappings":";;;;;AA2FA,MAAM,oBAAoB;AAE1B,IAAa,aAAb,MAIA;CACC,AAAS;CACT,AAAS;CACT,AAAS;;;;;CAMT,AAAiB;CAQjB,YACCA,IACiBC,QAChB;EADgB;EAEjB,MAAM,YAAY,YAAY,GAAa;AAE3C,OAAK,KAAK;AACV,OAAK,WAAW,OAAO,YAAY;EAInC,MAAM,YAAY,EAAE,UAAU;AAC9B,OAAK,OAAO;GACX;GACA,QAAQ,gBAAgB,SAAS;GACjC,KAAK,WAAW,WAAW,MAAM;GACjC,gBAAgB,WAAW,WAAW,iBAAiB;GACvD,cAAc,WAAW,WAAW,eAAe;EACnD;AAGD,OAAK,UAAU;GACd,aAAa,WAAW,UAAU;GAClC,UAAU,CAAC,YAAY,KAAK,QAAQ,QAAQ;EAC5C;CACD;;;;;;;;;;;;;;;CAgBD,UAAyB;AACxB,SAAO,CACN;GACC,MAAM;GACN,IAAI,KAAK,KAAK;GACd,UAAU,CAAC,KAAK,KAAK,MAAO;EAC5B,GACD;GACC,MAAM;GACN,IAAI,KAAK;GACT,GAAI,KAAK,OAAO,MAAM,EAAE,KAAK,KAAK,OAAO,IAAK,IAAG,CA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,WAAW,UAAU;IACxB,EACD,IACA,CAAE;GACL;EACD,EAAC;CACF;AACD"}
@@ -1,8 +1,8 @@
1
1
  require('../construct-interface-BfjcOD_E.cjs');
2
2
  require('../Construct-CyS3RpTL.cjs');
3
- require('../functions-Bd3TPxid.cjs');
3
+ require('../functions-DJJA7VGc.cjs');
4
4
  require('../clone-Dy0cR2SZ.cjs');
5
- const require_CronBuilder = require('../CronBuilder-CkXPJiGO.cjs');
5
+ const require_CronBuilder = require('../CronBuilder-DyUr6nYz.cjs');
6
6
 
7
7
  //#region src/crons/index.ts
8
8
  const c = new require_CronBuilder.CronBuilder();
@@ -1,14 +1,14 @@
1
1
  import "../Construct-C0ijr2qp.cjs";
2
- import "../index-JSf9xNIJ.cjs";
2
+ import "../index-AIfVzkhi.cjs";
3
3
  import "../construct-interface-D9d4Gm4p.cjs";
4
- import { Cron, CronExpression, RateExpression, ScheduleExpression } from "../Cron-Wqh464aO.cjs";
5
- import { CronBuilder } from "../CronBuilder-BqpEzMPQ.cjs";
6
- import * as _geekmidas_logger20 from "@geekmidas/logger";
7
- import * as _geekmidas_schema18 from "@geekmidas/schema";
8
- import * as _geekmidas_services19 from "@geekmidas/services";
4
+ import { Cron, CronExpression, RateExpression, ScheduleExpression } from "../Cron-B2OFsfDM.cjs";
5
+ import { CronBuilder } from "../CronBuilder-LSJMfqnq.cjs";
6
+ import * as _geekmidas_logger2 from "@geekmidas/logger";
7
+ import * as _geekmidas_schema0 from "@geekmidas/schema";
8
+ import * as _geekmidas_services1 from "@geekmidas/services";
9
9
 
10
10
  //#region src/crons/index.d.ts
11
- declare const c: CronBuilder<_geekmidas_schema18.ComposableStandardSchema, _geekmidas_services19.Service<string, unknown>[], _geekmidas_logger20.Logger, undefined, undefined, string, undefined, string>;
11
+ declare const c: CronBuilder<_geekmidas_schema0.ComposableStandardSchema, _geekmidas_services1.Service<string, unknown>[], _geekmidas_logger2.Logger, undefined, undefined, string, undefined, string>;
12
12
  //# sourceMappingURL=index.d.ts.map
13
13
 
14
14
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/crons/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAUa,GAAC,YAAoB,mBAAA,CAApB,wBAAA,EAAA,qBAAA,CAAA,4BAAA,mBAAA,CAAA,MAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/crons/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAUa,GAAC,YAAoB,kBAAA,CAApB,wBAAA,EAAA,oBAAA,CAAA,4BAAA,kBAAA,CAAA,MAAA"}
@@ -1,14 +1,14 @@
1
1
  import "../Construct-Ct8nalEi.mjs";
2
- import "../index-CubPzHd9.mjs";
2
+ import "../index-D3zjrwjr.mjs";
3
3
  import "../construct-interface-g5GM5pwR.mjs";
4
- import { Cron, CronExpression, RateExpression, ScheduleExpression } from "../Cron-ByxdOfpE.mjs";
5
- import { CronBuilder } from "../CronBuilder-BL0AP6fs.mjs";
6
- import * as _geekmidas_services19 from "@geekmidas/services";
7
- import * as _geekmidas_logger20 from "@geekmidas/logger";
8
- import * as _geekmidas_schema18 from "@geekmidas/schema";
4
+ import { Cron, CronExpression, RateExpression, ScheduleExpression } from "../Cron-CqEbBbwH.mjs";
5
+ import { CronBuilder } from "../CronBuilder-Bg-9h2cc.mjs";
6
+ import * as _geekmidas_services23 from "@geekmidas/services";
7
+ import * as _geekmidas_logger24 from "@geekmidas/logger";
8
+ import * as _geekmidas_schema22 from "@geekmidas/schema";
9
9
 
10
10
  //#region src/crons/index.d.ts
11
- declare const c: CronBuilder<_geekmidas_schema18.ComposableStandardSchema, _geekmidas_services19.Service<string, unknown>[], _geekmidas_logger20.Logger, undefined, undefined, string, undefined, string>;
11
+ declare const c: CronBuilder<_geekmidas_schema22.ComposableStandardSchema, _geekmidas_services23.Service<string, unknown>[], _geekmidas_logger24.Logger, undefined, undefined, string, undefined, string>;
12
12
  //# sourceMappingURL=index.d.ts.map
13
13
 
14
14
  //#endregion
@@ -1,8 +1,8 @@
1
1
  import "../Construct-BD5neF7w.mjs";
2
2
  import "../construct-interface-Z4CpS8tK.mjs";
3
- import "../functions-Cxbo-pEd.mjs";
3
+ import "../functions-Ck21Uyq0.mjs";
4
4
  import "../clone-DblgEZZa.mjs";
5
- import { Cron, CronBuilder } from "../CronBuilder-BmABazzH.mjs";
5
+ import { Cron, CronBuilder } from "../CronBuilder-CdibiHNB.mjs";
6
6
 
7
7
  //#region src/crons/index.ts
8
8
  const c = new CronBuilder();
@@ -1,9 +1,9 @@
1
1
  require('../construct-interface-BfjcOD_E.cjs');
2
2
  require('../Construct-CyS3RpTL.cjs');
3
- require('../functions-Bd3TPxid.cjs');
4
- const require_EndpointFactory = require('../EndpointFactory-ChxLZllA.cjs');
3
+ require('../functions-DJJA7VGc.cjs');
4
+ const require_EndpointFactory = require('../EndpointFactory-BHFMmFkV.cjs');
5
5
  require('../clone-Dy0cR2SZ.cjs');
6
- const require_Endpoint = require('../Endpoint-BiaaMEn_.cjs');
6
+ const require_Endpoint = require('../Endpoint-DODn1RhN.cjs');
7
7
  const require_surfaceEnv = require('../surfaceEnv-BFXEms2f.cjs');
8
8
  const require_lazyAccessors = require('../lazyAccessors-e3j2oE2m.cjs');
9
9
 
@@ -1,7 +1,7 @@
1
1
  import "../Construct-C0ijr2qp.cjs";
2
- import "../index-JSf9xNIJ.cjs";
2
+ import "../index-AIfVzkhi.cjs";
3
3
  import "../construct-interface-D9d4Gm4p.cjs";
4
4
  import "../types-BlAkSuGI.cjs";
5
- import { ActorExtractor, Authorizer, BUILT_IN_SECURITY_SCHEMES, BuiltInSecuritySchemeId, Endpoint, EndpointContext, EndpointHandler, EndpointOutput, EndpointSchemas, MappedAudit, OAuthFlow, OAuthFlows, RLS_BYPASS, ResponseBuilder, RlsBypass, RlsConfig, RlsContext, RlsContextExtractor, SecurityScheme, createAuthorizer, getSecurityScheme, isBuiltInSecurityScheme } from "../Endpoint-CH9Fn1AD.cjs";
6
- import { EndpointBuilder, EndpointFactory, createApiGatewayCookies, createApiGatewayHeaders, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, defaultEnvParser, envParserFor, publishConstructEvents } from "../index-V2nksZIJ.cjs";
5
+ import { ActorExtractor, Authorizer, BUILT_IN_SECURITY_SCHEMES, BuiltInSecuritySchemeId, Endpoint, EndpointContext, EndpointHandler, EndpointOutput, EndpointSchemas, MappedAudit, OAuthFlow, OAuthFlows, RLS_BYPASS, ResponseBuilder, RlsBypass, RlsConfig, RlsContext, RlsContextExtractor, SecurityScheme, createAuthorizer, getSecurityScheme, isBuiltInSecurityScheme } from "../Endpoint-DrD8a1yH.cjs";
6
+ import { EndpointBuilder, EndpointFactory, createApiGatewayCookies, createApiGatewayHeaders, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, defaultEnvParser, envParserFor, publishConstructEvents } from "../index-B8g8POkr.cjs";
7
7
  export { ActorExtractor, Authorizer, BUILT_IN_SECURITY_SCHEMES, BuiltInSecuritySchemeId, Endpoint, EndpointBuilder, EndpointContext, EndpointFactory, EndpointHandler, EndpointOutput, EndpointSchemas, MappedAudit, OAuthFlow, OAuthFlows, RLS_BYPASS, ResponseBuilder, RlsBypass, RlsConfig, RlsContext, RlsContextExtractor, SecurityScheme, createApiGatewayCookies, createApiGatewayHeaders, createAuthorizer, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, defaultEnvParser, envParserFor, getSecurityScheme, isBuiltInSecurityScheme, publishConstructEvents };
@@ -1,7 +1,7 @@
1
1
  import "../Construct-Ct8nalEi.mjs";
2
- import "../index-CubPzHd9.mjs";
2
+ import "../index-D3zjrwjr.mjs";
3
3
  import "../construct-interface-g5GM5pwR.mjs";
4
4
  import "../types-aKksMEWL.mjs";
5
- import { ActorExtractor, Authorizer, BUILT_IN_SECURITY_SCHEMES, BuiltInSecuritySchemeId, Endpoint, EndpointContext, EndpointHandler, EndpointOutput, EndpointSchemas, MappedAudit, OAuthFlow, OAuthFlows, RLS_BYPASS, ResponseBuilder, RlsBypass, RlsConfig, RlsContext, RlsContextExtractor, SecurityScheme, createAuthorizer, getSecurityScheme, isBuiltInSecurityScheme } from "../Endpoint-2Wg7T7Cq.mjs";
6
- import { EndpointBuilder, EndpointFactory, createApiGatewayCookies, createApiGatewayHeaders, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, defaultEnvParser, envParserFor, publishConstructEvents } from "../index-BxHDdy6a.mjs";
5
+ import { ActorExtractor, Authorizer, BUILT_IN_SECURITY_SCHEMES, BuiltInSecuritySchemeId, Endpoint, EndpointContext, EndpointHandler, EndpointOutput, EndpointSchemas, MappedAudit, OAuthFlow, OAuthFlows, RLS_BYPASS, ResponseBuilder, RlsBypass, RlsConfig, RlsContext, RlsContextExtractor, SecurityScheme, createAuthorizer, getSecurityScheme, isBuiltInSecurityScheme } from "../Endpoint-Dem2XyCu.mjs";
6
+ import { EndpointBuilder, EndpointFactory, createApiGatewayCookies, createApiGatewayHeaders, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, defaultEnvParser, envParserFor, publishConstructEvents } from "../index-DbKmfl-q.mjs";
7
7
  export { ActorExtractor, Authorizer, BUILT_IN_SECURITY_SCHEMES, BuiltInSecuritySchemeId, Endpoint, EndpointBuilder, EndpointContext, EndpointFactory, EndpointHandler, EndpointOutput, EndpointSchemas, MappedAudit, OAuthFlow, OAuthFlows, RLS_BYPASS, ResponseBuilder, RlsBypass, RlsConfig, RlsContext, RlsContextExtractor, SecurityScheme, createApiGatewayCookies, createApiGatewayHeaders, createAuthorizer, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, defaultEnvParser, envParserFor, getSecurityScheme, isBuiltInSecurityScheme, publishConstructEvents };
@@ -1,9 +1,9 @@
1
1
  import "../Construct-BD5neF7w.mjs";
2
2
  import "../construct-interface-Z4CpS8tK.mjs";
3
- import "../functions-Cxbo-pEd.mjs";
4
- import { BUILT_IN_SECURITY_SCHEMES, EndpointBuilder, EndpointFactory, RLS_BYPASS, createAuthorizer, getSecurityScheme, isBuiltInSecurityScheme } from "../EndpointFactory-DTTCkGEL.mjs";
3
+ import "../functions-Ck21Uyq0.mjs";
4
+ import { BUILT_IN_SECURITY_SCHEMES, EndpointBuilder, EndpointFactory, RLS_BYPASS, createAuthorizer, getSecurityScheme, isBuiltInSecurityScheme } from "../EndpointFactory-b4ituq-s.mjs";
5
5
  import "../clone-DblgEZZa.mjs";
6
- import { Endpoint, ResponseBuilder } from "../Endpoint-VIOpSo0S.mjs";
6
+ import { Endpoint, ResponseBuilder } from "../Endpoint-Dij_wOcc.mjs";
7
7
  import { defaultEnvParser, envParserFor } from "../surfaceEnv-C3Ktahea.mjs";
8
8
  import { createApiGatewayCookies, createApiGatewayHeaders, createHonoCookies, createHonoHeaders, createNoopCookies, createNoopHeaders, publishConstructEvents } from "../lazyAccessors-BoJN3SMd.mjs";
9
9
 
@@ -1,6 +1,6 @@
1
1
  require('../construct-interface-BfjcOD_E.cjs');
2
2
  require('../Construct-CyS3RpTL.cjs');
3
- const require_functions = require('../functions-Bd3TPxid.cjs');
3
+ const require_functions = require('../functions-DJJA7VGc.cjs');
4
4
  require('../clone-Dy0cR2SZ.cjs');
5
5
 
6
6
  exports.BaseFunctionBuilder = require_functions.BaseFunctionBuilder;
@@ -1,4 +1,4 @@
1
1
  import "../Construct-C0ijr2qp.cjs";
2
- import { BaseFunctionBuilder, Function, FunctionBuilder, FunctionContext, FunctionHandler, f } from "../index-JSf9xNIJ.cjs";
2
+ import { BaseFunctionBuilder, Function, FunctionBuilder, FunctionContext, FunctionHandler, f } from "../index-AIfVzkhi.cjs";
3
3
  import "../construct-interface-D9d4Gm4p.cjs";
4
4
  export { BaseFunctionBuilder, Function, FunctionBuilder, FunctionContext, FunctionHandler, f };
@@ -1,4 +1,4 @@
1
1
  import "../Construct-Ct8nalEi.mjs";
2
- import { BaseFunctionBuilder, Function, FunctionBuilder, FunctionContext, FunctionHandler, f } from "../index-CubPzHd9.mjs";
2
+ import { BaseFunctionBuilder, Function, FunctionBuilder, FunctionContext, FunctionHandler, f } from "../index-D3zjrwjr.mjs";
3
3
  import "../construct-interface-g5GM5pwR.mjs";
4
4
  export { BaseFunctionBuilder, Function, FunctionBuilder, FunctionContext, FunctionHandler, f };
@@ -1,6 +1,6 @@
1
1
  import "../Construct-BD5neF7w.mjs";
2
2
  import "../construct-interface-Z4CpS8tK.mjs";
3
- import { BaseFunctionBuilder, Function, FunctionBuilder, f } from "../functions-Cxbo-pEd.mjs";
3
+ import { BaseFunctionBuilder, Function, FunctionBuilder, f } from "../functions-Ck21Uyq0.mjs";
4
4
  import "../clone-DblgEZZa.mjs";
5
5
 
6
6
  export { BaseFunctionBuilder, Function, FunctionBuilder, f };
@@ -2707,8 +2707,9 @@ var BaseFunctionBuilder = class BaseFunctionBuilder {
2707
2707
  return validated.value;
2708
2708
  }
2709
2709
  const result = {};
2710
- for (const key in schema) {
2711
- const item = schema[key];
2710
+ const fields = schema;
2711
+ for (const key in fields) {
2712
+ const item = fields[key];
2712
2713
  if (BaseFunctionBuilder.isStandardSchemaV1(item)) {
2713
2714
  const value = (0, import_lodash$2.default)(data, key);
2714
2715
  const validated = await item["~standard"].validate(value);
@@ -2873,4 +2874,4 @@ const f = new FunctionBuilder();
2873
2874
 
2874
2875
  //#endregion
2875
2876
  export { BaseFunctionBuilder, Function$1 as Function, FunctionBuilder, f, require_lodash$1 as require_lodash };
2876
- //# sourceMappingURL=functions-Cxbo-pEd.mjs.map
2877
+ //# sourceMappingURL=functions-Ck21Uyq0.mjs.map