@cherwell/emdash-shortlinks 0.0.0-stage → 0.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/dist/index.mjs ADDED
@@ -0,0 +1,620 @@
1
+ // Auto-generated by emdash-plugin build. Do not edit.
2
+ // Source: emdash-plugin.jsonc + package.json
3
+ //
4
+ // Default-exports a sandboxed plugin descriptor. Pass it directly into
5
+ // emdash's `plugins:` or `sandboxed:` array — no factory call needed.
6
+
7
+ /** @type {import("emdash").PluginDescriptor} */
8
+ const descriptor = Object.freeze({
9
+ "id": "shortlinks",
10
+ "displayName": "Short Links",
11
+ "description": "Short, trackable links and QR codes for print, social and email, with campaign reports and no tracking cookies.",
12
+ "version": "0.1.0",
13
+ "format": "standard",
14
+ "entrypoint": "@cherwell/emdash-shortlinks/sandbox",
15
+ "capabilities": [
16
+ "content:read",
17
+ "network:request:unrestricted",
18
+ "network:request"
19
+ ],
20
+ "allowedHosts": [],
21
+ "storage": {
22
+ "links": {
23
+ "indexes": [
24
+ "status",
25
+ "createdAt",
26
+ "campaign",
27
+ "scope",
28
+ [
29
+ "scope",
30
+ "createdAt"
31
+ ],
32
+ [
33
+ "campaign",
34
+ "createdAt"
35
+ ],
36
+ [
37
+ "status",
38
+ "createdAt"
39
+ ]
40
+ ],
41
+ "uniqueIndexes": [
42
+ "key"
43
+ ]
44
+ },
45
+ "stats": {
46
+ "indexes": [
47
+ "linkId",
48
+ "month",
49
+ [
50
+ "linkId",
51
+ "month"
52
+ ]
53
+ ]
54
+ },
55
+ "audit": {
56
+ "indexes": [
57
+ "at",
58
+ "target",
59
+ "actor",
60
+ [
61
+ "target",
62
+ "at"
63
+ ]
64
+ ]
65
+ },
66
+ "webhooks": {
67
+ "indexes": [
68
+ "createdAt"
69
+ ]
70
+ },
71
+ "deliveries": {
72
+ "indexes": [
73
+ "status",
74
+ "createdAt",
75
+ [
76
+ "status",
77
+ "nextAt"
78
+ ]
79
+ ]
80
+ },
81
+ "rate_limits": {
82
+ "indexes": [
83
+ "expiresAt"
84
+ ]
85
+ }
86
+ },
87
+ "hooks": [
88
+ "plugin:activate",
89
+ "cron"
90
+ ],
91
+ "routes": [
92
+ {
93
+ "name": "resolve",
94
+ "methods": [
95
+ "POST"
96
+ ],
97
+ "request": {
98
+ "body": "json",
99
+ "headers": [
100
+ "x-server-key"
101
+ ]
102
+ },
103
+ "public": true
104
+ },
105
+ {
106
+ "name": "qr",
107
+ "methods": [
108
+ "GET"
109
+ ],
110
+ "response": "raw",
111
+ "public": true,
112
+ "cacheControl": "private, max-age=3600"
113
+ },
114
+ {
115
+ "name": "export",
116
+ "methods": [
117
+ "GET"
118
+ ],
119
+ "response": "raw",
120
+ "public": true
121
+ },
122
+ {
123
+ "name": "links/list",
124
+ "permission": "content:edit_any"
125
+ },
126
+ {
127
+ "name": "links/get",
128
+ "permission": "content:edit_any"
129
+ },
130
+ {
131
+ "name": "links/create",
132
+ "methods": [
133
+ "POST"
134
+ ],
135
+ "permission": "content:edit_any"
136
+ },
137
+ {
138
+ "name": "links/update",
139
+ "methods": [
140
+ "POST"
141
+ ],
142
+ "permission": "content:edit_any"
143
+ },
144
+ {
145
+ "name": "links/delete",
146
+ "methods": [
147
+ "POST"
148
+ ],
149
+ "permission": "content:edit_any"
150
+ },
151
+ {
152
+ "name": "admin",
153
+ "permission": "content:edit_any"
154
+ }
155
+ ],
156
+ "mcp": {
157
+ "tools": [
158
+ {
159
+ "name": "shortlinks_list",
160
+ "description": "List short links, newest first, optionally by campaign, status or site. Pass the cursor to page.",
161
+ "route": "links/list",
162
+ "permission": "content:edit_any",
163
+ "destructive": false,
164
+ "inputSchema": {
165
+ "$schema": "http://json-schema.org/draft-07/schema#",
166
+ "type": "object",
167
+ "properties": {
168
+ "campaign": {
169
+ "type": "string",
170
+ "maxLength": 80
171
+ },
172
+ "status": {
173
+ "type": "string",
174
+ "enum": [
175
+ "active",
176
+ "disabled"
177
+ ]
178
+ },
179
+ "scope": {
180
+ "type": "string",
181
+ "maxLength": 40
182
+ },
183
+ "cursor": {
184
+ "type": "string",
185
+ "maxLength": 500
186
+ },
187
+ "limit": {
188
+ "type": "integer",
189
+ "minimum": 1,
190
+ "maximum": 100
191
+ }
192
+ },
193
+ "additionalProperties": false
194
+ }
195
+ },
196
+ {
197
+ "name": "shortlink_get",
198
+ "description": "Read one short link and its daily clicks, QR scans, top countries and referrers.",
199
+ "route": "links/get",
200
+ "permission": "content:edit_any",
201
+ "destructive": false,
202
+ "inputSchema": {
203
+ "$schema": "http://json-schema.org/draft-07/schema#",
204
+ "type": "object",
205
+ "properties": {
206
+ "code": {
207
+ "type": "string",
208
+ "maxLength": 32
209
+ },
210
+ "scope": {
211
+ "default": "",
212
+ "type": "string",
213
+ "maxLength": 40
214
+ },
215
+ "days": {
216
+ "type": "integer",
217
+ "minimum": 1,
218
+ "maximum": 366
219
+ }
220
+ },
221
+ "required": [
222
+ "code",
223
+ "scope"
224
+ ],
225
+ "additionalProperties": false
226
+ }
227
+ },
228
+ {
229
+ "name": "shortlink_create",
230
+ "description": "Create a live short link to a URL or an entry (collection:id), with optional code, campaign, UTM tags and expiry.",
231
+ "route": "links/create",
232
+ "permission": "content:edit_any",
233
+ "destructive": true,
234
+ "inputSchema": {
235
+ "$schema": "http://json-schema.org/draft-07/schema#",
236
+ "type": "object",
237
+ "properties": {
238
+ "target": {
239
+ "type": "string",
240
+ "minLength": 3,
241
+ "maxLength": 2000
242
+ },
243
+ "code": {
244
+ "anyOf": [
245
+ {
246
+ "type": "string",
247
+ "maxLength": 32
248
+ },
249
+ {
250
+ "type": "string",
251
+ "const": ""
252
+ }
253
+ ]
254
+ },
255
+ "scope": {
256
+ "anyOf": [
257
+ {
258
+ "type": "string",
259
+ "maxLength": 40
260
+ },
261
+ {
262
+ "type": "string",
263
+ "const": ""
264
+ }
265
+ ]
266
+ },
267
+ "title": {
268
+ "type": "string",
269
+ "maxLength": 200
270
+ },
271
+ "campaign": {
272
+ "type": "string",
273
+ "maxLength": 80
274
+ },
275
+ "utmSource": {
276
+ "type": "string",
277
+ "maxLength": 80
278
+ },
279
+ "utmMedium": {
280
+ "type": "string",
281
+ "maxLength": 80
282
+ },
283
+ "utmCampaign": {
284
+ "type": "string",
285
+ "maxLength": 80
286
+ },
287
+ "expiresOn": {
288
+ "anyOf": [
289
+ {
290
+ "type": "string",
291
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
292
+ },
293
+ {
294
+ "type": "string",
295
+ "const": ""
296
+ }
297
+ ]
298
+ },
299
+ "custom": {
300
+ "type": "object",
301
+ "propertyNames": {
302
+ "type": "string"
303
+ },
304
+ "additionalProperties": {}
305
+ }
306
+ },
307
+ "required": [
308
+ "target"
309
+ ],
310
+ "additionalProperties": false
311
+ }
312
+ },
313
+ {
314
+ "name": "shortlink_update",
315
+ "description": "Change where a short link goes, its UTM tags, expiry or status (active/disabled).",
316
+ "route": "links/update",
317
+ "permission": "content:edit_any",
318
+ "destructive": true,
319
+ "inputSchema": {
320
+ "$schema": "http://json-schema.org/draft-07/schema#",
321
+ "type": "object",
322
+ "properties": {
323
+ "code": {
324
+ "type": "string",
325
+ "maxLength": 32
326
+ },
327
+ "scope": {
328
+ "default": "",
329
+ "type": "string",
330
+ "maxLength": 40
331
+ },
332
+ "changes": {
333
+ "type": "object",
334
+ "properties": {
335
+ "target": {
336
+ "type": "string",
337
+ "minLength": 3,
338
+ "maxLength": 2000
339
+ },
340
+ "title": {
341
+ "type": "string",
342
+ "maxLength": 200
343
+ },
344
+ "campaign": {
345
+ "type": "string",
346
+ "maxLength": 80
347
+ },
348
+ "utmSource": {
349
+ "type": "string",
350
+ "maxLength": 80
351
+ },
352
+ "utmMedium": {
353
+ "type": "string",
354
+ "maxLength": 80
355
+ },
356
+ "utmCampaign": {
357
+ "type": "string",
358
+ "maxLength": 80
359
+ },
360
+ "expiresOn": {
361
+ "anyOf": [
362
+ {
363
+ "type": "string",
364
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
365
+ },
366
+ {
367
+ "type": "string",
368
+ "const": ""
369
+ }
370
+ ]
371
+ },
372
+ "custom": {
373
+ "type": "object",
374
+ "propertyNames": {
375
+ "type": "string"
376
+ },
377
+ "additionalProperties": {}
378
+ },
379
+ "status": {
380
+ "type": "string",
381
+ "enum": [
382
+ "active",
383
+ "disabled"
384
+ ]
385
+ }
386
+ },
387
+ "additionalProperties": false
388
+ }
389
+ },
390
+ "required": [
391
+ "code",
392
+ "scope",
393
+ "changes"
394
+ ],
395
+ "additionalProperties": false
396
+ }
397
+ },
398
+ {
399
+ "name": "shortlink_delete",
400
+ "description": "Delete a short link and its statistics. Visitors then reach the fallback page.",
401
+ "route": "links/delete",
402
+ "permission": "content:edit_any",
403
+ "destructive": true,
404
+ "inputSchema": {
405
+ "$schema": "http://json-schema.org/draft-07/schema#",
406
+ "type": "object",
407
+ "properties": {
408
+ "code": {
409
+ "type": "string",
410
+ "maxLength": 32
411
+ },
412
+ "scope": {
413
+ "default": "",
414
+ "type": "string",
415
+ "maxLength": 40
416
+ }
417
+ },
418
+ "required": [
419
+ "code",
420
+ "scope"
421
+ ],
422
+ "additionalProperties": false
423
+ }
424
+ }
425
+ ]
426
+ },
427
+ "adminPages": [
428
+ {
429
+ "path": "/links",
430
+ "label": "Short links",
431
+ "icon": "link",
432
+ "group": "Short links"
433
+ },
434
+ {
435
+ "path": "/import",
436
+ "label": "Import and export",
437
+ "icon": "upload",
438
+ "group": "Short links"
439
+ },
440
+ {
441
+ "path": "/webhooks",
442
+ "label": "Webhooks",
443
+ "icon": "plugs",
444
+ "group": "Short links"
445
+ },
446
+ {
447
+ "path": "/audit",
448
+ "label": "Audit trail",
449
+ "icon": "clock-counter-clockwise",
450
+ "group": "Short links"
451
+ }
452
+ ],
453
+ "adminWidgets": [
454
+ {
455
+ "id": "clicks",
456
+ "title": "Short links",
457
+ "size": "third"
458
+ }
459
+ ],
460
+ "settingsSchema": {
461
+ "prefix": {
462
+ "label": "Path the site serves short links on",
463
+ "type": "string",
464
+ "default": "/s/"
465
+ },
466
+ "fallback": {
467
+ "label": "Where a missing, disabled or expired link goes",
468
+ "type": "string",
469
+ "default": "/"
470
+ },
471
+ "passParams": {
472
+ "label": "Visitor query parameters passed through (comma-separated)",
473
+ "type": "string",
474
+ "default": "ref,gclid,fbclid,msclkid,utm_content,utm_term"
475
+ },
476
+ "publicOrigin": {
477
+ "label": "Public address for short links, if not the site's (e.g. a short domain)",
478
+ "type": "url"
479
+ },
480
+ "scopeOrigins": {
481
+ "label": "Per-site addresses as JSON, e.g. {\"south\": \"https://sth.example\"}",
482
+ "type": "string",
483
+ "multiline": true
484
+ },
485
+ "serverKey": {
486
+ "label": "Server key (the same value as SHORTLINKS_KEY in the site)",
487
+ "type": "secret"
488
+ },
489
+ "webhookSecret": {
490
+ "label": "Webhook signing secret",
491
+ "type": "secret"
492
+ },
493
+ "statsMonths": {
494
+ "label": "Keep click statistics for (months)",
495
+ "type": "number",
496
+ "default": 24,
497
+ "min": 1,
498
+ "max": 120
499
+ },
500
+ "callBudget": {
501
+ "label": "Host calls per background run (28 suits a Cloudflare sandbox; raise it when running in-process)",
502
+ "type": "number",
503
+ "default": 28,
504
+ "min": 10,
505
+ "max": 10000
506
+ },
507
+ "auditDays": {
508
+ "label": "Keep the audit trail for (days)",
509
+ "type": "number",
510
+ "default": 365,
511
+ "min": 30,
512
+ "max": 3650
513
+ },
514
+ "linkFields": {
515
+ "label": "Custom fields on links (JSON; see the README)",
516
+ "type": "string",
517
+ "multiline": true
518
+ },
519
+ "codeLength": {
520
+ "label": "Length of random codes",
521
+ "type": "number",
522
+ "default": 7,
523
+ "min": 4,
524
+ "max": 32
525
+ },
526
+ "codeAlphabet": {
527
+ "label": "Characters random codes use (a-z and 0-9, at least 10)",
528
+ "type": "string",
529
+ "default": "abcdefghjkmnpqrstuvwxyz23456789"
530
+ },
531
+ "reservedCodes": {
532
+ "label": "Codes nobody can use (comma-separated, e.g. admin,login)",
533
+ "type": "string"
534
+ },
535
+ "redirectStatus": {
536
+ "label": "Redirect status for live links",
537
+ "type": "select",
538
+ "options": [
539
+ {
540
+ "value": "302",
541
+ "label": "302 Found (temporary)"
542
+ },
543
+ {
544
+ "value": "307",
545
+ "label": "307 Temporary Redirect"
546
+ },
547
+ {
548
+ "value": "301",
549
+ "label": "301 Moved Permanently"
550
+ },
551
+ {
552
+ "value": "308",
553
+ "label": "308 Permanent Redirect"
554
+ }
555
+ ],
556
+ "default": "302"
557
+ },
558
+ "repeatSeconds": {
559
+ "label": "Don't count the same address again on a link for (seconds; 0 counts every click)",
560
+ "type": "number",
561
+ "default": 60,
562
+ "min": 0,
563
+ "max": 86400
564
+ },
565
+ "recordCountries": {
566
+ "label": "Record visitors' countries",
567
+ "type": "boolean",
568
+ "default": true
569
+ },
570
+ "recordReferrers": {
571
+ "label": "Record referring sites (hostnames)",
572
+ "type": "boolean",
573
+ "default": true
574
+ },
575
+ "timeZone": {
576
+ "label": "Time zone for daily statistics and expiry dates (e.g. Europe/London)",
577
+ "type": "string",
578
+ "default": "UTC"
579
+ },
580
+ "qrLevel": {
581
+ "label": "QR error correction",
582
+ "type": "select",
583
+ "options": [
584
+ {
585
+ "value": "L",
586
+ "label": "Low (7%)"
587
+ },
588
+ {
589
+ "value": "M",
590
+ "label": "Medium (15%)"
591
+ },
592
+ {
593
+ "value": "Q",
594
+ "label": "Quartile (25%)"
595
+ },
596
+ {
597
+ "value": "H",
598
+ "label": "High (30%, for a logo over the code)"
599
+ }
600
+ ],
601
+ "default": "M"
602
+ },
603
+ "qrScale": {
604
+ "label": "QR pixels per module",
605
+ "type": "number",
606
+ "default": 8,
607
+ "min": 1,
608
+ "max": 40
609
+ },
610
+ "qrMargin": {
611
+ "label": "QR quiet zone (modules)",
612
+ "type": "number",
613
+ "default": 4,
614
+ "min": 0,
615
+ "max": 16
616
+ }
617
+ }
618
+ });
619
+
620
+ export default descriptor;