@fitzzero/quickdraw-core 5.0.0 → 5.1.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.
Files changed (68) hide show
  1. package/README.md +343 -49
  2. package/dist/{admin-BiU4LRZS.d.ts → admin-DKwkIh5i.d.ts} +25 -10
  3. package/dist/{adminSchemas-k5a1Ov7b.d.ts → adminSchemas-2DUA_hZ8.d.ts} +15 -9
  4. package/dist/{auth-CMyRkfjZ.d.ts → auth-BhWqdyb-.d.ts} +2 -2
  5. package/dist/{caller-DHzK3oiI.d.ts → caller-CXTFswBO.d.ts} +28 -6
  6. package/dist/{chunk-2XJFNVHW.js → chunk-2PWMUVC7.js} +1 -1
  7. package/dist/{chunk-2XJFNVHW.js.map → chunk-2PWMUVC7.js.map} +1 -1
  8. package/dist/{chunk-5IC5VZ7T.js → chunk-2UELNHDD.js} +3 -3
  9. package/dist/{chunk-XFDOGTMC.js → chunk-3674EIRT.js} +4 -4
  10. package/dist/{chunk-DNCAI3KY.js → chunk-4DIQHASK.js} +1 -1
  11. package/dist/chunk-4DIQHASK.js.map +1 -0
  12. package/dist/{chunk-LLLYILEP.js → chunk-A6DJBGOG.js} +411 -43
  13. package/dist/chunk-A6DJBGOG.js.map +1 -0
  14. package/dist/{chunk-B2UQ27GH.js → chunk-CDKG4TFA.js} +25 -5
  15. package/dist/{chunk-B2UQ27GH.js.map → chunk-CDKG4TFA.js.map} +1 -1
  16. package/dist/{chunk-IRGAGRVG.js → chunk-JZBCLNDU.js} +4 -4
  17. package/dist/{chunk-XUSN5WKU.js → chunk-KNDDCVQJ.js} +4 -4
  18. package/dist/{chunk-5YRQ26LF.js → chunk-RT6OILOI.js} +1 -1
  19. package/dist/chunk-RT6OILOI.js.map +1 -0
  20. package/dist/{chunk-7QIY2DDX.js → chunk-VJTFXHOK.js} +2 -2
  21. package/dist/{chunk-7QIY2DDX.js.map → chunk-VJTFXHOK.js.map} +1 -1
  22. package/dist/chunk-XNLWBZIG.js +9 -0
  23. package/dist/chunk-XNLWBZIG.js.map +1 -0
  24. package/dist/cli/quickdraw-docs.js +241 -27
  25. package/dist/cli/quickdraw-docs.js.map +1 -1
  26. package/dist/client/index.d.ts +7 -7
  27. package/dist/client/index.js +5 -5
  28. package/dist/{clientTypes-B3o_99Xq.d.ts → clientTypes-Bc-G8n-U.d.ts} +3 -3
  29. package/dist/{connection-DuN8GvcD.d.ts → connection-Cr1BU07W.d.ts} +2 -2
  30. package/dist/{createServer-DUacdfKl.d.ts → createServer-CP9eDHZZ.d.ts} +30 -9
  31. package/dist/{createTestApp-DFLXoTKm.d.ts → createTestApp-UKVGEmOf.d.ts} +6 -6
  32. package/dist/{envelope-nf5eGB-a.d.ts → envelope-Cp3YcVxC.d.ts} +1 -1
  33. package/dist/{http--uoooIH5.d.ts → http-Djj2Inuu.d.ts} +6 -6
  34. package/dist/index.d.ts +6 -6
  35. package/dist/index.js +27 -7
  36. package/dist/index.js.map +1 -1
  37. package/dist/{infer-Dw21kmLw.d.ts → infer-Teo1xpsd.d.ts} +17 -0
  38. package/dist/{metrics-C0WvB7-I.d.ts → metrics-BdBu5o8G.d.ts} +2 -2
  39. package/dist/prisma/index.d.ts +4 -4
  40. package/dist/prisma/index.js +1 -1
  41. package/dist/server/auth/index.d.ts +14 -5
  42. package/dist/server/auth/index.js +0 -5
  43. package/dist/server/auth/index.js.map +1 -1
  44. package/dist/server/index.d.ts +120 -33
  45. package/dist/server/index.js +146 -193
  46. package/dist/server/index.js.map +1 -1
  47. package/dist/server/mcp/index.d.ts +51 -11
  48. package/dist/server/mcp/index.js +129 -8
  49. package/dist/server/mcp/index.js.map +1 -1
  50. package/dist/server/otel.d.ts +3 -3
  51. package/dist/{sharing-n4ss-ONM.d.ts → sharing-DVa8W-yR.d.ts} +3 -3
  52. package/dist/testing/client.d.ts +13 -13
  53. package/dist/testing/client.js +6 -6
  54. package/dist/testing/index.d.ts +156 -12
  55. package/dist/testing/index.js +1037 -22
  56. package/dist/testing/index.js.map +1 -1
  57. package/dist/testing/mock.d.ts +5 -5
  58. package/dist/testing/mock.js +5 -5
  59. package/dist/{types-Bwg3kIEc.d.ts → types-Cu0vmx7c.d.ts} +8 -2
  60. package/dist/utils/index.d.ts +1 -1
  61. package/package.json +1 -1
  62. package/dist/chunk-5YRQ26LF.js.map +0 -1
  63. package/dist/chunk-DNCAI3KY.js.map +0 -1
  64. package/dist/chunk-LLLYILEP.js.map +0 -1
  65. /package/dist/{chunk-5IC5VZ7T.js.map → chunk-2UELNHDD.js.map} +0 -0
  66. /package/dist/{chunk-XFDOGTMC.js.map → chunk-3674EIRT.js.map} +0 -0
  67. /package/dist/{chunk-IRGAGRVG.js.map → chunk-JZBCLNDU.js.map} +0 -0
  68. /package/dist/{chunk-XUSN5WKU.js.map → chunk-KNDDCVQJ.js.map} +0 -0
@@ -347,6 +347,8 @@ interface CollectionWhere {
347
347
  }
348
348
  /** Any collection of any contract, as `defineContract` stores it. */
349
349
  interface CollectionDef {
350
+ /** What the list holds, in a sentence or two, for the generated docs. */
351
+ readonly describe?: string | undefined;
350
352
  /** A string column of the entity, or `via(...)` for a junction table. */
351
353
  readonly scope: string | ViaScope;
352
354
  /** The projection each item is sent as: `"entity"` or a named projection. */
@@ -434,6 +436,8 @@ interface StreamDef<Item extends StandardSchemaV1 = StandardSchemaV1> {
434
436
  readonly volatile?: boolean;
435
437
  /** Who may subscribe. Without it the stream is closed. */
436
438
  readonly access?: StreamAccess;
439
+ /** What the stream carries, in a sentence or two, for the generated docs. */
440
+ readonly describe?: string;
437
441
  }
438
442
  /**
439
443
  * Where a channel requirement finds its row id or scope value in the parsed
@@ -498,10 +502,14 @@ interface ChannelDef<Payload extends StandardSchemaV1 = StandardSchemaV1> {
498
502
  readonly burst?: number;
499
503
  /** What the sender must already be subscribed to, or the app room it must be in. */
500
504
  readonly requires?: ChannelRequires;
505
+ /** What a message says, in a sentence or two, for the generated docs. */
506
+ readonly describe?: string;
501
507
  }
502
508
  /** A typed custom room event, delivered as `qd:event` (RFC 0003 section 8.3). */
503
509
  interface EventDef<Payload extends StandardSchemaV1 = StandardSchemaV1> {
504
510
  readonly payload: Payload;
511
+ /** What the event announces, in a sentence or two, for the generated docs. */
512
+ readonly describe?: string;
505
513
  }
506
514
  /** True when a stream has one feed per scope value; false for a global stream. */
507
515
  declare function isScopedStream(def: Pick<StreamDef, "scope">): boolean;
@@ -521,6 +529,11 @@ interface ChannelDefinition extends Omit<ChannelDef, "requires"> {
521
529
  }
522
530
  /** The second argument of {@link defineContract}. */
523
531
  interface ContractDefinition {
532
+ /**
533
+ * What the service is for, in a sentence or two. The generated API docs
534
+ * lead the service's page with it and list it in their index.
535
+ */
536
+ readonly describe?: string;
524
537
  /**
525
538
  * The full row; its output must contain `id: string`. Omit it for a service
526
539
  * without a model, which then has no projections, fields or collections.
@@ -567,6 +580,8 @@ type MemberOf<Def, Key extends string, Absent> = Def extends {
567
580
  interface Contract<Name extends string = string, Def extends ContractDefinition = ContractDefinition> {
568
581
  /** The service name, unchanged on the wire and in stored grants. */
569
582
  readonly name: Name;
583
+ /** What the service is for; absent when the definition has none. */
584
+ readonly describe?: string;
570
585
  readonly entity: MemberOf<Def, "entity", undefined>;
571
586
  readonly projections: MemberOf<Def, "projections", Empty>;
572
587
  readonly fields: MemberOf<Def, "fields", Empty>;
@@ -579,6 +594,7 @@ interface Contract<Name extends string = string, Def extends ContractDefinition
579
594
  /** Any contract. Every contract `defineContract` returns is assignable to it. */
580
595
  interface AnyContract {
581
596
  readonly name: string;
597
+ readonly describe?: string;
582
598
  readonly entity: RowSchema | undefined;
583
599
  readonly projections: {
584
600
  readonly [name: string]: RowSchema;
@@ -615,6 +631,7 @@ type IndexRow<Item, Fields> = Pick<Item, Extract<keyof Item, "id" | Fields>>;
615
631
  type ColumnOf<Row> = [Row] extends [never] ? string : keyof Row & string;
616
632
  type ScopeColumnOf<Row> = [Row] extends [never] ? string : StringColumn<Row> & string;
617
633
  interface CollectionContext<Row, Entity, Projections, Item, Index> {
634
+ readonly describe?: string | undefined;
618
635
  readonly scope: NoInfer<ViaScope | ScopeColumnOf<Row>>;
619
636
  readonly item: Item;
620
637
  readonly order: NoInfer<OrderBy<ColumnOf<Row>>>;
@@ -1,6 +1,6 @@
1
- import { k as MethodKind } from './infer-Dw21kmLw.js';
1
+ import { k as MethodKind } from './infer-Teo1xpsd.js';
2
2
  import { a as ErrorCode } from './errors-S-bxEIBC.js';
3
- import { T as Transport } from './types-Bwg3kIEc.js';
3
+ import { T as Transport } from './types-Cu0vmx7c.js';
4
4
 
5
5
  /** How a call ended: `"ok"`, `"not-modified"`, or the error code it failed with. */
6
6
  type CallOutcome = "ok" | "not-modified" | ErrorCode;
@@ -1,9 +1,9 @@
1
1
  import { L as Logger } from '../logger-BY28acW-.js';
2
- export { C as CountArgs, F as FindManyArgs, c as StatementCount, S as StorageAdapter, a as StorageRow, b as StorageWhere, s as storageOf } from '../caller-DHzK3oiI.js';
3
- import '../envelope-nf5eGB-a.js';
4
- import '../infer-Dw21kmLw.js';
2
+ export { C as CountArgs, F as FindManyArgs, c as StatementCount, S as StorageAdapter, a as StorageRow, b as StorageWhere, s as storageOf } from '../caller-CXTFswBO.js';
3
+ import '../envelope-Cp3YcVxC.js';
4
+ import '../infer-Teo1xpsd.js';
5
5
  import '../errors-S-bxEIBC.js';
6
- import '../types-Bwg3kIEc.js';
6
+ import '../types-Cu0vmx7c.js';
7
7
 
8
8
  /** Options of {@link trackPrisma}. */
9
9
  interface TrackPrismaOptions {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createWriteTracker,
3
3
  quietly
4
- } from "../chunk-DNCAI3KY.js";
4
+ } from "../chunk-4DIQHASK.js";
5
5
  import "../chunk-DD4SKCNO.js";
6
6
  import {
7
7
  STORAGE_KEY,
@@ -1,8 +1,8 @@
1
1
  import { L as Logger } from '../../logger-BY28acW-.js';
2
2
  import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'node:http';
3
- import { M as MaybePromise, P as Principal } from '../../types-Bwg3kIEc.js';
4
- import { b as AuthenticateRequest, H as HttpRequest } from '../../auth-CMyRkfjZ.js';
5
- import '../../infer-Dw21kmLw.js';
3
+ import { M as MaybePromise, P as Principal } from '../../types-Cu0vmx7c.js';
4
+ import { b as AuthenticateRequest, H as HttpRequest } from '../../auth-BhWqdyb-.js';
5
+ import '../../infer-Teo1xpsd.js';
6
6
  import 'socket.io';
7
7
 
8
8
  /**
@@ -266,6 +266,14 @@ declare function registerMockOAuthProvider(router: MockOAuthRouter, options: Reg
266
266
 
267
267
  /**
268
268
  * Origin validation utility for OAuth redirect and CORS security.
269
+ *
270
+ * An origin is allowed when it is the client URL, one of the extra origins
271
+ * or matches an app's pattern, or, outside production, is localhost. GitHub
272
+ * Codespaces origins (`*.app.github.dev`) are never allowed by default since
273
+ * 5.0.1 (finding R1.2 of the 5.0.0 review): anyone can open a Codespace, so
274
+ * the allowance let any such page open a socket or finish a sign-in as a
275
+ * signed-in user in production, wherever an app used this helper for CORS or
276
+ * a cookie check. An app that wants one lists a pattern in `allowedPatterns`.
269
277
  */
270
278
  declare const OAUTH_RETURN_ORIGIN_COOKIE = "oauth_return_origin";
271
279
  interface ValidateOriginOptions {
@@ -284,8 +292,9 @@ interface ValidateOriginOptions {
284
292
  */
285
293
  allowedPatterns?: RegExp[];
286
294
  /**
287
- * Allow GitHub Codespace forwarded-port origins
288
- * (https://{workspace}-{username}-{port}.app.github.dev). Default: true.
295
+ * Ignored: kept so 5.0.0 code that passes it still compiles.
296
+ *
297
+ * @deprecated Codespaces origins are never allowed since 5.0.1; list a pattern in allowedPatterns if one is wanted.
289
298
  */
290
299
  allowCodespaces?: boolean;
291
300
  /**
@@ -130,7 +130,6 @@ import { randomBytes } from "crypto";
130
130
 
131
131
  // src/server/auth/validateOrigin.ts
132
132
  var OAUTH_RETURN_ORIGIN_COOKIE = "oauth_return_origin";
133
- var CODESPACE_REGEX = /^https:\/\/[a-z0-9-]+-[a-z0-9-]+-\d+\.app\.github\.dev$/;
134
133
  var LOCALHOST_REGEX = /^http:\/\/localhost:\d+$/;
135
134
  function envExtraOrigins() {
136
135
  const raw = process.env.EXTRA_ALLOWED_ORIGINS;
@@ -157,9 +156,6 @@ function validateRedirectOrigin(origin, options = {}) {
157
156
  if (options.allowedPatterns?.some((pattern) => pattern.test(cleanOrigin))) {
158
157
  return cleanOrigin;
159
158
  }
160
- if ((options.allowCodespaces ?? true) && CODESPACE_REGEX.test(cleanOrigin)) {
161
- return cleanOrigin;
162
- }
163
159
  if ((options.allowLocalhostInDev ?? true) && process.env.NODE_ENV !== "production" && LOCALHOST_REGEX.test(cleanOrigin)) {
164
160
  return cleanOrigin;
165
161
  }
@@ -459,7 +455,6 @@ function originAllowlist(allowedOrigins, owner, allowEmpty = false) {
459
455
  clientUrl: "",
460
456
  extraAllowedOrigins: exact,
461
457
  allowedPatterns: patterns,
462
- allowCodespaces: false,
463
458
  allowLocalhostInDev: false
464
459
  };
465
460
  return Object.freeze({