refactor: 拆分品牌业务类型与页面方案
CI / Static checks (push) Has been cancelled
CI / Production build (push) Has been cancelled
CI / API integration (push) Has been cancelled
CI / Taro builds (acheng-campus-food) (push) Has been cancelled
CI / Taro builds (atelier-solopreneur) (push) Has been cancelled
CI / Taro builds (linjing-editorial) (push) Has been cancelled
CI / Browser regression (push) Has been cancelled
CI / Static checks (push) Has been cancelled
CI / Production build (push) Has been cancelled
CI / API integration (push) Has been cancelled
CI / Taro builds (acheng-campus-food) (push) Has been cancelled
CI / Taro builds (atelier-solopreneur) (push) Has been cancelled
CI / Taro builds (linjing-editorial) (push) Has been cancelled
CI / Browser regression (push) Has been cancelled
This commit is contained in:
1 parent
f02e2cafbb
commit
0d9f4a7d6f
86 files changed
+4111
-1543
No files matched your search
@@ -11,10 +11,15 @@ export type {
|
||||
export type {
|
||||
AdminBrandMember,
|
||||
AdminBrandMembership,
|
||||
BrandCreationOptions,
|
||||
BrandCreationOptionBusiness,
|
||||
BrandCreationOptionPageScheme,
|
||||
BrandPageSchemeOptions,
|
||||
BrandPresentationUpdate,
|
||||
BrandProfile,
|
||||
BrandReleaseSummary,
|
||||
BrandUpdate,
|
||||
CreateBrandInput,
|
||||
} from "./types/brand.js";
|
||||
export type { MiniAppReleaseSettings, MiniAppReleaseTask } from "./types/brand.js";
|
||||
export type { CapabilityInstallation } from "./types/capability.js";
|
||||
@@ -192,6 +197,11 @@ export class ApiClient
|
||||
this.resources.brand.getAdminBrand(...arguments_);
|
||||
listAdminBrands = (...arguments_: Parameters<BrandMethods["listAdminBrands"]>) =>
|
||||
this.resources.brand.listAdminBrands(...arguments_);
|
||||
getAdminBrandCreationOptions = (
|
||||
...arguments_: Parameters<BrandMethods["getAdminBrandCreationOptions"]>
|
||||
) => this.resources.brand.getAdminBrandCreationOptions(...arguments_);
|
||||
createAdminBrand = (...arguments_: Parameters<BrandMethods["createAdminBrand"]>) =>
|
||||
this.resources.brand.createAdminBrand(...arguments_);
|
||||
switchAdminBrand = (...arguments_: Parameters<BrandMethods["switchAdminBrand"]>) =>
|
||||
this.resources.brand.switchAdminBrand(...arguments_);
|
||||
listAdminMembers = (...arguments_: Parameters<BrandMethods["listAdminMembers"]>) =>
|
||||
@@ -291,6 +301,9 @@ export class ApiClient
|
||||
getAdminTemplateOperationFailures = (
|
||||
...arguments_: Parameters<TemplateMethods["getAdminTemplateOperationFailures"]>
|
||||
) => this.resources.template.getAdminTemplateOperationFailures(...arguments_);
|
||||
getAdminPageSchemeOptions = (
|
||||
...arguments_: Parameters<TemplateMethods["getAdminPageSchemeOptions"]>
|
||||
) => this.resources.template.getAdminPageSchemeOptions(...arguments_);
|
||||
getPublicOffering = (...arguments_: Parameters<OfferingMethods["getPublicOffering"]>) =>
|
||||
this.resources.offering.getPublicOffering(...arguments_);
|
||||
listPublicOfferings = (...arguments_: Parameters<OfferingMethods["listPublicOfferings"]>) =>
|
||||
|
||||
@@ -2,9 +2,11 @@ import type { RequestFn } from "../client/request.js";
|
||||
import type {
|
||||
AdminBrandMember,
|
||||
AdminBrandMembership,
|
||||
BrandCreationOptions,
|
||||
BrandPresentationUpdate,
|
||||
BrandProfile,
|
||||
BrandReleaseSummary,
|
||||
CreateBrandInput,
|
||||
MiniAppReleaseTask,
|
||||
MiniAppReleaseSettings,
|
||||
BrandUpdate,
|
||||
@@ -13,6 +15,11 @@ import type {
|
||||
export interface BrandMethods {
|
||||
getAdminBrand(): Promise<BrandProfile>;
|
||||
listAdminBrands(): Promise<AdminBrandMembership[]>;
|
||||
getAdminBrandCreationOptions(): Promise<BrandCreationOptions>;
|
||||
createAdminBrand(body: CreateBrandInput): Promise<{
|
||||
role: string;
|
||||
brand: AdminBrandMembership["brand"];
|
||||
}>;
|
||||
switchAdminBrand(
|
||||
brandId: string,
|
||||
): Promise<{ role: string; brand: AdminBrandMembership["brand"] }>;
|
||||
@@ -74,6 +81,8 @@ export function brandMethods({ request }: { request: RequestFn }): BrandMethods
|
||||
return {
|
||||
getAdminBrand: () => request("/admin/config/brand"),
|
||||
listAdminBrands: () => request("/admin/brands"),
|
||||
getAdminBrandCreationOptions: () => request("/admin/brands/creation-options"),
|
||||
createAdminBrand: (body) => request("/admin/brands", { method: "POST", body }),
|
||||
switchAdminBrand: (brandId) =>
|
||||
request(`/admin/brands/${encodeURIComponent(brandId)}/switch`, { method: "POST" }),
|
||||
listAdminMembers: () => request("/admin/brands/members"),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { BrandTemplateKey, RuntimeWorkspace } from "@personal-brand/types";
|
||||
import type { RequestFn } from "../client/request.js";
|
||||
import type { BrandProfile } from "../types/brand.js";
|
||||
import type { BrandPageSchemeOptions, BrandProfile } from "../types/brand.js";
|
||||
import type { CapabilityWithMetadata } from "../types/capability.js";
|
||||
import type { BrandFieldDefinition } from "../types/field.js";
|
||||
import type { Offering } from "../types/offering.js";
|
||||
@@ -8,6 +8,7 @@ import type { AdminTemplateContent } from "../types/template.js";
|
||||
import type { BrandTemplateDefinition } from "../types/template-definition.js";
|
||||
|
||||
export interface TemplateMethods {
|
||||
getAdminPageSchemeOptions(): Promise<BrandPageSchemeOptions>;
|
||||
listAdminTemplatePackages(params?: {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
@@ -310,6 +311,7 @@ export interface TemplatePackageImportResult {
|
||||
|
||||
export function templateMethods({ request }: { request: RequestFn }): TemplateMethods {
|
||||
return {
|
||||
getAdminPageSchemeOptions: () => request("/admin/workspace/template/options"),
|
||||
listAdminTemplatePackages: (params = {}) => {
|
||||
const query = [
|
||||
params.page === undefined ? null : `page=${encodeURIComponent(String(params.page))}`,
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { BrandTemplateKey } from "@personal-brand/types";
|
||||
|
||||
export interface BrandProfile {
|
||||
id: string;
|
||||
slug?: string;
|
||||
slug: string;
|
||||
name: string;
|
||||
templateKey: BrandTemplateKey;
|
||||
tagline: string | null;
|
||||
@@ -20,7 +20,39 @@ export interface BrandProfile {
|
||||
export interface AdminBrandMembership {
|
||||
id: string;
|
||||
role: string;
|
||||
brand: Pick<BrandProfile, "id" | "name" | "templateKey"> & { slug?: string };
|
||||
brand: Pick<BrandProfile, "id" | "name" | "templateKey" | "slug">;
|
||||
}
|
||||
|
||||
export interface BrandCreationOptionBusiness {
|
||||
key: BrandTemplateKey;
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface BrandCreationOptionPageScheme {
|
||||
templatePackageVersionId: string;
|
||||
name: string;
|
||||
description: string;
|
||||
version: string;
|
||||
supportedBusinessTypes: BrandTemplateKey[];
|
||||
isLatestForPackage: boolean;
|
||||
}
|
||||
|
||||
export interface BrandCreationOptions {
|
||||
businesses: BrandCreationOptionBusiness[];
|
||||
pageSchemes: BrandCreationOptionPageScheme[];
|
||||
}
|
||||
|
||||
export interface BrandPageSchemeOptions {
|
||||
business: BrandCreationOptionBusiness;
|
||||
pageSchemes: BrandCreationOptionPageScheme[];
|
||||
}
|
||||
|
||||
export interface CreateBrandInput {
|
||||
name: string;
|
||||
slug: string;
|
||||
businessType: BrandTemplateKey;
|
||||
templatePackageVersionId: string;
|
||||
}
|
||||
|
||||
export interface AdminBrandMember {
|
||||
|
||||
@@ -101,6 +101,40 @@ test("品牌切换客户端不再接收 token", async () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test("创建品牌与品牌内页面方案选项使用各自授权接口", async () => {
|
||||
const calls: Array<{ url: string; method?: string; body?: string }> = [];
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
token: "owner-token",
|
||||
fetcher: async (url, init) => {
|
||||
calls.push({ url, method: init?.method, body: init?.body });
|
||||
return response({});
|
||||
},
|
||||
});
|
||||
await client.getAdminBrandCreationOptions();
|
||||
await client.createAdminBrand({
|
||||
name: "林境门窗",
|
||||
slug: "linjing-windows",
|
||||
businessType: "doors",
|
||||
templatePackageVersionId: "version-1",
|
||||
});
|
||||
await client.getAdminPageSchemeOptions();
|
||||
assert.deepEqual(calls, [
|
||||
{ url: "http://api.test/admin/brands/creation-options", method: "GET", body: undefined },
|
||||
{
|
||||
url: "http://api.test/admin/brands",
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
name: "林境门窗",
|
||||
slug: "linjing-windows",
|
||||
businessType: "doors",
|
||||
templatePackageVersionId: "version-1",
|
||||
}),
|
||||
},
|
||||
{ url: "http://api.test/admin/workspace/template/options", method: "GET", body: undefined },
|
||||
]);
|
||||
});
|
||||
|
||||
test("客户端将统一错误响应转换为 ApiClientError", async () => {
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
@@ -206,7 +240,7 @@ test("模板目录客户端发送分页并支持版本发布和审计", async ()
|
||||
]);
|
||||
});
|
||||
|
||||
test("模板升级和回滚提交预览版本、checksum 与逐项保留确认", async () => {
|
||||
test("模板升级和回滚提交预览版本、checksum 与全部保留确认", async () => {
|
||||
const calls: Array<{ url: string; method?: string; body?: string }> = [];
|
||||
const client = new ApiClient({
|
||||
baseUrl: "http://api.test",
|
||||
|
||||
Reference in new issue
Block a user