UNPKG

@wishcbg/bobcode

Version:

基於店家同步功能的需求,讓店家能夠在不同的店家之間同步各項功能設定,並且能夠檢視各項功能的異動情況。 規劃出一套店家設定即程式碼的機制,讓店家能夠以 config file (.sac) 來定義各項功能設定,並且能夠還原店家各項功能設定。 暫且稱這個機制為「Settings as Code」「店家設定即程式碼」。

52 lines (51 loc) 1.75 kB
import * as zod from 'zod'; import Bob from '../utils/bobAPI.js'; type RelationScope = 'shop' | 'org'; type RelationType = 'single' | 'multi'; export type RelationResource = { resourceType: string; settingSchemaField: string; relationType: RelationType; useLogicIdToResourceId?: boolean; logicIdToResourceIdNewField?: string; acceptsNullValue?: boolean; }; export type PathParams = { shopId: string; resourceId?: string; }; export interface BaseResourceSchema<S extends zod.ZodTypeAny = zod.ZodTypeAny> { /** 資源識別 */ resourceType: string; resourceName: string; /** 設定結構 (Zod schema) */ resourceSettingSchema: S; /** 關聯範圍 & 類型 */ relationScope: RelationScope; relationType: RelationType; /** 定義關聯資源 */ relationResources: RelationResource[]; /** Apply API 路徑 */ applySingleUpdateApiPath: string | null; applyCreateApiPath: string | null; applyUpdateApiPath: string | null; applyDestroyApiPath: string | null; /** Apply API config (可動態調整 query/body) */ applySingleUpdateApiBodyTransform?: (pathParams: PathParams, body: any, bobApi: Bob) => Promise<{ apiPath: string | null; apiBody: any; }>; applyCreateApiBodyTransform?: (pathParams: PathParams, body: any, bobApi: Bob) => Promise<{ apiPath: string | null; apiBody: any; }>; applyUpdateApiBodyTransform?: (pathParams: PathParams, body: any, bobApi: Bob) => Promise<{ apiPath: string | null; apiBody: any; }>; applyDestroyApiBodyTransform?: (pathParams: PathParams, body: any, bobApi: Bob) => Promise<{ apiPath: string | null; apiBody: any; }>; } export {};