@bockit/sequel 0.0.0-stage → 0.2.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 (104) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +227 -2
  3. package/THIRD_PARTY_NOTICES.md +268 -0
  4. package/binaries.json +106 -0
  5. package/dist/binaries/cache.d.ts +6 -0
  6. package/dist/binaries/cache.js +36 -0
  7. package/dist/binaries/ensure-binary.d.ts +10 -0
  8. package/dist/binaries/ensure-binary.js +85 -0
  9. package/dist/binaries/manifest.d.ts +30 -0
  10. package/dist/binaries/manifest.js +112 -0
  11. package/dist/binaries/platform.d.ts +3 -0
  12. package/dist/binaries/platform.js +10 -0
  13. package/dist/binaries/unpack.d.ts +2 -0
  14. package/dist/binaries/unpack.js +35 -0
  15. package/dist/binaries/verify.d.ts +2 -0
  16. package/dist/binaries/verify.js +16 -0
  17. package/dist/check.d.ts +9 -0
  18. package/dist/check.js +178 -0
  19. package/dist/cli.d.ts +2 -0
  20. package/dist/cli.js +339 -0
  21. package/dist/config/define-config.d.ts +24 -0
  22. package/dist/config/define-config.js +4 -0
  23. package/dist/config/load-config.d.ts +6 -0
  24. package/dist/config/load-config.js +34 -0
  25. package/dist/config/resolve-config.d.ts +35 -0
  26. package/dist/config/resolve-config.js +159 -0
  27. package/dist/db/connection.d.ts +6 -0
  28. package/dist/db/connection.js +38 -0
  29. package/dist/db/shadow.d.ts +11 -0
  30. package/dist/db/shadow.js +68 -0
  31. package/dist/engine/client.d.ts +24 -0
  32. package/dist/engine/client.js +123 -0
  33. package/dist/engine/diff.d.ts +12 -0
  34. package/dist/engine/diff.js +51 -0
  35. package/dist/errors.d.ts +3 -0
  36. package/dist/errors.js +5 -0
  37. package/dist/extras/snapshot.d.ts +3 -0
  38. package/dist/extras/snapshot.js +99 -0
  39. package/dist/files.d.ts +1 -0
  40. package/dist/files.js +15 -0
  41. package/dist/generate/generate-modules.d.ts +17 -0
  42. package/dist/generate/generate-modules.js +97 -0
  43. package/dist/generate/modules.d.ts +16 -0
  44. package/dist/generate/modules.js +118 -0
  45. package/dist/generate/pg-dump.d.ts +8 -0
  46. package/dist/generate/pg-dump.js +66 -0
  47. package/dist/generate/plugin-wrapper.d.ts +3 -0
  48. package/dist/generate/plugin-wrapper.js +20 -0
  49. package/dist/generate/sqlc.d.ts +27 -0
  50. package/dist/generate/sqlc.js +113 -0
  51. package/dist/generate/watch.d.ts +16 -0
  52. package/dist/generate/watch.js +73 -0
  53. package/dist/generator/generate.d.ts +21 -0
  54. package/dist/generator/generate.js +440 -0
  55. package/dist/generator/keys.d.ts +4 -0
  56. package/dist/generator/keys.js +24 -0
  57. package/dist/generator/lexer.d.ts +12 -0
  58. package/dist/generator/lexer.js +210 -0
  59. package/dist/generator/main.d.ts +1 -0
  60. package/dist/generator/main.js +12 -0
  61. package/dist/generator/pg-array-helper.d.ts +2 -0
  62. package/dist/generator/pg-array-helper.js +53 -0
  63. package/dist/generator/plugin.d.ts +6 -0
  64. package/dist/generator/plugin.js +26 -0
  65. package/dist/generator/request.d.ts +57 -0
  66. package/dist/generator/request.js +96 -0
  67. package/dist/generator/select-list.d.ts +27 -0
  68. package/dist/generator/select-list.js +580 -0
  69. package/dist/generator/strings.d.ts +2 -0
  70. package/dist/generator/strings.js +34 -0
  71. package/dist/generator/types.d.ts +23 -0
  72. package/dist/generator/types.js +216 -0
  73. package/dist/index.d.ts +2 -0
  74. package/dist/index.js +2 -0
  75. package/dist/migrate/adopt-prisma.d.ts +23 -0
  76. package/dist/migrate/adopt-prisma.js +119 -0
  77. package/dist/migrate/deploy.d.ts +7 -0
  78. package/dist/migrate/deploy.js +23 -0
  79. package/dist/migrate/drift.d.ts +10 -0
  80. package/dist/migrate/drift.js +36 -0
  81. package/dist/migrate/files.d.ts +19 -0
  82. package/dist/migrate/files.js +97 -0
  83. package/dist/migrate/history.d.ts +20 -0
  84. package/dist/migrate/history.js +54 -0
  85. package/dist/migrate/lint.d.ts +21 -0
  86. package/dist/migrate/lint.js +153 -0
  87. package/dist/migrate/new.d.ts +13 -0
  88. package/dist/migrate/new.js +41 -0
  89. package/dist/migrate/runner.d.ts +28 -0
  90. package/dist/migrate/runner.js +124 -0
  91. package/dist/migrate/sql-text.d.ts +33 -0
  92. package/dist/migrate/sql-text.js +233 -0
  93. package/dist/schema/schema.d.ts +16 -0
  94. package/dist/schema/schema.js +111 -0
  95. package/dist/schema/unsupported.d.ts +3 -0
  96. package/dist/schema/unsupported.js +36 -0
  97. package/dist/schema/wasm.d.ts +8 -0
  98. package/dist/schema/wasm.js +32 -0
  99. package/package.json +50 -4
  100. package/vendor/prisma-schema-wasm/LICENSE +201 -0
  101. package/vendor/prisma-schema-wasm/README.md +32 -0
  102. package/vendor/prisma-schema-wasm/package.json +3 -0
  103. package/vendor/prisma-schema-wasm/prisma_schema_build.js +539 -0
  104. package/vendor/prisma-schema-wasm/prisma_schema_build_bg.wasm +0 -0
@@ -0,0 +1,268 @@
1
+ # Third-party notices
2
+
3
+ sequel fetches, mirrors or vendors the tools below, unmodified. Each is a pinned version, verified against the sha256 recorded in `binaries.json` (or, for the vendored WASM, in `vendor/prisma-schema-wasm/README.md`). Each binary also contains its own dependencies, under the licences its upstream project lists.
4
+
5
+ `pg` (MIT) is an npm dependency of sequel and carries its own licence.
6
+
7
+ ## Prisma schema engine
8
+
9
+ - **Version:** `8.1.0-1.d1b3f377ca835d73fd50954a5e22128b9ebdd6b8`, the engine behind Prisma 7.10.1
10
+ - **Source:** [`prisma/prisma-engines`](https://github.com/prisma/prisma-engines/tree/d1b3f377ca835d73fd50954a5e22128b9ebdd6b8) at commit `d1b3f377ca835d73fd50954a5e22128b9ebdd6b8`. Binaries from `https://binaries.prisma.sh/all_commits/d1b3f377ca835d73fd50954a5e22128b9ebdd6b8/<platform>/schema-engine.gz`, for `darwin-arm64`, `linux-static-x64` and `linux-static-arm64`.
11
+ - **Licence:** Apache-2.0, whose full text is [below](#apache-license-20).
12
+ - **Copyright:** Prisma Data, Inc. and the prisma-engines contributors. The repository's `LICENSE` names no copyright holder, and it has no NOTICE file.
13
+
14
+ ## Prisma schema WASM
15
+
16
+ Vendored in `vendor/prisma-schema-wasm/`, built from the same engine commit.
17
+
18
+ - **Version:** `@prisma/prisma-schema-wasm` `8.1.0-1.d1b3f377ca835d73fd50954a5e22128b9ebdd6b8`
19
+ - **Source:** the npm registry; built from [`prisma/prisma-engines`](https://github.com/prisma/prisma-engines/tree/d1b3f377ca835d73fd50954a5e22128b9ebdd6b8/prisma-schema-wasm) at commit `d1b3f377ca835d73fd50954a5e22128b9ebdd6b8`.
20
+ - **Licence:** Apache-2.0. Its `LICENSE` is in the vendored folder, and its full text is [below](#apache-license-20).
21
+ - **Copyright:** as for the schema engine.
22
+
23
+ ## sqlc
24
+
25
+ - **Version:** v1.31.1
26
+ - **Source:** [`sqlc-dev/sqlc`](https://github.com/sqlc-dev/sqlc/tree/v1.31.1). Binaries from its [v1.31.1 release](https://github.com/sqlc-dev/sqlc/releases/tag/v1.31.1): `sqlc_1.31.1_darwin_arm64.tar.gz`, `sqlc_1.31.1_linux_amd64.tar.gz` and `sqlc_1.31.1_linux_arm64.tar.gz`.
27
+ - **Licence:** MIT, whose full text follows, copied from its `LICENSE` at v1.31.1.
28
+ - **Copyright:** Copyright (c) 2024 Riza, Inc.
29
+
30
+ ```
31
+ MIT License
32
+
33
+ Copyright (c) 2024 Riza, Inc.
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining a copy
36
+ of this software and associated documentation files (the "Software"), to deal
37
+ in the Software without restriction, including without limitation the rights
38
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39
+ copies of the Software, and to permit persons to whom the Software is
40
+ furnished to do so, subject to the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be included in all
43
+ copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
48
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
51
+ SOFTWARE.
52
+ ```
53
+
54
+ ## Squawk
55
+
56
+ - **Version:** 2.71.0
57
+ - **Source:** [`sbdchd/squawk`](https://github.com/sbdchd/squawk/tree/v2.71.0). Binaries from its [v2.71.0 release](https://github.com/sbdchd/squawk/releases/tag/v2.71.0): `squawk-darwin-arm64`, `squawk-linux-musl-x64` and `squawk-linux-musl-arm64`.
58
+ - **Licence:** Squawk is licensed under Apache-2.0 or MIT, at the user's option. sequel uses and redistributes it under Apache-2.0, whose full text is [below](#apache-license-20).
59
+ - **Copyright:** Squawk Team & Contributors, as its `Cargo.toml` names its authors. Its licence files name no copyright holder.
60
+
61
+ ## Apache License 2.0
62
+
63
+ The full text, from <https://www.apache.org/licenses/LICENSE-2.0.txt>, which applies to the Prisma schema engine, the Prisma schema WASM and Squawk.
64
+
65
+ ```
66
+
67
+ Apache License
68
+ Version 2.0, January 2004
69
+ http://www.apache.org/licenses/
70
+
71
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
72
+
73
+ 1. Definitions.
74
+
75
+ "License" shall mean the terms and conditions for use, reproduction,
76
+ and distribution as defined by Sections 1 through 9 of this document.
77
+
78
+ "Licensor" shall mean the copyright owner or entity authorized by
79
+ the copyright owner that is granting the License.
80
+
81
+ "Legal Entity" shall mean the union of the acting entity and all
82
+ other entities that control, are controlled by, or are under common
83
+ control with that entity. For the purposes of this definition,
84
+ "control" means (i) the power, direct or indirect, to cause the
85
+ direction or management of such entity, whether by contract or
86
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
87
+ outstanding shares, or (iii) beneficial ownership of such entity.
88
+
89
+ "You" (or "Your") shall mean an individual or Legal Entity
90
+ exercising permissions granted by this License.
91
+
92
+ "Source" form shall mean the preferred form for making modifications,
93
+ including but not limited to software source code, documentation
94
+ source, and configuration files.
95
+
96
+ "Object" form shall mean any form resulting from mechanical
97
+ transformation or translation of a Source form, including but
98
+ not limited to compiled object code, generated documentation,
99
+ and conversions to other media types.
100
+
101
+ "Work" shall mean the work of authorship, whether in Source or
102
+ Object form, made available under the License, as indicated by a
103
+ copyright notice that is included in or attached to the work
104
+ (an example is provided in the Appendix below).
105
+
106
+ "Derivative Works" shall mean any work, whether in Source or Object
107
+ form, that is based on (or derived from) the Work and for which the
108
+ editorial revisions, annotations, elaborations, or other modifications
109
+ represent, as a whole, an original work of authorship. For the purposes
110
+ of this License, Derivative Works shall not include works that remain
111
+ separable from, or merely link (or bind by name) to the interfaces of,
112
+ the Work and Derivative Works thereof.
113
+
114
+ "Contribution" shall mean any work of authorship, including
115
+ the original version of the Work and any modifications or additions
116
+ to that Work or Derivative Works thereof, that is intentionally
117
+ submitted to Licensor for inclusion in the Work by the copyright owner
118
+ or by an individual or Legal Entity authorized to submit on behalf of
119
+ the copyright owner. For the purposes of this definition, "submitted"
120
+ means any form of electronic, verbal, or written communication sent
121
+ to the Licensor or its representatives, including but not limited to
122
+ communication on electronic mailing lists, source code control systems,
123
+ and issue tracking systems that are managed by, or on behalf of, the
124
+ Licensor for the purpose of discussing and improving the Work, but
125
+ excluding communication that is conspicuously marked or otherwise
126
+ designated in writing by the copyright owner as "Not a Contribution."
127
+
128
+ "Contributor" shall mean Licensor and any individual or Legal Entity
129
+ on behalf of whom a Contribution has been received by Licensor and
130
+ subsequently incorporated within the Work.
131
+
132
+ 2. Grant of Copyright License. Subject to the terms and conditions of
133
+ this License, each Contributor hereby grants to You a perpetual,
134
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
135
+ copyright license to reproduce, prepare Derivative Works of,
136
+ publicly display, publicly perform, sublicense, and distribute the
137
+ Work and such Derivative Works in Source or Object form.
138
+
139
+ 3. Grant of Patent License. Subject to the terms and conditions of
140
+ this License, each Contributor hereby grants to You a perpetual,
141
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
142
+ (except as stated in this section) patent license to make, have made,
143
+ use, offer to sell, sell, import, and otherwise transfer the Work,
144
+ where such license applies only to those patent claims licensable
145
+ by such Contributor that are necessarily infringed by their
146
+ Contribution(s) alone or by combination of their Contribution(s)
147
+ with the Work to which such Contribution(s) was submitted. If You
148
+ institute patent litigation against any entity (including a
149
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
150
+ or a Contribution incorporated within the Work constitutes direct
151
+ or contributory patent infringement, then any patent licenses
152
+ granted to You under this License for that Work shall terminate
153
+ as of the date such litigation is filed.
154
+
155
+ 4. Redistribution. You may reproduce and distribute copies of the
156
+ Work or Derivative Works thereof in any medium, with or without
157
+ modifications, and in Source or Object form, provided that You
158
+ meet the following conditions:
159
+
160
+ (a) You must give any other recipients of the Work or
161
+ Derivative Works a copy of this License; and
162
+
163
+ (b) You must cause any modified files to carry prominent notices
164
+ stating that You changed the files; and
165
+
166
+ (c) You must retain, in the Source form of any Derivative Works
167
+ that You distribute, all copyright, patent, trademark, and
168
+ attribution notices from the Source form of the Work,
169
+ excluding those notices that do not pertain to any part of
170
+ the Derivative Works; and
171
+
172
+ (d) If the Work includes a "NOTICE" text file as part of its
173
+ distribution, then any Derivative Works that You distribute must
174
+ include a readable copy of the attribution notices contained
175
+ within such NOTICE file, excluding those notices that do not
176
+ pertain to any part of the Derivative Works, in at least one
177
+ of the following places: within a NOTICE text file distributed
178
+ as part of the Derivative Works; within the Source form or
179
+ documentation, if provided along with the Derivative Works; or,
180
+ within a display generated by the Derivative Works, if and
181
+ wherever such third-party notices normally appear. The contents
182
+ of the NOTICE file are for informational purposes only and
183
+ do not modify the License. You may add Your own attribution
184
+ notices within Derivative Works that You distribute, alongside
185
+ or as an addendum to the NOTICE text from the Work, provided
186
+ that such additional attribution notices cannot be construed
187
+ as modifying the License.
188
+
189
+ You may add Your own copyright statement to Your modifications and
190
+ may provide additional or different license terms and conditions
191
+ for use, reproduction, or distribution of Your modifications, or
192
+ for any such Derivative Works as a whole, provided Your use,
193
+ reproduction, and distribution of the Work otherwise complies with
194
+ the conditions stated in this License.
195
+
196
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
197
+ any Contribution intentionally submitted for inclusion in the Work
198
+ by You to the Licensor shall be under the terms and conditions of
199
+ this License, without any additional terms or conditions.
200
+ Notwithstanding the above, nothing herein shall supersede or modify
201
+ the terms of any separate license agreement you may have executed
202
+ with Licensor regarding such Contributions.
203
+
204
+ 6. Trademarks. This License does not grant permission to use the trade
205
+ names, trademarks, service marks, or product names of the Licensor,
206
+ except as required for reasonable and customary use in describing the
207
+ origin of the Work and reproducing the content of the NOTICE file.
208
+
209
+ 7. Disclaimer of Warranty. Unless required by applicable law or
210
+ agreed to in writing, Licensor provides the Work (and each
211
+ Contributor provides its Contributions) on an "AS IS" BASIS,
212
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
213
+ implied, including, without limitation, any warranties or conditions
214
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
215
+ PARTICULAR PURPOSE. You are solely responsible for determining the
216
+ appropriateness of using or redistributing the Work and assume any
217
+ risks associated with Your exercise of permissions under this License.
218
+
219
+ 8. Limitation of Liability. In no event and under no legal theory,
220
+ whether in tort (including negligence), contract, or otherwise,
221
+ unless required by applicable law (such as deliberate and grossly
222
+ negligent acts) or agreed to in writing, shall any Contributor be
223
+ liable to You for damages, including any direct, indirect, special,
224
+ incidental, or consequential damages of any character arising as a
225
+ result of this License or out of the use or inability to use the
226
+ Work (including but not limited to damages for loss of goodwill,
227
+ work stoppage, computer failure or malfunction, or any and all
228
+ other commercial damages or losses), even if such Contributor
229
+ has been advised of the possibility of such damages.
230
+
231
+ 9. Accepting Warranty or Additional Liability. While redistributing
232
+ the Work or Derivative Works thereof, You may choose to offer,
233
+ and charge a fee for, acceptance of support, warranty, indemnity,
234
+ or other liability obligations and/or rights consistent with this
235
+ License. However, in accepting such obligations, You may act only
236
+ on Your own behalf and on Your sole responsibility, not on behalf
237
+ of any other Contributor, and only if You agree to indemnify,
238
+ defend, and hold each Contributor harmless for any liability
239
+ incurred by, or claims asserted against, such Contributor by reason
240
+ of your accepting any such warranty or additional liability.
241
+
242
+ END OF TERMS AND CONDITIONS
243
+
244
+ APPENDIX: How to apply the Apache License to your work.
245
+
246
+ To apply the Apache License to your work, attach the following
247
+ boilerplate notice, with the fields enclosed by brackets "[]"
248
+ replaced with your own identifying information. (Don't include
249
+ the brackets!) The text should be enclosed in the appropriate
250
+ comment syntax for the file format. We also recommend that a
251
+ file or class name and description of purpose be included on the
252
+ same "printed page" as the copyright notice for easier
253
+ identification within third-party archives.
254
+
255
+ Copyright [yyyy] [name of copyright owner]
256
+
257
+ Licensed under the Apache License, Version 2.0 (the "License");
258
+ you may not use this file except in compliance with the License.
259
+ You may obtain a copy of the License at
260
+
261
+ http://www.apache.org/licenses/LICENSE-2.0
262
+
263
+ Unless required by applicable law or agreed to in writing, software
264
+ distributed under the License is distributed on an "AS IS" BASIS,
265
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
266
+ See the License for the specific language governing permissions and
267
+ limitations under the License.
268
+ ```
package/binaries.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "tools": {
3
+ "sqlc": {
4
+ "version": "1.31.1",
5
+ "executable": "sqlc",
6
+ "platforms": {
7
+ "darwin-arm64": {
8
+ "platform": "darwin_arm64",
9
+ "asset": "sqlc_1.31.1_darwin_arm64.tar.gz",
10
+ "archive": "tar.gz",
11
+ "member": "sqlc",
12
+ "upstream": "https://github.com/sqlc-dev/sqlc/releases/download/v1.31.1/sqlc_1.31.1_darwin_arm64.tar.gz",
13
+ "mirror": "https://github.com/Bockit/sequel/releases/download/bin-sqlc-1.31.1/sqlc_1.31.1_darwin_arm64.tar.gz",
14
+ "assetSha256": "21602158c99eb1f2bae197a66abfb1941d1e9e50b23125bb193349c6b1acc71e",
15
+ "executableSha256": "7e63a8b2166f1103a2ad1d2e5d05d8fe3f13ca65ecf2774a2570b830d32055fd"
16
+ },
17
+ "linux-x64": {
18
+ "platform": "linux_amd64",
19
+ "asset": "sqlc_1.31.1_linux_amd64.tar.gz",
20
+ "archive": "tar.gz",
21
+ "member": "sqlc",
22
+ "upstream": "https://github.com/sqlc-dev/sqlc/releases/download/v1.31.1/sqlc_1.31.1_linux_amd64.tar.gz",
23
+ "mirror": "https://github.com/Bockit/sequel/releases/download/bin-sqlc-1.31.1/sqlc_1.31.1_linux_amd64.tar.gz",
24
+ "assetSha256": "497ae4fcdfa64c5b0c311ffe4c2bd991e43991e82e5367792ed78bc2dca27354",
25
+ "executableSha256": "0496fbc18f603e2fbd10c752942d1389a1fa9bc3d18de7243ec00cccd611575f"
26
+ },
27
+ "linux-arm64": {
28
+ "platform": "linux_arm64",
29
+ "asset": "sqlc_1.31.1_linux_arm64.tar.gz",
30
+ "archive": "tar.gz",
31
+ "member": "sqlc",
32
+ "upstream": "https://github.com/sqlc-dev/sqlc/releases/download/v1.31.1/sqlc_1.31.1_linux_arm64.tar.gz",
33
+ "mirror": "https://github.com/Bockit/sequel/releases/download/bin-sqlc-1.31.1/sqlc_1.31.1_linux_arm64.tar.gz",
34
+ "assetSha256": "b7cae247740d0c51a1e657479e5b2d21e6fef428f596682a01bc55bf4ab8a23d",
35
+ "executableSha256": "3b42bdbc5be1d534b95fc6b9f0e1572e6aa555fda3c96f208cb26abb1bb77d7e"
36
+ }
37
+ }
38
+ },
39
+ "squawk": {
40
+ "version": "2.71.0",
41
+ "executable": "squawk",
42
+ "platforms": {
43
+ "darwin-arm64": {
44
+ "platform": "darwin-arm64",
45
+ "asset": "squawk-darwin-arm64",
46
+ "archive": "none",
47
+ "upstream": "https://github.com/sbdchd/squawk/releases/download/v2.71.0/squawk-darwin-arm64",
48
+ "mirror": "https://github.com/Bockit/sequel/releases/download/bin-squawk-2.71.0/squawk-darwin-arm64",
49
+ "assetSha256": "6132cb9779c688303e43746e10268f280b35a3fbcc70b851472021cc882ef5a2",
50
+ "executableSha256": "6132cb9779c688303e43746e10268f280b35a3fbcc70b851472021cc882ef5a2"
51
+ },
52
+ "linux-x64": {
53
+ "platform": "linux-musl-x64",
54
+ "asset": "squawk-linux-musl-x64",
55
+ "archive": "none",
56
+ "upstream": "https://github.com/sbdchd/squawk/releases/download/v2.71.0/squawk-linux-musl-x64",
57
+ "mirror": "https://github.com/Bockit/sequel/releases/download/bin-squawk-2.71.0/squawk-linux-musl-x64",
58
+ "assetSha256": "cf542e159fb3a94e5fd31d8b5282a31334df8205c6d7993afe286e9133fdff3e",
59
+ "executableSha256": "cf542e159fb3a94e5fd31d8b5282a31334df8205c6d7993afe286e9133fdff3e"
60
+ },
61
+ "linux-arm64": {
62
+ "platform": "linux-musl-arm64",
63
+ "asset": "squawk-linux-musl-arm64",
64
+ "archive": "none",
65
+ "upstream": "https://github.com/sbdchd/squawk/releases/download/v2.71.0/squawk-linux-musl-arm64",
66
+ "mirror": "https://github.com/Bockit/sequel/releases/download/bin-squawk-2.71.0/squawk-linux-musl-arm64",
67
+ "assetSha256": "3b350a7ad426cd4f000b9b43211b19d8a724392ad715ad454156653aadf77347",
68
+ "executableSha256": "3b350a7ad426cd4f000b9b43211b19d8a724392ad715ad454156653aadf77347"
69
+ }
70
+ }
71
+ },
72
+ "schema-engine": {
73
+ "version": "8.1.0-1.d1b3f377ca835d73fd50954a5e22128b9ebdd6b8",
74
+ "executable": "schema-engine",
75
+ "platforms": {
76
+ "darwin-arm64": {
77
+ "platform": "darwin-arm64",
78
+ "asset": "schema-engine-darwin-arm64.gz",
79
+ "archive": "gz",
80
+ "upstream": "https://binaries.prisma.sh/all_commits/d1b3f377ca835d73fd50954a5e22128b9ebdd6b8/darwin-arm64/schema-engine.gz",
81
+ "mirror": "https://github.com/Bockit/sequel/releases/download/bin-schema-engine-8.1.0-1.d1b3f377ca835d73fd50954a5e22128b9ebdd6b8/schema-engine-darwin-arm64.gz",
82
+ "assetSha256": "d7e50db1fa19f659dc95050e0e5b23bd3699c5db2f33bd0c43cb3e9bf7df3dc6",
83
+ "executableSha256": "6032ea1bdbd6dc3d453c36a22838d1d3b3554053083bf7695c104e9993637ba1"
84
+ },
85
+ "linux-x64": {
86
+ "platform": "linux-static-x64",
87
+ "asset": "schema-engine-linux-static-x64.gz",
88
+ "archive": "gz",
89
+ "upstream": "https://binaries.prisma.sh/all_commits/d1b3f377ca835d73fd50954a5e22128b9ebdd6b8/linux-static-x64/schema-engine.gz",
90
+ "mirror": "https://github.com/Bockit/sequel/releases/download/bin-schema-engine-8.1.0-1.d1b3f377ca835d73fd50954a5e22128b9ebdd6b8/schema-engine-linux-static-x64.gz",
91
+ "assetSha256": "1f609ddc58e6f5e21934976311162f1e5daa954fd6359c55ef65fee2033c45b4",
92
+ "executableSha256": "ec4adf16b03f1a37bae5965e4a8f265dccb48096fe03ec253385609babbddfaf"
93
+ },
94
+ "linux-arm64": {
95
+ "platform": "linux-static-arm64",
96
+ "asset": "schema-engine-linux-static-arm64.gz",
97
+ "archive": "gz",
98
+ "upstream": "https://binaries.prisma.sh/all_commits/d1b3f377ca835d73fd50954a5e22128b9ebdd6b8/linux-static-arm64/schema-engine.gz",
99
+ "mirror": "https://github.com/Bockit/sequel/releases/download/bin-schema-engine-8.1.0-1.d1b3f377ca835d73fd50954a5e22128b9ebdd6b8/schema-engine-linux-static-arm64.gz",
100
+ "assetSha256": "a80add0047a24ef33cc8e87070caa65a107a406addf3341bc4ccad72c147bbd4",
101
+ "executableSha256": "edd9415943a93f06ca11564f1fb151e6966410bb35d52ab1fe6d5d613fce91ab"
102
+ }
103
+ }
104
+ }
105
+ }
106
+ }
@@ -0,0 +1,6 @@
1
+ import type { Platform } from './platform.ts';
2
+ export declare function cacheRoot(env?: NodeJS.ProcessEnv, home?: string): string;
3
+ export declare function cachedPath(root: string, tool: string, version: string, platform: Platform, executable: string): string;
4
+ export declare function makeWorkDir(root: string): Promise<string>;
5
+ export declare function installExecutable(source: string, destination: string): Promise<void>;
6
+ export declare function removeWorkDir(dir: string): Promise<void>;
@@ -0,0 +1,36 @@
1
+ import { randomBytes } from 'node:crypto';
2
+ import { chmod, mkdir, rename, rm } from 'node:fs/promises';
3
+ import { homedir } from 'node:os';
4
+ import path from 'node:path';
5
+ // `$SEQUEL_CACHE_DIR`, else `$XDG_CACHE_HOME/sequel`, else `~/.cache/sequel`.
6
+ export function cacheRoot(env = process.env, home = homedir()) {
7
+ if (env.SEQUEL_CACHE_DIR)
8
+ return path.resolve(env.SEQUEL_CACHE_DIR);
9
+ // The XDG spec says a relative XDG_CACHE_HOME is invalid and is to be ignored.
10
+ if (env.XDG_CACHE_HOME && path.isAbsolute(env.XDG_CACHE_HOME)) {
11
+ return path.join(env.XDG_CACHE_HOME, 'sequel');
12
+ }
13
+ return path.join(home, '.cache', 'sequel');
14
+ }
15
+ // Where a verified executable lives: keyed by tool, version and platform.
16
+ export function cachedPath(root, tool, version, platform, executable) {
17
+ return path.join(root, tool, version, platform, executable);
18
+ }
19
+ // A fresh working folder inside the cache, on the same filesystem as the executables, so a
20
+ // finished file can be renamed into place. The caller removes it.
21
+ export async function makeWorkDir(root) {
22
+ const dir = path.join(root, 'tmp', `${process.pid}-${randomBytes(6).toString('hex')}`);
23
+ await mkdir(dir, { recursive: true });
24
+ return dir;
25
+ }
26
+ // Makes `source` executable and renames it to `destination`. The rename is atomic, so a
27
+ // concurrent run or an interrupted one never sees a partial file at `destination`, and two
28
+ // runs installing the same verified file at once both succeed.
29
+ export async function installExecutable(source, destination) {
30
+ await chmod(source, 0o755);
31
+ await mkdir(path.dirname(destination), { recursive: true });
32
+ await rename(source, destination);
33
+ }
34
+ export async function removeWorkDir(dir) {
35
+ await rm(dir, { recursive: true, force: true });
36
+ }
@@ -0,0 +1,10 @@
1
+ import { type Manifest } from './manifest.ts';
2
+ import { type Platform } from './platform.ts';
3
+ export type EnsureBinaryOptions = {
4
+ manifest?: Manifest;
5
+ platform?: Platform;
6
+ cacheDir?: string;
7
+ fetch?: typeof globalThis.fetch;
8
+ log?: (message: string) => void;
9
+ };
10
+ export declare function ensureBinary(tool: string, options?: EnsureBinaryOptions): Promise<string>;
@@ -0,0 +1,85 @@
1
+ import { createWriteStream, existsSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { Readable } from 'node:stream';
4
+ import { pipeline } from 'node:stream/promises';
5
+ import { SequelError } from '../errors.js';
6
+ import { cachedPath, cacheRoot, installExecutable, makeWorkDir, removeWorkDir } from './cache.js';
7
+ import { loadManifest, manifestEntry } from './manifest.js';
8
+ import { currentPlatform } from './platform.js';
9
+ import { unpack } from './unpack.js';
10
+ import { sha256File, verifySha256 } from './verify.js';
11
+ const DOWNLOAD_TIMEOUT_MS = 10 * 60_000;
12
+ // Executables verified by this process, keyed by path and expected hash. Each process checks
13
+ // a cached binary's sha256 once, before its first use, and shares the check between callers.
14
+ const verified = new Map();
15
+ // Returns the path of a pinned tool's verified executable, fetching it into the cache on
16
+ // first use: from the mirror, then upstream.
17
+ export function ensureBinary(tool, options = {}) {
18
+ const manifest = options.manifest ?? loadManifest();
19
+ const platform = options.platform ?? currentPlatform();
20
+ const root = options.cacheDir ?? cacheRoot();
21
+ const { version, executable, entry } = manifestEntry(manifest, tool, platform);
22
+ const destination = cachedPath(root, tool, version, platform, executable);
23
+ const key = `${destination}\0${entry.executableSha256}`;
24
+ let pending = verified.get(key);
25
+ if (pending === undefined) {
26
+ pending = prepare({
27
+ label: `${tool} ${version} (${platform})`,
28
+ entry,
29
+ root,
30
+ destination,
31
+ fetch: options.fetch ?? globalThis.fetch,
32
+ log: options.log ?? ((message) => process.stderr.write(`${message}\n`)),
33
+ });
34
+ verified.set(key, pending);
35
+ // A failure isn't remembered, so a later call in the same process tries again.
36
+ pending.catch(() => verified.delete(key));
37
+ }
38
+ return pending;
39
+ }
40
+ async function prepare(job) {
41
+ const { label, entry, destination } = job;
42
+ if (existsSync(destination)) {
43
+ const actual = await sha256File(destination);
44
+ if (actual === entry.executableSha256)
45
+ return destination;
46
+ throw new SequelError(`The cached ${label} at ${destination} failed its checksum: expected sha256 ${entry.executableSha256}, got ${actual}. It changed after it was verified, so it was not run. Delete ${path.dirname(destination)} and rerun to fetch it again.`);
47
+ }
48
+ job.log(`Fetching ${label}…`);
49
+ const workDir = await makeWorkDir(job.root);
50
+ try {
51
+ const asset = await download(job, workDir);
52
+ const unpacked = await unpack(asset, entry, workDir);
53
+ await verifySha256(unpacked, entry.executableSha256, `The executable in ${entry.asset}`);
54
+ await installExecutable(unpacked, destination);
55
+ }
56
+ finally {
57
+ await removeWorkDir(workDir);
58
+ }
59
+ return destination;
60
+ }
61
+ // Downloads the asset and verifies it, trying the mirror first and then upstream. A source
62
+ // that fails, or serves bytes with the wrong checksum, is passed over for the next.
63
+ async function download(job, workDir) {
64
+ const { entry } = job;
65
+ const file = path.join(workDir, 'asset');
66
+ const failures = [];
67
+ for (const [source, url] of [
68
+ ['mirror', entry.mirror],
69
+ ['upstream', entry.upstream],
70
+ ]) {
71
+ try {
72
+ const response = await job.fetch(url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
73
+ if (!response.ok || response.body === null) {
74
+ throw new Error(`HTTP ${response.status}`);
75
+ }
76
+ await pipeline(Readable.fromWeb(response.body), createWriteStream(file));
77
+ await verifySha256(file, entry.assetSha256, entry.asset);
78
+ return file;
79
+ }
80
+ catch (error) {
81
+ failures.push(` ${source} ${url}: ${error.message}`);
82
+ }
83
+ }
84
+ throw new SequelError(`Could not fetch ${job.label}:\n${failures.join('\n')}\nCheck the network connection and rerun.`);
85
+ }
@@ -0,0 +1,30 @@
1
+ import { type Platform } from './platform.ts';
2
+ export type Archive = 'none' | 'tar.gz' | 'gz';
3
+ export type PlatformEntry = {
4
+ platform: string;
5
+ asset: string;
6
+ archive: Archive;
7
+ member?: string;
8
+ upstream: string;
9
+ mirror: string;
10
+ assetSha256: string;
11
+ executableSha256: string;
12
+ };
13
+ export type ToolEntry = {
14
+ version: string;
15
+ executable: string;
16
+ platforms: Record<Platform, PlatformEntry>;
17
+ };
18
+ export type Manifest = {
19
+ tools: Record<string, ToolEntry>;
20
+ };
21
+ export declare const MANIFEST_FILE: string;
22
+ export declare const MIRROR_PREFIX = "https://github.com/Bockit/sequel/releases/download/";
23
+ export declare function loadManifest(file?: string): Manifest;
24
+ export declare function parseManifest(json: unknown, file?: string): Manifest;
25
+ export declare function manifestEntry(manifest: Manifest, tool: string, platform: Platform): {
26
+ version: string;
27
+ executable: string;
28
+ entry: PlatformEntry;
29
+ };
30
+ export declare function mirrorTag(entry: PlatformEntry): string | undefined;
@@ -0,0 +1,112 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { SequelError } from '../errors.js';
5
+ import { PLATFORMS } from './platform.js';
6
+ export const MANIFEST_FILE = fileURLToPath(new URL('../../binaries.json', import.meta.url));
7
+ export const MIRROR_PREFIX = 'https://github.com/Bockit/sequel/releases/download/';
8
+ const SHA256 = /^[0-9a-f]{64}$/;
9
+ const ARCHIVES = ['none', 'tar.gz', 'gz'];
10
+ export function loadManifest(file = MANIFEST_FILE) {
11
+ let json;
12
+ try {
13
+ json = JSON.parse(readFileSync(file, 'utf8'));
14
+ }
15
+ catch (error) {
16
+ throw new SequelError(`${file} could not be read: ${error.message}`);
17
+ }
18
+ return parseManifest(json, file);
19
+ }
20
+ // Checks the manifest's shape, so a bad edit fails on load rather than mid-download.
21
+ export function parseManifest(json, file = 'binaries.json') {
22
+ const fail = (where, problem) => {
23
+ throw new SequelError(where ? `${file}: \`${where}\` ${problem}` : `${file} ${problem}`);
24
+ };
25
+ const tools = object(object(json, '', fail).tools, 'tools', fail);
26
+ for (const [name, toolValue] of Object.entries(tools)) {
27
+ const tool = object(toolValue, `tools.${name}`, fail);
28
+ for (const key of ['version', 'executable']) {
29
+ if (typeof tool[key] !== 'string' || tool[key] === '') {
30
+ fail(`tools.${name}.${key}`, 'must be a non-empty string.');
31
+ }
32
+ }
33
+ if (tool.executable.includes('/')) {
34
+ fail(`tools.${name}.executable`, 'must be a file name, not a path.');
35
+ }
36
+ const platforms = object(tool.platforms, `tools.${name}.platforms`, fail);
37
+ const keys = Object.keys(platforms).sort();
38
+ if (keys.join() !== [...PLATFORMS].sort().join()) {
39
+ fail(`tools.${name}.platforms`, `must have exactly ${PLATFORMS.join(', ')}; it has ${keys.join(', ') || 'none'}.`);
40
+ }
41
+ for (const platform of PLATFORMS) {
42
+ checkEntry(platforms[platform], `tools.${name}.platforms.${platform}`, fail);
43
+ }
44
+ }
45
+ return json;
46
+ }
47
+ // The manifest entry for one tool on one platform.
48
+ export function manifestEntry(manifest, tool, platform) {
49
+ const toolEntry = manifest.tools[tool];
50
+ if (toolEntry === undefined) {
51
+ throw new SequelError(`binaries.json has no entry for ${tool}.`);
52
+ }
53
+ return {
54
+ version: toolEntry.version,
55
+ executable: toolEntry.executable,
56
+ entry: toolEntry.platforms[platform],
57
+ };
58
+ }
59
+ // The `Bockit/sequel` release tag a mirror URL points into, or undefined if it isn't one.
60
+ export function mirrorTag(entry) {
61
+ const suffix = `/${entry.asset}`;
62
+ if (!entry.mirror.startsWith(MIRROR_PREFIX) || !entry.mirror.endsWith(suffix))
63
+ return undefined;
64
+ const tag = entry.mirror.slice(MIRROR_PREFIX.length, -suffix.length);
65
+ return /^[A-Za-z0-9._-]+$/.test(tag) ? tag : undefined;
66
+ }
67
+ function object(value, where, fail) {
68
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
69
+ fail(where, 'must be an object.');
70
+ }
71
+ return value;
72
+ }
73
+ function checkEntry(value, where, fail) {
74
+ const entry = object(value, where, fail);
75
+ for (const key of ['platform', 'asset', 'upstream', 'mirror']) {
76
+ if (typeof entry[key] !== 'string' || entry[key] === '') {
77
+ fail(`${where}.${key}`, 'must be a non-empty string.');
78
+ }
79
+ }
80
+ for (const key of ['assetSha256', 'executableSha256']) {
81
+ if (typeof entry[key] !== 'string' || !SHA256.test(entry[key])) {
82
+ fail(`${where}.${key}`, 'must be a sha256: 64 lower-case hex digits.');
83
+ }
84
+ }
85
+ if (!ARCHIVES.includes(entry.archive)) {
86
+ fail(`${where}.archive`, `must be one of ${ARCHIVES.join(', ')}.`);
87
+ }
88
+ if (entry.asset.includes('/')) {
89
+ fail(`${where}.asset`, 'must be a file name, not a path.');
90
+ }
91
+ if (entry.archive === 'tar.gz') {
92
+ const member = entry.member;
93
+ if (typeof member !== 'string' || member === '') {
94
+ fail(`${where}.member`, 'must name the executable inside the tar.gz.');
95
+ }
96
+ if (path.isAbsolute(member) || member.split('/').includes('..')) {
97
+ fail(`${where}.member`, 'must be a relative path inside the archive.');
98
+ }
99
+ }
100
+ else if (entry.member !== undefined) {
101
+ fail(`${where}.member`, 'is only for tar.gz assets.');
102
+ }
103
+ if (entry.archive === 'none' && entry.assetSha256 !== entry.executableSha256) {
104
+ fail(where, 'is a bare executable, so its two sha256s must be the same.');
105
+ }
106
+ if (!entry.upstream.startsWith('https://')) {
107
+ fail(`${where}.upstream`, 'must be an https URL.');
108
+ }
109
+ if (mirrorTag(entry) === undefined) {
110
+ fail(`${where}.mirror`, `must be ${MIRROR_PREFIX}<tag>/${entry.asset}.`);
111
+ }
112
+ }