UNPKG

@wishcbg/bobcode

Version:

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

60 lines (59 loc) 2.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MemberGameResourceSchema = exports.memberGameResourceSettingSchema = void 0; const zod_1 = require("zod"); const requirementTypes = ['memberCard', 'totalUsed', 'dayUsed', 'memberTag', 'costPoint']; const requirementItemSchema = zod_1.z.object({ type: zod_1.z.enum(requirementTypes).describe('抽獎條件類型'), levels: zod_1.z.array(zod_1.z.number().int().min(0)).optional().describe('會員卡等級'), // TODO tags: zod_1.z.array(zod_1.z.string().uuid().optional().describe('會員標籤')), times: zod_1.z.number().int().min(1).optional().describe('次數限制'), costAmount: zod_1.z.number().int().min(1).optional().describe('抽獎權益數量'), // TODO shopPointKey: zod_1.z.string().optional().describe('店家點數服務 key'), }); exports.memberGameResourceSettingSchema = zod_1.z.object({ name: zod_1.z.string().describe('遊戲名稱'), enable: zod_1.z.boolean().describe('狀態'), startAt: zod_1.z.coerce.date().describe('開始時間'), endAt: zod_1.z.coerce.date().describe('結束時間'), checkEnableTimerNotifyId: zod_1.z.string().uuid().optional().describe('檢查是否啟用的定時器通知ID'), description: zod_1.z.string().optional().describe('活動說明'), notice: zod_1.z.string().optional().describe('注意事項'), againDelay: zod_1.z.boolean().default(false).describe('再抽一次是否延遲'), requirements: zod_1.z.array(requirementItemSchema).describe('抽獎條件設定'), imageLogicId: zod_1.z.string().uuid().optional(), memberGameModeLogicId: zod_1.z.string().uuid(), }).describe('抽獎設定'); // 改成export一個 config 而不是class exports.MemberGameResourceSchema = { // —— 基本欄位 resourceType: 'memberGame', resourceName: '抽獎設定', resourceSettingSchema: exports.memberGameResourceSettingSchema, // —— 關聯 relationScope: 'shop', relationType: 'multi', relationResources: [ { resourceType: 'image', useLogicIdToResourceId: false, settingSchemaField: 'imageLogicId', logicIdToResourceIdNewField: 'image', relationType: 'single', acceptsNullValue: true, }, { resourceType: 'memberGameMode', settingSchemaField: 'memberGameModeLogicId', logicIdToResourceIdNewField: 'memberGameModeId', relationType: 'single', }, ], // —— apply API path applySingleUpdateApiPath: null, applyCreateApiPath: '/:shopId/memberGame', applyUpdateApiPath: '/:shopId/memberGame/:resourceId', applyDestroyApiPath: '/:shopId/memberGame/:resourceId', };