@larkup/marketplace 0.1.25 → 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 (40) hide show
  1. package/.env.example +3 -0
  2. package/CHANGELOG.md +173 -0
  3. package/README.md +34 -0
  4. package/db/drizzle/0000_hesitant_joseph.sql +69 -0
  5. package/db/drizzle/0001_deep_phil_sheldon.sql +1 -0
  6. package/db/drizzle/0002_jittery_living_mummy.sql +18 -0
  7. package/db/drizzle/meta/0000_snapshot.json +483 -0
  8. package/db/drizzle/meta/0001_snapshot.json +490 -0
  9. package/db/drizzle/meta/0002_snapshot.json +615 -0
  10. package/db/drizzle/meta/_journal.json +27 -0
  11. package/db/drizzle.config.ts +19 -0
  12. package/db/tsconfig.build.json +11 -0
  13. package/db/tsconfig.json +17 -0
  14. package/db/vitest.config.ts +11 -0
  15. package/package.json +31 -4
  16. package/src/db/builtin-tools.ts +613 -0
  17. package/src/db/client.ts +26 -0
  18. package/src/db/repo.test.ts +309 -0
  19. package/src/db/repo.ts +558 -0
  20. package/src/db/schema/audit.ts +27 -0
  21. package/src/db/schema/extensions.ts +73 -0
  22. package/src/db/schema/index.ts +5 -0
  23. package/src/db/schema/installations.ts +23 -0
  24. package/src/db/schema/publishers.ts +13 -0
  25. package/src/db/schema/versions.ts +22 -0
  26. package/src/db/seed.ts +33 -0
  27. package/src/db/validate.test.ts +79 -0
  28. package/src/db/validate.ts +84 -0
  29. package/src/output-sanitizer.test.ts +17 -0
  30. package/src/output-sanitizer.ts +8 -0
  31. package/src/storage-provider-s3.test.ts +110 -0
  32. package/src/storage-provider.ts +164 -13
  33. package/src/tool-extension.ts +247 -0
  34. package/src/tool-installer.ts +80 -109
  35. package/src/tool-loader.test.ts +120 -0
  36. package/src/tool-loader.ts +99 -37
  37. package/src/tool-manifest.schema.ts +89 -32
  38. package/src/tool-registry.ts +34 -111
  39. package/src/types.ts +217 -87
  40. package/vitest.config.ts +13 -0
@@ -0,0 +1,615 @@
1
+ {
2
+ "id": "703535c9-6ecc-4a6e-9c07-838860ccd634",
3
+ "prevId": "9a51f664-6160-43f4-91b9-a0c1d47575b7",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.publishers": {
8
+ "name": "publishers",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "text",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "name": {
18
+ "name": "name",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "contact_email": {
24
+ "name": "contact_email",
25
+ "type": "text",
26
+ "primaryKey": false,
27
+ "notNull": false
28
+ },
29
+ "verification": {
30
+ "name": "verification",
31
+ "type": "text",
32
+ "primaryKey": false,
33
+ "notNull": true,
34
+ "default": "'unverified'"
35
+ },
36
+ "created_at": {
37
+ "name": "created_at",
38
+ "type": "timestamp with time zone",
39
+ "primaryKey": false,
40
+ "notNull": true,
41
+ "default": "now()"
42
+ },
43
+ "updated_at": {
44
+ "name": "updated_at",
45
+ "type": "timestamp with time zone",
46
+ "primaryKey": false,
47
+ "notNull": true,
48
+ "default": "now()"
49
+ }
50
+ },
51
+ "indexes": {},
52
+ "foreignKeys": {},
53
+ "compositePrimaryKeys": {},
54
+ "uniqueConstraints": {},
55
+ "policies": {},
56
+ "checkConstraints": {},
57
+ "isRLSEnabled": false
58
+ },
59
+ "public.extension_access_keys": {
60
+ "name": "extension_access_keys",
61
+ "schema": "",
62
+ "columns": {
63
+ "id": {
64
+ "name": "id",
65
+ "type": "text",
66
+ "primaryKey": true,
67
+ "notNull": true
68
+ },
69
+ "extension_id": {
70
+ "name": "extension_id",
71
+ "type": "text",
72
+ "primaryKey": false,
73
+ "notNull": true
74
+ },
75
+ "key_hash": {
76
+ "name": "key_hash",
77
+ "type": "text",
78
+ "primaryKey": false,
79
+ "notNull": true
80
+ },
81
+ "key_prefix": {
82
+ "name": "key_prefix",
83
+ "type": "text",
84
+ "primaryKey": false,
85
+ "notNull": true
86
+ },
87
+ "scope": {
88
+ "name": "scope",
89
+ "type": "text",
90
+ "primaryKey": false,
91
+ "notNull": true
92
+ },
93
+ "scope_id": {
94
+ "name": "scope_id",
95
+ "type": "text",
96
+ "primaryKey": false,
97
+ "notNull": false
98
+ },
99
+ "max_installs": {
100
+ "name": "max_installs",
101
+ "type": "integer",
102
+ "primaryKey": false,
103
+ "notNull": false
104
+ },
105
+ "install_count": {
106
+ "name": "install_count",
107
+ "type": "integer",
108
+ "primaryKey": false,
109
+ "notNull": true,
110
+ "default": 0
111
+ },
112
+ "expires_at": {
113
+ "name": "expires_at",
114
+ "type": "timestamp with time zone",
115
+ "primaryKey": false,
116
+ "notNull": false
117
+ },
118
+ "revoked_at": {
119
+ "name": "revoked_at",
120
+ "type": "timestamp with time zone",
121
+ "primaryKey": false,
122
+ "notNull": false
123
+ },
124
+ "created_by": {
125
+ "name": "created_by",
126
+ "type": "text",
127
+ "primaryKey": false,
128
+ "notNull": true
129
+ },
130
+ "created_at": {
131
+ "name": "created_at",
132
+ "type": "timestamp with time zone",
133
+ "primaryKey": false,
134
+ "notNull": true,
135
+ "default": "now()"
136
+ }
137
+ },
138
+ "indexes": {
139
+ "extension_access_keys_extension_id_idx": {
140
+ "name": "extension_access_keys_extension_id_idx",
141
+ "columns": [
142
+ {
143
+ "expression": "extension_id",
144
+ "isExpression": false,
145
+ "asc": true,
146
+ "nulls": "last"
147
+ }
148
+ ],
149
+ "isUnique": false,
150
+ "concurrently": false,
151
+ "method": "btree",
152
+ "with": {}
153
+ }
154
+ },
155
+ "foreignKeys": {
156
+ "extension_access_keys_extension_id_extensions_id_fk": {
157
+ "name": "extension_access_keys_extension_id_extensions_id_fk",
158
+ "tableFrom": "extension_access_keys",
159
+ "tableTo": "extensions",
160
+ "columnsFrom": [
161
+ "extension_id"
162
+ ],
163
+ "columnsTo": [
164
+ "id"
165
+ ],
166
+ "onDelete": "no action",
167
+ "onUpdate": "no action"
168
+ }
169
+ },
170
+ "compositePrimaryKeys": {},
171
+ "uniqueConstraints": {
172
+ "extension_access_keys_key_hash_unique": {
173
+ "name": "extension_access_keys_key_hash_unique",
174
+ "nullsNotDistinct": false,
175
+ "columns": [
176
+ "key_hash"
177
+ ]
178
+ }
179
+ },
180
+ "policies": {},
181
+ "checkConstraints": {},
182
+ "isRLSEnabled": false
183
+ },
184
+ "public.extension_workspace_grants": {
185
+ "name": "extension_workspace_grants",
186
+ "schema": "",
187
+ "columns": {
188
+ "id": {
189
+ "name": "id",
190
+ "type": "text",
191
+ "primaryKey": true,
192
+ "notNull": true
193
+ },
194
+ "extension_id": {
195
+ "name": "extension_id",
196
+ "type": "text",
197
+ "primaryKey": false,
198
+ "notNull": true
199
+ },
200
+ "workspace_id": {
201
+ "name": "workspace_id",
202
+ "type": "text",
203
+ "primaryKey": false,
204
+ "notNull": true
205
+ },
206
+ "granted_at": {
207
+ "name": "granted_at",
208
+ "type": "timestamp with time zone",
209
+ "primaryKey": false,
210
+ "notNull": true,
211
+ "default": "now()"
212
+ }
213
+ },
214
+ "indexes": {},
215
+ "foreignKeys": {
216
+ "extension_workspace_grants_extension_id_extensions_id_fk": {
217
+ "name": "extension_workspace_grants_extension_id_extensions_id_fk",
218
+ "tableFrom": "extension_workspace_grants",
219
+ "tableTo": "extensions",
220
+ "columnsFrom": [
221
+ "extension_id"
222
+ ],
223
+ "columnsTo": [
224
+ "id"
225
+ ],
226
+ "onDelete": "no action",
227
+ "onUpdate": "no action"
228
+ }
229
+ },
230
+ "compositePrimaryKeys": {},
231
+ "uniqueConstraints": {},
232
+ "policies": {},
233
+ "checkConstraints": {},
234
+ "isRLSEnabled": false
235
+ },
236
+ "public.extensions": {
237
+ "name": "extensions",
238
+ "schema": "",
239
+ "columns": {
240
+ "id": {
241
+ "name": "id",
242
+ "type": "text",
243
+ "primaryKey": true,
244
+ "notNull": true
245
+ },
246
+ "publisher_id": {
247
+ "name": "publisher_id",
248
+ "type": "text",
249
+ "primaryKey": false,
250
+ "notNull": true
251
+ },
252
+ "kind": {
253
+ "name": "kind",
254
+ "type": "text",
255
+ "primaryKey": false,
256
+ "notNull": true,
257
+ "default": "'tool'"
258
+ },
259
+ "name": {
260
+ "name": "name",
261
+ "type": "text",
262
+ "primaryKey": false,
263
+ "notNull": true
264
+ },
265
+ "description": {
266
+ "name": "description",
267
+ "type": "text",
268
+ "primaryKey": false,
269
+ "notNull": true
270
+ },
271
+ "category": {
272
+ "name": "category",
273
+ "type": "text",
274
+ "primaryKey": false,
275
+ "notNull": true
276
+ },
277
+ "package_name": {
278
+ "name": "package_name",
279
+ "type": "text",
280
+ "primaryKey": false,
281
+ "notNull": true
282
+ },
283
+ "requires_sandbox": {
284
+ "name": "requires_sandbox",
285
+ "type": "boolean",
286
+ "primaryKey": false,
287
+ "notNull": true,
288
+ "default": true
289
+ },
290
+ "distribution": {
291
+ "name": "distribution",
292
+ "type": "text",
293
+ "primaryKey": false,
294
+ "notNull": true,
295
+ "default": "'public'"
296
+ },
297
+ "repository_url": {
298
+ "name": "repository_url",
299
+ "type": "text",
300
+ "primaryKey": false,
301
+ "notNull": false
302
+ },
303
+ "license": {
304
+ "name": "license",
305
+ "type": "text",
306
+ "primaryKey": false,
307
+ "notNull": false
308
+ },
309
+ "deprecated_at": {
310
+ "name": "deprecated_at",
311
+ "type": "timestamp with time zone",
312
+ "primaryKey": false,
313
+ "notNull": false
314
+ },
315
+ "created_at": {
316
+ "name": "created_at",
317
+ "type": "timestamp with time zone",
318
+ "primaryKey": false,
319
+ "notNull": true,
320
+ "default": "now()"
321
+ },
322
+ "updated_at": {
323
+ "name": "updated_at",
324
+ "type": "timestamp with time zone",
325
+ "primaryKey": false,
326
+ "notNull": true,
327
+ "default": "now()"
328
+ }
329
+ },
330
+ "indexes": {},
331
+ "foreignKeys": {
332
+ "extensions_publisher_id_publishers_id_fk": {
333
+ "name": "extensions_publisher_id_publishers_id_fk",
334
+ "tableFrom": "extensions",
335
+ "tableTo": "publishers",
336
+ "columnsFrom": [
337
+ "publisher_id"
338
+ ],
339
+ "columnsTo": [
340
+ "id"
341
+ ],
342
+ "onDelete": "no action",
343
+ "onUpdate": "no action"
344
+ }
345
+ },
346
+ "compositePrimaryKeys": {},
347
+ "uniqueConstraints": {},
348
+ "policies": {},
349
+ "checkConstraints": {},
350
+ "isRLSEnabled": false
351
+ },
352
+ "public.extension_versions": {
353
+ "name": "extension_versions",
354
+ "schema": "",
355
+ "columns": {
356
+ "id": {
357
+ "name": "id",
358
+ "type": "text",
359
+ "primaryKey": true,
360
+ "notNull": true
361
+ },
362
+ "extension_id": {
363
+ "name": "extension_id",
364
+ "type": "text",
365
+ "primaryKey": false,
366
+ "notNull": true
367
+ },
368
+ "version": {
369
+ "name": "version",
370
+ "type": "text",
371
+ "primaryKey": false,
372
+ "notNull": true
373
+ },
374
+ "manifest": {
375
+ "name": "manifest",
376
+ "type": "jsonb",
377
+ "primaryKey": false,
378
+ "notNull": true
379
+ },
380
+ "integrity": {
381
+ "name": "integrity",
382
+ "type": "text",
383
+ "primaryKey": false,
384
+ "notNull": true
385
+ },
386
+ "published_by": {
387
+ "name": "published_by",
388
+ "type": "text",
389
+ "primaryKey": false,
390
+ "notNull": true
391
+ },
392
+ "published_at": {
393
+ "name": "published_at",
394
+ "type": "timestamp with time zone",
395
+ "primaryKey": false,
396
+ "notNull": true,
397
+ "default": "now()"
398
+ }
399
+ },
400
+ "indexes": {
401
+ "extension_versions_extension_id_idx": {
402
+ "name": "extension_versions_extension_id_idx",
403
+ "columns": [
404
+ {
405
+ "expression": "extension_id",
406
+ "isExpression": false,
407
+ "asc": true,
408
+ "nulls": "last"
409
+ }
410
+ ],
411
+ "isUnique": false,
412
+ "concurrently": false,
413
+ "method": "btree",
414
+ "with": {}
415
+ }
416
+ },
417
+ "foreignKeys": {
418
+ "extension_versions_extension_id_extensions_id_fk": {
419
+ "name": "extension_versions_extension_id_extensions_id_fk",
420
+ "tableFrom": "extension_versions",
421
+ "tableTo": "extensions",
422
+ "columnsFrom": [
423
+ "extension_id"
424
+ ],
425
+ "columnsTo": [
426
+ "id"
427
+ ],
428
+ "onDelete": "no action",
429
+ "onUpdate": "no action"
430
+ }
431
+ },
432
+ "compositePrimaryKeys": {},
433
+ "uniqueConstraints": {
434
+ "extension_versions_extension_version_unique": {
435
+ "name": "extension_versions_extension_version_unique",
436
+ "nullsNotDistinct": false,
437
+ "columns": [
438
+ "extension_id",
439
+ "version"
440
+ ]
441
+ }
442
+ },
443
+ "policies": {},
444
+ "checkConstraints": {},
445
+ "isRLSEnabled": false
446
+ },
447
+ "public.workspace_installations": {
448
+ "name": "workspace_installations",
449
+ "schema": "",
450
+ "columns": {
451
+ "id": {
452
+ "name": "id",
453
+ "type": "text",
454
+ "primaryKey": true,
455
+ "notNull": true
456
+ },
457
+ "extension_id": {
458
+ "name": "extension_id",
459
+ "type": "text",
460
+ "primaryKey": false,
461
+ "notNull": true
462
+ },
463
+ "workspace_id": {
464
+ "name": "workspace_id",
465
+ "type": "text",
466
+ "primaryKey": false,
467
+ "notNull": true
468
+ },
469
+ "installed_at": {
470
+ "name": "installed_at",
471
+ "type": "timestamp with time zone",
472
+ "primaryKey": false,
473
+ "notNull": true,
474
+ "default": "now()"
475
+ },
476
+ "updated_at": {
477
+ "name": "updated_at",
478
+ "type": "timestamp with time zone",
479
+ "primaryKey": false,
480
+ "notNull": true,
481
+ "default": "now()"
482
+ }
483
+ },
484
+ "indexes": {
485
+ "workspace_installations_extension_id_idx": {
486
+ "name": "workspace_installations_extension_id_idx",
487
+ "columns": [
488
+ {
489
+ "expression": "extension_id",
490
+ "isExpression": false,
491
+ "asc": true,
492
+ "nulls": "last"
493
+ }
494
+ ],
495
+ "isUnique": false,
496
+ "concurrently": false,
497
+ "method": "btree",
498
+ "with": {}
499
+ }
500
+ },
501
+ "foreignKeys": {
502
+ "workspace_installations_extension_id_extensions_id_fk": {
503
+ "name": "workspace_installations_extension_id_extensions_id_fk",
504
+ "tableFrom": "workspace_installations",
505
+ "tableTo": "extensions",
506
+ "columnsFrom": [
507
+ "extension_id"
508
+ ],
509
+ "columnsTo": [
510
+ "id"
511
+ ],
512
+ "onDelete": "no action",
513
+ "onUpdate": "no action"
514
+ }
515
+ },
516
+ "compositePrimaryKeys": {},
517
+ "uniqueConstraints": {
518
+ "workspace_installations_extension_workspace_unique": {
519
+ "name": "workspace_installations_extension_workspace_unique",
520
+ "nullsNotDistinct": false,
521
+ "columns": [
522
+ "extension_id",
523
+ "workspace_id"
524
+ ]
525
+ }
526
+ },
527
+ "policies": {},
528
+ "checkConstraints": {},
529
+ "isRLSEnabled": false
530
+ },
531
+ "public.audit_events": {
532
+ "name": "audit_events",
533
+ "schema": "",
534
+ "columns": {
535
+ "id": {
536
+ "name": "id",
537
+ "type": "text",
538
+ "primaryKey": true,
539
+ "notNull": true
540
+ },
541
+ "actor": {
542
+ "name": "actor",
543
+ "type": "text",
544
+ "primaryKey": false,
545
+ "notNull": true
546
+ },
547
+ "action": {
548
+ "name": "action",
549
+ "type": "text",
550
+ "primaryKey": false,
551
+ "notNull": true
552
+ },
553
+ "extension_id": {
554
+ "name": "extension_id",
555
+ "type": "text",
556
+ "primaryKey": false,
557
+ "notNull": false
558
+ },
559
+ "workspace_id": {
560
+ "name": "workspace_id",
561
+ "type": "text",
562
+ "primaryKey": false,
563
+ "notNull": false
564
+ },
565
+ "metadata": {
566
+ "name": "metadata",
567
+ "type": "jsonb",
568
+ "primaryKey": false,
569
+ "notNull": false
570
+ },
571
+ "created_at": {
572
+ "name": "created_at",
573
+ "type": "timestamp with time zone",
574
+ "primaryKey": false,
575
+ "notNull": true,
576
+ "default": "now()"
577
+ }
578
+ },
579
+ "indexes": {
580
+ "audit_events_extension_id_idx": {
581
+ "name": "audit_events_extension_id_idx",
582
+ "columns": [
583
+ {
584
+ "expression": "extension_id",
585
+ "isExpression": false,
586
+ "asc": true,
587
+ "nulls": "last"
588
+ }
589
+ ],
590
+ "isUnique": false,
591
+ "concurrently": false,
592
+ "method": "btree",
593
+ "with": {}
594
+ }
595
+ },
596
+ "foreignKeys": {},
597
+ "compositePrimaryKeys": {},
598
+ "uniqueConstraints": {},
599
+ "policies": {},
600
+ "checkConstraints": {},
601
+ "isRLSEnabled": false
602
+ }
603
+ },
604
+ "enums": {},
605
+ "schemas": {},
606
+ "sequences": {},
607
+ "roles": {},
608
+ "policies": {},
609
+ "views": {},
610
+ "_meta": {
611
+ "columns": {},
612
+ "schemas": {},
613
+ "tables": {}
614
+ }
615
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1786508615130,
9
+ "tag": "0000_hesitant_joseph",
10
+ "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "7",
15
+ "when": 1786653489517,
16
+ "tag": "0001_deep_phil_sheldon",
17
+ "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "7",
22
+ "when": 1787471857722,
23
+ "tag": "0002_jittery_living_mummy",
24
+ "breakpoints": true
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,19 @@
1
+ import { defineConfig } from 'drizzle-kit';
2
+ import 'dotenv/config';
3
+
4
+ const connectionString = process.env.DATABASE_URL;
5
+ if (!connectionString) {
6
+ throw new Error(
7
+ 'DATABASE_URL is not set. Copy packages/marketplace/.env.example to packages/marketplace/.env ' +
8
+ 'after starting docker compose -f docker/marketplace-db.yml up, or export it before running drizzle-kit.',
9
+ );
10
+ }
11
+
12
+ export default defineConfig({
13
+ dialect: 'postgresql',
14
+ schema: './src/db/schema/index.ts',
15
+ out: './db/drizzle',
16
+ dbCredentials: { url: connectionString },
17
+ strict: true,
18
+ verbose: true,
19
+ });
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": false,
5
+ "outDir": "dist",
6
+ "rootDir": "../src/db",
7
+ "module": "NodeNext",
8
+ "moduleResolution": "NodeNext"
9
+ },
10
+ "exclude": ["../src/db/**/*.test.ts"]
11
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["esnext"],
4
+ "target": "ES2022",
5
+ "module": "esnext",
6
+ "moduleResolution": "bundler",
7
+ "strict": true,
8
+ "types": ["node"],
9
+ "skipLibCheck": true,
10
+ "esModuleInterop": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
13
+ "declaration": true
14
+ },
15
+ "include": ["../src/db/**/*.ts"],
16
+ "exclude": ["node_modules"]
17
+ }
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ['src/db/**/*.test.ts'],
6
+ exclude: ['node_modules/**'],
7
+ environment: 'node',
8
+ // Database tests share one connection pool.
9
+ fileParallelism: false,
10
+ },
11
+ });