@zmdb/compiler 1.0.0-beta.1

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 (172) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +40 -0
  3. package/dist/codegen/index.d.ts +50 -0
  4. package/dist/codegen/index.d.ts.map +1 -0
  5. package/dist/codegen/index.js +364 -0
  6. package/dist/codegen/index.js.map +1 -0
  7. package/dist/codegen/scan.d.ts +105 -0
  8. package/dist/codegen/scan.d.ts.map +1 -0
  9. package/dist/codegen/scan.js +450 -0
  10. package/dist/codegen/scan.js.map +1 -0
  11. package/dist/codegen/witness.d.ts +76 -0
  12. package/dist/codegen/witness.d.ts.map +1 -0
  13. package/dist/codegen/witness.js +690 -0
  14. package/dist/codegen/witness.js.map +1 -0
  15. package/dist/config/contract.d.ts +41 -0
  16. package/dist/config/contract.d.ts.map +1 -0
  17. package/dist/config/contract.js +5 -0
  18. package/dist/config/contract.js.map +1 -0
  19. package/dist/config/index.d.ts +53 -0
  20. package/dist/config/index.d.ts.map +1 -0
  21. package/dist/config/index.js +277 -0
  22. package/dist/config/index.js.map +1 -0
  23. package/dist/config/index.zmdb.generated.d.ts +12 -0
  24. package/dist/config/index.zmdb.generated.js +28 -0
  25. package/dist/config/index.zmdb.witness.d.ts +3 -0
  26. package/dist/config/index.zmdb.witness.d.ts.map +1 -0
  27. package/dist/config/index.zmdb.witness.js +20 -0
  28. package/dist/config/index.zmdb.witness.js.map +1 -0
  29. package/dist/configured-plugin.d.ts +11 -0
  30. package/dist/configured-plugin.d.ts.map +1 -0
  31. package/dist/configured-plugin.js +27 -0
  32. package/dist/configured-plugin.js.map +1 -0
  33. package/dist/emit/index.d.ts +103 -0
  34. package/dist/emit/index.d.ts.map +1 -0
  35. package/dist/emit/index.js +1356 -0
  36. package/dist/emit/index.js.map +1 -0
  37. package/dist/errors.d.ts +7 -0
  38. package/dist/errors.d.ts.map +1 -0
  39. package/dist/errors.js +2 -0
  40. package/dist/errors.js.map +1 -0
  41. package/dist/index.d.ts +46 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +254 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/lint/ast.d.ts +17 -0
  46. package/dist/lint/ast.d.ts.map +1 -0
  47. package/dist/lint/ast.js +77 -0
  48. package/dist/lint/ast.js.map +1 -0
  49. package/dist/lint/host-types.d.ts +9 -0
  50. package/dist/lint/host-types.d.ts.map +1 -0
  51. package/dist/lint/host-types.js +2 -0
  52. package/dist/lint/host-types.js.map +1 -0
  53. package/dist/lint/index.d.ts +23 -0
  54. package/dist/lint/index.d.ts.map +1 -0
  55. package/dist/lint/index.js +53 -0
  56. package/dist/lint/index.js.map +1 -0
  57. package/dist/lint/rules/no-distributed-nullable-tags.d.ts +3 -0
  58. package/dist/lint/rules/no-distributed-nullable-tags.d.ts.map +1 -0
  59. package/dist/lint/rules/no-distributed-nullable-tags.js +71 -0
  60. package/dist/lint/rules/no-distributed-nullable-tags.js.map +1 -0
  61. package/dist/lint/rules/no-empty-patch.d.ts +3 -0
  62. package/dist/lint/rules/no-empty-patch.d.ts.map +1 -0
  63. package/dist/lint/rules/no-empty-patch.js +26 -0
  64. package/dist/lint/rules/no-empty-patch.js.map +1 -0
  65. package/dist/lint/rules/no-interpolated-sql.d.ts +3 -0
  66. package/dist/lint/rules/no-interpolated-sql.d.ts.map +1 -0
  67. package/dist/lint/rules/no-interpolated-sql.js +35 -0
  68. package/dist/lint/rules/no-interpolated-sql.js.map +1 -0
  69. package/dist/lint/rules/no-unbounded-find.d.ts +3 -0
  70. package/dist/lint/rules/no-unbounded-find.d.ts.map +1 -0
  71. package/dist/lint/rules/no-unbounded-find.js +26 -0
  72. package/dist/lint/rules/no-unbounded-find.js.map +1 -0
  73. package/dist/lint/rules/no-unknown-json-column.d.ts +3 -0
  74. package/dist/lint/rules/no-unknown-json-column.d.ts.map +1 -0
  75. package/dist/lint/rules/no-unknown-json-column.js +35 -0
  76. package/dist/lint/rules/no-unknown-json-column.js.map +1 -0
  77. package/dist/lint/rules/require-sql-on-number.d.ts +3 -0
  78. package/dist/lint/rules/require-sql-on-number.d.ts.map +1 -0
  79. package/dist/lint/rules/require-sql-on-number.js +34 -0
  80. package/dist/lint/rules/require-sql-on-number.js.map +1 -0
  81. package/dist/lint/types.d.ts +12 -0
  82. package/dist/lint/types.d.ts.map +1 -0
  83. package/dist/lint/types.js +2 -0
  84. package/dist/lint/types.js.map +1 -0
  85. package/dist/metro/metro.d.ts +22 -0
  86. package/dist/metro/metro.d.ts.map +1 -0
  87. package/dist/metro/metro.js +242 -0
  88. package/dist/metro/metro.js.map +1 -0
  89. package/dist/protobuf/decode.d.ts +20 -0
  90. package/dist/protobuf/decode.d.ts.map +1 -0
  91. package/dist/protobuf/decode.js +289 -0
  92. package/dist/protobuf/decode.js.map +1 -0
  93. package/dist/protobuf/descriptor.d.ts +16 -0
  94. package/dist/protobuf/descriptor.d.ts.map +1 -0
  95. package/dist/protobuf/descriptor.js +303 -0
  96. package/dist/protobuf/descriptor.js.map +1 -0
  97. package/dist/protobuf/encode.d.ts +20 -0
  98. package/dist/protobuf/encode.d.ts.map +1 -0
  99. package/dist/protobuf/encode.js +203 -0
  100. package/dist/protobuf/encode.js.map +1 -0
  101. package/dist/protobuf/grpc-ir.d.ts +16 -0
  102. package/dist/protobuf/grpc-ir.d.ts.map +1 -0
  103. package/dist/protobuf/grpc-ir.js +2 -0
  104. package/dist/protobuf/grpc-ir.js.map +1 -0
  105. package/dist/protobuf/plan.d.ts +42 -0
  106. package/dist/protobuf/plan.d.ts.map +1 -0
  107. package/dist/protobuf/plan.js +158 -0
  108. package/dist/protobuf/plan.js.map +1 -0
  109. package/dist/reflect/callsites.d.ts +40 -0
  110. package/dist/reflect/callsites.d.ts.map +1 -0
  111. package/dist/reflect/callsites.js +153 -0
  112. package/dist/reflect/callsites.js.map +1 -0
  113. package/dist/reflect/index.d.ts +106 -0
  114. package/dist/reflect/index.d.ts.map +1 -0
  115. package/dist/reflect/index.js +1421 -0
  116. package/dist/reflect/index.js.map +1 -0
  117. package/dist/reflect/session.d.ts +118 -0
  118. package/dist/reflect/session.d.ts.map +1 -0
  119. package/dist/reflect/session.js +228 -0
  120. package/dist/reflect/session.js.map +1 -0
  121. package/dist/testing/index.d.ts +69 -0
  122. package/dist/testing/index.d.ts.map +1 -0
  123. package/dist/testing/index.js +210 -0
  124. package/dist/testing/index.js.map +1 -0
  125. package/dist/transform/index.d.ts +74 -0
  126. package/dist/transform/index.d.ts.map +1 -0
  127. package/dist/transform/index.js +572 -0
  128. package/dist/transform/index.js.map +1 -0
  129. package/dist/unplugin/index.d.ts +53 -0
  130. package/dist/unplugin/index.d.ts.map +1 -0
  131. package/dist/unplugin/index.js +130 -0
  132. package/dist/unplugin/index.js.map +1 -0
  133. package/dist/unplugin/inline-bench.d.ts +29 -0
  134. package/dist/unplugin/inline-bench.d.ts.map +1 -0
  135. package/dist/unplugin/inline-bench.js +82 -0
  136. package/dist/unplugin/inline-bench.js.map +1 -0
  137. package/package.json +110 -0
  138. package/src/codegen/index.ts +451 -0
  139. package/src/codegen/scan.ts +574 -0
  140. package/src/codegen/witness.ts +819 -0
  141. package/src/config/contract.ts +48 -0
  142. package/src/config/index.ts +384 -0
  143. package/src/config/index.zmdb.generated.d.ts +12 -0
  144. package/src/config/index.zmdb.generated.js +28 -0
  145. package/src/config/index.zmdb.witness.ts +22 -0
  146. package/src/configured-plugin.ts +35 -0
  147. package/src/emit/index.ts +1496 -0
  148. package/src/errors.ts +6 -0
  149. package/src/index.ts +336 -0
  150. package/src/lint/ast.ts +96 -0
  151. package/src/lint/host-types.ts +9 -0
  152. package/src/lint/index.ts +80 -0
  153. package/src/lint/rules/no-distributed-nullable-tags.ts +76 -0
  154. package/src/lint/rules/no-empty-patch.ts +26 -0
  155. package/src/lint/rules/no-interpolated-sql.ts +45 -0
  156. package/src/lint/rules/no-unbounded-find.ts +26 -0
  157. package/src/lint/rules/no-unknown-json-column.ts +36 -0
  158. package/src/lint/rules/require-sql-on-number.ts +34 -0
  159. package/src/lint/types.ts +11 -0
  160. package/src/metro/metro.ts +313 -0
  161. package/src/protobuf/decode.ts +375 -0
  162. package/src/protobuf/descriptor.ts +353 -0
  163. package/src/protobuf/encode.ts +277 -0
  164. package/src/protobuf/grpc-ir.ts +17 -0
  165. package/src/protobuf/plan.ts +244 -0
  166. package/src/reflect/callsites.ts +198 -0
  167. package/src/reflect/index.ts +1723 -0
  168. package/src/reflect/session.ts +276 -0
  169. package/src/testing/index.ts +298 -0
  170. package/src/transform/index.ts +690 -0
  171. package/src/unplugin/index.ts +182 -0
  172. package/src/unplugin/inline-bench.ts +92 -0
@@ -0,0 +1,53 @@
1
+ import { noDistributedNullableTags } from './rules/no-distributed-nullable-tags.js';
2
+ import { noEmptyPatch } from './rules/no-empty-patch.js';
3
+ import { noInterpolatedSql } from './rules/no-interpolated-sql.js';
4
+ import { noUnboundedFind } from './rules/no-unbounded-find.js';
5
+ import { noUnknownJsonColumn } from './rules/no-unknown-json-column.js';
6
+ import { requireSqlOnNumber } from './rules/require-sql-on-number.js';
7
+ const rules = {
8
+ 'no-distributed-nullable-tags': noDistributedNullableTags,
9
+ 'no-empty-patch': noEmptyPatch,
10
+ 'no-interpolated-sql': noInterpolatedSql,
11
+ 'no-unbounded-find': noUnboundedFind,
12
+ 'no-unknown-json-column': noUnknownJsonColumn,
13
+ 'require-sql-on-number': requireSqlOnNumber,
14
+ };
15
+ const plugin = {
16
+ meta: {
17
+ name: '@zmdb/compiler',
18
+ version: '1.0.0-beta.1',
19
+ },
20
+ rules,
21
+ };
22
+ export const configs = {
23
+ recommended: [
24
+ {
25
+ name: 'zmdb/recommended',
26
+ plugins: { zmdb: plugin },
27
+ rules: {
28
+ 'zmdb/no-distributed-nullable-tags': 'error',
29
+ 'zmdb/no-empty-patch': 'warn',
30
+ 'zmdb/no-interpolated-sql': 'error',
31
+ 'zmdb/no-unbounded-find': 'warn',
32
+ 'zmdb/no-unknown-json-column': 'error',
33
+ 'zmdb/require-sql-on-number': 'warn',
34
+ },
35
+ },
36
+ ],
37
+ strict: [
38
+ {
39
+ name: 'zmdb/strict',
40
+ plugins: { zmdb: plugin },
41
+ rules: {
42
+ 'zmdb/no-distributed-nullable-tags': 'error',
43
+ 'zmdb/no-empty-patch': 'error',
44
+ 'zmdb/no-interpolated-sql': 'error',
45
+ 'zmdb/no-unbounded-find': 'error',
46
+ 'zmdb/no-unknown-json-column': 'error',
47
+ 'zmdb/require-sql-on-number': 'error',
48
+ },
49
+ },
50
+ ],
51
+ };
52
+ export default plugin;
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lint/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AA0BtE,MAAM,KAAK,GAAuC;IAChD,8BAA8B,EAAE,yBAAyB;IACzD,gBAAgB,EAAE,YAAY;IAC9B,qBAAqB,EAAE,iBAAiB;IACxC,mBAAmB,EAAE,eAAe;IACpC,wBAAwB,EAAE,mBAAmB;IAC7C,uBAAuB,EAAE,kBAAkB;CAC5C,CAAC;AAEF,MAAM,MAAM,GAAe;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,cAAc;KACxB;IACD,KAAK;CACN,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAgB;IAClC,WAAW,EAAE;QACX;YACE,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACzB,KAAK,EAAE;gBACL,mCAAmC,EAAE,OAAO;gBAC5C,qBAAqB,EAAE,MAAM;gBAC7B,0BAA0B,EAAE,OAAO;gBACnC,wBAAwB,EAAE,MAAM;gBAChC,6BAA6B,EAAE,OAAO;gBACtC,4BAA4B,EAAE,MAAM;aACrC;SACF;KACF;IACD,MAAM,EAAE;QACN;YACE,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;YACzB,KAAK,EAAE;gBACL,mCAAmC,EAAE,OAAO;gBAC5C,qBAAqB,EAAE,OAAO;gBAC9B,0BAA0B,EAAE,OAAO;gBACnC,wBAAwB,EAAE,OAAO;gBACjC,6BAA6B,EAAE,OAAO;gBACtC,4BAA4B,EAAE,OAAO;aACtC;SACF;KACF;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { HostLintRule } from '../host-types.js';
2
+ export declare const noDistributedNullableTags: HostLintRule;
3
+ //# sourceMappingURL=no-distributed-nullable-tags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-distributed-nullable-tags.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/no-distributed-nullable-tags.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,kBAAkB,CAAC;AAWlE,eAAO,MAAM,yBAAyB,EAAE,YA+DvC,CAAC"}
@@ -0,0 +1,71 @@
1
+ import { importedTagBindings, isImportedTagReference, isTableDeclaration } from '../ast.js';
2
+ const message = 'Move null and undefined outside the tagged intersection; nullish values cannot carry zmdb tags.';
3
+ function isNullish(node) {
4
+ return node.type === 'TSNullKeyword' || node.type === 'TSUndefinedKeyword';
5
+ }
6
+ export const noDistributedNullableTags = {
7
+ meta: {
8
+ type: 'problem',
9
+ docs: {
10
+ description: 'Keep nullable arms outside intersections with zmdb declaration tags.',
11
+ recommended: true,
12
+ },
13
+ fixable: 'code',
14
+ messages: { distributed: message },
15
+ schema: [],
16
+ },
17
+ create(context) {
18
+ let bindings = { tables: new Set(), tags: new Set() };
19
+ return {
20
+ Program(node) {
21
+ bindings = importedTagBindings(node);
22
+ },
23
+ TSInterfaceDeclaration(node) {
24
+ if (!isTableDeclaration(node, bindings))
25
+ return;
26
+ for (const property of node.body.body) {
27
+ if (property.type !== 'TSPropertySignature')
28
+ continue;
29
+ const annotation = property.typeAnnotation?.typeAnnotation;
30
+ if (annotation?.type !== 'TSIntersectionType')
31
+ continue;
32
+ let nullableUnion;
33
+ const tags = [];
34
+ let unsafe = false;
35
+ for (const member of annotation.types) {
36
+ if (member.type === 'TSUnionType') {
37
+ const nullishCount = member.types.filter(isNullish).length;
38
+ if (nullishCount === 1 && nullableUnion === undefined) {
39
+ nullableUnion = member;
40
+ continue;
41
+ }
42
+ }
43
+ if (isImportedTagReference(member, bindings))
44
+ tags.push(member);
45
+ else
46
+ unsafe = true;
47
+ }
48
+ if (unsafe || nullableUnion === undefined || tags.length === 0)
49
+ continue;
50
+ const nullish = nullableUnion.types.find(isNullish);
51
+ if (nullish === undefined)
52
+ continue;
53
+ const data = nullableUnion.types.filter(member => !isNullish(member));
54
+ if (data.length === 0)
55
+ continue;
56
+ const tagText = tags.map(tag => context.sourceCode.getText(tag)).join(' & ');
57
+ const replacement = [
58
+ ...data.map(member => `(${context.sourceCode.getText(member)} & ${tagText})`),
59
+ context.sourceCode.getText(nullish),
60
+ ].join(' | ');
61
+ context.report({
62
+ node: annotation,
63
+ messageId: 'distributed',
64
+ fix: fixer => fixer.replaceText(annotation, replacement),
65
+ });
66
+ }
67
+ },
68
+ };
69
+ },
70
+ };
71
+ //# sourceMappingURL=no-distributed-nullable-tags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-distributed-nullable-tags.js","sourceRoot":"","sources":["../../../src/lint/rules/no-distributed-nullable-tags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,kBA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AC,CAAC;oBAEd,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,UAAU;wBAChB,SAAS,EAAE,aAAa;wBACxB,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,CAAC;qBACzD,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { HostLintRule } from '../host-types.js';
2
+ export declare const noEmptyPatch: HostLintRule;
3
+ //# sourceMappingURL=no-empty-patch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-empty-patch.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/no-empty-patch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIrD,eAAO,MAAM,YAAY,EAAE,YAoB1B,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { staticMemberName } from '../ast.js';
2
+ const message = 'update(id, {}) performs no write; it reads and returns the matching row.';
3
+ export const noEmptyPatch = {
4
+ meta: {
5
+ type: 'problem',
6
+ docs: {
7
+ description: 'Report update calls whose literal patch is empty.',
8
+ recommended: true,
9
+ },
10
+ messages: { emptyPatch: message },
11
+ schema: [],
12
+ },
13
+ create(context) {
14
+ return {
15
+ CallExpression(node) {
16
+ if (staticMemberName(node.callee) !== 'update')
17
+ return;
18
+ const patch = node.arguments[1];
19
+ if (patch?.type !== 'ObjectExpression' || patch.properties.length !== 0)
20
+ return;
21
+ context.report({ node: patch, messageId: 'emptyPatch' });
22
+ },
23
+ };
24
+ },
25
+ };
26
+ //# sourceMappingURL=no-empty-patch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-empty-patch.js","sourceRoot":"","sources":["../../../src/lint/rules/no-empty-patch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,MAAM,OAAO,GAAG,0EAA0E,CAAC;AAE3F,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,mDAAmD;YAChE,WAAW,EAAE,IAAI;SAClB;QACD,QAAQ,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE;QACjC,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,cAAc,CAAC,IAAI;gBACjB,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,QAAQ;oBAAE,OAAO;gBACvD,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBAChC,IAAI,KAAK,EAAE,IAAI,KAAK,kBAAkB,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;oBAAE,OAAO;gBAChF,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;YAC3D,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { HostLintRule } from '../host-types.js';
2
+ export declare const noInterpolatedSql: HostLintRule;
3
+ //# sourceMappingURL=no-interpolated-sql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-interpolated-sql.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/no-interpolated-sql.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,kBAAkB,CAAC;AAyBlE,eAAO,MAAM,iBAAiB,EAAE,YAkB/B,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { staticMemberName, staticPropertyName } from '../ast.js';
2
+ const message = 'Do not interpolate values into SQL text; use driver parameters.';
3
+ function isSqlSink(node) {
4
+ const parent = node.parent;
5
+ if (parent.type === 'Property' &&
6
+ parent.parent.type === 'ObjectExpression' &&
7
+ staticPropertyName(parent) === 'text' &&
8
+ parent.parent.properties.some(property => property.type === 'Property' && staticPropertyName(property) === 'parameters')) {
9
+ return true;
10
+ }
11
+ return (parent.type === 'CallExpression' &&
12
+ staticMemberName(parent.callee) === 'execute' &&
13
+ parent.arguments.some(argument => argument === node));
14
+ }
15
+ export const noInterpolatedSql = {
16
+ meta: {
17
+ type: 'problem',
18
+ docs: {
19
+ description: 'Report interpolated template literals used directly as SQL text.',
20
+ recommended: true,
21
+ },
22
+ messages: { interpolation: message },
23
+ schema: [],
24
+ },
25
+ create(context) {
26
+ return {
27
+ TemplateLiteral(node) {
28
+ if (node.expressions.length === 0 || !isSqlSink(node))
29
+ return;
30
+ context.report({ node, messageId: 'interpolation' });
31
+ },
32
+ };
33
+ },
34
+ };
35
+ //# sourceMappingURL=no-interpolated-sql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-interpolated-sql.js","sourceRoot":"","sources":["../../../src/lint/rules/no-interpolated-sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAKjE,MAAM,OAAO,GAAG,iEAAiE,CAAC;AAElF,SAAS,SAAS,CAAC,IAAyB;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IACE,MAAM,CAAC,IAAI,KAAK,UAAU;QAC1B,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB;QACzC,kBAAkB,CAAC,MAAM,CAAC,KAAK,MAAM;QACrC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAC3B,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU,IAAI,kBAAkB,CAAC,QAAQ,CAAC,KAAK,YAAY,CAC1F,EACD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,gBAAgB;QAChC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,SAAS;QAC7C,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,KAAK,IAAI,CAAC,CACrD,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAiB;IAC7C,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,kEAAkE;YAC/E,WAAW,EAAE,IAAI;SAClB;QACD,QAAQ,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE;QACpC,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,eAAe,CAAC,IAAI;gBAClB,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;oBAAE,OAAO;gBAC9D,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;YACvD,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { HostLintRule } from '../host-types.js';
2
+ export declare const noUnboundedFind: HostLintRule;
3
+ //# sourceMappingURL=no-unbounded-find.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unbounded-find.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/no-unbounded-find.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIrD,eAAO,MAAM,eAAe,EAAE,YAoB7B,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { staticMemberName } from '../ast.js';
2
+ const message = 'find() and find({}) are unbounded; use list() with a page.';
3
+ export const noUnboundedFind = {
4
+ meta: {
5
+ type: 'problem',
6
+ docs: {
7
+ description: 'Report find calls with no syntactic filter.',
8
+ recommended: true,
9
+ },
10
+ messages: { unbounded: message },
11
+ schema: [],
12
+ },
13
+ create(context) {
14
+ return {
15
+ CallExpression(node) {
16
+ if (staticMemberName(node.callee) !== 'find')
17
+ return;
18
+ const filter = node.arguments[0];
19
+ if (filter !== undefined && (filter.type !== 'ObjectExpression' || filter.properties.length !== 0))
20
+ return;
21
+ context.report({ node, messageId: 'unbounded' });
22
+ },
23
+ };
24
+ },
25
+ };
26
+ //# sourceMappingURL=no-unbounded-find.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unbounded-find.js","sourceRoot":"","sources":["../../../src/lint/rules/no-unbounded-find.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,MAAM,OAAO,GAAG,4DAA4D,CAAC;AAE7E,MAAM,CAAC,MAAM,eAAe,GAAiB;IAC3C,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,6CAA6C;YAC1D,WAAW,EAAE,IAAI;SAClB;QACD,QAAQ,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE;QAChC,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,cAAc,CAAC,IAAI;gBACjB,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,MAAM;oBAAE,OAAO;gBACrD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACjC,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC;oBAAE,OAAO;gBAC3G,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;YACnD,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { HostLintRule } from '../host-types.js';
2
+ export declare const noUnknownJsonColumn: HostLintRule;
3
+ //# sourceMappingURL=no-unknown-json-column.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unknown-json-column.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/no-unknown-json-column.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIrD,eAAO,MAAM,mBAAmB,EAAE,YA+BjC,CAAC"}
@@ -0,0 +1,35 @@
1
+ const message = "unknown & X collapses to X; use object & Sql<'json'> or declare the JSON shape.";
2
+ export const noUnknownJsonColumn = {
3
+ meta: {
4
+ type: 'problem',
5
+ docs: {
6
+ description: 'Report unknown where an intersection silently erases its data shape.',
7
+ recommended: true,
8
+ },
9
+ hasSuggestions: true,
10
+ messages: {
11
+ collapsed: message,
12
+ replace: 'Replace unknown with object',
13
+ },
14
+ schema: [],
15
+ },
16
+ create(context) {
17
+ return {
18
+ TSUnknownKeyword(node) {
19
+ if (node.parent.type !== 'TSIntersectionType')
20
+ return;
21
+ context.report({
22
+ node,
23
+ messageId: 'collapsed',
24
+ suggest: [
25
+ {
26
+ messageId: 'replace',
27
+ fix: fixer => fixer.replaceText(node, 'object'),
28
+ },
29
+ ],
30
+ });
31
+ },
32
+ };
33
+ },
34
+ };
35
+ //# sourceMappingURL=no-unknown-json-column.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unknown-json-column.js","sourceRoot":"","sources":["../../../src/lint/rules/no-unknown-json-column.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG,iFAAiF,CAAC;AAElG,MAAM,CAAC,MAAM,mBAAmB,GAAiB;IAC/C,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,sEAAsE;YACnF,WAAW,EAAE,IAAI;SAClB;QACD,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,SAAS,EAAE,OAAO;YAClB,OAAO,EAAE,6BAA6B;SACvC;QACD,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,gBAAgB,CAAC,IAAI;gBACnB,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,oBAAoB;oBAAE,OAAO;gBACtD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,WAAW;oBACtB,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,SAAS;4BACpB,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC;yBAChD;qBACF;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { HostLintRule } from '../host-types.js';
2
+ export declare const requireSqlOnNumber: HostLintRule;
3
+ //# sourceMappingURL=require-sql-on-number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-sql-on-number.d.ts","sourceRoot":"","sources":["../../../src/lint/rules/require-sql-on-number.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIrD,eAAO,MAAM,kBAAkB,EAAE,YA4BhC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { importedTagBindings, isTableDeclaration } from '../ast.js';
2
+ const message = "A bare number is ambiguous; add Sql<'integer'> or Sql<'numeric'>.";
3
+ export const requireSqlOnNumber = {
4
+ meta: {
5
+ type: 'problem',
6
+ docs: {
7
+ description: 'Report bare number annotations on tagged table properties.',
8
+ recommended: true,
9
+ },
10
+ messages: { ambiguous: message },
11
+ schema: [],
12
+ },
13
+ create(context) {
14
+ let bindings = { tables: new Set(), tags: new Set() };
15
+ return {
16
+ Program(node) {
17
+ bindings = importedTagBindings(node);
18
+ },
19
+ TSInterfaceDeclaration(node) {
20
+ if (!isTableDeclaration(node, bindings))
21
+ return;
22
+ for (const property of node.body.body) {
23
+ if (property.type !== 'TSPropertySignature')
24
+ continue;
25
+ const annotation = property.typeAnnotation?.typeAnnotation;
26
+ if (annotation?.type !== 'TSNumberKeyword')
27
+ continue;
28
+ context.report({ node: annotation, messageId: 'ambiguous' });
29
+ }
30
+ },
31
+ };
32
+ },
33
+ };
34
+ //# sourceMappingURL=require-sql-on-number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-sql-on-number.js","sourceRoot":"","sources":["../../../src/lint/rules/require-sql-on-number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAA4B,MAAM,WAAW,CAAC;AAG9F,MAAM,OAAO,GAAG,mEAAmE,CAAC;AAEpF,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,4DAA4D;YACzE,WAAW,EAAE,IAAI;SAClB;QACD,QAAQ,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE;QAChC,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,IAAI,QAAQ,GAAwB,EAAE,MAAM,EAAE,IAAI,GAAG,EAAU,EAAE,IAAI,EAAE,IAAI,GAAG,EAAU,EAAE,CAAC;QAE3F,OAAO;YACL,OAAO,CAAC,IAAI;gBACV,QAAQ,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;YACvC,CAAC;YACD,sBAAsB,CAAC,IAAI;gBACzB,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC;oBAAE,OAAO;gBAChD,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;oBACtC,IAAI,QAAQ,CAAC,IAAI,KAAK,qBAAqB;wBAAE,SAAS;oBACtD,MAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;oBAC3D,IAAI,UAAU,EAAE,IAAI,KAAK,iBAAiB;wBAAE,SAAS;oBACrD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The host-neutral rule shape published to consumers.
3
+ *
4
+ * The implementation is checked against oxlint's exact alpha API internally,
5
+ * but the public declaration cannot import one host's types: the same plugin is
6
+ * also loadable by ESLint without oxlint installed.
7
+ */
8
+ export interface LintRule<Context = never, Visitor extends object = object> {
9
+ readonly meta?: unknown;
10
+ readonly create: (context: Context) => Visitor;
11
+ }
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lint/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ,CAAC,OAAO,GAAG,KAAK,EAAE,OAAO,SAAS,MAAM,GAAG,MAAM;IACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;CAChD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lint/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import type { MetroConfig } from 'metro';
2
+ import type { BabelTransformer, BabelTransformerArgs, BabelTransformerCacheKeyOptions } from 'metro-babel-transformer';
3
+ export interface MetroOptions {
4
+ readonly workerCount?: number;
5
+ }
6
+ /**
7
+ * Wrap Metro's existing Babel transformer without replacing its worker.
8
+ *
9
+ * The same `metro.config.js` form works for bare React Native and Expo because
10
+ * both have already selected their Babel transformer before this wrapper reads it.
11
+ */
12
+ export declare function withZmdb<Config extends MetroConfig>(config: Config, options?: MetroOptions): Config;
13
+ /** Run zmdb first, then hand the rewritten source to the transform Metro already used. */
14
+ export declare function transform(args: BabelTransformerArgs): ReturnType<BabelTransformer['transform']>;
15
+ /**
16
+ * Return unhashed cache material. Metro folds this into its own digest.
17
+ *
18
+ * A different delegate, zmdb release, wrapper option, tsconfig, or project source
19
+ * stat therefore invalidates every transformed module on the next build.
20
+ */
21
+ export declare function getCacheKey(options?: BabelTransformerCacheKeyOptions): string;
22
+ //# sourceMappingURL=metro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metro.d.ts","sourceRoot":"","sources":["../../src/metro/metro.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAmCvH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAkDD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,MAAM,SAAS,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CA+CvG;AAED,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,IAAI,EAAE,oBAAoB,GAAG,UAAU,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAe/F;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,+BAA+B,GAAG,MAAM,CAe7E"}