@molecule/api-bonds-default-express 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +111 -24
- package/README.md +85 -2
- package/dist/migrate.d.ts +30 -9
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +37 -9
- package/dist/setup.d.ts +37 -0
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +46 -0
- package/package.json +58 -41
package/LICENSE
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
Apache License
|
|
2
3
|
Version 2.0, January 2004
|
|
3
4
|
http://www.apache.org/licenses/
|
|
@@ -34,21 +35,33 @@
|
|
|
34
35
|
|
|
35
36
|
"Work" shall mean the work of authorship, whether in Source or
|
|
36
37
|
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
38
40
|
|
|
39
41
|
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
42
|
form, that is based on (or derived from) the Work and for which the
|
|
41
43
|
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
-
represent, as a whole, an original work of authorship.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
49
62
|
|
|
50
63
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
51
|
-
on behalf of whom a Contribution has been received by
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
52
65
|
subsequently incorporated within the Work.
|
|
53
66
|
|
|
54
67
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
@@ -61,8 +74,18 @@
|
|
|
61
74
|
3. Grant of Patent License. Subject to the terms and conditions of
|
|
62
75
|
this License, each Contributor hereby grants to You a perpetual,
|
|
63
76
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
64
|
-
|
|
65
|
-
and otherwise transfer the Work
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
66
89
|
|
|
67
90
|
4. Redistribution. You may reproduce and distribute copies of the
|
|
68
91
|
Work or Derivative Works thereof in any medium, with or without
|
|
@@ -84,23 +107,87 @@
|
|
|
84
107
|
(d) If the Work includes a "NOTICE" text file as part of its
|
|
85
108
|
distribution, then any Derivative Works that You distribute must
|
|
86
109
|
include a readable copy of the attribution notices contained
|
|
87
|
-
within such NOTICE file
|
|
88
|
-
|
|
89
|
-
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
90
138
|
|
|
91
139
|
6. Trademarks. This License does not grant permission to use the trade
|
|
92
|
-
names, trademarks, service marks, or product names of the Licensor
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
93
143
|
|
|
94
144
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
95
|
-
agreed to in writing, Licensor provides the Work
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
104
191
|
|
|
105
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
106
193
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-10-06T19:54:54.472Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-bonds-default-express
|
|
@@ -79,7 +79,8 @@ const billingRouter = createBillingRouter<AppLimits>({
|
|
|
79
79
|
## Installation
|
|
80
80
|
|
|
81
81
|
```bash
|
|
82
|
-
npm install @molecule/api-bonds-default-express @molecule/api-ai-anthropic @molecule/api-ai-embeddings @molecule/api-ai-embeddings-openai @molecule/api-ai-openai @molecule/api-ai-speech @molecule/api-ai-speech-openai @molecule/api-ai-vector-store @molecule/api-ai-vector-store-pgvector @molecule/api-analytics @molecule/api-audit @molecule/api-audit-database @molecule/api-bond @molecule/api-cache @molecule/api-cache-memory @molecule/api-cache-redis @molecule/api-config @molecule/api-config-env @molecule/api-cron @molecule/api-cron-node-cron @molecule/api-database @molecule/api-database-postgresql @molecule/api-emails @molecule/api-emails-capture @molecule/api-emails-mailgun @molecule/api-encryption @molecule/api-encryption-aes @molecule/api-entitlements @molecule/api-error-tracking @molecule/api-error-tracking-console @molecule/api-error-tracking-sentry @molecule/api-geolocation @molecule/api-geolocation-google @molecule/api-geolocation-mapbox @molecule/api-geolocation-nominatim @molecule/api-http @molecule/api-http-fetch @molecule/api-i18n @molecule/api-image @molecule/api-image-sharp @molecule/api-import-export @molecule/api-import-export-csv @molecule/api-jwt @molecule/api-jwt-jsonwebtoken @molecule/api-logger @molecule/api-media-streaming @molecule/api-media-streaming-hls @molecule/api-middleware-body-parser @molecule/api-middleware-body-parser-express @molecule/api-middleware-cookie-parser @molecule/api-middleware-cookie-parser-express @molecule/api-middleware-cors @molecule/api-middleware-cors-express @molecule/api-middleware-validation @molecule/api-notifications-webhook @molecule/api-password @molecule/api-password-bcrypt @molecule/api-payments @molecule/api-payments-stripe @molecule/api-pdf @molecule/api-pdf-pdfkit @molecule/api-permissions @molecule/api-permissions-custom @molecule/api-push-capture @molecule/api-push-notifications @molecule/api-push-notifications-web-push @molecule/api-queue @molecule/api-queue-memory @molecule/api-queue-redis @molecule/api-rate-limit @molecule/api-rate-limit-memory @molecule/api-realtime @molecule/api-realtime-socketio @molecule/api-realtime-sse @molecule/api-realtime-ws @molecule/api-reporting @molecule/api-reporting-database @molecule/api-resource @molecule/api-resource-device @molecule/api-resource-payment @molecule/api-resource-user @molecule/api-search @molecule/api-search-meilisearch @molecule/api-search-postgres @molecule/api-secrets @molecule/api-secrets-env @molecule/api-two-factor @molecule/api-two-factor-otplib @molecule/api-uploads @molecule/api-uploads-filesystem @molecule/api-uploads-s3 @molecule/api-webhook @molecule/api-webhook-http @molecule/api-workflow @molecule/api-workflow-database
|
|
82
|
+
npm install @molecule/api-bonds-default-express @molecule/api-ai-anthropic @molecule/api-ai-embeddings @molecule/api-ai-embeddings-openai @molecule/api-ai-openai @molecule/api-ai-speech @molecule/api-ai-speech-openai @molecule/api-ai-vector-store @molecule/api-ai-vector-store-pgvector @molecule/api-analytics @molecule/api-audit @molecule/api-audit-database @molecule/api-bond @molecule/api-cache @molecule/api-cache-memory @molecule/api-cache-redis @molecule/api-config @molecule/api-config-env @molecule/api-cron @molecule/api-cron-node-cron @molecule/api-database @molecule/api-database-pglite @molecule/api-database-postgresql @molecule/api-emails @molecule/api-emails-capture @molecule/api-emails-mailgun @molecule/api-encryption @molecule/api-encryption-aes @molecule/api-entitlements @molecule/api-error-tracking @molecule/api-error-tracking-console @molecule/api-error-tracking-sentry @molecule/api-geolocation @molecule/api-geolocation-google @molecule/api-geolocation-mapbox @molecule/api-geolocation-nominatim @molecule/api-http @molecule/api-http-fetch @molecule/api-i18n @molecule/api-image @molecule/api-image-sharp @molecule/api-import-export @molecule/api-import-export-csv @molecule/api-jwt @molecule/api-jwt-jsonwebtoken @molecule/api-logger @molecule/api-media-streaming @molecule/api-media-streaming-hls @molecule/api-middleware-body-parser @molecule/api-middleware-body-parser-express @molecule/api-middleware-cookie-parser @molecule/api-middleware-cookie-parser-express @molecule/api-middleware-cors @molecule/api-middleware-cors-express @molecule/api-middleware-validation @molecule/api-notifications-webhook @molecule/api-password @molecule/api-password-bcrypt @molecule/api-payments @molecule/api-payments-capture @molecule/api-payments-stripe @molecule/api-pdf @molecule/api-pdf-pdfkit @molecule/api-permissions @molecule/api-permissions-custom @molecule/api-push-capture @molecule/api-push-notifications @molecule/api-push-notifications-web-push @molecule/api-queue @molecule/api-queue-memory @molecule/api-queue-redis @molecule/api-rate-limit @molecule/api-rate-limit-memory @molecule/api-realtime @molecule/api-realtime-socketio @molecule/api-realtime-sse @molecule/api-realtime-ws @molecule/api-reporting @molecule/api-reporting-database @molecule/api-resource @molecule/api-resource-device @molecule/api-resource-payment @molecule/api-resource-user @molecule/api-search @molecule/api-search-meilisearch @molecule/api-search-postgres @molecule/api-secrets @molecule/api-secrets-env @molecule/api-server-default-express @molecule/api-two-factor @molecule/api-two-factor-otplib @molecule/api-uploads @molecule/api-uploads-filesystem @molecule/api-uploads-s3 @molecule/api-webhook @molecule/api-webhook-http @molecule/api-workflow @molecule/api-workflow-database express zod
|
|
83
|
+
npm install -D @types/express
|
|
83
84
|
```
|
|
84
85
|
|
|
85
86
|
## API
|
|
@@ -123,6 +124,30 @@ function createMigrator(migrationsDir: string): () => Promise<void>
|
|
|
123
124
|
|
|
124
125
|
**Returns:** A no-arg `runMigrations()` that creates the database (if missing) and applies every migration file in lexical order.
|
|
125
126
|
|
|
127
|
+
#### `createMigratorPglite(migrationsDir, extraDirs)`
|
|
128
|
+
|
|
129
|
+
Returns a `runMigrations()` that applies every `*.sql` file in
|
|
130
|
+
`migrationsDir`, in lexical order, to `@molecule/api-database-pglite`'s
|
|
131
|
+
default pool — the pool `setupDatabasePglite()` bonds, so the schema
|
|
132
|
+
lands in the database the app queries (an in-memory PGlite database exists
|
|
133
|
+
only inside that one instance). Same files and same "already exists is a
|
|
134
|
+
warning, anything else fails the boot" contract as `createMigrator`; there
|
|
135
|
+
is no `CREATE DATABASE` step.
|
|
136
|
+
|
|
137
|
+
Further directories run after it, each in its own lexical order — e.g. a
|
|
138
|
+
scaffolded app's `__setup__/` (resource-package DDL such as `payments.sql`)
|
|
139
|
+
after `migrations/`, the order the scaffolded Postgres runner uses. A
|
|
140
|
+
directory that does not exist counts as empty.
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
function createMigratorPglite(migrationsDir: string, extraDirs?: string[]): () => Promise<void>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
- `migrationsDir` — Absolute path to the app's `migrations/` directory.
|
|
147
|
+
- `extraDirs` — Absolute paths of further `*.sql` directories to apply after it, in order.
|
|
148
|
+
|
|
149
|
+
**Returns:** A no-arg migration runner.
|
|
150
|
+
|
|
126
151
|
#### `getParamId(req, name?)`
|
|
127
152
|
|
|
128
153
|
Read a route param as a string, defending against the Express
|
|
@@ -418,6 +443,27 @@ Wires `@molecule/api-cron-node-cron` to `@molecule/api-cron`.
|
|
|
418
443
|
function setupCronNodeCron(): Promise<void>
|
|
419
444
|
```
|
|
420
445
|
|
|
446
|
+
#### `setupDatabasePglite()`
|
|
447
|
+
|
|
448
|
+
Wires `@molecule/api-database-pglite` (real Postgres compiled to
|
|
449
|
+
WebAssembly, in-process) to `@molecule/api-database` — the database half of
|
|
450
|
+
the zero-server "browser" profile. Same SQL, placeholders and error codes as
|
|
451
|
+
the postgresql bond, so app code and migrations do not change.
|
|
452
|
+
|
|
453
|
+
Binds the pglite package's DEFAULT pool, whose data directory comes from
|
|
454
|
+
`PGLITE_DATA_DIR` (`memory://`, `idb://<name>`, or a filesystem path; the
|
|
455
|
+
bond's Node default is `./data/pglite`). Run migrations with
|
|
456
|
+
{@link createMigratorPglite}, which targets the same default pool — an
|
|
457
|
+
in-memory database exists only inside that one instance, so the migrator
|
|
458
|
+
and the app must share it.
|
|
459
|
+
|
|
460
|
+
`@molecule/api-database-pglite` is an OPTIONAL peer, imported lazily, so a
|
|
461
|
+
postgres-only app never needs it installed.
|
|
462
|
+
|
|
463
|
+
```typescript
|
|
464
|
+
function setupDatabasePglite(): Promise<void>
|
|
465
|
+
```
|
|
466
|
+
|
|
421
467
|
#### `setupDatabasePostgresql()`
|
|
422
468
|
|
|
423
469
|
Wires `@molecule/api-database-postgresql` to `@molecule/api-database`.
|
|
@@ -426,6 +472,18 @@ Wires `@molecule/api-database-postgresql` to `@molecule/api-database`.
|
|
|
426
472
|
function setupDatabasePostgresql(): void
|
|
427
473
|
```
|
|
428
474
|
|
|
475
|
+
#### `setupEmailsCapture()`
|
|
476
|
+
|
|
477
|
+
Wires `@molecule/api-emails-capture` to `@molecule/api-emails`
|
|
478
|
+
unconditionally — every message is captured in memory instead of sent.
|
|
479
|
+
Unlike {@link setupEmailsMailgun}'s development fallback, this does not
|
|
480
|
+
depend on `NODE_ENV` or on which env vars are missing, so a profile that
|
|
481
|
+
selects it always gets it.
|
|
482
|
+
|
|
483
|
+
```typescript
|
|
484
|
+
function setupEmailsCapture(): void
|
|
485
|
+
```
|
|
486
|
+
|
|
429
487
|
#### `setupEmailsMailgun()`
|
|
430
488
|
|
|
431
489
|
Wires `@molecule/api-emails-mailgun` to `@molecule/api-emails`.
|
|
@@ -561,6 +619,22 @@ Wires `@molecule/api-password-bcrypt` to `@molecule/api-password`.
|
|
|
561
619
|
function setupPasswordBcrypt(): void
|
|
562
620
|
```
|
|
563
621
|
|
|
622
|
+
#### `setupPaymentsCapture()`
|
|
623
|
+
|
|
624
|
+
Registers `@molecule/api-payments-capture` (a payments vendor simulated in
|
|
625
|
+
memory: checkouts complete at once, signed local webhooks) under the name
|
|
626
|
+
`'stripe'` — the name {@link setupPaymentsStripe} uses — so the billing
|
|
627
|
+
router, the `/users/:id/verify-payment/stripe` and
|
|
628
|
+
`/users/payment-notification/stripe` routes, and the plan catalogue's
|
|
629
|
+
`platformKey` work unchanged. Grants plans without taking money: bond it in
|
|
630
|
+
a development / browser profile only, never in production.
|
|
631
|
+
|
|
632
|
+
`@molecule/api-payments-capture` is an OPTIONAL peer, imported lazily.
|
|
633
|
+
|
|
634
|
+
```typescript
|
|
635
|
+
function setupPaymentsCapture(): Promise<void>
|
|
636
|
+
```
|
|
637
|
+
|
|
564
638
|
#### `setupPaymentsStripe()`
|
|
565
639
|
|
|
566
640
|
Registers `@molecule/api-payments-stripe` as a named `'stripe'` payments provider.
|
|
@@ -834,6 +908,7 @@ Peer dependencies:
|
|
|
834
908
|
- `@molecule/api-cron` ^1.0.1
|
|
835
909
|
- `@molecule/api-cron-node-cron` ^1.0.1
|
|
836
910
|
- `@molecule/api-database` ^1.0.1
|
|
911
|
+
- `@molecule/api-database-pglite` ^1.0.0
|
|
837
912
|
- `@molecule/api-database-postgresql` ^1.0.1
|
|
838
913
|
- `@molecule/api-emails` ^1.0.1
|
|
839
914
|
- `@molecule/api-emails-capture` ^1.0.1
|
|
@@ -871,6 +946,7 @@ Peer dependencies:
|
|
|
871
946
|
- `@molecule/api-password` ^1.0.1
|
|
872
947
|
- `@molecule/api-password-bcrypt` ^1.0.1
|
|
873
948
|
- `@molecule/api-payments` ^1.0.1
|
|
949
|
+
- `@molecule/api-payments-capture` ^1.0.0
|
|
874
950
|
- `@molecule/api-payments-stripe` ^1.0.1
|
|
875
951
|
- `@molecule/api-pdf` ^1.0.1
|
|
876
952
|
- `@molecule/api-pdf-pdfkit` ^1.0.1
|
|
@@ -899,6 +975,7 @@ Peer dependencies:
|
|
|
899
975
|
- `@molecule/api-search-postgres` ^1.0.1
|
|
900
976
|
- `@molecule/api-secrets` ^1.0.1
|
|
901
977
|
- `@molecule/api-secrets-env` ^1.0.1
|
|
978
|
+
- `@molecule/api-server-default-express` ^1.0.1
|
|
902
979
|
- `@molecule/api-two-factor` ^1.0.1
|
|
903
980
|
- `@molecule/api-two-factor-otplib` ^1.0.1
|
|
904
981
|
- `@molecule/api-uploads` ^1.0.1
|
|
@@ -908,6 +985,7 @@ Peer dependencies:
|
|
|
908
985
|
- `@molecule/api-webhook-http` ^1.0.1
|
|
909
986
|
- `@molecule/api-workflow` ^1.0.1
|
|
910
987
|
- `@molecule/api-workflow-database` ^1.0.1
|
|
988
|
+
- `express` ^4.0.0 || ^5.0.0
|
|
911
989
|
|
|
912
990
|
### Runtime Dependencies
|
|
913
991
|
|
|
@@ -931,6 +1009,7 @@ Peer dependencies:
|
|
|
931
1009
|
- `@molecule/api-cron`
|
|
932
1010
|
- `@molecule/api-cron-node-cron`
|
|
933
1011
|
- `@molecule/api-database`
|
|
1012
|
+
- `@molecule/api-database-pglite`
|
|
934
1013
|
- `@molecule/api-database-postgresql`
|
|
935
1014
|
- `@molecule/api-emails`
|
|
936
1015
|
- `@molecule/api-emails-capture`
|
|
@@ -968,6 +1047,7 @@ Peer dependencies:
|
|
|
968
1047
|
- `@molecule/api-password`
|
|
969
1048
|
- `@molecule/api-password-bcrypt`
|
|
970
1049
|
- `@molecule/api-payments`
|
|
1050
|
+
- `@molecule/api-payments-capture`
|
|
971
1051
|
- `@molecule/api-payments-stripe`
|
|
972
1052
|
- `@molecule/api-pdf`
|
|
973
1053
|
- `@molecule/api-pdf-pdfkit`
|
|
@@ -996,6 +1076,7 @@ Peer dependencies:
|
|
|
996
1076
|
- `@molecule/api-search-postgres`
|
|
997
1077
|
- `@molecule/api-secrets`
|
|
998
1078
|
- `@molecule/api-secrets-env`
|
|
1079
|
+
- `@molecule/api-server-default-express`
|
|
999
1080
|
- `@molecule/api-two-factor`
|
|
1000
1081
|
- `@molecule/api-two-factor-otplib`
|
|
1001
1082
|
- `@molecule/api-uploads`
|
|
@@ -1005,6 +1086,8 @@ Peer dependencies:
|
|
|
1005
1086
|
- `@molecule/api-webhook-http`
|
|
1006
1087
|
- `@molecule/api-workflow`
|
|
1007
1088
|
- `@molecule/api-workflow-database`
|
|
1089
|
+
- `express`
|
|
1090
|
+
- `zod`
|
|
1008
1091
|
|
|
1009
1092
|
- **Development falls back to zero-credential providers; production never
|
|
1010
1093
|
does.** When `NODE_ENV !== 'production'` and a provider's required env
|
package/dist/migrate.d.ts
CHANGED
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* bond.
|
|
2
|
+
* Migration runner factories.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* peer-depends on. App `scripts/migrate.ts` files keep importing
|
|
4
|
+
* `createMigrator` (Postgres) is re-exported from the PostgreSQL bond: it is
|
|
5
|
+
* Postgres-specific bootstrapping plumbing (`CREATE DATABASE`, the
|
|
6
|
+
* `pg_database` catalog probe, raw `pg.Client` connections), and this
|
|
7
|
+
* bond-setup package must not import the concrete `pg` driver directly — it
|
|
8
|
+
* reaches Postgres only through the `@molecule/api-database-postgresql` bond
|
|
9
|
+
* it already peer-depends on. App `scripts/migrate.ts` files keep importing
|
|
12
10
|
* `createMigrator` from here unchanged.
|
|
13
11
|
*
|
|
12
|
+
* `createMigratorPglite` is the same contract for the PGlite bond (the
|
|
13
|
+
* zero-server "browser" profile), loaded lazily because that bond is an
|
|
14
|
+
* optional peer.
|
|
15
|
+
*
|
|
14
16
|
* @module
|
|
15
17
|
*/
|
|
16
18
|
export { createMigrator } from '@molecule/api-database-postgresql';
|
|
19
|
+
/**
|
|
20
|
+
* Returns a `runMigrations()` that applies every `*.sql` file in
|
|
21
|
+
* `migrationsDir`, in lexical order, to `@molecule/api-database-pglite`'s
|
|
22
|
+
* default pool — the pool `setupDatabasePglite()` bonds, so the schema
|
|
23
|
+
* lands in the database the app queries (an in-memory PGlite database exists
|
|
24
|
+
* only inside that one instance). Same files and same "already exists is a
|
|
25
|
+
* warning, anything else fails the boot" contract as `createMigrator`; there
|
|
26
|
+
* is no `CREATE DATABASE` step.
|
|
27
|
+
*
|
|
28
|
+
* Further directories run after it, each in its own lexical order — e.g. a
|
|
29
|
+
* scaffolded app's `__setup__/` (resource-package DDL such as `payments.sql`)
|
|
30
|
+
* after `migrations/`, the order the scaffolded Postgres runner uses. A
|
|
31
|
+
* directory that does not exist counts as empty.
|
|
32
|
+
*
|
|
33
|
+
* @param migrationsDir - Absolute path to the app's `migrations/` directory.
|
|
34
|
+
* @param extraDirs - Absolute paths of further `*.sql` directories to apply after it, in order.
|
|
35
|
+
* @returns A no-arg migration runner.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createMigratorPglite(migrationsDir: string, ...extraDirs: string[]): () => Promise<void>;
|
|
17
38
|
//# sourceMappingURL=migrate.d.ts.map
|
package/dist/migrate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAA;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EACrB,GAAG,SAAS,EAAE,MAAM,EAAE,GACrB,MAAM,OAAO,CAAC,IAAI,CAAC,CAOrB"}
|
package/dist/migrate.js
CHANGED
|
@@ -1,16 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* bond.
|
|
2
|
+
* Migration runner factories.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* peer-depends on. App `scripts/migrate.ts` files keep importing
|
|
4
|
+
* `createMigrator` (Postgres) is re-exported from the PostgreSQL bond: it is
|
|
5
|
+
* Postgres-specific bootstrapping plumbing (`CREATE DATABASE`, the
|
|
6
|
+
* `pg_database` catalog probe, raw `pg.Client` connections), and this
|
|
7
|
+
* bond-setup package must not import the concrete `pg` driver directly — it
|
|
8
|
+
* reaches Postgres only through the `@molecule/api-database-postgresql` bond
|
|
9
|
+
* it already peer-depends on. App `scripts/migrate.ts` files keep importing
|
|
12
10
|
* `createMigrator` from here unchanged.
|
|
13
11
|
*
|
|
12
|
+
* `createMigratorPglite` is the same contract for the PGlite bond (the
|
|
13
|
+
* zero-server "browser" profile), loaded lazily because that bond is an
|
|
14
|
+
* optional peer.
|
|
15
|
+
*
|
|
14
16
|
* @module
|
|
15
17
|
*/
|
|
16
18
|
export { createMigrator } from '@molecule/api-database-postgresql';
|
|
19
|
+
/**
|
|
20
|
+
* Returns a `runMigrations()` that applies every `*.sql` file in
|
|
21
|
+
* `migrationsDir`, in lexical order, to `@molecule/api-database-pglite`'s
|
|
22
|
+
* default pool — the pool `setupDatabasePglite()` bonds, so the schema
|
|
23
|
+
* lands in the database the app queries (an in-memory PGlite database exists
|
|
24
|
+
* only inside that one instance). Same files and same "already exists is a
|
|
25
|
+
* warning, anything else fails the boot" contract as `createMigrator`; there
|
|
26
|
+
* is no `CREATE DATABASE` step.
|
|
27
|
+
*
|
|
28
|
+
* Further directories run after it, each in its own lexical order — e.g. a
|
|
29
|
+
* scaffolded app's `__setup__/` (resource-package DDL such as `payments.sql`)
|
|
30
|
+
* after `migrations/`, the order the scaffolded Postgres runner uses. A
|
|
31
|
+
* directory that does not exist counts as empty.
|
|
32
|
+
*
|
|
33
|
+
* @param migrationsDir - Absolute path to the app's `migrations/` directory.
|
|
34
|
+
* @param extraDirs - Absolute paths of further `*.sql` directories to apply after it, in order.
|
|
35
|
+
* @returns A no-arg migration runner.
|
|
36
|
+
*/
|
|
37
|
+
export function createMigratorPglite(migrationsDir, ...extraDirs) {
|
|
38
|
+
return async function runMigrations() {
|
|
39
|
+
const { createMigrator: createPgliteMigrator } = await import('@molecule/api-database-pglite');
|
|
40
|
+
for (const dir of [migrationsDir, ...extraDirs]) {
|
|
41
|
+
await createPgliteMigrator(dir)();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
package/dist/setup.d.ts
CHANGED
|
@@ -14,6 +14,23 @@
|
|
|
14
14
|
export declare function setupConfigEnv(): void;
|
|
15
15
|
/** Wires `@molecule/api-database-postgresql` to `@molecule/api-database`. */
|
|
16
16
|
export declare function setupDatabasePostgresql(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Wires `@molecule/api-database-pglite` (real Postgres compiled to
|
|
19
|
+
* WebAssembly, in-process) to `@molecule/api-database` — the database half of
|
|
20
|
+
* the zero-server "browser" profile. Same SQL, placeholders and error codes as
|
|
21
|
+
* the postgresql bond, so app code and migrations do not change.
|
|
22
|
+
*
|
|
23
|
+
* Binds the pglite package's DEFAULT pool, whose data directory comes from
|
|
24
|
+
* `PGLITE_DATA_DIR` (`memory://`, `idb://<name>`, or a filesystem path; the
|
|
25
|
+
* bond's Node default is `./data/pglite`). Run migrations with
|
|
26
|
+
* {@link createMigratorPglite}, which targets the same default pool — an
|
|
27
|
+
* in-memory database exists only inside that one instance, so the migrator
|
|
28
|
+
* and the app must share it.
|
|
29
|
+
*
|
|
30
|
+
* `@molecule/api-database-pglite` is an OPTIONAL peer, imported lazily, so a
|
|
31
|
+
* postgres-only app never needs it installed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function setupDatabasePglite(): Promise<void>;
|
|
17
34
|
/** Wires `@molecule/api-jwt-jsonwebtoken` to `@molecule/api-jwt`. */
|
|
18
35
|
export declare function setupJwtJsonwebtoken(): void;
|
|
19
36
|
/** Wires `@molecule/api-middleware-body-parser-express` to `@molecule/api-middleware-body-parser`. */
|
|
@@ -32,8 +49,28 @@ export declare function setupServiceDevice(): void;
|
|
|
32
49
|
export declare function setupTwoFactorOtplib(): void;
|
|
33
50
|
/** Wires `@molecule/api-emails-mailgun` to `@molecule/api-emails`. */
|
|
34
51
|
export declare function setupEmailsMailgun(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Wires `@molecule/api-emails-capture` to `@molecule/api-emails`
|
|
54
|
+
* unconditionally — every message is captured in memory instead of sent.
|
|
55
|
+
* Unlike {@link setupEmailsMailgun}'s development fallback, this does not
|
|
56
|
+
* depend on `NODE_ENV` or on which env vars are missing, so a profile that
|
|
57
|
+
* selects it always gets it.
|
|
58
|
+
*/
|
|
59
|
+
export declare function setupEmailsCapture(): void;
|
|
35
60
|
/** Registers `@molecule/api-payments-stripe` as a named `'stripe'` payments provider. */
|
|
36
61
|
export declare function setupPaymentsStripe(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Registers `@molecule/api-payments-capture` (a payments vendor simulated in
|
|
64
|
+
* memory: checkouts complete at once, signed local webhooks) under the name
|
|
65
|
+
* `'stripe'` — the name {@link setupPaymentsStripe} uses — so the billing
|
|
66
|
+
* router, the `/users/:id/verify-payment/stripe` and
|
|
67
|
+
* `/users/payment-notification/stripe` routes, and the plan catalogue's
|
|
68
|
+
* `platformKey` work unchanged. Grants plans without taking money: bond it in
|
|
69
|
+
* a development / browser profile only, never in production.
|
|
70
|
+
*
|
|
71
|
+
* `@molecule/api-payments-capture` is an OPTIONAL peer, imported lazily.
|
|
72
|
+
*/
|
|
73
|
+
export declare function setupPaymentsCapture(): Promise<void>;
|
|
37
74
|
/** Registers the plan + paymentRecord services from `@molecule/api-resource-payment`. */
|
|
38
75
|
export declare function setupServicePayment(): void;
|
|
39
76
|
/** Wires `@molecule/api-search-meilisearch` to `@molecule/api-search`. */
|
package/dist/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAoEH,kEAAkE;AAClE,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C;AAED,qEAAqE;AACrE,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,sGAAsG;AACtG,wBAAgB,gCAAgC,IAAI,IAAI,CAGvD;AAED,0GAA0G;AAC1G,wBAAgB,kCAAkC,IAAI,IAAI,CAGzD;AAED,wFAAwF;AACxF,wBAAgB,0BAA0B,IAAI,IAAI,CAGjD;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED,oEAAoE;AACpE,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED,4FAA4F;AAC5F,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,sEAAsE;AACtE,wBAAgB,kBAAkB,IAAI,IAAI,CAOzC;AAED,yFAAyF;AACzF,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED,yFAAyF;AACzF,wBAAgB,mBA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,OAAO,CAAC,IAAI,CAAC,CAMtD;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAWrD;AAsBD,6EAA6E;AAC7E,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CASnD;AAED,mFAAmF;AACnF,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAU7D;AAED,qEAAqE;AACrE,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAMtD;AAED,yFAAyF;AACzF,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAMhE;AAED,2EAA2E;AAC3E,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAWzD;AAED,2EAA2E;AAC3E,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAM3D;AAED,gEAAgE;AAChE,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAMpD;AAED,qGAAqG;AACrG,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAG/D;AAED,+EAA+E;AAC/E,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAe5D;AAED,oFAAoF;AACpF,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAM5D;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAM1D"}
|
package/dist/setup.js
CHANGED
|
@@ -73,6 +73,27 @@ export function setupDatabasePostgresql() {
|
|
|
73
73
|
setPool(dbPool);
|
|
74
74
|
setStore(dbStore);
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Wires `@molecule/api-database-pglite` (real Postgres compiled to
|
|
78
|
+
* WebAssembly, in-process) to `@molecule/api-database` — the database half of
|
|
79
|
+
* the zero-server "browser" profile. Same SQL, placeholders and error codes as
|
|
80
|
+
* the postgresql bond, so app code and migrations do not change.
|
|
81
|
+
*
|
|
82
|
+
* Binds the pglite package's DEFAULT pool, whose data directory comes from
|
|
83
|
+
* `PGLITE_DATA_DIR` (`memory://`, `idb://<name>`, or a filesystem path; the
|
|
84
|
+
* bond's Node default is `./data/pglite`). Run migrations with
|
|
85
|
+
* {@link createMigratorPglite}, which targets the same default pool — an
|
|
86
|
+
* in-memory database exists only inside that one instance, so the migrator
|
|
87
|
+
* and the app must share it.
|
|
88
|
+
*
|
|
89
|
+
* `@molecule/api-database-pglite` is an OPTIONAL peer, imported lazily, so a
|
|
90
|
+
* postgres-only app never needs it installed.
|
|
91
|
+
*/
|
|
92
|
+
export async function setupDatabasePglite() {
|
|
93
|
+
const { pool, store } = await import('@molecule/api-database-pglite');
|
|
94
|
+
setPool(pool);
|
|
95
|
+
setStore(store);
|
|
96
|
+
}
|
|
76
97
|
/** Wires `@molecule/api-jwt-jsonwebtoken` to `@molecule/api-jwt`. */
|
|
77
98
|
export function setupJwtJsonwebtoken() {
|
|
78
99
|
setJwt(jwtProvider);
|
|
@@ -117,10 +138,35 @@ export function setupEmailsMailgun() {
|
|
|
117
138
|
}
|
|
118
139
|
setEmails(emailsMailgunProvider);
|
|
119
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Wires `@molecule/api-emails-capture` to `@molecule/api-emails`
|
|
143
|
+
* unconditionally — every message is captured in memory instead of sent.
|
|
144
|
+
* Unlike {@link setupEmailsMailgun}'s development fallback, this does not
|
|
145
|
+
* depend on `NODE_ENV` or on which env vars are missing, so a profile that
|
|
146
|
+
* selects it always gets it.
|
|
147
|
+
*/
|
|
148
|
+
export function setupEmailsCapture() {
|
|
149
|
+
setEmails(emailsCaptureProvider);
|
|
150
|
+
}
|
|
120
151
|
/** Registers `@molecule/api-payments-stripe` as a named `'stripe'` payments provider. */
|
|
121
152
|
export function setupPaymentsStripe() {
|
|
122
153
|
bond('payments', 'stripe', stripePaymentProvider);
|
|
123
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Registers `@molecule/api-payments-capture` (a payments vendor simulated in
|
|
157
|
+
* memory: checkouts complete at once, signed local webhooks) under the name
|
|
158
|
+
* `'stripe'` — the name {@link setupPaymentsStripe} uses — so the billing
|
|
159
|
+
* router, the `/users/:id/verify-payment/stripe` and
|
|
160
|
+
* `/users/payment-notification/stripe` routes, and the plan catalogue's
|
|
161
|
+
* `platformKey` work unchanged. Grants plans without taking money: bond it in
|
|
162
|
+
* a development / browser profile only, never in production.
|
|
163
|
+
*
|
|
164
|
+
* `@molecule/api-payments-capture` is an OPTIONAL peer, imported lazily.
|
|
165
|
+
*/
|
|
166
|
+
export async function setupPaymentsCapture() {
|
|
167
|
+
const { provider } = await import('@molecule/api-payments-capture');
|
|
168
|
+
bond('payments', 'stripe', provider);
|
|
169
|
+
}
|
|
124
170
|
/** Registers the plan + paymentRecord services from `@molecule/api-resource-payment`. */
|
|
125
171
|
export function setupServicePayment() {
|
|
126
172
|
bond('plans', planService);
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-bonds-default-express",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Default API bond setup for Express-based apps. Provides setup functions for the 10 byte-identical bond wirings shared across the molecule fleet — config-env, database-postgresql, jwt-jsonwebtoken, middleware-{body-parser,cookie-parser,cors}-express, password-bcrypt, secrets-env, service-device, two-factor-otplib.",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/api-bonds-default-express",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"zod": "4.4.3"
|
|
8
|
+
},
|
|
6
9
|
"type": "module",
|
|
7
10
|
"main": "dist/index.js",
|
|
8
11
|
"types": "dist/index.d.ts",
|
|
@@ -34,37 +37,38 @@
|
|
|
34
37
|
"directory": "packages/api/infrastructure/bonds-default-express"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {
|
|
37
|
-
"@molecule/api-ai-anthropic": "1.
|
|
40
|
+
"@molecule/api-ai-anthropic": "1.3.2",
|
|
38
41
|
"@molecule/api-ai-embeddings": "1.0.2",
|
|
39
|
-
"@molecule/api-ai-embeddings-openai": "1.0.
|
|
40
|
-
"@molecule/api-ai-openai": "1.
|
|
41
|
-
"@molecule/api-ai-speech": "1.0
|
|
42
|
-
"@molecule/api-ai-speech-openai": "1.0.
|
|
42
|
+
"@molecule/api-ai-embeddings-openai": "1.0.4",
|
|
43
|
+
"@molecule/api-ai-openai": "1.4.3",
|
|
44
|
+
"@molecule/api-ai-speech": "1.1.0",
|
|
45
|
+
"@molecule/api-ai-speech-openai": "1.0.3",
|
|
43
46
|
"@molecule/api-ai-vector-store": "1.0.2",
|
|
44
47
|
"@molecule/api-ai-vector-store-pgvector": "1.0.2",
|
|
45
|
-
"@molecule/api-analytics": "1.0
|
|
46
|
-
"@molecule/api-audit": "1.0.
|
|
48
|
+
"@molecule/api-analytics": "1.1.0",
|
|
49
|
+
"@molecule/api-audit": "1.0.3",
|
|
47
50
|
"@molecule/api-audit-database": "1.0.2",
|
|
48
51
|
"@molecule/api-bond": "1.0.2",
|
|
49
52
|
"@molecule/api-cache": "1.0.2",
|
|
50
|
-
"@molecule/api-cache-memory": "1.0.
|
|
51
|
-
"@molecule/api-cache-redis": "1.0.
|
|
53
|
+
"@molecule/api-cache-memory": "1.0.3",
|
|
54
|
+
"@molecule/api-cache-redis": "1.0.3",
|
|
52
55
|
"@molecule/api-config": "1.0.2",
|
|
53
56
|
"@molecule/api-config-env": "1.0.2",
|
|
54
|
-
"@molecule/api-cron": "1.0.
|
|
57
|
+
"@molecule/api-cron": "1.0.3",
|
|
55
58
|
"@molecule/api-cron-node-cron": "1.0.2",
|
|
56
59
|
"@molecule/api-database": "1.0.2",
|
|
57
|
-
"@molecule/api-database-
|
|
60
|
+
"@molecule/api-database-pglite": "1.0.0",
|
|
61
|
+
"@molecule/api-database-postgresql": "1.0.5",
|
|
58
62
|
"@molecule/api-emails": "1.0.2",
|
|
59
63
|
"@molecule/api-emails-capture": "1.0.3",
|
|
60
|
-
"@molecule/api-emails-mailgun": "1.0.
|
|
61
|
-
"@molecule/api-encryption": "1.
|
|
62
|
-
"@molecule/api-encryption-aes": "1.
|
|
63
|
-
"@molecule/api-entitlements": "1.0
|
|
64
|
-
"@molecule/api-error-tracking": "1.0.
|
|
64
|
+
"@molecule/api-emails-mailgun": "1.0.7",
|
|
65
|
+
"@molecule/api-encryption": "1.1.1",
|
|
66
|
+
"@molecule/api-encryption-aes": "1.1.1",
|
|
67
|
+
"@molecule/api-entitlements": "1.1.0",
|
|
68
|
+
"@molecule/api-error-tracking": "1.0.3",
|
|
65
69
|
"@molecule/api-error-tracking-console": "1.0.2",
|
|
66
70
|
"@molecule/api-error-tracking-sentry": "1.0.2",
|
|
67
|
-
"@molecule/api-geolocation": "1.0.
|
|
71
|
+
"@molecule/api-geolocation": "1.0.3",
|
|
68
72
|
"@molecule/api-geolocation-google": "1.0.2",
|
|
69
73
|
"@molecule/api-geolocation-mapbox": "1.0.2",
|
|
70
74
|
"@molecule/api-geolocation-nominatim": "1.0.2",
|
|
@@ -72,29 +76,30 @@
|
|
|
72
76
|
"@molecule/api-http-fetch": "1.0.2",
|
|
73
77
|
"@molecule/api-i18n": "1.0.3",
|
|
74
78
|
"@molecule/api-image": "1.0.2",
|
|
75
|
-
"@molecule/api-image-sharp": "1.0.
|
|
76
|
-
"@molecule/api-import-export": "1.0.
|
|
79
|
+
"@molecule/api-image-sharp": "1.0.4",
|
|
80
|
+
"@molecule/api-import-export": "1.0.3",
|
|
77
81
|
"@molecule/api-import-export-csv": "1.0.2",
|
|
78
82
|
"@molecule/api-jwt": "1.0.3",
|
|
79
83
|
"@molecule/api-jwt-jsonwebtoken": "1.0.2",
|
|
80
84
|
"@molecule/api-logger": "1.0.2",
|
|
81
|
-
"@molecule/api-media-streaming": "1.0.
|
|
85
|
+
"@molecule/api-media-streaming": "1.0.3",
|
|
82
86
|
"@molecule/api-media-streaming-hls": "1.1.1",
|
|
83
87
|
"@molecule/api-middleware-body-parser": "1.0.2",
|
|
84
|
-
"@molecule/api-middleware-body-parser-express": "1.0.
|
|
88
|
+
"@molecule/api-middleware-body-parser-express": "1.0.3",
|
|
85
89
|
"@molecule/api-middleware-cookie-parser": "1.0.2",
|
|
86
90
|
"@molecule/api-middleware-cookie-parser-express": "1.0.2",
|
|
87
91
|
"@molecule/api-middleware-cors": "1.0.2",
|
|
88
92
|
"@molecule/api-middleware-cors-express": "1.0.2",
|
|
89
|
-
"@molecule/api-middleware-validation": "1.0.
|
|
93
|
+
"@molecule/api-middleware-validation": "1.0.3",
|
|
90
94
|
"@molecule/api-notifications-webhook": "1.0.2",
|
|
91
95
|
"@molecule/api-password": "1.0.2",
|
|
92
|
-
"@molecule/api-password-bcrypt": "1.0.
|
|
96
|
+
"@molecule/api-password-bcrypt": "1.0.3",
|
|
93
97
|
"@molecule/api-payments": "1.2.1",
|
|
94
|
-
"@molecule/api-payments-
|
|
98
|
+
"@molecule/api-payments-capture": "1.0.0",
|
|
99
|
+
"@molecule/api-payments-stripe": "1.2.6",
|
|
95
100
|
"@molecule/api-pdf": "1.0.2",
|
|
96
101
|
"@molecule/api-pdf-pdfkit": "1.0.2",
|
|
97
|
-
"@molecule/api-permissions": "1.0.
|
|
102
|
+
"@molecule/api-permissions": "1.0.3",
|
|
98
103
|
"@molecule/api-permissions-custom": "1.0.2",
|
|
99
104
|
"@molecule/api-push-capture": "1.0.3",
|
|
100
105
|
"@molecule/api-push-notifications": "1.0.2",
|
|
@@ -102,34 +107,36 @@
|
|
|
102
107
|
"@molecule/api-queue": "1.0.2",
|
|
103
108
|
"@molecule/api-queue-memory": "1.0.3",
|
|
104
109
|
"@molecule/api-queue-redis": "1.0.2",
|
|
105
|
-
"@molecule/api-rate-limit": "1.0.
|
|
110
|
+
"@molecule/api-rate-limit": "1.0.3",
|
|
106
111
|
"@molecule/api-rate-limit-memory": "1.0.2",
|
|
107
|
-
"@molecule/api-realtime": "1.0.
|
|
108
|
-
"@molecule/api-realtime-socketio": "1.0.
|
|
112
|
+
"@molecule/api-realtime": "1.0.3",
|
|
113
|
+
"@molecule/api-realtime-socketio": "1.0.3",
|
|
109
114
|
"@molecule/api-realtime-sse": "1.0.2",
|
|
110
115
|
"@molecule/api-realtime-ws": "1.0.2",
|
|
111
116
|
"@molecule/api-reporting": "1.0.2",
|
|
112
|
-
"@molecule/api-reporting-database": "1.0.
|
|
117
|
+
"@molecule/api-reporting-database": "1.0.3",
|
|
113
118
|
"@molecule/api-resource": "1.0.2",
|
|
114
|
-
"@molecule/api-resource-device": "1.0.
|
|
119
|
+
"@molecule/api-resource-device": "1.0.4",
|
|
115
120
|
"@molecule/api-resource-payment": "1.0.2",
|
|
116
|
-
"@molecule/api-resource-user": "1.4.
|
|
117
|
-
"@molecule/api-search": "1.0.
|
|
121
|
+
"@molecule/api-resource-user": "1.4.6",
|
|
122
|
+
"@molecule/api-search": "1.0.3",
|
|
118
123
|
"@molecule/api-search-meilisearch": "1.0.2",
|
|
119
124
|
"@molecule/api-search-postgres": "1.0.2",
|
|
120
125
|
"@molecule/api-secrets": "1.0.2",
|
|
121
126
|
"@molecule/api-secrets-env": "1.0.2",
|
|
122
|
-
"@molecule/api-server-default-express": "1.0.
|
|
127
|
+
"@molecule/api-server-default-express": "1.0.3",
|
|
123
128
|
"@molecule/api-two-factor": "1.0.2",
|
|
124
|
-
"@molecule/api-two-factor-otplib": "1.0.
|
|
129
|
+
"@molecule/api-two-factor-otplib": "1.0.3",
|
|
125
130
|
"@molecule/api-uploads": "1.0.2",
|
|
126
|
-
"@molecule/api-uploads-filesystem": "1.0.
|
|
127
|
-
"@molecule/api-uploads-s3": "1.
|
|
128
|
-
"@molecule/api-webhook": "1.0.
|
|
129
|
-
"@molecule/api-webhook-http": "1.0.
|
|
130
|
-
"@molecule/api-workflow": "1.0.
|
|
131
|
+
"@molecule/api-uploads-filesystem": "1.0.3",
|
|
132
|
+
"@molecule/api-uploads-s3": "1.1.1",
|
|
133
|
+
"@molecule/api-webhook": "1.0.3",
|
|
134
|
+
"@molecule/api-webhook-http": "1.0.3",
|
|
135
|
+
"@molecule/api-workflow": "1.0.3",
|
|
131
136
|
"@molecule/api-workflow-database": "1.0.2",
|
|
137
|
+
"@types/express": "5.0.6",
|
|
132
138
|
"@types/node": "26.1.2",
|
|
139
|
+
"express": "5.2.1",
|
|
133
140
|
"typescript": "6.0.3",
|
|
134
141
|
"vitest": "4.1.11"
|
|
135
142
|
},
|
|
@@ -154,6 +161,7 @@
|
|
|
154
161
|
"@molecule/api-cron": "^1.0.1",
|
|
155
162
|
"@molecule/api-cron-node-cron": "^1.0.1",
|
|
156
163
|
"@molecule/api-database": "^1.0.1",
|
|
164
|
+
"@molecule/api-database-pglite": "^1.0.0",
|
|
157
165
|
"@molecule/api-database-postgresql": "^1.0.1",
|
|
158
166
|
"@molecule/api-emails": "^1.0.1",
|
|
159
167
|
"@molecule/api-emails-capture": "^1.0.1",
|
|
@@ -191,6 +199,7 @@
|
|
|
191
199
|
"@molecule/api-password": "^1.0.1",
|
|
192
200
|
"@molecule/api-password-bcrypt": "^1.0.1",
|
|
193
201
|
"@molecule/api-payments": "^1.0.1",
|
|
202
|
+
"@molecule/api-payments-capture": "^1.0.0",
|
|
194
203
|
"@molecule/api-payments-stripe": "^1.0.1",
|
|
195
204
|
"@molecule/api-pdf": "^1.0.1",
|
|
196
205
|
"@molecule/api-pdf-pdfkit": "^1.0.1",
|
|
@@ -219,6 +228,7 @@
|
|
|
219
228
|
"@molecule/api-search-postgres": "^1.0.1",
|
|
220
229
|
"@molecule/api-secrets": "^1.0.1",
|
|
221
230
|
"@molecule/api-secrets-env": "^1.0.1",
|
|
231
|
+
"@molecule/api-server-default-express": "^1.0.1",
|
|
222
232
|
"@molecule/api-two-factor": "^1.0.1",
|
|
223
233
|
"@molecule/api-two-factor-otplib": "^1.0.1",
|
|
224
234
|
"@molecule/api-uploads": "^1.0.1",
|
|
@@ -227,7 +237,8 @@
|
|
|
227
237
|
"@molecule/api-webhook": "^1.0.1",
|
|
228
238
|
"@molecule/api-webhook-http": "^1.0.1",
|
|
229
239
|
"@molecule/api-workflow": "^1.0.1",
|
|
230
|
-
"@molecule/api-workflow-database": "^1.0.1"
|
|
240
|
+
"@molecule/api-workflow-database": "^1.0.1",
|
|
241
|
+
"express": "^4.0.0 || ^5.0.0"
|
|
231
242
|
},
|
|
232
243
|
"peerDependenciesMeta": {
|
|
233
244
|
"@molecule/api-cron": {
|
|
@@ -379,6 +390,12 @@
|
|
|
379
390
|
},
|
|
380
391
|
"@molecule/api-media-streaming-hls": {
|
|
381
392
|
"optional": true
|
|
393
|
+
},
|
|
394
|
+
"@molecule/api-database-pglite": {
|
|
395
|
+
"optional": true
|
|
396
|
+
},
|
|
397
|
+
"@molecule/api-payments-capture": {
|
|
398
|
+
"optional": true
|
|
382
399
|
}
|
|
383
400
|
}
|
|
384
401
|
}
|