Skip to content

Commit e1b8378

Browse files
authored
Merge pull request #5 from interscript/fix/vendor-side-effects
fix(vendor): keep ML model registrations in the bundle (sideEffects)
2 parents bf9e8a5 + e242ab9 commit e1b8378

7 files changed

Lines changed: 70 additions & 68 deletions

File tree

‎README.md‎

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ Any organization can deploy this package privately on their own domain.
1313

1414
Field-for-field identical to the long-running Ruby API:
1515

16-
| field | behavior |
17-
|---|---|
18-
| `info` | version JSON |
19-
| `systemCodes` | all 287 transliteration systems |
20-
| `transliterate(systemCode!, input!)` | transliterate (1MB input cap) |
21-
| `detect(input!, output!)` | ranked `[{mapName, distance}]` |
16+
| field | behavior |
17+
| ------------------------------------ | ------------------------------- |
18+
| `info` | version JSON |
19+
| `systemCodes` | all 287 transliteration systems |
20+
| `transliterate(systemCode!, input!)` | transliterate (1MB input cap) |
21+
| `detect(input!, output!)` | ranked `[{mapName, distance}]` |
2222

2323
Error strings match byte-for-byte (`Couldn't locate <code>`).
2424

@@ -28,16 +28,19 @@ Error strings match byte-for-byte (`Couldn't locate <code>`).
2828
[`interscript-ts`](https://github.com/interscript/interscript-ts) —
2929
no regex compilation.
3030
- **Maps**: the full corpus (287 systems + 4 dependency libraries,
31-
compiled to schema-versioned JSON IR from interscript-maps 2.4.3) is
32-
**bundled with the deploy as static assets** — minified ~260MB,
33-
~21MB gzipped, every file well under the 20MiB asset limit. Immutable
34-
per release, edge-cached, zero runtime third-party fetches.
31+
compiled to schema-versioned JSON IR from interscript-maps) is a
32+
deploy-time asset, not part of this npm package. Deployment repos fetch
33+
a pinned map artifact from `interscript/maps`, verify it, and expose it
34+
through the Workers Assets binding. Immutable per release, edge-cached,
35+
zero runtime third-party fetches.
3536
- **Server**: Hono + GraphQL Yoga.
3637

3738
## Deploy your own
3839

3940
```bash
4041
npm install @interscript/api-worker
42+
# Then fetch/extract a pinned interscript/maps JSON-IR artifact into ./maps.
43+
# Do not copy maps from this npm package; the package is code-only.
4144
```
4245

4346
Minimal `wrangler.jsonc`:
@@ -48,10 +51,10 @@ Minimal `wrangler.jsonc`:
4851
"main": "src/index.ts",
4952
"compatibility_date": "2026-08-01",
5053
"assets": {
51-
"directory": "./node_modules/@interscript/api-worker/maps",
52-
"binding": "ASSETS"
54+
"directory": "./maps",
55+
"binding": "ASSETS",
5356
},
54-
"routes": [{ "pattern": "api.example.org/*" }]
57+
"routes": [{ "pattern": "api.example.org/*" }],
5558
}
5659
```
5760

@@ -72,16 +75,19 @@ npm run lint
7275
Regenerating the map corpus (requires interscript-ruby + interscript-maps):
7376

7477
```bash
75-
ruby -e '... see scripts/build-maps.rb ...'
78+
ruby scripts/build-maps.rb /path/to/interscript-ruby /path/to/maps ./maps
7679
```
7780

81+
For production deploys, prefer a pinned release artifact from
82+
`interscript/maps` over local regeneration; verify the artifact checksum
83+
before `wrangler deploy`.
84+
7885
## Parity
7986

8087
`test/fixtures/parity.json` holds queries recorded from the production
8188
Ruby API; CI replays them against this implementation. Zero-diff is the
8289
release gate.
8390

84-
8591
## REST v1 (OpenAPI)
8692

8793
REST endpoints serve alongside GraphQL (which remains at `POST /graphql`):

‎dist/src/generated/models.json‎

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
{
55
"id": "khm-latn-1.0",
66
"task": "translit",
7-
"scripts": [
8-
"Khmr",
9-
"Latn"
10-
],
7+
"scripts": ["Khmr", "Latn"],
118
"precision": "fp32",
129
"filename": "khm-latn-1.0-fp32.zip",
1310
"url": "https://github.com/interscript/interscript-ml/releases/download/khm-latn-1.0/khm-latn-1.0-fp32.zip",
@@ -35,10 +32,7 @@
3532
{
3633
"id": "urd-g2p-1.0",
3734
"task": "g2p",
38-
"scripts": [
39-
"Arab",
40-
"IPA"
41-
],
35+
"scripts": ["Arab", "IPA"],
4236
"precision": "fp32",
4337
"filename": "urd-g2p-1.0-fp32.zip",
4438
"url": "https://github.com/interscript/interscript-ml/releases/download/urd-g2p-1.0/urd-g2p-1.0-fp32.zip",
@@ -66,10 +60,7 @@
6660
{
6761
"id": "urd-diac-1.0",
6862
"task": "diacritization",
69-
"scripts": [
70-
"Arab",
71-
"Arab"
72-
],
63+
"scripts": ["Arab", "Arab"],
7364
"precision": "fp32",
7465
"filename": "urd-diac-1.0-fp32.zip",
7566
"url": "https://github.com/interscript/interscript-ml/releases/download/urd-diac-1.0/urd-diac-1.0-fp32.zip",
@@ -92,10 +83,7 @@
9283
{
9384
"id": "heb-diac-1.0",
9485
"task": "diacritization",
95-
"scripts": [
96-
"Hebr",
97-
"Hebr"
98-
],
86+
"scripts": ["Hebr", "Hebr"],
9987
"precision": "fp32",
10088
"filename": "heb-diac-1.0-fp32.zip",
10189
"url": null,
@@ -134,10 +122,7 @@
134122
{
135123
"id": "tha-g2p-base-1.0",
136124
"task": "g2p",
137-
"scripts": [
138-
"Thai",
139-
"IPA"
140-
],
125+
"scripts": ["Thai", "IPA"],
141126
"precision": "fp32",
142127
"filename": "tha-g2p-base-1.0-fp32.zip",
143128
"url": null,
@@ -176,10 +161,7 @@
176161
{
177162
"id": "tha-g2p-small-1.0",
178163
"task": "g2p",
179-
"scripts": [
180-
"Thai",
181-
"IPA"
182-
],
164+
"scripts": ["Thai", "IPA"],
183165
"precision": "int8",
184166
"filename": "tha-g2p-small-1.0-int8.zip",
185167
"url": "https://github.com/interscript/interscript-ml/releases/download/tha-g2p-small-1.0/tha-g2p-small-1.0-int8.zip",
@@ -207,10 +189,7 @@
207189
{
208190
"id": "tha-g2p-small-1.0-int4",
209191
"task": "g2p",
210-
"scripts": [
211-
"Thai",
212-
"IPA"
213-
],
192+
"scripts": ["Thai", "IPA"],
214193
"precision": "int4",
215194
"filename": "tha-g2p-small-1.0-int4.zip",
216195
"url": "https://github.com/interscript/interscript-ml/releases/download/tha-g2p-small-1.0/tha-g2p-small-1.0-int4.zip",
@@ -238,10 +217,7 @@
238217
{
239218
"id": "heb-diac-small-1.0",
240219
"task": "diacritization",
241-
"scripts": [
242-
"Hebr",
243-
"Hebr"
244-
],
220+
"scripts": ["Hebr", "Hebr"],
245221
"precision": "fp32",
246222
"filename": "heb-diac-small-1.0-fp32.zip",
247223
"url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-small-1.0/heb-diac-small-1.0-fp32.zip",
@@ -269,10 +245,7 @@
269245
{
270246
"id": "fas-g2p-1.0",
271247
"task": "g2p",
272-
"scripts": [
273-
"Arab",
274-
"Latn"
275-
],
248+
"scripts": ["Arab", "Latn"],
276249
"precision": "fp32",
277250
"filename": "fas-g2p-1.0-fp32.zip",
278251
"url": null,
@@ -311,10 +284,7 @@
311284
{
312285
"id": "heb-diac-1.1",
313286
"task": "diacritization",
314-
"scripts": [
315-
"Hebr",
316-
"Hebr"
317-
],
287+
"scripts": ["Hebr", "Hebr"],
318288
"precision": "fp32",
319289
"filename": "heb.zip",
320290
"url": null,

0 commit comments

Comments
 (0)