better-design 0.35.0 → 0.35.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/dist/index.js +44 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13676,7 +13676,7 @@ function parseShopifyPrimitiveSet(value) {
|
|
|
13676
13676
|
const parsed = shopifyPrimitiveSetSchema.safeParse(value);
|
|
13677
13677
|
return parsed.success ? parsed.data : null;
|
|
13678
13678
|
}
|
|
13679
|
-
var SHOPIFY_PRIMITIVE_CONTRACT_VERSION, SHOPIFY_ICON_MATERIAL_VERSION, shopifyThemeFileSchema, primitiveFields, iconLibrarySchema, currentShopifyPrimitiveSetSchema, shopifyPrimitiveSetSchema, localImport;
|
|
13679
|
+
var SHOPIFY_PRIMITIVE_CONTRACT_VERSION, SHOPIFY_ICON_MATERIAL_VERSION, SHOPIFY_PILOT_REQUIRED, shopifyThemeFileSchema, primitiveFields, iconLibrarySchema, currentShopifyPrimitiveSetSchema, shopifyPrimitiveSetSchema, localImport;
|
|
13680
13680
|
var init_shopify_primitives = __esm({
|
|
13681
13681
|
"../shared/src/mcp/shopify-primitives.ts"() {
|
|
13682
13682
|
"use strict";
|
|
@@ -13688,6 +13688,7 @@ var init_shopify_primitives = __esm({
|
|
|
13688
13688
|
init_shopify_icons();
|
|
13689
13689
|
SHOPIFY_PRIMITIVE_CONTRACT_VERSION = 1;
|
|
13690
13690
|
SHOPIFY_ICON_MATERIAL_VERSION = 2;
|
|
13691
|
+
SHOPIFY_PILOT_REQUIRED = "SHOPIFY_PILOT_REQUIRED";
|
|
13691
13692
|
shopifyThemeFileSchema = z12.object({
|
|
13692
13693
|
path: z12.string().min(1),
|
|
13693
13694
|
content: z12.string().min(1)
|
|
@@ -13848,6 +13849,9 @@ function parseProjectShopifyPrimitives(projectId, name, value) {
|
|
|
13848
13849
|
primitives
|
|
13849
13850
|
};
|
|
13850
13851
|
}
|
|
13852
|
+
function shopifyPilotDenied(name, subject, viewUrl) {
|
|
13853
|
+
return `Shopify target unavailable. The Shopify kit is a private pilot and this API key is not in it, so the stored theme for ${name} was withheld. Nothing is wrong with the ${subject}. To join the pilot, email info@better-design.com. Until then, use target "react" or "html". See ${viewUrl}.`;
|
|
13854
|
+
}
|
|
13851
13855
|
async function fetchProjectShopifyPrimitives(projectId, apiFetch, authContext) {
|
|
13852
13856
|
try {
|
|
13853
13857
|
const res = await apiFetch(
|
|
@@ -14377,14 +14381,18 @@ ${fence3}` }],
|
|
|
14377
14381
|
if (projectId) {
|
|
14378
14382
|
const viewUrl2 = `${APP_BASE_URL}/projects/${projectId}`;
|
|
14379
14383
|
const providerResult = await provider.getProjectShopifyPrimitives?.(projectId);
|
|
14380
|
-
const
|
|
14384
|
+
const denied = Boolean(providerResult && "shopifyAccess" in providerResult);
|
|
14385
|
+
const result = denied ? null : providerResult && "shopifyPrimitives" in providerResult ? parseProjectShopifyPrimitives(
|
|
14381
14386
|
projectId,
|
|
14382
14387
|
providerResult.name,
|
|
14383
14388
|
providerResult.shopifyPrimitives
|
|
14384
14389
|
) : await fetchProjectShopifyPrimitives(projectId, apiFetch, authContext);
|
|
14385
14390
|
if (!result) {
|
|
14386
14391
|
return {
|
|
14387
|
-
content: [{
|
|
14392
|
+
content: [{
|
|
14393
|
+
type: "text",
|
|
14394
|
+
text: denied ? shopifyPilotDenied(`project "${projectId}"`, "project", viewUrl2) : `Shopify version unavailable. Project "${projectId}" has no maintained Shopify primitive set yet. It may still be generating, belong to another account, or predate Shopify persistence. Check ${viewUrl2}.`
|
|
14395
|
+
}],
|
|
14388
14396
|
structuredContent: { status: "error", name: `Project ${projectId.slice(0, 8)}`, viewUrl: viewUrl2, tokensCss: "" }
|
|
14389
14397
|
};
|
|
14390
14398
|
}
|
|
@@ -14414,7 +14422,7 @@ ${fence3}` }],
|
|
|
14414
14422
|
const viewUrl = `${APP_BASE_URL}/design-systems/${designSystemId}`;
|
|
14415
14423
|
const primitives = parseShopifyPrimitiveSet(ds.metadata.shopifyPrimitives);
|
|
14416
14424
|
if (!primitives) {
|
|
14417
|
-
const text3 = ds.metadata.shopifyAccess === "denied" ? `
|
|
14425
|
+
const text3 = ds.metadata.shopifyAccess === "denied" ? shopifyPilotDenied(`"${designSystemId}"`, "design system", viewUrl) : `Shopify version unavailable. Design system "${designSystemId}" has no maintained Shopify primitive set. Shopify output is unavailable until that system is seeded and certified; no generic fallback was returned. See ${viewUrl}.`;
|
|
14418
14426
|
return {
|
|
14419
14427
|
content: [{ type: "text", text: text3 }],
|
|
14420
14428
|
structuredContent: { status: "error", name: ds.metadata.title, viewUrl, tokensCss: "" }
|
|
@@ -23364,7 +23372,7 @@ var init_agent_feedback = __esm({
|
|
|
23364
23372
|
|
|
23365
23373
|
// ../shared/src/schema.ts
|
|
23366
23374
|
import { z as z17 } from "zod";
|
|
23367
|
-
var vector2, messageRoleEnum, messageTypeEnum, designSystemStatusEnum, onboardingPathValues, onboardingPathSchema, onboardingPathSqlValues, mcpIssueCategoryValues, mcpIssueStatusValues, mcpIssueImprovementStatusValues, mcpIssueImprovementVerdictValues, mcpIssueImprovementStatusSchema, mcpIssueImprovementVerdictSchema, mcpIssueImprovementStatusSqlValues, mcpIssueImprovementVerdictSqlValues, designConfigSchema, projectMemoryDataSchema, projects, messages, projectMemory, fragments, usage, scrapeBlock, resourceAccess, user, signupAlertDeliveries, billingAlertDeliveries, billingEmailDeliveries, TEAM_RULES_MAX_BYTES, teamRules, agentFeedbackStatusValues, agentFeedback, billingSubscription, githubInstallationClaim, githubInstallation, featureAccess, session, account, verification, jwks, oauthClient, oauthRefreshToken, oauthAccessToken, oauthConsent, designSystems, designSystemComponents, foundationalDocs, apiKeys, emailCampaignSends, emailCampaignSteps, projectEvents, iconLibraries, dsSearchQueries, mcpToolCalls, mcpClientConnections, evalVerdicts, generationInputs, mcpIssues, mcpIssueImprovements, projectsRelations, projectMemoryRelations, mcpIssuesRelations, mcpIssueImprovementsRelations, messagesRelations, fragmentsRelations, designSystemsRelations, designSystemComponentsRelations, insertProjectSchema, selectProjectSchema, insertMessageSchema, selectMessageSchema, insertFragmentSchema, selectFragmentSchema, insertProjectMemorySchema, selectProjectMemorySchema, insertDesignSystemSchema, selectDesignSystemSchema, insertDesignSystemComponentSchema, selectDesignSystemComponentSchema, insertFoundationalDocSchema, selectFoundationalDocSchema, insertIconLibrarySchema, selectIconLibrarySchema, insertApiKeySchema, selectApiKeySchema, insertUserSchema, selectUserSchema, insertSignupAlertDeliverySchema, selectSignupAlertDeliverySchema, insertEmailCampaignSendSchema, selectEmailCampaignSendSchema, insertEmailCampaignStepSchema, selectEmailCampaignStepSchema, insertMcpIssueImprovementSchema, selectMcpIssueImprovementSchema, pluginAuthNonces;
|
|
23375
|
+
var vector2, messageRoleEnum, messageTypeEnum, designSystemStatusEnum, onboardingPathValues, onboardingPathSchema, onboardingPathSqlValues, mcpIssueCategoryValues, mcpIssueStatusValues, mcpIssueImprovementStatusValues, mcpIssueImprovementVerdictValues, mcpIssueImprovementStatusSchema, mcpIssueImprovementVerdictSchema, mcpIssueImprovementStatusSqlValues, mcpIssueImprovementVerdictSqlValues, designConfigSchema, projectMemoryDataSchema, projects, messages, projectMemory, fragments, usage, scrapeBlock, resourceAccess, user, signupAlertDeliveries, billingAlertDeliveries, billingEmailDeliveries, TEAM_RULES_MAX_BYTES, teamRules, agentFeedbackStatusValues, agentFeedback, billingSubscription, githubInstallationClaim, githubInstallation, featureAccess, session, account, verification, jwks, oauthClient, oauthRefreshToken, oauthAccessToken, oauthConsent, designSystems, designSystemComponents, foundationalDocs, apiKeys, emailCampaignSends, emailCampaignSteps, projectEvents, adminProjectReadRouteValues, adminProjectReads, iconLibraries, dsSearchQueries, mcpToolCalls, mcpClientConnections, evalVerdicts, generationInputs, mcpIssues, mcpIssueImprovements, projectsRelations, projectMemoryRelations, mcpIssuesRelations, mcpIssueImprovementsRelations, messagesRelations, fragmentsRelations, designSystemsRelations, designSystemComponentsRelations, insertProjectSchema, selectProjectSchema, insertMessageSchema, selectMessageSchema, insertFragmentSchema, selectFragmentSchema, insertProjectMemorySchema, selectProjectMemorySchema, insertDesignSystemSchema, selectDesignSystemSchema, insertDesignSystemComponentSchema, selectDesignSystemComponentSchema, insertFoundationalDocSchema, selectFoundationalDocSchema, insertIconLibrarySchema, selectIconLibrarySchema, insertApiKeySchema, selectApiKeySchema, insertUserSchema, selectUserSchema, insertSignupAlertDeliverySchema, selectSignupAlertDeliverySchema, insertEmailCampaignSendSchema, selectEmailCampaignSendSchema, insertEmailCampaignStepSchema, selectEmailCampaignStepSchema, insertMcpIssueImprovementSchema, selectMcpIssueImprovementSchema, pluginAuthNonces;
|
|
23368
23376
|
var init_schema2 = __esm({
|
|
23369
23377
|
"../shared/src/schema.ts"() {
|
|
23370
23378
|
"use strict";
|
|
@@ -24128,6 +24136,25 @@ var init_schema2 = __esm({
|
|
|
24128
24136
|
},
|
|
24129
24137
|
(t) => [index("project_events_project_id_id_idx").on(t.projectId, t.id)]
|
|
24130
24138
|
);
|
|
24139
|
+
adminProjectReadRouteValues = ["project", "messages", "events"];
|
|
24140
|
+
adminProjectReads = pgTable(
|
|
24141
|
+
"admin_project_reads",
|
|
24142
|
+
{
|
|
24143
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
24144
|
+
adminUserId: text("admin_user_id").notNull(),
|
|
24145
|
+
/** The project's owner at the time of the read. */
|
|
24146
|
+
targetUserId: text("target_user_id").notNull(),
|
|
24147
|
+
projectId: uuid("project_id").notNull(),
|
|
24148
|
+
route: text("route", { enum: adminProjectReadRouteValues }).notNull(),
|
|
24149
|
+
/** The UTC hour the read fell in. */
|
|
24150
|
+
readHour: timestamp("read_hour", { withTimezone: true }).notNull(),
|
|
24151
|
+
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull()
|
|
24152
|
+
},
|
|
24153
|
+
(t) => [
|
|
24154
|
+
index("admin_project_reads_created_at_idx").on(t.createdAt),
|
|
24155
|
+
uniqueIndex("admin_project_reads_hour_uniq").on(t.adminUserId, t.projectId, t.route, t.readHour)
|
|
24156
|
+
]
|
|
24157
|
+
);
|
|
24131
24158
|
iconLibraries = pgTable("icon_libraries", {
|
|
24132
24159
|
id: text("id").primaryKey(),
|
|
24133
24160
|
name: text("name").notNull(),
|
|
@@ -29586,7 +29613,7 @@ var MCP_IMPLEMENTATION_VERSION;
|
|
|
29586
29613
|
var init_version2 = __esm({
|
|
29587
29614
|
"../shared/src/mcp/version.ts"() {
|
|
29588
29615
|
"use strict";
|
|
29589
|
-
MCP_IMPLEMENTATION_VERSION = "0.35.
|
|
29616
|
+
MCP_IMPLEMENTATION_VERSION = "0.35.1";
|
|
29590
29617
|
}
|
|
29591
29618
|
});
|
|
29592
29619
|
|
|
@@ -29752,7 +29779,8 @@ async function request(path6, options = {}) {
|
|
|
29752
29779
|
});
|
|
29753
29780
|
if (!res.ok) {
|
|
29754
29781
|
const body = await res.json().catch(() => ({ message: res.statusText }));
|
|
29755
|
-
|
|
29782
|
+
const { message, code } = body;
|
|
29783
|
+
throw new ApiError(res.status, message ?? `API error ${res.status}`, code);
|
|
29756
29784
|
}
|
|
29757
29785
|
return res.json();
|
|
29758
29786
|
}
|
|
@@ -29802,7 +29830,12 @@ async function getProjectMobilePrimitives(projectId) {
|
|
|
29802
29830
|
return request(`/projects/${encodeURIComponent(projectId)}/mobile/all.json`);
|
|
29803
29831
|
}
|
|
29804
29832
|
async function getProjectShopifyPrimitives(projectId) {
|
|
29805
|
-
|
|
29833
|
+
try {
|
|
29834
|
+
return await request(`/projects/${encodeURIComponent(projectId)}/shopify/all.json`);
|
|
29835
|
+
} catch (err) {
|
|
29836
|
+
if (err instanceof ApiError && err.code === SHOPIFY_PILOT_REQUIRED) return { shopifyAccess: "denied" };
|
|
29837
|
+
throw err;
|
|
29838
|
+
}
|
|
29806
29839
|
}
|
|
29807
29840
|
async function listPrinciples(area) {
|
|
29808
29841
|
const params = area ? `?area=${area}` : "";
|
|
@@ -29882,14 +29915,16 @@ var API_URL2, API_KEY, API_KEY_HASH, ApiError;
|
|
|
29882
29915
|
var init_api_client = __esm({
|
|
29883
29916
|
"src/lib/api-client.ts"() {
|
|
29884
29917
|
"use strict";
|
|
29918
|
+
init_shopify_primitives();
|
|
29885
29919
|
init_api_url();
|
|
29886
29920
|
API_URL2 = resolveApiUrl();
|
|
29887
29921
|
API_KEY = process.env.BETTER_DESIGN_API_KEY;
|
|
29888
29922
|
API_KEY_HASH = API_KEY ? createHash3("sha256").update(API_KEY).digest("hex") : void 0;
|
|
29889
29923
|
ApiError = class extends Error {
|
|
29890
|
-
constructor(status, message) {
|
|
29924
|
+
constructor(status, message, code) {
|
|
29891
29925
|
super(message);
|
|
29892
29926
|
this.status = status;
|
|
29927
|
+
this.code = code;
|
|
29893
29928
|
this.name = "ApiError";
|
|
29894
29929
|
}
|
|
29895
29930
|
};
|