uql-orm 0.112.0 → 0.113.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 (96) hide show
  1. package/README.md +1 -1
  2. package/dist/browser/http/httpTransport.d.ts +29 -0
  3. package/dist/browser/http/httpTransport.js +59 -0
  4. package/dist/browser/http/index.d.ts +1 -2
  5. package/dist/browser/http/index.js +1 -2
  6. package/dist/browser/index.d.ts +1 -0
  7. package/dist/browser/querier/clientQuerier.d.ts +7 -0
  8. package/dist/browser/querier/clientQuerier.js +43 -0
  9. package/dist/browser/querier/index.d.ts +2 -1
  10. package/dist/browser/querier/index.js +2 -1
  11. package/dist/browser/querier/queryOptions.d.ts +23 -0
  12. package/dist/browser/querier/queryOptions.js +35 -0
  13. package/dist/browser/type/clientQuerier.d.ts +10 -11
  14. package/dist/browser/type/index.d.ts +1 -1
  15. package/dist/browser/type/index.js +1 -1
  16. package/dist/browser/type/transport.d.ts +13 -0
  17. package/dist/dialect/abstractDialect.d.ts +2 -2
  18. package/dist/dialect/abstractSqlDialect.js +3 -3
  19. package/dist/dialect/jsonSql.js +2 -3
  20. package/dist/dialect/operators.js +4 -5
  21. package/dist/express/index.d.ts +1 -1
  22. package/dist/express/index.js +1 -1
  23. package/dist/express/router.d.ts +8 -0
  24. package/dist/express/router.js +50 -0
  25. package/dist/http/api.d.ts +36 -0
  26. package/dist/http/api.js +136 -0
  27. package/dist/http/apiCall.d.ts +59 -0
  28. package/dist/http/apiCall.js +52 -0
  29. package/dist/http/errors.d.ts +20 -0
  30. package/dist/http/errors.js +27 -0
  31. package/dist/http/exposure.d.ts +54 -0
  32. package/dist/http/exposure.js +171 -0
  33. package/dist/http/handler.d.ts +23 -88
  34. package/dist/http/handler.js +42 -155
  35. package/dist/http/index.d.ts +8 -4
  36. package/dist/http/index.js +6 -3
  37. package/dist/http/route.d.ts +34 -0
  38. package/dist/http/route.js +82 -0
  39. package/dist/http/wireCall.d.ts +115 -0
  40. package/dist/http/wireCall.js +126 -0
  41. package/dist/http/wireQuery.d.ts +8 -0
  42. package/dist/http/wireQuery.js +51 -0
  43. package/dist/http/wireRow.d.ts +20 -0
  44. package/dist/http/wireRow.js +170 -0
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.js +1 -1
  47. package/dist/migrate/introspection/mysqlIntrospector.d.ts +4 -1
  48. package/dist/migrate/introspection/mysqlIntrospector.js +12 -2
  49. package/dist/mongodb/mongoDialect.d.ts +6 -6
  50. package/dist/mongodb/mongoDialect.js +6 -6
  51. package/dist/mongodb/mongodbQuerier.d.ts +8 -8
  52. package/dist/mssql/mssqlDialect.js +2 -2
  53. package/dist/nestjs/uqlContextInterceptor.d.ts +3 -3
  54. package/dist/nestjs/uqlContextInterceptor.js +7 -7
  55. package/dist/nestjs/uqlModule.d.ts +5 -11
  56. package/dist/nestjs/uqlModule.js +10 -15
  57. package/dist/querier/abstractQuerier.d.ts +8 -8
  58. package/dist/querier/abstractQuerier.js +15 -8
  59. package/dist/querier/abstractSqlQuerier.d.ts +8 -8
  60. package/dist/querier/keyset.d.ts +15 -0
  61. package/dist/querier/keyset.js +16 -11
  62. package/dist/sqlite/localSqliteQuerierPool.d.ts +1 -1
  63. package/dist/type/column.d.ts +4 -1
  64. package/dist/type/querier.d.ts +2 -2
  65. package/dist/type/query.d.ts +18 -4
  66. package/dist/type/universalQuerier.d.ts +16 -16
  67. package/dist/type/wire.d.ts +1 -31
  68. package/dist/util/dialect.util.d.ts +9 -16
  69. package/dist/util/dialect.util.js +20 -26
  70. package/dist/util/field.util.d.ts +4 -1
  71. package/dist/util/field.util.js +5 -2
  72. package/dist/util/object.util.d.ts +5 -2
  73. package/dist/util/object.util.js +12 -15
  74. package/dist/util/query.util.js +3 -10
  75. package/dist/util/uqlError.d.ts +27 -1
  76. package/dist/util/uqlError.js +43 -0
  77. package/package.json +5 -10
  78. package/skills/uql-orm/SKILL.md +4 -1
  79. package/dist/browser/http/bus.d.ts +0 -3
  80. package/dist/browser/http/bus.js +0 -12
  81. package/dist/browser/http/http.d.ts +0 -20
  82. package/dist/browser/http/http.js +0 -67
  83. package/dist/browser/querier/httpQuerier.d.ts +0 -46
  84. package/dist/browser/querier/httpQuerier.js +0 -64
  85. package/dist/browser/type/request.d.ts +0 -27
  86. package/dist/browser/uql-browser.min.js +0 -4
  87. package/dist/browser/uql-browser.min.js.map +0 -19
  88. package/dist/express/querierMiddleware.d.ts +0 -11
  89. package/dist/express/querierMiddleware.js +0 -39
  90. package/dist/http/contract.d.ts +0 -98
  91. package/dist/http/contract.js +0 -83
  92. package/dist/http/fetchHandler.d.ts +0 -13
  93. package/dist/http/fetchHandler.js +0 -63
  94. package/dist/http/query.d.ts +0 -28
  95. package/dist/http/query.js +0 -119
  96. /package/dist/browser/type/{request.js → transport.js} +0 -0
@@ -1,119 +0,0 @@
1
- // the clause table itself, not the barrel: this module is in the browser bundle's graph
2
- import { QUERY_CLAUSES } from '../type/query.js';
3
- // the brand alone, not the class: importing `QuerySql` for an `instanceof` kept it, and `ColumnRef`
4
- // with it, in the browser bundle, which is on a size budget
5
- import { SQL_FN } from '../type/querySql.js';
6
- // the specific util module, not the barrel, so the browser bundle does not pull in entity metadata
7
- import { getKeys, isRecord, isWhereMap } from '../util/object.util.js';
8
- // the error class alone, from its own leaf module: `queryError.ts` carries every driver's code map
9
- import { UqlUsageError } from '../util/uqlError.js';
10
- /** The flags a request carries beside its query: `hardDelete` on a delete, `count` on a `findMany`. */
11
- const WIRE_FLAGS = ['hardDelete', 'count'];
12
- /**
13
- * The keys accepted from the wire, mapped to how each value is decoded: every query clause ({@link QUERY_CLAUSES})
14
- * HTTP carries, plus the {@link WIRE_FLAGS}. Any other `$` key is refused, since dropping a clause answers a read
15
- * other than the one asked for; any other key (e.g. `filters`, `context`) is dropped, so a remote client can't
16
- * bypass a security filter or inject ambient context.
17
- */
18
- const WIRE_VALUES = new Map([
19
- ...getKeys(QUERY_CLAUSES)
20
- .filter((key) => carriedOverHttp(QUERY_CLAUSES[key]))
21
- .map((key) => [key, QUERY_CLAUSES[key].value]),
22
- ...WIRE_FLAGS.map((flag) => [flag, 'boolean']),
23
- ]);
24
- function carriedOverHttp(clause) {
25
- return clause.wire !== false;
26
- }
27
- /**
28
- * Parse raw query-string entries (with JSON-stringified values), or a `QUERY` body, into a UQL query
29
- * object. Symmetric counterpart of {@link stringifyQuery}. Only the keys in {@link WIRE_VALUES} are honored.
30
- */
31
- export function parseQueryParams(params = {}) {
32
- if (!isRecord(params)) {
33
- throw new UqlUsageError('the query must be a JSON object');
34
- }
35
- const query = {};
36
- for (const key of getKeys(params)) {
37
- const shape = WIRE_VALUES.get(key);
38
- if (!shape && key.startsWith('$')) {
39
- throw new UqlUsageError(`'${key}' is not a query key HTTP takes`);
40
- }
41
- if (shape && params[key] !== undefined) {
42
- query[key] = decodeWireValue(key, shape, params[key]);
43
- }
44
- }
45
- query['$where'] ??= {};
46
- if (!isWhereMap(query['$where'])) {
47
- throw new UqlUsageError("'$where' must be a JSON object");
48
- }
49
- return query;
50
- }
51
- /**
52
- * Decodes a value to the type its clause declares. A query string carries every value as text, so a boolean
53
- * must be decoded: `'false'` is a non-empty string, and taken as is, `$distinct=false` would turn it on.
54
- */
55
- function decodeWireValue(key, shape, value) {
56
- switch (shape) {
57
- case 'object':
58
- return typeof value === 'string' ? parseJson(key, value) : value;
59
- case 'number':
60
- return Number(value);
61
- case 'boolean':
62
- return value === true || value === 'true';
63
- case 'string':
64
- // A cursor arrives as the exact text a page handed out, never as JSON, so any other value is not a cursor.
65
- if (typeof value !== 'string') {
66
- throw new UqlUsageError(`'${key}' must be a cursor a page handed out`);
67
- }
68
- return value;
69
- }
70
- }
71
- function parseJson(key, text) {
72
- try {
73
- return JSON.parse(text);
74
- }
75
- catch {
76
- throw new UqlUsageError(`invalid JSON in '${key}'`);
77
- }
78
- }
79
- /**
80
- * Serialize a UQL query object into a percent-encoded query string where object values
81
- * are JSON-stringified. Symmetric counterpart of {@link parseQueryParams}.
82
- */
83
- export function stringifyQuery(query) {
84
- if (!query) {
85
- return '';
86
- }
87
- const params = new URLSearchParams();
88
- for (const key of getKeys(query)) {
89
- const value = query[key];
90
- if (value === undefined) {
91
- continue;
92
- }
93
- params.append(key, typeof value === 'object' && value !== null ? wireJson(value) : String(value));
94
- }
95
- const qs = params.toString();
96
- return qs ? `?${qs}` : '';
97
- }
98
- /**
99
- * What leaves the browser, as JSON, refusing what JSON keeps nothing of rather than letting the server
100
- * build a statement around the remains. A `sql` fragment renders SQL against a dialect the client does not
101
- * have and arrives as `{}`; binary arrives as an object keyed by index. A `Date` is not among them - it
102
- * serializes to ISO 8601, which is what a date column reads. This is what a cast, or a JavaScript caller,
103
- * hits where the client's types already refuse a fragment.
104
- */
105
- export function wireJson(value) {
106
- return JSON.stringify(value, (_key, held) => {
107
- if (typeof held !== 'object' || held === null) {
108
- return held;
109
- }
110
- if (SQL_FN in held) {
111
- throw new UqlUsageError('raw SQL cannot travel over HTTP: what leaves the browser is JSON');
112
- }
113
- // A blob is a field value, so no type parameter reaches it: this is the only place it is caught.
114
- if (held instanceof ArrayBuffer || ArrayBuffer.isView(held)) {
115
- throw new UqlUsageError('binary cannot travel over HTTP: what leaves the browser is JSON');
116
- }
117
- return held;
118
- });
119
- }
File without changes