@larkup/marketplace 0.1.25 → 0.2.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.
- package/.env +6 -0
- package/.env.example +3 -0
- package/.turbo/turbo-test.log +17 -0
- package/.turbo/turbo-type-check.log +4 -0
- package/CHANGELOG.md +183 -0
- package/README.md +34 -0
- package/db/dist/builtin-tools.d.ts +2 -0
- package/db/dist/builtin-tools.js +116 -0
- package/db/dist/client.d.ts +7 -0
- package/db/dist/client.js +20 -0
- package/db/dist/repo.d.ts +67 -0
- package/db/dist/repo.js +236 -0
- package/db/dist/schema/audit.d.ts +128 -0
- package/db/dist/schema/audit.js +18 -0
- package/db/dist/schema/extensions.d.ts +326 -0
- package/db/dist/schema/extensions.js +36 -0
- package/db/dist/schema/index.d.ts +5 -0
- package/db/dist/schema/index.js +5 -0
- package/db/dist/schema/installations.d.ts +93 -0
- package/db/dist/schema/installations.js +15 -0
- package/db/dist/schema/publishers.d.ts +110 -0
- package/db/dist/schema/publishers.js +12 -0
- package/db/dist/schema/versions.d.ts +127 -0
- package/db/dist/schema/versions.js +17 -0
- package/db/dist/seed.d.ts +2 -0
- package/db/dist/seed.js +31 -0
- package/db/dist/validate.d.ts +6 -0
- package/db/dist/validate.js +51 -0
- package/db/drizzle/0000_hesitant_joseph.sql +69 -0
- package/db/drizzle/0001_deep_phil_sheldon.sql +1 -0
- package/db/drizzle/0002_jittery_living_mummy.sql +18 -0
- package/db/drizzle/meta/0000_snapshot.json +483 -0
- package/db/drizzle/meta/0001_snapshot.json +490 -0
- package/db/drizzle/meta/0002_snapshot.json +615 -0
- package/db/drizzle/meta/_journal.json +27 -0
- package/db/drizzle.config.ts +19 -0
- package/db/tsconfig.build.json +11 -0
- package/db/tsconfig.json +17 -0
- package/db/vitest.config.ts +11 -0
- package/package.json +31 -4
- package/src/db/builtin-tools.ts +613 -0
- package/src/db/client.ts +26 -0
- package/src/db/repo.test.ts +309 -0
- package/src/db/repo.ts +558 -0
- package/src/db/schema/audit.ts +27 -0
- package/src/db/schema/extensions.ts +73 -0
- package/src/db/schema/index.ts +5 -0
- package/src/db/schema/installations.ts +23 -0
- package/src/db/schema/publishers.ts +13 -0
- package/src/db/schema/versions.ts +22 -0
- package/src/db/seed.ts +33 -0
- package/src/db/validate.test.ts +79 -0
- package/src/db/validate.ts +84 -0
- package/src/output-sanitizer.test.ts +17 -0
- package/src/output-sanitizer.ts +8 -0
- package/src/storage-provider-s3.test.ts +110 -0
- package/src/storage-provider.ts +164 -13
- package/src/tool-extension.ts +247 -0
- package/src/tool-installer.ts +80 -109
- package/src/tool-loader.test.ts +120 -0
- package/src/tool-loader.ts +99 -37
- package/src/tool-manifest.schema.ts +89 -32
- package/src/tool-registry.ts +34 -111
- package/src/types.ts +217 -87
- package/vitest.config.ts +13 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/** Immutable published extension versions. */
|
|
2
|
+
export declare const extensionVersions: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
3
|
+
name: "extension_versions";
|
|
4
|
+
schema: undefined;
|
|
5
|
+
columns: {
|
|
6
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
7
|
+
name: "id";
|
|
8
|
+
tableName: "extension_versions";
|
|
9
|
+
dataType: "string";
|
|
10
|
+
columnType: "PgText";
|
|
11
|
+
data: string;
|
|
12
|
+
driverParam: string;
|
|
13
|
+
notNull: true;
|
|
14
|
+
hasDefault: false;
|
|
15
|
+
isPrimaryKey: true;
|
|
16
|
+
isAutoincrement: false;
|
|
17
|
+
hasRuntimeDefault: false;
|
|
18
|
+
enumValues: [string, ...string[]];
|
|
19
|
+
baseColumn: never;
|
|
20
|
+
identity: undefined;
|
|
21
|
+
generated: undefined;
|
|
22
|
+
}, {}, {}>;
|
|
23
|
+
extensionId: import("drizzle-orm/pg-core").PgColumn<{
|
|
24
|
+
name: "extension_id";
|
|
25
|
+
tableName: "extension_versions";
|
|
26
|
+
dataType: "string";
|
|
27
|
+
columnType: "PgText";
|
|
28
|
+
data: string;
|
|
29
|
+
driverParam: string;
|
|
30
|
+
notNull: true;
|
|
31
|
+
hasDefault: false;
|
|
32
|
+
isPrimaryKey: false;
|
|
33
|
+
isAutoincrement: false;
|
|
34
|
+
hasRuntimeDefault: false;
|
|
35
|
+
enumValues: [string, ...string[]];
|
|
36
|
+
baseColumn: never;
|
|
37
|
+
identity: undefined;
|
|
38
|
+
generated: undefined;
|
|
39
|
+
}, {}, {}>;
|
|
40
|
+
version: import("drizzle-orm/pg-core").PgColumn<{
|
|
41
|
+
name: "version";
|
|
42
|
+
tableName: "extension_versions";
|
|
43
|
+
dataType: "string";
|
|
44
|
+
columnType: "PgText";
|
|
45
|
+
data: string;
|
|
46
|
+
driverParam: string;
|
|
47
|
+
notNull: true;
|
|
48
|
+
hasDefault: false;
|
|
49
|
+
isPrimaryKey: false;
|
|
50
|
+
isAutoincrement: false;
|
|
51
|
+
hasRuntimeDefault: false;
|
|
52
|
+
enumValues: [string, ...string[]];
|
|
53
|
+
baseColumn: never;
|
|
54
|
+
identity: undefined;
|
|
55
|
+
generated: undefined;
|
|
56
|
+
}, {}, {}>;
|
|
57
|
+
manifest: import("drizzle-orm/pg-core").PgColumn<{
|
|
58
|
+
name: "manifest";
|
|
59
|
+
tableName: "extension_versions";
|
|
60
|
+
dataType: "json";
|
|
61
|
+
columnType: "PgJsonb";
|
|
62
|
+
data: unknown;
|
|
63
|
+
driverParam: unknown;
|
|
64
|
+
notNull: true;
|
|
65
|
+
hasDefault: false;
|
|
66
|
+
isPrimaryKey: false;
|
|
67
|
+
isAutoincrement: false;
|
|
68
|
+
hasRuntimeDefault: false;
|
|
69
|
+
enumValues: undefined;
|
|
70
|
+
baseColumn: never;
|
|
71
|
+
identity: undefined;
|
|
72
|
+
generated: undefined;
|
|
73
|
+
}, {}, {}>;
|
|
74
|
+
integrity: import("drizzle-orm/pg-core").PgColumn<{
|
|
75
|
+
name: "integrity";
|
|
76
|
+
tableName: "extension_versions";
|
|
77
|
+
dataType: "string";
|
|
78
|
+
columnType: "PgText";
|
|
79
|
+
data: string;
|
|
80
|
+
driverParam: string;
|
|
81
|
+
notNull: true;
|
|
82
|
+
hasDefault: false;
|
|
83
|
+
isPrimaryKey: false;
|
|
84
|
+
isAutoincrement: false;
|
|
85
|
+
hasRuntimeDefault: false;
|
|
86
|
+
enumValues: [string, ...string[]];
|
|
87
|
+
baseColumn: never;
|
|
88
|
+
identity: undefined;
|
|
89
|
+
generated: undefined;
|
|
90
|
+
}, {}, {}>;
|
|
91
|
+
publishedBy: import("drizzle-orm/pg-core").PgColumn<{
|
|
92
|
+
name: "published_by";
|
|
93
|
+
tableName: "extension_versions";
|
|
94
|
+
dataType: "string";
|
|
95
|
+
columnType: "PgText";
|
|
96
|
+
data: string;
|
|
97
|
+
driverParam: string;
|
|
98
|
+
notNull: true;
|
|
99
|
+
hasDefault: false;
|
|
100
|
+
isPrimaryKey: false;
|
|
101
|
+
isAutoincrement: false;
|
|
102
|
+
hasRuntimeDefault: false;
|
|
103
|
+
enumValues: [string, ...string[]];
|
|
104
|
+
baseColumn: never;
|
|
105
|
+
identity: undefined;
|
|
106
|
+
generated: undefined;
|
|
107
|
+
}, {}, {}>;
|
|
108
|
+
publishedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
109
|
+
name: "published_at";
|
|
110
|
+
tableName: "extension_versions";
|
|
111
|
+
dataType: "date";
|
|
112
|
+
columnType: "PgTimestamp";
|
|
113
|
+
data: Date;
|
|
114
|
+
driverParam: string;
|
|
115
|
+
notNull: true;
|
|
116
|
+
hasDefault: true;
|
|
117
|
+
isPrimaryKey: false;
|
|
118
|
+
isAutoincrement: false;
|
|
119
|
+
hasRuntimeDefault: false;
|
|
120
|
+
enumValues: undefined;
|
|
121
|
+
baseColumn: never;
|
|
122
|
+
identity: undefined;
|
|
123
|
+
generated: undefined;
|
|
124
|
+
}, {}, {}>;
|
|
125
|
+
};
|
|
126
|
+
dialect: "pg";
|
|
127
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { index, jsonb, pgTable, text, timestamp, unique } from 'drizzle-orm/pg-core';
|
|
2
|
+
import { extensions } from './extensions.js';
|
|
3
|
+
/** Immutable published extension versions. */
|
|
4
|
+
export const extensionVersions = pgTable('extension_versions', {
|
|
5
|
+
id: text('id').primaryKey(),
|
|
6
|
+
extensionId: text('extension_id')
|
|
7
|
+
.notNull()
|
|
8
|
+
.references(() => extensions.id),
|
|
9
|
+
version: text('version').notNull(),
|
|
10
|
+
manifest: jsonb('manifest').notNull(),
|
|
11
|
+
integrity: text('integrity').notNull(),
|
|
12
|
+
publishedBy: text('published_by').notNull(),
|
|
13
|
+
publishedAt: timestamp('published_at', { withTimezone: true }).notNull().defaultNow(),
|
|
14
|
+
}, (table) => [
|
|
15
|
+
unique('extension_versions_extension_version_unique').on(table.extensionId, table.version),
|
|
16
|
+
index('extension_versions_extension_id_idx').on(table.extensionId),
|
|
17
|
+
]);
|
package/db/dist/seed.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Seeds built-in Marketplace tools. */
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
import { BUILTIN_TOOLS } from './builtin-tools.js';
|
|
4
|
+
import { getMarketplaceDb } from './client.js';
|
|
5
|
+
import { publishExtension, VersionExistsError } from './repo.js';
|
|
6
|
+
async function main() {
|
|
7
|
+
const db = getMarketplaceDb();
|
|
8
|
+
for (const manifest of BUILTIN_TOOLS) {
|
|
9
|
+
try {
|
|
10
|
+
await publishExtension(db, {
|
|
11
|
+
manifest,
|
|
12
|
+
publisherId: 'larkup',
|
|
13
|
+
publisherName: 'Larkup',
|
|
14
|
+
});
|
|
15
|
+
console.log(`seeded ${manifest.id}@${manifest.version}`);
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
if (err instanceof VersionExistsError) {
|
|
19
|
+
console.log(`already seeded: ${manifest.id}@${manifest.version}`);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
main()
|
|
27
|
+
.then(() => process.exit(0))
|
|
28
|
+
.catch((err) => {
|
|
29
|
+
console.error(err);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Validates Marketplace tool manifests. */
|
|
2
|
+
const ID_PATTERN = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
|
|
3
|
+
const VERSION_PATTERN = /^\d+\.\d+\.\d+/;
|
|
4
|
+
const CATEGORIES = [
|
|
5
|
+
'media',
|
|
6
|
+
'search',
|
|
7
|
+
'analytics',
|
|
8
|
+
'integration',
|
|
9
|
+
'embedding',
|
|
10
|
+
'ai',
|
|
11
|
+
'automation',
|
|
12
|
+
'utility',
|
|
13
|
+
];
|
|
14
|
+
const PRICING = ['free', 'pro', 'enterprise'];
|
|
15
|
+
export function validateToolManifest(manifest) {
|
|
16
|
+
const errors = [];
|
|
17
|
+
if (!manifest || typeof manifest !== 'object') {
|
|
18
|
+
return { valid: false, errors: ['manifest must be an object'] };
|
|
19
|
+
}
|
|
20
|
+
const m = manifest;
|
|
21
|
+
const requireString = (key) => {
|
|
22
|
+
if (typeof m[key] !== 'string' || !m[key])
|
|
23
|
+
errors.push(`"${key}" is required`);
|
|
24
|
+
};
|
|
25
|
+
requireString('id');
|
|
26
|
+
if (typeof m.id === 'string' && !ID_PATTERN.test(m.id)) {
|
|
27
|
+
errors.push('"id" must be lowercase alphanumeric with hyphens, e.g. "video-audio"');
|
|
28
|
+
}
|
|
29
|
+
requireString('name');
|
|
30
|
+
requireString('description');
|
|
31
|
+
requireString('icon');
|
|
32
|
+
requireString('packageName');
|
|
33
|
+
requireString('installSize');
|
|
34
|
+
requireString('author');
|
|
35
|
+
if (typeof m.category !== 'string' || !CATEGORIES.includes(m.category)) {
|
|
36
|
+
errors.push(`"category" must be one of: ${CATEGORIES.join(', ')}`);
|
|
37
|
+
}
|
|
38
|
+
if (typeof m.pricing !== 'string' || !PRICING.includes(m.pricing)) {
|
|
39
|
+
errors.push(`"pricing" must be one of: ${PRICING.join(', ')}`);
|
|
40
|
+
}
|
|
41
|
+
if (typeof m.version !== 'string' || !VERSION_PATTERN.test(m.version)) {
|
|
42
|
+
errors.push('"version" must be semver, e.g. "1.0.0"');
|
|
43
|
+
}
|
|
44
|
+
if (!Array.isArray(m.capabilities) || m.capabilities.length === 0) {
|
|
45
|
+
errors.push('"capabilities" must be a non-empty array');
|
|
46
|
+
}
|
|
47
|
+
if (m.requiresSandbox !== undefined && typeof m.requiresSandbox !== 'boolean') {
|
|
48
|
+
errors.push('"requiresSandbox" must be a boolean when provided');
|
|
49
|
+
}
|
|
50
|
+
return { valid: errors.length === 0, errors };
|
|
51
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
CREATE TABLE "publishers" (
|
|
2
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"name" text NOT NULL,
|
|
4
|
+
"contact_email" text,
|
|
5
|
+
"verification" text DEFAULT 'unverified' NOT NULL,
|
|
6
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
7
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
8
|
+
);
|
|
9
|
+
--> statement-breakpoint
|
|
10
|
+
CREATE TABLE "extension_workspace_grants" (
|
|
11
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
12
|
+
"extension_id" text NOT NULL,
|
|
13
|
+
"workspace_id" text NOT NULL,
|
|
14
|
+
"granted_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
15
|
+
);
|
|
16
|
+
--> statement-breakpoint
|
|
17
|
+
CREATE TABLE "extensions" (
|
|
18
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
19
|
+
"publisher_id" text NOT NULL,
|
|
20
|
+
"kind" text DEFAULT 'tool' NOT NULL,
|
|
21
|
+
"name" text NOT NULL,
|
|
22
|
+
"description" text NOT NULL,
|
|
23
|
+
"category" text NOT NULL,
|
|
24
|
+
"package_name" text NOT NULL,
|
|
25
|
+
"distribution" text DEFAULT 'public' NOT NULL,
|
|
26
|
+
"repository_url" text,
|
|
27
|
+
"license" text,
|
|
28
|
+
"deprecated_at" timestamp with time zone,
|
|
29
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
30
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
31
|
+
);
|
|
32
|
+
--> statement-breakpoint
|
|
33
|
+
CREATE TABLE "extension_versions" (
|
|
34
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
35
|
+
"extension_id" text NOT NULL,
|
|
36
|
+
"version" text NOT NULL,
|
|
37
|
+
"manifest" jsonb NOT NULL,
|
|
38
|
+
"integrity" text NOT NULL,
|
|
39
|
+
"published_by" text NOT NULL,
|
|
40
|
+
"published_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
41
|
+
CONSTRAINT "extension_versions_extension_version_unique" UNIQUE("extension_id","version")
|
|
42
|
+
);
|
|
43
|
+
--> statement-breakpoint
|
|
44
|
+
CREATE TABLE "workspace_installations" (
|
|
45
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
46
|
+
"extension_id" text NOT NULL,
|
|
47
|
+
"workspace_id" text NOT NULL,
|
|
48
|
+
"installed_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
49
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
50
|
+
CONSTRAINT "workspace_installations_extension_workspace_unique" UNIQUE("extension_id","workspace_id")
|
|
51
|
+
);
|
|
52
|
+
--> statement-breakpoint
|
|
53
|
+
CREATE TABLE "audit_events" (
|
|
54
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
55
|
+
"actor" text NOT NULL,
|
|
56
|
+
"action" text NOT NULL,
|
|
57
|
+
"extension_id" text,
|
|
58
|
+
"workspace_id" text,
|
|
59
|
+
"metadata" jsonb,
|
|
60
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
61
|
+
);
|
|
62
|
+
--> statement-breakpoint
|
|
63
|
+
ALTER TABLE "extension_workspace_grants" ADD CONSTRAINT "extension_workspace_grants_extension_id_extensions_id_fk" FOREIGN KEY ("extension_id") REFERENCES "public"."extensions"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
64
|
+
ALTER TABLE "extensions" ADD CONSTRAINT "extensions_publisher_id_publishers_id_fk" FOREIGN KEY ("publisher_id") REFERENCES "public"."publishers"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
65
|
+
ALTER TABLE "extension_versions" ADD CONSTRAINT "extension_versions_extension_id_extensions_id_fk" FOREIGN KEY ("extension_id") REFERENCES "public"."extensions"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
66
|
+
ALTER TABLE "workspace_installations" ADD CONSTRAINT "workspace_installations_extension_id_extensions_id_fk" FOREIGN KEY ("extension_id") REFERENCES "public"."extensions"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
67
|
+
CREATE INDEX "extension_versions_extension_id_idx" ON "extension_versions" USING btree ("extension_id");--> statement-breakpoint
|
|
68
|
+
CREATE INDEX "workspace_installations_extension_id_idx" ON "workspace_installations" USING btree ("extension_id");--> statement-breakpoint
|
|
69
|
+
CREATE INDEX "audit_events_extension_id_idx" ON "audit_events" USING btree ("extension_id");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "extensions" ADD COLUMN "requires_sandbox" boolean DEFAULT true NOT NULL;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
CREATE TABLE "extension_access_keys" (
|
|
2
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"extension_id" text NOT NULL,
|
|
4
|
+
"key_hash" text NOT NULL,
|
|
5
|
+
"key_prefix" text NOT NULL,
|
|
6
|
+
"scope" text NOT NULL,
|
|
7
|
+
"scope_id" text,
|
|
8
|
+
"max_installs" integer,
|
|
9
|
+
"install_count" integer DEFAULT 0 NOT NULL,
|
|
10
|
+
"expires_at" timestamp with time zone,
|
|
11
|
+
"revoked_at" timestamp with time zone,
|
|
12
|
+
"created_by" text NOT NULL,
|
|
13
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
14
|
+
CONSTRAINT "extension_access_keys_key_hash_unique" UNIQUE("key_hash")
|
|
15
|
+
);
|
|
16
|
+
--> statement-breakpoint
|
|
17
|
+
ALTER TABLE "extension_access_keys" ADD CONSTRAINT "extension_access_keys_extension_id_extensions_id_fk" FOREIGN KEY ("extension_id") REFERENCES "public"."extensions"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
18
|
+
CREATE INDEX "extension_access_keys_extension_id_idx" ON "extension_access_keys" USING btree ("extension_id");
|