@supatype/client 0.3.0 → 0.3.2

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 (74) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-test.log +28 -21
  3. package/.turbo/turbo-typecheck.log +2 -2
  4. package/dist/auth.d.ts +1 -1
  5. package/dist/auth.d.ts.map +1 -1
  6. package/dist/exact-response.d.ts +26 -0
  7. package/dist/exact-response.d.ts.map +1 -0
  8. package/dist/exact-response.js +51 -0
  9. package/dist/exact-response.js.map +1 -0
  10. package/dist/exact-values.d.ts +50 -0
  11. package/dist/exact-values.d.ts.map +1 -0
  12. package/dist/exact-values.js +254 -0
  13. package/dist/exact-values.js.map +1 -0
  14. package/dist/field-kinds-registry.d.ts +46 -0
  15. package/dist/field-kinds-registry.d.ts.map +1 -0
  16. package/dist/field-kinds-registry.js +51 -0
  17. package/dist/field-kinds-registry.js.map +1 -0
  18. package/dist/identity.d.ts +29 -0
  19. package/dist/identity.d.ts.map +1 -0
  20. package/dist/identity.js +30 -0
  21. package/dist/identity.js.map +1 -0
  22. package/dist/index.d.ts +17 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +29 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/query-cache.d.ts +1 -1
  27. package/dist/query-cache.d.ts.map +1 -1
  28. package/dist/query-cache.js +2 -8
  29. package/dist/query-cache.js.map +1 -1
  30. package/dist/query.d.ts +13 -1
  31. package/dist/query.d.ts.map +1 -1
  32. package/dist/query.js +36 -7
  33. package/dist/query.js.map +1 -1
  34. package/dist/realtime.d.ts +61 -3
  35. package/dist/realtime.d.ts.map +1 -1
  36. package/dist/realtime.js +181 -24
  37. package/dist/realtime.js.map +1 -1
  38. package/dist/storage.d.ts +12 -0
  39. package/dist/storage.d.ts.map +1 -1
  40. package/dist/storage.js +17 -1
  41. package/dist/storage.js.map +1 -1
  42. package/dist/types.d.ts +20 -0
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/types.js.map +1 -1
  45. package/package.json +2 -2
  46. package/src/auth.ts +1 -1
  47. package/src/exact-response.ts +76 -0
  48. package/src/exact-values.ts +281 -0
  49. package/src/field-kinds-registry.ts +80 -0
  50. package/src/identity.ts +43 -0
  51. package/src/index.ts +54 -1
  52. package/src/query-cache.ts +3 -10
  53. package/src/query.ts +41 -7
  54. package/src/realtime.ts +195 -27
  55. package/src/storage.ts +17 -1
  56. package/src/types.ts +28 -0
  57. package/tests/data-plane-auth.test.ts +6 -4
  58. package/tests/draft-profile.test.ts +3 -0
  59. package/tests/exact-response.test.ts +95 -0
  60. package/tests/exact-values.test.ts +171 -0
  61. package/tests/field-kinds-registry.test.ts +80 -0
  62. package/tests/fixtures/models.ts +55 -0
  63. package/tests/helpers/mock-websocket.ts +70 -0
  64. package/tests/identity-change.test.ts +120 -0
  65. package/tests/query-cache.test.ts +14 -8
  66. package/tests/query.test.ts +1 -0
  67. package/tests/realtime-exact-values.test.ts +161 -0
  68. package/tests/realtime-multi-tenant-integration.test.ts +5 -50
  69. package/tests/realtime-session-auth.test.ts +177 -0
  70. package/tests/signed-url-absolute.test.ts +84 -0
  71. package/tests/subscribe-frame.test.ts +102 -0
  72. package/tests/tsconfig.json +9 -0
  73. package/tests/types.test.ts +40 -32
  74. package/tsconfig.tsbuildinfo +1 -1
@@ -1,4 +1,4 @@
1
1
 
2
- > @supatype/client@0.3.0 build /home/runner/work/supatype/supatype/packages/client
2
+ > @supatype/client@0.3.2 build /home/runner/work/supatype/supatype/packages/client
3
3
  > tsc --project tsconfig.json
4
4
 
@@ -1,30 +1,37 @@
1
1
 
2
- > @supatype/client@0.3.0 test /home/runner/work/supatype/supatype/packages/client
2
+ > @supatype/client@0.3.2 test /home/runner/work/supatype/supatype/packages/client
3
3
  > vitest run
4
4
 
5
5
 
6
6
   RUN  v4.0.18 /home/runner/work/supatype/supatype/packages/client
7
7
 
8
- ✓ tests/realtime-multi-tenant-integration.test.ts (7 tests) 259ms
8
+ ✓ tests/auth.test.ts (36 tests) 87ms
9
9
  ✓ tests/query.test.ts (35 tests) 97ms
10
- ✓ tests/auth.test.ts (36 tests) 172ms
11
- ✓ tests/mfa-totp-integration.test.ts (12 tests) 40ms
12
- ✓ tests/retry-integration.test.ts (12 tests) 287ms
13
- ✓ tests/draft-profile.test.ts (18 tests) 76ms
14
- ✓ tests/storage-quota-integration.test.ts (10 tests) 684ms
15
- ✓ first upload succeeds, second hits quota  438ms
16
- ✓ tests/rate-limit-integration.test.ts (8 tests) 271ms
17
- ✓ tests/storage-upload-limit-integration.test.ts (11 tests) 459ms
18
- ✓ tests/types.test.ts (12 tests) 175ms
19
- ✓ tests/serverless.test.ts (9 tests) 48ms
20
- ✓ tests/data-plane-auth.test.ts (2 tests) 24ms
21
- ✓ tests/masked-fields.test.ts (6 tests) 27ms
22
- ✓ tests/query-cache.test.ts (8 tests) 197ms
23
- ✓ tests/pkce.test.ts (4 tests) 33ms
24
- ✓ tests/sha256-hex.test.ts (1 test) 5ms
10
+ ✓ tests/draft-profile.test.ts (18 tests) 129ms
11
+ ✓ tests/mfa-totp-integration.test.ts (12 tests) 155ms
12
+ ✓ tests/realtime-multi-tenant-integration.test.ts (7 tests) 232ms
13
+ ✓ tests/retry-integration.test.ts (12 tests) 211ms
14
+ ✓ tests/exact-values.test.ts (24 tests) 51ms
15
+ ✓ tests/storage-quota-integration.test.ts (10 tests) 379ms
16
+ ✓ tests/storage-upload-limit-integration.test.ts (11 tests) 313ms
17
+ ✓ tests/rate-limit-integration.test.ts (8 tests) 140ms
18
+ ✓ tests/realtime-session-auth.test.ts (7 tests) 177ms
19
+ ✓ tests/realtime-exact-values.test.ts (8 tests) 246ms
20
+ ✓ tests/types.test.ts (16 tests) 132ms
21
+ ✓ tests/exact-response.test.ts (8 tests) 36ms
22
+ ✓ tests/data-plane-auth.test.ts (2 tests) 36ms
23
+ ✓ tests/query-cache.test.ts (8 tests) 109ms
24
+ ✓ tests/serverless.test.ts (9 tests) 34ms
25
+ ✓ tests/subscribe-frame.test.ts (4 tests) 195ms
26
+ ✓ tests/identity-change.test.ts (6 tests) 18ms
27
+ ✓ tests/signed-url-absolute.test.ts (5 tests) 24ms
28
+ ✓ tests/masked-fields.test.ts (6 tests) 13ms
29
+ ✓ tests/field-kinds-registry.test.ts (7 tests) 19ms
30
+ ✓ tests/pkce.test.ts (4 tests) 20ms
31
+ ✓ tests/sha256-hex.test.ts (1 test) 11ms
25
32
 
26
-  Test Files  16 passed (16)
27
-  Tests  191 passed (191)
28
-  Start at  09:24:21
29
-  Duration  6.59s (transform 3.29s, setup 0ms, import 5.35s, tests 2.85s, environment 15ms)
33
+  Test Files  24 passed (24)
34
+  Tests  264 passed (264)
35
+  Start at  06:44:29
36
+  Duration  7.55s (transform 2.66s, setup 0ms, import 5.46s, tests 2.87s, environment 8ms)
30
37
 
@@ -1,4 +1,4 @@
1
1
 
2
- > @supatype/client@0.3.0 typecheck /home/runner/work/supatype/supatype/packages/client
3
- > tsc --project tsconfig.json --noEmit
2
+ > @supatype/client@0.3.2 typecheck /home/runner/work/supatype/supatype/packages/client
3
+ > tsc --project tsconfig.json --noEmit && tsc --project tests/tsconfig.json --noEmit
4
4
 
package/dist/auth.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { AuthChangeEvent, AuthFlowType, AuthMFAChallengeResponse, AuthMFAEnrollResponse, AuthMFAListFactorsResponse, AuthStorage, OtpType, Session, SupatypeError, User } from "./types.js";
2
- type AuthListener = (event: AuthChangeEvent, session: Session | null) => void;
2
+ export type AuthListener = (event: AuthChangeEvent, session: Session | null) => void;
3
3
  interface AuthClientOptions {
4
4
  initialSession?: Session | undefined;
5
5
  persistSession?: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B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,OAAO,CAAC,WAAW;IAgBnB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI;IAqB1C,OAAO,CAAC,UAAU;YAMJ,WAAW;YASX,kBAAkB;IA4BhC,OAAO,CAAC,UAAU;CAqCnB"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Either the parsed rows, or the reason they could not be read without corrupting something.
3
+ *
4
+ * A result rather than an exception, because every other failure in this client is reported
5
+ * through `QueryResult.error` and a lone throw from the parse path would be the odd one out.
6
+ */
7
+ export type ExactParse = {
8
+ readonly ok: true;
9
+ readonly value: unknown;
10
+ } | {
11
+ readonly ok: false;
12
+ readonly message: string;
13
+ readonly columns: readonly string[];
14
+ };
15
+ /** The table a PostgREST path names, for looking its columns up. */
16
+ export declare function tableFromPath(path: string): string;
17
+ /**
18
+ * Parse a response body, keeping exact-value columns exact.
19
+ *
20
+ * When a numeric literal would lose its value and the column is not one the generated code
21
+ * described, this reports a failure rather than returning a wrong number. There is deliberately no
22
+ * fallback to asking the database: reconstructing the answer always succeeds, which would make a
23
+ * project that never generated indistinguishable from one that did.
24
+ */
25
+ export declare function parseRowsExactly(body: string, table: string): ExactParse;
26
+ //# sourceMappingURL=exact-response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exact-response.d.ts","sourceRoot":"","sources":["../src/exact-response.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC9C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAA;AAEzF,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAWxE"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Reading a response body without losing the columns a double cannot hold.
3
+ *
4
+ * Joins the two halves: the registry says which columns are exact-value kinds, `exact-values` keeps
5
+ * their digits intact across the parse. Kept apart from both so neither has to know about the
6
+ * other, and so the decision about what to do when the kinds are unknown lives in one place.
7
+ */
8
+ import { coerceExactKinds, findLossyNumbers, quoteExactNumbers, } from "./exact-values.js";
9
+ import { fieldKindsAreRegistered, registeredFieldsFor } from "./field-kinds-registry.js";
10
+ /** The table a PostgREST path names, for looking its columns up. */
11
+ export function tableFromPath(path) {
12
+ const withoutPrefix = path.replace(/^\/rest\/v1\//, "");
13
+ const [table] = withoutPrefix.split("?");
14
+ return table ?? withoutPrefix;
15
+ }
16
+ /**
17
+ * Parse a response body, keeping exact-value columns exact.
18
+ *
19
+ * When a numeric literal would lose its value and the column is not one the generated code
20
+ * described, this reports a failure rather than returning a wrong number. There is deliberately no
21
+ * fallback to asking the database: reconstructing the answer always succeeds, which would make a
22
+ * project that never generated indistinguishable from one that did.
23
+ */
24
+ export function parseRowsExactly(body, table) {
25
+ const fields = registeredFieldsFor(table);
26
+ const rewritten = quoteExactNumbers(body, fields);
27
+ // Anything still lossy is a column nothing described: the known ones are strings by now.
28
+ const stranded = findLossyNumbers(rewritten);
29
+ if (stranded.length === 0) {
30
+ return { ok: true, value: coerceExactKinds(JSON.parse(rewritten), fields) };
31
+ }
32
+ return { ok: false, columns: stranded, message: describe(table, stranded) };
33
+ }
34
+ function describe(table, columns) {
35
+ const named = columns.join(", ");
36
+ const which = columns.length === 1 ? "column" : "columns";
37
+ if (!fieldKindsAreRegistered()) {
38
+ return (`The ${which} ${named} on ${table} returned a value that JavaScript cannot hold exactly, and ` +
39
+ `this project's generated types have not been loaded, so Supatype does not know which ` +
40
+ `columns to keep exact. Run \`supatype push\` and import the client from the generated file:` +
41
+ `\n\n import { createClient } from "./supatype/client"\n\n` +
42
+ `Reading it as a number would have silently changed the value, so it has not guessed.`);
43
+ }
44
+ return (`The ${which} ${named} on ${table} returned a value that JavaScript cannot hold exactly, and ` +
45
+ `the generated types do not describe it as one Supatype knows how to keep exact, so it has ` +
46
+ `not guessed. The usual cause is an embedded resource: a column reached through an embed is ` +
47
+ `left alone, because the select that produced it is not parsed here. Selecting it directly ` +
48
+ `rather than through an embed returns it exactly. If the column is new, \`supatype push\` ` +
49
+ `regenerates the types.`);
50
+ }
51
+ //# sourceMappingURL=exact-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exact-response.js","sourceRoot":"","sources":["../src/exact-response.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GAElB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAYxF,oEAAoE;AACpE,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAA;IACvD,MAAM,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACxC,OAAO,KAAK,IAAI,aAAa,CAAA;AAC/B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,KAAa;IAC1D,MAAM,MAAM,GAAgB,mBAAmB,CAAC,KAAK,CAAC,CAAA;IACtD,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAEjD,yFAAyF;IACzF,MAAM,QAAQ,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAA;IAC5C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,EAAE,CAAA;IAC7E,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAA;AAC7E,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,OAA0B;IACzD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAChC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAA;IAEzD,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC;QAC/B,OAAO,CACL,OAAO,KAAK,IAAI,KAAK,OAAO,KAAK,6DAA6D;YAC9F,uFAAuF;YACvF,6FAA6F;YAC7F,4DAA4D;YAC5D,sFAAsF,CACvF,CAAA;IACH,CAAC;IAED,OAAO,CACL,OAAO,KAAK,IAAI,KAAK,OAAO,KAAK,6DAA6D;QAC9F,4FAA4F;QAC5F,6FAA6F;QAC7F,4FAA4F;QAC5F,2FAA2F;QAC3F,wBAAwB,CACzB,CAAA;AACH,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Keeping exact-value columns intact across `JSON.parse`.
3
+ *
4
+ * `bigInt`, `decimal` and `money` name values no binary float holds. Postgres stores them exactly
5
+ * and PostgREST writes the correct digits on the wire, as unquoted JSON numbers. `JSON.parse` then
6
+ * reads each one into an IEEE-754 double, and 9007199254740993 comes back as 9007199254740992.
7
+ *
8
+ * Nothing after the parse can recover the digits, so the repair has to happen on the response text
9
+ * while they are still there: quote the value, let `JSON.parse` produce a string, and convert from
10
+ * that. This also makes runtime agree with the generated types, which declare `bigint` for BIGINT
11
+ * and `string` for the two NUMERIC kinds, matching `@supatype/types`.
12
+ *
13
+ * Deliberately not implemented with `JSON.parse`'s source-accessing reviver: that is recent enough
14
+ * that a runtime without it would silently fall back to corruption, which is the failure this
15
+ * module exists to remove.
16
+ */
17
+ /** The two shapes a column can need. `numeric` covers both `decimal` and `money`. */
18
+ export type ExactKind = "bigint" | "numeric";
19
+ /** Column name to kind, for the table being read. */
20
+ export type ExactFields = Readonly<Record<string, ExactKind>>;
21
+ /**
22
+ * Quote the numeric literals belonging to exact-value columns, so the digits survive the parse.
23
+ *
24
+ * Returns `body` unchanged when there is nothing to do, so the common request pays a scan and no
25
+ * string building.
26
+ */
27
+ export declare function quoteExactNumbers(body: string, fields: ExactFields): string;
28
+ /**
29
+ * The columns whose literals will not survive `JSON.parse`.
30
+ *
31
+ * The safety net for when column metadata could not be loaded. Without it a failed metadata fetch
32
+ * would quietly restore the corruption this module exists to remove. Reports at any depth, since
33
+ * over-reporting here costs a clear error and under-reporting costs a wrong number.
34
+ */
35
+ export declare function findLossyNumbers(body: string): string[];
36
+ /**
37
+ * Convert the quoted values to the types the generated `database.ts` declares.
38
+ *
39
+ * `bigint` columns become native bigints. `numeric` columns stay exact strings, because JavaScript
40
+ * has no native exact decimal, which is why `@supatype/types` declares Decimal and Money `string`.
41
+ */
42
+ export declare function coerceExactKinds(value: unknown, fields: ExactFields): unknown;
43
+ /**
44
+ * `JSON.stringify` that does not throw on a bigint.
45
+ *
46
+ * Reading a row and writing it back would otherwise fail the moment the generated types started
47
+ * declaring `bigint`, because `JSON.stringify` refuses to serialise one.
48
+ */
49
+ export declare function stringifyWithBigInts(value: unknown): string;
50
+ //# sourceMappingURL=exact-values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exact-values.d.ts","sourceRoot":"","sources":["../src/exact-values.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,qFAAqF;AACrF,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;AAE5C,qDAAqD;AACrD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;AAkE7D;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAwB3E;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAUvD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAI7E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI3D"}
@@ -0,0 +1,254 @@
1
+ /**
2
+ * Keeping exact-value columns intact across `JSON.parse`.
3
+ *
4
+ * `bigInt`, `decimal` and `money` name values no binary float holds. Postgres stores them exactly
5
+ * and PostgREST writes the correct digits on the wire, as unquoted JSON numbers. `JSON.parse` then
6
+ * reads each one into an IEEE-754 double, and 9007199254740993 comes back as 9007199254740992.
7
+ *
8
+ * Nothing after the parse can recover the digits, so the repair has to happen on the response text
9
+ * while they are still there: quote the value, let `JSON.parse` produce a string, and convert from
10
+ * that. This also makes runtime agree with the generated types, which declare `bigint` for BIGINT
11
+ * and `string` for the two NUMERIC kinds, matching `@supatype/types`.
12
+ *
13
+ * Deliberately not implemented with `JSON.parse`'s source-accessing reviver: that is recent enough
14
+ * that a runtime without it would silently fall back to corruption, which is the failure this
15
+ * module exists to remove.
16
+ */
17
+ const WHITESPACE = new Set([" ", "\t", "\n", "\r"]);
18
+ const QUOTE = '"';
19
+ /**
20
+ * Walk the JSON text and report every numeric literal that is the value of a key.
21
+ *
22
+ * One scanner rather than one per caller, because the hard part is shared: tracking string state
23
+ * so a key name written inside a string value is not mistaken for a column.
24
+ */
25
+ function forEachKeyedNumber(body, visit) {
26
+ let i = 0;
27
+ let depth = 0;
28
+ let pendingKey = null;
29
+ while (i < body.length) {
30
+ const ch = body[i];
31
+ if (ch === QUOTE) {
32
+ const end = endOfString(body, i);
33
+ const raw = body.slice(i, end);
34
+ i = end;
35
+ pendingKey = nextMeaningfulChar(body, i) === ":" ? readKey(raw) : null;
36
+ continue;
37
+ }
38
+ if (ch === "{" || ch === "[") {
39
+ depth += 1;
40
+ i += 1;
41
+ continue;
42
+ }
43
+ if (ch === "}" || ch === "]") {
44
+ depth -= 1;
45
+ i += 1;
46
+ continue;
47
+ }
48
+ if (ch === ":") {
49
+ i += 1;
50
+ while (i < body.length && WHITESPACE.has(body[i]))
51
+ i += 1;
52
+ const key = pendingKey;
53
+ pendingKey = null;
54
+ if (key !== null) {
55
+ const end = endOfNumber(body, i);
56
+ if (end > i) {
57
+ visit({ key, depth, start: i, end });
58
+ i = end;
59
+ }
60
+ }
61
+ continue;
62
+ }
63
+ i += 1;
64
+ }
65
+ }
66
+ /**
67
+ * Quote the numeric literals belonging to exact-value columns, so the digits survive the parse.
68
+ *
69
+ * Returns `body` unchanged when there is nothing to do, so the common request pays a scan and no
70
+ * string building.
71
+ */
72
+ export function quoteExactNumbers(body, fields) {
73
+ if (Object.keys(fields).length === 0)
74
+ return body;
75
+ // A list response nests rows one level deeper than a single-object response. Columns are only
76
+ // rewritten at row level: an embedded resource can carry a same-named column of another kind,
77
+ // and the select that produced it is not parsed here, so rewriting it would be a guess.
78
+ const rowDepth = firstMeaningfulChar(body) === "[" ? 2 : 1;
79
+ const spans = [];
80
+ forEachKeyedNumber(body, (found) => {
81
+ if (found.depth === rowDepth && fields[found.key] !== undefined)
82
+ spans.push(found);
83
+ });
84
+ if (spans.length === 0)
85
+ return body;
86
+ let out = "";
87
+ let cursor = 0;
88
+ for (const span of spans) {
89
+ // The literal, verbatim. Trailing zeros and exponents are part of what was sent.
90
+ const literal = body.slice(span.start, span.end);
91
+ out += body.slice(cursor, span.start);
92
+ out += JSON.stringify(literal);
93
+ cursor = span.end;
94
+ }
95
+ return out + body.slice(cursor);
96
+ }
97
+ /**
98
+ * The columns whose literals will not survive `JSON.parse`.
99
+ *
100
+ * The safety net for when column metadata could not be loaded. Without it a failed metadata fetch
101
+ * would quietly restore the corruption this module exists to remove. Reports at any depth, since
102
+ * over-reporting here costs a clear error and under-reporting costs a wrong number.
103
+ */
104
+ export function findLossyNumbers(body) {
105
+ const names = [];
106
+ const seen = new Set();
107
+ forEachKeyedNumber(body, (found) => {
108
+ if (seen.has(found.key))
109
+ return;
110
+ if (!isLossy(body.slice(found.start, found.end)))
111
+ return;
112
+ seen.add(found.key);
113
+ names.push(found.key);
114
+ });
115
+ return names;
116
+ }
117
+ /**
118
+ * Convert the quoted values to the types the generated `database.ts` declares.
119
+ *
120
+ * `bigint` columns become native bigints. `numeric` columns stay exact strings, because JavaScript
121
+ * has no native exact decimal, which is why `@supatype/types` declares Decimal and Money `string`.
122
+ */
123
+ export function coerceExactKinds(value, fields) {
124
+ if (Object.keys(fields).length === 0)
125
+ return value;
126
+ if (Array.isArray(value))
127
+ return value.map((row) => coerceRow(row, fields));
128
+ return coerceRow(value, fields);
129
+ }
130
+ /**
131
+ * `JSON.stringify` that does not throw on a bigint.
132
+ *
133
+ * Reading a row and writing it back would otherwise fail the moment the generated types started
134
+ * declaring `bigint`, because `JSON.stringify` refuses to serialise one.
135
+ */
136
+ export function stringifyWithBigInts(value) {
137
+ return JSON.stringify(value, (_key, item) => typeof item === "bigint" ? item.toString() : item);
138
+ }
139
+ function coerceRow(row, fields) {
140
+ if (row === null || typeof row !== "object" || Array.isArray(row))
141
+ return row;
142
+ const source = row;
143
+ let copy = null;
144
+ for (const [name, kind] of Object.entries(fields)) {
145
+ if (kind !== "bigint")
146
+ continue;
147
+ const current = source[name];
148
+ if (typeof current !== "string")
149
+ continue;
150
+ copy ??= { ...source };
151
+ copy[name] = BigInt(current);
152
+ }
153
+ return copy ?? row;
154
+ }
155
+ /** Whether parsing this literal as a double changes the value it names. */
156
+ function isLossy(literal) {
157
+ const asNumber = Number(literal);
158
+ if (!Number.isFinite(asNumber))
159
+ return true;
160
+ // Compared as values rather than as text, so `19.0000` arriving as `19` is not called a loss.
161
+ // It is a type-fidelity problem, and throwing on it would break every project with a money
162
+ // column whose metadata failed to load.
163
+ return normalizeDecimal(literal) !== normalizeDecimal(String(asNumber));
164
+ }
165
+ /** A literal rewritten as a plain decimal with no exponent and no insignificant zeros. */
166
+ function normalizeDecimal(literal) {
167
+ const parts = /^(-?)(\d*)(?:\.(\d*))?(?:[eE]([+-]?\d+))?$/.exec(literal);
168
+ if (parts === null)
169
+ return literal;
170
+ const sign = parts[1] ?? "";
171
+ const exponent = parts[4] !== undefined ? Number(parts[4]) : 0;
172
+ const integerPart = parts[2] ?? "";
173
+ const fractionPart = parts[3] ?? "";
174
+ let digits = integerPart + fractionPart;
175
+ let pointAt = integerPart.length + exponent;
176
+ if (pointAt <= 0) {
177
+ digits = "0".repeat(1 - pointAt) + digits;
178
+ pointAt = 1;
179
+ }
180
+ if (pointAt >= digits.length) {
181
+ digits += "0".repeat(pointAt - digits.length);
182
+ }
183
+ const head = digits.slice(0, pointAt).replace(/^0+(?=\d)/, "");
184
+ const tail = digits.slice(pointAt).replace(/0+$/, "");
185
+ const magnitude = tail === "" ? head : head + "." + tail;
186
+ return /^0(\.0*)?$/.test(magnitude) ? "0" : sign + magnitude;
187
+ }
188
+ function firstMeaningfulChar(body) {
189
+ return nextMeaningfulChar(body, 0);
190
+ }
191
+ function nextMeaningfulChar(body, from) {
192
+ for (let i = from; i < body.length; i += 1) {
193
+ const ch = body[i];
194
+ if (!WHITESPACE.has(ch))
195
+ return ch;
196
+ }
197
+ return undefined;
198
+ }
199
+ /** Index just past the closing quote of the string starting at `start`. */
200
+ function endOfString(body, start) {
201
+ let i = start + 1;
202
+ while (i < body.length) {
203
+ const ch = body[i];
204
+ if (ch === "\\") {
205
+ i += 2;
206
+ continue;
207
+ }
208
+ if (ch === QUOTE)
209
+ return i + 1;
210
+ i += 1;
211
+ }
212
+ return i;
213
+ }
214
+ /** The key a raw JSON string token names, with escapes resolved. */
215
+ function readKey(raw) {
216
+ try {
217
+ const parsed = JSON.parse(raw);
218
+ return typeof parsed === "string" ? parsed : null;
219
+ }
220
+ catch {
221
+ return null;
222
+ }
223
+ }
224
+ /** Index just past the JSON number starting at `from`, or `from` when one does not start there. */
225
+ function endOfNumber(body, from) {
226
+ let i = from;
227
+ if (body[i] === "-")
228
+ i += 1;
229
+ const digitsStart = i;
230
+ while (i < body.length && isDigit(body[i]))
231
+ i += 1;
232
+ if (i === digitsStart)
233
+ return from;
234
+ if (body[i] === ".") {
235
+ i += 1;
236
+ while (i < body.length && isDigit(body[i]))
237
+ i += 1;
238
+ }
239
+ if (body[i] === "e" || body[i] === "E") {
240
+ let j = i + 1;
241
+ if (body[j] === "+" || body[j] === "-")
242
+ j += 1;
243
+ const expStart = j;
244
+ while (j < body.length && isDigit(body[j]))
245
+ j += 1;
246
+ if (j > expStart)
247
+ i = j;
248
+ }
249
+ return i;
250
+ }
251
+ function isDigit(ch) {
252
+ return ch >= "0" && ch <= "9";
253
+ }
254
+ //# sourceMappingURL=exact-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exact-values.js","sourceRoot":"","sources":["../src/exact-values.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AACnD,MAAM,KAAK,GAAG,GAAG,CAAA;AAUjB;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,IAAY,EAAE,KAAmC;IAC3E,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,IAAI,UAAU,GAAkB,IAAI,CAAA;IAEpC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,C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+ * Which columns hold values a JSON parser would destroy, told to the client by generated code.
3
+ *
4
+ * `supatype push` writes `supatype/client.ts` into the project. That file calls
5
+ * {@link registerFieldKinds} at import time and re-exports `createClient`, so an app writes
6
+ *
7
+ * import { createClient } from "./supatype/client"
8
+ *
9
+ * and the kinds arrive by the same import that brings the client. They are compiled into the same
10
+ * bundle, so there is nothing to fetch, nothing to read from disk, and nothing that can be stale
11
+ * relative to the code that shipped.
12
+ *
13
+ * This replaced reading the kinds off the filesystem with a fetch of PostgREST's OpenAPI document
14
+ * as a fallback. That fallback reconstructed the answer from the live database, so it always
15
+ * succeeded, which meant a project that had never generated was indistinguishable from one that
16
+ * had. The gap could not be reported because nothing could detect it. Here, absence is a fact:
17
+ * {@link fieldKindsAreRegistered} is false, and the caller can say so.
18
+ */
19
+ import type { ExactFields, ExactKind } from "./exact-values.js";
20
+ /** Table name to its exact-value columns. */
21
+ export type ExactFieldsByTable = Readonly<Record<string, ExactFields>>;
22
+ /** The shape the generated file passes. Versioned so an older client declines a newer one. */
23
+ export type FieldKindsDocument = {
24
+ readonly version: 1;
25
+ readonly tables: Readonly<Record<string, Readonly<Record<string, ExactKind>>>>;
26
+ };
27
+ /**
28
+ * Record a project's exact-value columns. Called by generated code, not by hand.
29
+ *
30
+ * A document whose version this client does not understand is ignored rather than guessed at: a
31
+ * newer shape read by older rules is how a client starts converting the wrong columns.
32
+ */
33
+ export declare function registerFieldKinds(document: FieldKindsDocument): void;
34
+ /** The exact-value columns of one table, or none when the table has any. */
35
+ export declare function registeredFieldsFor(table: string): ExactFields;
36
+ /**
37
+ * Whether generated code has registered anything at all.
38
+ *
39
+ * Distinct from a table having no exact columns. A project with no `bigInt`, `decimal` or `money`
40
+ * anywhere still generated, and shouting at it would be wrong; a project that never generated is
41
+ * the case worth reporting.
42
+ */
43
+ export declare function fieldKindsAreRegistered(): boolean;
44
+ /** Forget what was registered. For tests, and for a process that switches projects. */
45
+ export declare function forgetRegisteredFieldKinds(): void;
46
+ //# sourceMappingURL=field-kinds-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-kinds-registry.d.ts","sourceRoot":"","sources":["../src/field-kinds-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE/D,6CAA6C;AAC7C,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;AAEtE,8FAA8F;AAC9F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;CAC/E,CAAA;AASD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAgBrE;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAED,uFAAuF;AACvF,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD"}
@@ -0,0 +1,51 @@
1
+ const SUPPORTED_VERSION = 1;
2
+ const NO_FIELDS = {};
3
+ // Module level, and deliberately not per client. Server-side rendering builds a client per
4
+ // request, and the schema does not change between them.
5
+ let registered = null;
6
+ /**
7
+ * Record a project's exact-value columns. Called by generated code, not by hand.
8
+ *
9
+ * A document whose version this client does not understand is ignored rather than guessed at: a
10
+ * newer shape read by older rules is how a client starts converting the wrong columns.
11
+ */
12
+ export function registerFieldKinds(document) {
13
+ if (document === null || typeof document !== "object")
14
+ return;
15
+ if (document.version !== SUPPORTED_VERSION)
16
+ return;
17
+ if (document.tables === null || typeof document.tables !== "object")
18
+ return;
19
+ const tables = {};
20
+ for (const [table, columns] of Object.entries(document.tables)) {
21
+ if (columns === null || typeof columns !== "object")
22
+ continue;
23
+ const fields = {};
24
+ for (const [column, kind] of Object.entries(columns)) {
25
+ if (kind === "bigint" || kind === "numeric")
26
+ fields[column] = kind;
27
+ }
28
+ if (Object.keys(fields).length > 0)
29
+ tables[table] = fields;
30
+ }
31
+ registered = tables;
32
+ }
33
+ /** The exact-value columns of one table, or none when the table has any. */
34
+ export function registeredFieldsFor(table) {
35
+ return registered?.[table] ?? NO_FIELDS;
36
+ }
37
+ /**
38
+ * Whether generated code has registered anything at all.
39
+ *
40
+ * Distinct from a table having no exact columns. A project with no `bigInt`, `decimal` or `money`
41
+ * anywhere still generated, and shouting at it would be wrong; a project that never generated is
42
+ * the case worth reporting.
43
+ */
44
+ export function fieldKindsAreRegistered() {
45
+ return registered !== null;
46
+ }
47
+ /** Forget what was registered. For tests, and for a process that switches projects. */
48
+ export function forgetRegisteredFieldKinds() {
49
+ registered = null;
50
+ }
51
+ //# sourceMappingURL=field-kinds-registry.js.map