@cherwell/emdash-shortlinks 0.0.0-stage → 0.1.1

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