spoclip-kit 2.6.0 → 4.0.0
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/README.md +17 -9
- package/dist/index.cjs +49 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +46 -76
- package/dist/index.js.map +1 -1
- package/dist/libs.cjs +51 -81
- package/dist/libs.cjs.map +1 -1
- package/dist/libs.d.cts +22 -53
- package/dist/libs.d.ts +22 -53
- package/dist/libs.js +47 -77
- package/dist/libs.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +0 -2
- package/dist/types.d.ts +0 -2
- package/package.json +1 -1
- package/dist/membership-C_ziSHS0.d.cts +0 -3
- package/dist/membership-C_ziSHS0.d.ts +0 -3
package/README.md
CHANGED
|
@@ -13,15 +13,23 @@ npm install spoclip-kit
|
|
|
13
13
|
### Import specific modules
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
import {
|
|
17
|
+
calculateOriginalDownloadCostWon,
|
|
18
|
+
isDownloadDurationAllowed,
|
|
19
|
+
} from 'spoclip-kit/libs';
|
|
20
|
+
|
|
21
|
+
// 10초 미만은 다운로드 불가
|
|
22
|
+
isDownloadDurationAllowed(8); // false
|
|
23
|
+
isDownloadDurationAllowed(60); // true
|
|
24
|
+
|
|
25
|
+
// 30초 무료 + 초과분 100원/분 (멤버십 구분 없음)
|
|
26
|
+
calculateOriginalDownloadCostWon(60); // 50 (30초 초과분 30초 과금)
|
|
27
|
+
|
|
28
|
+
// 전체 영상 10% 할인
|
|
29
|
+
calculateOriginalDownloadCostWon(60, { isFullVideo: true }); // 45
|
|
30
|
+
|
|
31
|
+
// 중복 화각 동시 다운로드 (단일 화각 비용 × 화각 수)
|
|
32
|
+
calculateOriginalDownloadCostWon(60, { angleCount: 3 }); // 150
|
|
25
33
|
```
|
|
26
34
|
|
|
27
35
|
## Development
|
package/dist/index.cjs
CHANGED
|
@@ -20,15 +20,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
-
|
|
23
|
+
GYM_GOLD_CHARGE_POLICY: () => GYM_GOLD_CHARGE_POLICY,
|
|
24
24
|
MIN_DOWNLOAD_SECONDS: () => MIN_DOWNLOAD_SECONDS,
|
|
25
25
|
ORIGINAL_DOWNLOAD_COST_POLICY: () => ORIGINAL_DOWNLOAD_COST_POLICY,
|
|
26
|
-
|
|
27
|
-
calculateGymPartnerRegistrationGoldTotal: () => calculateGymPartnerRegistrationGoldTotal,
|
|
26
|
+
assertValidGymGoldChargeKrw: () => assertValidGymGoldChargeKrw,
|
|
28
27
|
calculateOriginalDownloadCostWon: () => calculateOriginalDownloadCostWon,
|
|
29
28
|
color: () => color,
|
|
30
29
|
colorV2: () => colorV2,
|
|
31
30
|
isDownloadDurationAllowed: () => isDownloadDurationAllowed,
|
|
31
|
+
isGymGoldChargeKrwAllowed: () => isGymGoldChargeKrwAllowed,
|
|
32
32
|
mobileTypo: () => mobileTypo,
|
|
33
33
|
typo: () => typo
|
|
34
34
|
});
|
|
@@ -36,30 +36,20 @@ module.exports = __toCommonJS(src_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/libs/cost.ts
|
|
38
38
|
var ORIGINAL_DOWNLOAD_COST_POLICY = {
|
|
39
|
-
baseDurationSeconds: 600,
|
|
40
|
-
baseCostWon: 2e3,
|
|
41
|
-
fullVideoDiscountRate: 0.1,
|
|
42
39
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
40
|
+
* 무료 다운로드 구간(초). 멤버십 구분 없이 모든 사용자에게 동일하게 적용한다.
|
|
41
|
+
* 다운로드 길이 중 앞 `freeSeconds`초는 과금에서 제외하고,
|
|
42
|
+
* 이를 초과한 구간에만 `krwPerMinute` 요율을 적용한다 (초과분 과금).
|
|
46
43
|
*/
|
|
47
|
-
|
|
48
|
-
FREE: 100,
|
|
49
|
-
PLUS: 50,
|
|
50
|
-
PRO: 25
|
|
51
|
-
},
|
|
44
|
+
freeSeconds: 30,
|
|
52
45
|
/**
|
|
53
|
-
* 멤버십
|
|
54
|
-
* 다운로드 길이 중 앞 `freeSecondsByPlan[plan]`초는 과금에서 제외하고,
|
|
55
|
-
* 이를 초과한 구간에만 `perPlanKrwPerMinute[plan]` 요율을 적용한다 (초과분 과금).
|
|
56
|
-
* plan 미지정(레거시 단일 단가) 경로에는 무료 구간을 적용하지 않는다.
|
|
46
|
+
* 무료 구간 초과분에 적용하는 분당 KRW 요율. 멤버십 구분 없는 단일 요율.
|
|
57
47
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
48
|
+
krwPerMinute: 100,
|
|
49
|
+
/**
|
|
50
|
+
* 전체 영상 다운로드 시 할인율(10%).
|
|
51
|
+
*/
|
|
52
|
+
fullVideoDiscountRate: 0.1
|
|
63
53
|
};
|
|
64
54
|
var MIN_DOWNLOAD_SECONDS = 10;
|
|
65
55
|
function isDownloadDurationAllowed(durationSeconds) {
|
|
@@ -67,67 +57,47 @@ function isDownloadDurationAllowed(durationSeconds) {
|
|
|
67
57
|
}
|
|
68
58
|
function calculateOriginalDownloadCostWon(durationSeconds, options = {}) {
|
|
69
59
|
if (!Number.isFinite(durationSeconds) || durationSeconds <= 0) return 0;
|
|
70
|
-
const {
|
|
71
|
-
const
|
|
72
|
-
const billableSeconds = Math.max(
|
|
60
|
+
const { isFullVideo, angleCount } = options;
|
|
61
|
+
const normalizedAngleCount = Number.isFinite(angleCount) ? Math.max(1, Math.floor(angleCount)) : 1;
|
|
62
|
+
const billableSeconds = Math.max(
|
|
63
|
+
0,
|
|
64
|
+
durationSeconds - ORIGINAL_DOWNLOAD_COST_POLICY.freeSeconds
|
|
65
|
+
);
|
|
73
66
|
if (billableSeconds <= 0) return 0;
|
|
74
|
-
const unitPricePerSecond =
|
|
67
|
+
const unitPricePerSecond = ORIGINAL_DOWNLOAD_COST_POLICY.krwPerMinute / 60;
|
|
75
68
|
const discountMultiplier = isFullVideo ? 1 - ORIGINAL_DOWNLOAD_COST_POLICY.fullVideoDiscountRate : 1;
|
|
76
|
-
const
|
|
77
|
-
|
|
69
|
+
const rawCostPerAngle = billableSeconds * unitPricePerSecond * discountMultiplier;
|
|
70
|
+
const costPerAngle = Math.ceil(Number(rawCostPerAngle.toFixed(6)));
|
|
71
|
+
return costPerAngle * normalizedAngleCount;
|
|
78
72
|
}
|
|
79
73
|
|
|
80
|
-
// src/libs/gym-
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
// src/libs/gym-gold-charge.ts
|
|
75
|
+
var GYM_GOLD_CHARGE_POLICY = {
|
|
76
|
+
minChargeKrw: 1e4,
|
|
77
|
+
chargeUnitKrw: 1e4,
|
|
78
|
+
bonusRate: 0.2,
|
|
79
|
+
bonusRateBps: 2e3
|
|
84
80
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
function calculateGymPartnerRegistrationGold(input) {
|
|
88
|
-
const startDate = parseKstDateString(input.startDate, "startDate");
|
|
89
|
-
const endDate = parseKstDateString(input.endDate, "endDate");
|
|
90
|
-
const startDateKey = toUtcDateKey(startDate);
|
|
91
|
-
const endDateKey = toUtcDateKey(endDate);
|
|
92
|
-
if (endDateKey < startDateKey) {
|
|
93
|
-
throw new RangeError("endDate must be on or after startDate");
|
|
94
|
-
}
|
|
95
|
-
const days = Math.floor((endDateKey - startDateKey) / MS_PER_DAY) + 1;
|
|
96
|
-
return {
|
|
97
|
-
days,
|
|
98
|
-
goldAmount: days * GYM_PARTNER_REGISTRATION_GOLD_POLICY.goldPerDay
|
|
99
|
-
};
|
|
81
|
+
function isGymGoldChargeKrwAllowed(chargeKrw) {
|
|
82
|
+
return Number.isFinite(chargeKrw) && Number.isInteger(chargeKrw) && chargeKrw >= GYM_GOLD_CHARGE_POLICY.minChargeKrw && chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw === 0;
|
|
100
83
|
}
|
|
101
|
-
function
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
...period,
|
|
106
|
-
...result
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
return {
|
|
110
|
-
totalDays: items.reduce((sum, item) => sum + item.days, 0),
|
|
111
|
-
totalGoldAmount: items.reduce((sum, item) => sum + item.goldAmount, 0),
|
|
112
|
-
items
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function parseKstDateString(input, fieldName) {
|
|
116
|
-
const dateOnlyMatch = DATE_ONLY_PATTERN.exec(input);
|
|
117
|
-
if (dateOnlyMatch === null) {
|
|
118
|
-
throw new RangeError(`${fieldName} must be a YYYY-MM-DD date`);
|
|
84
|
+
function assertValidGymGoldChargeKrw(chargeKrw) {
|
|
85
|
+
if (!Number.isFinite(chargeKrw)) {
|
|
86
|
+
throw new RangeError("chargeKrw must be a finite number");
|
|
119
87
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
88
|
+
if (!Number.isInteger(chargeKrw)) {
|
|
89
|
+
throw new RangeError("chargeKrw must be an integer");
|
|
90
|
+
}
|
|
91
|
+
if (chargeKrw < GYM_GOLD_CHARGE_POLICY.minChargeKrw) {
|
|
92
|
+
throw new RangeError(
|
|
93
|
+
`chargeKrw must be at least ${GYM_GOLD_CHARGE_POLICY.minChargeKrw}`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw !== 0) {
|
|
97
|
+
throw new RangeError(
|
|
98
|
+
`chargeKrw must be a multiple of ${GYM_GOLD_CHARGE_POLICY.chargeUnitKrw}`
|
|
99
|
+
);
|
|
126
100
|
}
|
|
127
|
-
return { year, month, day };
|
|
128
|
-
}
|
|
129
|
-
function toUtcDateKey(date) {
|
|
130
|
-
return Date.UTC(date.year, date.month - 1, date.day);
|
|
131
101
|
}
|
|
132
102
|
|
|
133
103
|
// src/styles/color.ts
|
|
@@ -375,15 +345,15 @@ var mobileTypo = {
|
|
|
375
345
|
};
|
|
376
346
|
// Annotate the CommonJS export names for ESM import in node:
|
|
377
347
|
0 && (module.exports = {
|
|
378
|
-
|
|
348
|
+
GYM_GOLD_CHARGE_POLICY,
|
|
379
349
|
MIN_DOWNLOAD_SECONDS,
|
|
380
350
|
ORIGINAL_DOWNLOAD_COST_POLICY,
|
|
381
|
-
|
|
382
|
-
calculateGymPartnerRegistrationGoldTotal,
|
|
351
|
+
assertValidGymGoldChargeKrw,
|
|
383
352
|
calculateOriginalDownloadCostWon,
|
|
384
353
|
color,
|
|
385
354
|
colorV2,
|
|
386
355
|
isDownloadDurationAllowed,
|
|
356
|
+
isGymGoldChargeKrwAllowed,
|
|
387
357
|
mobileTypo,
|
|
388
358
|
typo
|
|
389
359
|
});
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/libs/cost.ts","../src/libs/gym-registration-gold.ts","../src/styles/color.ts","../src/styles/typo.ts"],"sourcesContent":["// Main entry point for spoclip-kit\nexport * from './libs';\nexport * from './types';\nexport * from './styles';\n","import type { TicketCode } from '../types/membership';\n\nexport const ORIGINAL_DOWNLOAD_COST_POLICY = {\n baseDurationSeconds: 600,\n baseCostWon: 2000,\n fullVideoDiscountRate: 0.1,\n /**\n * v14 신정책: 멤버십 plan별 분당 KRW 요율.\n * `calculateOriginalDownloadCostWon(duration, { plan })`로 호출 시 적용된다.\n * plan 미지정 시 `baseCostWon/baseDurationSeconds` 기반 단일 단가(레거시 200원/분)로 폴백 — 기존 호출자 호환.\n */\n perPlanKrwPerMinute: {\n FREE: 100,\n PLUS: 50,\n PRO: 25,\n },\n /**\n * 멤버십 plan별 무료 다운로드 구간(초).\n * 다운로드 길이 중 앞 `freeSecondsByPlan[plan]`초는 과금에서 제외하고,\n * 이를 초과한 구간에만 `perPlanKrwPerMinute[plan]` 요율을 적용한다 (초과분 과금).\n * plan 미지정(레거시 단일 단가) 경로에는 무료 구간을 적용하지 않는다.\n */\n freeSecondsByPlan: {\n FREE: 10,\n PLUS: 20,\n PRO: 30,\n },\n} as const;\n\n/**\n * 다운로드 가능한 최소 길이(초).\n * 이보다 짧은 구간은 다운로드 요청 자체를 허용하지 않는다 (server·FE 공용 제약).\n */\nexport const MIN_DOWNLOAD_SECONDS = 10;\n\n/**\n * 다운로드 요청 길이가 허용되는지 검사한다.\n * `durationSeconds >= MIN_DOWNLOAD_SECONDS`일 때만 true.\n */\nexport function isDownloadDurationAllowed(durationSeconds: number): boolean {\n return (\n Number.isFinite(durationSeconds) && durationSeconds >= MIN_DOWNLOAD_SECONDS\n );\n}\n\nexport interface OriginalDownloadCostOptions {\n isFullVideo?: boolean;\n /**\n * 멤버십 plan. 지정 시 `perPlanKrwPerMinute[plan]`을 단가로,\n * `freeSecondsByPlan[plan]`을 무료 구간으로 적용한다.\n * 미지정(undefined) 시 레거시 단일 단가(`baseCostWon/baseDurationSeconds`) + 무료 구간 없음.\n */\n plan?: TicketCode;\n}\n\nexport function calculateOriginalDownloadCostWon(\n durationSeconds: number,\n options: OriginalDownloadCostOptions = {},\n): number {\n if (!Number.isFinite(durationSeconds) || durationSeconds <= 0) return 0;\n\n const { plan, isFullVideo } = options;\n\n // plan 지정 시 앞 freeSeconds 구간은 과금에서 제외하고 초과분만 과금한다.\n // 레거시 경로(plan 미지정)는 무료 구간 0으로 기존 동작을 유지한다.\n const freeSeconds =\n plan !== undefined\n ? ORIGINAL_DOWNLOAD_COST_POLICY.freeSecondsByPlan[plan]\n : 0;\n const billableSeconds = Math.max(0, durationSeconds - freeSeconds);\n if (billableSeconds <= 0) return 0;\n\n const unitPricePerSecond =\n plan !== undefined\n ? ORIGINAL_DOWNLOAD_COST_POLICY.perPlanKrwPerMinute[plan] / 60\n : ORIGINAL_DOWNLOAD_COST_POLICY.baseCostWon /\n ORIGINAL_DOWNLOAD_COST_POLICY.baseDurationSeconds;\n\n const discountMultiplier = isFullVideo\n ? 1 - ORIGINAL_DOWNLOAD_COST_POLICY.fullVideoDiscountRate\n : 1;\n\n // 부동소수점 drift(예: 30.000000000000004) 때문에 1원 과다 청구되는 것을 막기 위해\n // 원 단위 미만 노이즈를 보정한 뒤 올림한다.\n const rawCost = billableSeconds * unitPricePerSecond * discountMultiplier;\n return Math.ceil(Number(rawCost.toFixed(6)));\n}\n","export const GYM_PARTNER_REGISTRATION_GOLD_POLICY = {\n goldPerDay: 350,\n timeZone: 'Asia/Seoul',\n} as const;\n\nexport interface GymPartnerRegistrationGoldInput {\n /**\n * KST calendar date in YYYY-MM-DD format.\n */\n startDate: string;\n /**\n * KST calendar date in YYYY-MM-DD format.\n */\n endDate: string;\n}\n\nexport interface GymPartnerRegistrationGoldResult {\n days: number;\n goldAmount: number;\n}\n\nexport interface GymPartnerRegistrationGoldTotalItem\n extends GymPartnerRegistrationGoldInput,\n GymPartnerRegistrationGoldResult {}\n\nexport interface GymPartnerRegistrationGoldTotalResult {\n totalDays: number;\n totalGoldAmount: number;\n items: GymPartnerRegistrationGoldTotalItem[];\n}\n\ninterface KstDateParts {\n year: number;\n month: number;\n day: number;\n}\n\nconst DATE_ONLY_PATTERN = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst MS_PER_DAY = 24 * 60 * 60 * 1000;\n\nexport function calculateGymPartnerRegistrationGold(\n input: GymPartnerRegistrationGoldInput,\n): GymPartnerRegistrationGoldResult {\n const startDate = parseKstDateString(input.startDate, 'startDate');\n const endDate = parseKstDateString(input.endDate, 'endDate');\n\n const startDateKey = toUtcDateKey(startDate);\n const endDateKey = toUtcDateKey(endDate);\n\n if (endDateKey < startDateKey) {\n throw new RangeError('endDate must be on or after startDate');\n }\n\n const days = Math.floor((endDateKey - startDateKey) / MS_PER_DAY) + 1;\n\n return {\n days,\n goldAmount: days * GYM_PARTNER_REGISTRATION_GOLD_POLICY.goldPerDay,\n };\n}\n\nexport function calculateGymPartnerRegistrationGoldTotal(\n periods: GymPartnerRegistrationGoldInput[],\n): GymPartnerRegistrationGoldTotalResult {\n const items = periods.map((period) => {\n const result = calculateGymPartnerRegistrationGold(period);\n\n return {\n ...period,\n ...result,\n };\n });\n\n return {\n totalDays: items.reduce((sum, item) => sum + item.days, 0),\n totalGoldAmount: items.reduce((sum, item) => sum + item.goldAmount, 0),\n items,\n };\n}\n\nfunction parseKstDateString(\n input: string,\n fieldName: 'startDate' | 'endDate',\n): KstDateParts {\n const dateOnlyMatch = DATE_ONLY_PATTERN.exec(input);\n if (dateOnlyMatch === null) {\n throw new RangeError(`${fieldName} must be a YYYY-MM-DD date`);\n }\n\n const year = Number(dateOnlyMatch[1]);\n const month = Number(dateOnlyMatch[2]);\n const day = Number(dateOnlyMatch[3]);\n const utcDate = new Date(Date.UTC(year, month - 1, day));\n\n if (\n utcDate.getUTCFullYear() !== year ||\n utcDate.getUTCMonth() + 1 !== month ||\n utcDate.getUTCDate() !== day\n ) {\n throw new RangeError(`${fieldName} must be a valid date`);\n }\n\n return { year, month, day };\n}\n\nfunction toUtcDateKey(date: KstDateParts): number {\n return Date.UTC(date.year, date.month - 1, date.day);\n}\n","const color = {\n primary: '#242535',\n primaryB: '#515265',\n primary2: '#9335FB',\n primary2B: '#6323AA',\n secondary: '#FADD32',\n bgColor: '#F3F4F6',\n error: '#EA2E2E',\n\n white: '#FFFFFF',\n black: '#111111',\n gray1: '#424242',\n gray2: '#616161',\n gray3: '#8E8E8E',\n gray4: '#BDBDBD',\n gray5: '#E0E0E0',\n gray6: '#EDEDED',\n\n sub: '#A3A4BD',\n sub3: '#5561E8',\n sub3b: '#F1F7FF',\n sub4: '#1D1A1A',\n\n point: '#FADD32',\n} as const;\n\n/**\n * @deprecated use color instead (작명 실수 ㅠ)\n */\n\nconst colorV2 = color;\n\nexport { colorV2, color };\n","type TypographyKey =\n | 'h1-24b'\n | 'h1-24m'\n | 'h1-24'\n | 'h2-20b'\n | 'h2-20m'\n | 'h2-20'\n | 'h3-18b'\n | 'h3-18m'\n | 'h3-18'\n | 'b1-16b'\n | 'b1-16m'\n | 'b1-16'\n | 'b2-14b'\n | 'b2-14m'\n | 'b2-14'\n | 'b3-12b'\n | 'b3-12m'\n | 'b3-12'\n | 's1-10b'\n | 's1-10m'\n | 's1-10';\n\nconst typo = {\n 'h1-24b': {\n fontSize: 24,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h1-24m': {\n fontSize: 24,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h1-24': {\n fontSize: 24,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'h2-20b': {\n fontSize: 20,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h2-20m': {\n fontSize: 20,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h2-20': {\n fontSize: 20,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18b': {\n fontSize: 18,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18m': {\n fontSize: 18,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18': {\n fontSize: 18,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16b': {\n fontSize: 16,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16m': {\n fontSize: 16,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16': {\n fontSize: 16,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'b2-14b': {\n fontSize: 14,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b2-14m': {\n fontSize: 14,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b2-14': {\n fontSize: 14,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'b3-12b': {\n fontSize: 12,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b3-12m': {\n fontSize: 12,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b3-12': {\n fontSize: 12,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 's1-10b': {\n fontSize: 10,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 's1-10m': {\n fontSize: 10,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 's1-10': {\n fontSize: 10,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n} as const;\n\nconst transformLineheight = (key: TypographyKey) => {\n return typo[key].lineHeight * typo[key].fontSize;\n};\n\nconst mobileTypo = {\n 'h1-24b': {\n ...typo['h1-24b'],\n lineHeight: transformLineheight('h1-24b'),\n },\n\n 'h1-24m': {\n ...typo['h1-24m'],\n lineHeight: transformLineheight('h1-24m'),\n },\n\n 'h1-24': {\n ...typo['h1-24'],\n lineHeight: transformLineheight('h1-24'),\n },\n\n 'h2-20b': {\n ...typo['h2-20b'],\n lineHeight: transformLineheight('h2-20b'),\n },\n\n 'h2-20m': {\n ...typo['h2-20m'],\n lineHeight: transformLineheight('h2-20m'),\n },\n\n 'h2-20': {\n ...typo['h2-20'],\n lineHeight: transformLineheight('h2-20'),\n },\n\n 'h3-18b': {\n ...typo['h3-18b'],\n lineHeight: transformLineheight('h3-18b'),\n },\n\n 'h3-18m': {\n ...typo['h3-18m'],\n lineHeight: transformLineheight('h3-18m'),\n },\n\n 'h3-18': {\n ...typo['h3-18'],\n lineHeight: transformLineheight('h3-18'),\n },\n\n 'b1-16b': {\n ...typo['b1-16b'],\n lineHeight: transformLineheight('b1-16b'),\n },\n\n 'b1-16m': {\n ...typo['b1-16m'],\n lineHeight: transformLineheight('b1-16m'),\n },\n\n 'b1-16': {\n ...typo['b1-16'],\n lineHeight: transformLineheight('b1-16'),\n },\n\n 'b2-14b': {\n ...typo['b2-14b'],\n lineHeight: transformLineheight('b2-14b'),\n },\n\n 'b2-14m': {\n ...typo['b2-14m'],\n lineHeight: transformLineheight('b2-14m'),\n },\n\n 'b2-14': {\n ...typo['b2-14'],\n lineHeight: transformLineheight('b2-14'),\n },\n\n 'b3-12b': {\n ...typo['b3-12b'],\n lineHeight: transformLineheight('b3-12b'),\n },\n\n 'b3-12m': {\n ...typo['b3-12m'],\n lineHeight: transformLineheight('b3-12m'),\n },\n\n 'b3-12': {\n ...typo['b3-12'],\n lineHeight: transformLineheight('b3-12'),\n },\n\n 's1-10b': {\n ...typo['s1-10b'],\n lineHeight: transformLineheight('s1-10b'),\n },\n\n 's1-10m': {\n ...typo['s1-10m'],\n lineHeight: transformLineheight('s1-10m'),\n },\n\n 's1-10': {\n ...typo['s1-10'],\n lineHeight: transformLineheight('s1-10'),\n },\n} as const;\n\nexport { typo, mobileTypo };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,gCAAgC;AAAA,EAC3C,qBAAqB;AAAA,EACrB,aAAa;AAAA,EACb,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvB,qBAAqB;AAAA,IACnB,MAAM;AAAA,IACN,MAAM;AAAA,IACN,KAAK;AAAA,EACP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mBAAmB;AAAA,I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K,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/libs/cost.ts","../src/libs/gym-gold-charge.ts","../src/styles/color.ts","../src/styles/typo.ts"],"sourcesContent":["// Main entry point for spoclip-kit\nexport * from './libs';\nexport * from './types';\nexport * from './styles';\n","export const ORIGINAL_DOWNLOAD_COST_POLICY = {\n /**\n * 무료 다운로드 구간(초). 멤버십 구분 없이 모든 사용자에게 동일하게 적용한다.\n * 다운로드 길이 중 앞 `freeSeconds`초는 과금에서 제외하고,\n * 이를 초과한 구간에만 `krwPerMinute` 요율을 적용한다 (초과분 과금).\n */\n freeSeconds: 30,\n /**\n * 무료 구간 초과분에 적용하는 분당 KRW 요율. 멤버십 구분 없는 단일 요율.\n */\n krwPerMinute: 100,\n /**\n * 전체 영상 다운로드 시 할인율(10%).\n */\n fullVideoDiscountRate: 0.1,\n} as const;\n\n/**\n * 다운로드 가능한 최소 길이(초).\n * 이보다 짧은 구간은 다운로드 요청 자체를 허용하지 않는다 (server·FE 공용 제약).\n */\nexport const MIN_DOWNLOAD_SECONDS = 10;\n\n/**\n * 다운로드 요청 길이가 허용되는지 검사한다.\n * `durationSeconds >= MIN_DOWNLOAD_SECONDS`일 때만 true.\n */\nexport function isDownloadDurationAllowed(durationSeconds: number): boolean {\n return (\n Number.isFinite(durationSeconds) && durationSeconds >= MIN_DOWNLOAD_SECONDS\n );\n}\n\nexport interface OriginalDownloadCostOptions {\n isFullVideo?: boolean;\n /**\n * 동시에 다운로드할 화각(camera angle) 수. 최소 1, 기본 1.\n * 모든 화각은 동일한 길이로 함께 받으므로 단일 화각 비용 × 화각 수로 과금한다.\n * 1 미만이거나 유한하지 않은 값은 1로 보정한다.\n */\n angleCount?: number;\n}\n\nexport function calculateOriginalDownloadCostWon(\n durationSeconds: number,\n options: OriginalDownloadCostOptions = {},\n): number {\n if (!Number.isFinite(durationSeconds) || durationSeconds <= 0) return 0;\n\n const { isFullVideo, angleCount } = options;\n\n // 화각 수는 최소 1로 보정한다. 정수가 아닌 값은 내림 처리.\n const normalizedAngleCount = Number.isFinite(angleCount)\n ? Math.max(1, Math.floor(angleCount as number))\n : 1;\n\n // 앞 freeSeconds 구간은 과금에서 제외하고 초과분만 과금한다.\n const billableSeconds = Math.max(\n 0,\n durationSeconds - ORIGINAL_DOWNLOAD_COST_POLICY.freeSeconds,\n );\n if (billableSeconds <= 0) return 0;\n\n const unitPricePerSecond = ORIGINAL_DOWNLOAD_COST_POLICY.krwPerMinute / 60;\n\n const discountMultiplier = isFullVideo\n ? 1 - ORIGINAL_DOWNLOAD_COST_POLICY.fullVideoDiscountRate\n : 1;\n\n // 부동소수점 drift(예: 30.000000000000004) 때문에 1원 과다 청구되는 것을 막기 위해\n // 원 단위 미만 노이즈를 보정한 뒤 올림한다. 단일 화각 비용을 원 단위로 확정한 뒤\n // 화각 수만큼 곱한다 (각 화각을 개별 다운로드 건으로 과금).\n const rawCostPerAngle =\n billableSeconds * unitPricePerSecond * discountMultiplier;\n const costPerAngle = Math.ceil(Number(rawCostPerAngle.toFixed(6)));\n\n return costPerAngle * normalizedAngleCount;\n}\n","export const GYM_GOLD_CHARGE_POLICY = {\n minChargeKrw: 10_000,\n chargeUnitKrw: 10_000,\n bonusRate: 0.2,\n bonusRateBps: 2_000,\n} as const;\n\nexport function isGymGoldChargeKrwAllowed(chargeKrw: number): boolean {\n return (\n Number.isFinite(chargeKrw) &&\n Number.isInteger(chargeKrw) &&\n chargeKrw >= GYM_GOLD_CHARGE_POLICY.minChargeKrw &&\n chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw === 0\n );\n}\n\nexport function assertValidGymGoldChargeKrw(chargeKrw: number): void {\n if (!Number.isFinite(chargeKrw)) {\n throw new RangeError('chargeKrw must be a finite number');\n }\n\n if (!Number.isInteger(chargeKrw)) {\n throw new RangeError('chargeKrw must be an integer');\n }\n\n if (chargeKrw < GYM_GOLD_CHARGE_POLICY.minChargeKrw) {\n throw new RangeError(\n `chargeKrw must be at least ${GYM_GOLD_CHARGE_POLICY.minChargeKrw}`,\n );\n }\n\n if (chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw !== 0) {\n throw new RangeError(\n `chargeKrw must be a multiple of ${GYM_GOLD_CHARGE_POLICY.chargeUnitKrw}`,\n );\n }\n}\n","const color = {\n primary: '#242535',\n primaryB: '#515265',\n primary2: '#9335FB',\n primary2B: '#6323AA',\n secondary: '#FADD32',\n bgColor: '#F3F4F6',\n error: '#EA2E2E',\n\n white: '#FFFFFF',\n black: '#111111',\n gray1: '#424242',\n gray2: '#616161',\n gray3: '#8E8E8E',\n gray4: '#BDBDBD',\n gray5: '#E0E0E0',\n gray6: '#EDEDED',\n\n sub: '#A3A4BD',\n sub3: '#5561E8',\n sub3b: '#F1F7FF',\n sub4: '#1D1A1A',\n\n point: '#FADD32',\n} as const;\n\n/**\n * @deprecated use color instead (작명 실수 ㅠ)\n */\n\nconst colorV2 = color;\n\nexport { colorV2, color };\n","type TypographyKey =\n | 'h1-24b'\n | 'h1-24m'\n | 'h1-24'\n | 'h2-20b'\n | 'h2-20m'\n | 'h2-20'\n | 'h3-18b'\n | 'h3-18m'\n | 'h3-18'\n | 'b1-16b'\n | 'b1-16m'\n | 'b1-16'\n | 'b2-14b'\n | 'b2-14m'\n | 'b2-14'\n | 'b3-12b'\n | 'b3-12m'\n | 'b3-12'\n | 's1-10b'\n | 's1-10m'\n | 's1-10';\n\nconst typo = {\n 'h1-24b': {\n fontSize: 24,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h1-24m': {\n fontSize: 24,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h1-24': {\n fontSize: 24,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'h2-20b': {\n fontSize: 20,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h2-20m': {\n fontSize: 20,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h2-20': {\n fontSize: 20,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18b': {\n fontSize: 18,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18m': {\n fontSize: 18,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18': {\n fontSize: 18,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16b': {\n fontSize: 16,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16m': {\n fontSize: 16,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16': {\n fontSize: 16,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'b2-14b': {\n fontSize: 14,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b2-14m': {\n fontSize: 14,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b2-14': {\n fontSize: 14,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'b3-12b': {\n fontSize: 12,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b3-12m': {\n fontSize: 12,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b3-12': {\n fontSize: 12,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 's1-10b': {\n fontSize: 10,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 's1-10m': {\n fontSize: 10,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 's1-10': {\n fontSize: 10,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n} as const;\n\nconst transformLineheight = (key: TypographyKey) => {\n return typo[key].lineHeight * typo[key].fontSize;\n};\n\nconst mobileTypo = {\n 'h1-24b': {\n ...typo['h1-24b'],\n lineHeight: transformLineheight('h1-24b'),\n },\n\n 'h1-24m': {\n ...typo['h1-24m'],\n lineHeight: transformLineheight('h1-24m'),\n },\n\n 'h1-24': {\n ...typo['h1-24'],\n lineHeight: transformLineheight('h1-24'),\n },\n\n 'h2-20b': {\n ...typo['h2-20b'],\n lineHeight: transformLineheight('h2-20b'),\n },\n\n 'h2-20m': {\n ...typo['h2-20m'],\n lineHeight: transformLineheight('h2-20m'),\n },\n\n 'h2-20': {\n ...typo['h2-20'],\n lineHeight: transformLineheight('h2-20'),\n },\n\n 'h3-18b': {\n ...typo['h3-18b'],\n lineHeight: transformLineheight('h3-18b'),\n },\n\n 'h3-18m': {\n ...typo['h3-18m'],\n lineHeight: transformLineheight('h3-18m'),\n },\n\n 'h3-18': {\n ...typo['h3-18'],\n lineHeight: transformLineheight('h3-18'),\n },\n\n 'b1-16b': {\n ...typo['b1-16b'],\n lineHeight: transformLineheight('b1-16b'),\n },\n\n 'b1-16m': {\n ...typo['b1-16m'],\n lineHeight: transformLineheight('b1-16m'),\n },\n\n 'b1-16': {\n ...typo['b1-16'],\n lineHeight: transformLineheight('b1-16'),\n },\n\n 'b2-14b': {\n ...typo['b2-14b'],\n lineHeight: transformLineheight('b2-14b'),\n },\n\n 'b2-14m': {\n ...typo['b2-14m'],\n lineHeight: transformLineheight('b2-14m'),\n },\n\n 'b2-14': {\n ...typo['b2-14'],\n lineHeight: transformLineheight('b2-14'),\n },\n\n 'b3-12b': {\n ...typo['b3-12b'],\n lineHeight: transformLineheight('b3-12b'),\n },\n\n 'b3-12m': {\n ...typo['b3-12m'],\n lineHeight: transformLineheight('b3-12m'),\n },\n\n 'b3-12': {\n ...typo['b3-12'],\n lineHeight: transformLineheight('b3-12'),\n },\n\n 's1-10b': {\n ...typo['s1-10b'],\n lineHeight: transformLineheight('s1-10b'),\n },\n\n 's1-10m': {\n ...typo['s1-10m'],\n lineHeight: transformLineheight('s1-10m'),\n },\n\n 's1-10': {\n ...typo['s1-10'],\n lineHeight: transformLineheight('s1-10'),\n },\n} as const;\n\nexport { typo, mobileTypo };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gCAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3C,aAAa;AAAA;AAAA;AAAA;AAAA,EAIb,cAAc;AAAA;AAAA;AAAA;AAAA,EAId,uBAAuB;AACzB;AAMO,IAAM,uBAAuB;AAM7B,SAAS,0BAA0B,iBAAkC;AAC1E,SACE,OAAO,SAAS,eAAe,KAAK,mBAAmB;AAE3D;AAYO,SAAS,iCACd,iBACA,UAAuC,CAAC,GAChC;AACR,MAAI,CAAC,OAAO,SAAS,eAAe,KAAK,mBAAmB,EAAG,QAAO;AAEtE,QAAM,EAAE,aAAa,WAAW,IAAI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UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AACF;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { T as TicketCode } from './membership-C_ziSHS0.cjs';
|
|
1
|
+
export { GYM_GOLD_CHARGE_POLICY, MIN_DOWNLOAD_SECONDS, ORIGINAL_DOWNLOAD_COST_POLICY, OriginalDownloadCostOptions, assertValidGymGoldChargeKrw, calculateOriginalDownloadCostWon, isDownloadDurationAllowed, isGymGoldChargeKrwAllowed } from './libs.cjs';
|
|
3
2
|
export { APIErrorResponse, APIResponse, APIResponseBase } from './types.cjs';
|
|
4
3
|
export { color, colorV2, mobileTypo, typo } from './styles.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { T as TicketCode } from './membership-C_ziSHS0.js';
|
|
1
|
+
export { GYM_GOLD_CHARGE_POLICY, MIN_DOWNLOAD_SECONDS, ORIGINAL_DOWNLOAD_COST_POLICY, OriginalDownloadCostOptions, assertValidGymGoldChargeKrw, calculateOriginalDownloadCostWon, isDownloadDurationAllowed, isGymGoldChargeKrwAllowed } from './libs.js';
|
|
3
2
|
export { APIErrorResponse, APIResponse, APIResponseBase } from './types.js';
|
|
4
3
|
export { color, colorV2, mobileTypo, typo } from './styles.js';
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
// src/libs/cost.ts
|
|
2
2
|
var ORIGINAL_DOWNLOAD_COST_POLICY = {
|
|
3
|
-
baseDurationSeconds: 600,
|
|
4
|
-
baseCostWon: 2e3,
|
|
5
|
-
fullVideoDiscountRate: 0.1,
|
|
6
3
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* 무료 다운로드 구간(초). 멤버십 구분 없이 모든 사용자에게 동일하게 적용한다.
|
|
5
|
+
* 다운로드 길이 중 앞 `freeSeconds`초는 과금에서 제외하고,
|
|
6
|
+
* 이를 초과한 구간에만 `krwPerMinute` 요율을 적용한다 (초과분 과금).
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
FREE: 100,
|
|
13
|
-
PLUS: 50,
|
|
14
|
-
PRO: 25
|
|
15
|
-
},
|
|
8
|
+
freeSeconds: 30,
|
|
16
9
|
/**
|
|
17
|
-
* 멤버십
|
|
18
|
-
* 다운로드 길이 중 앞 `freeSecondsByPlan[plan]`초는 과금에서 제외하고,
|
|
19
|
-
* 이를 초과한 구간에만 `perPlanKrwPerMinute[plan]` 요율을 적용한다 (초과분 과금).
|
|
20
|
-
* plan 미지정(레거시 단일 단가) 경로에는 무료 구간을 적용하지 않는다.
|
|
10
|
+
* 무료 구간 초과분에 적용하는 분당 KRW 요율. 멤버십 구분 없는 단일 요율.
|
|
21
11
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
krwPerMinute: 100,
|
|
13
|
+
/**
|
|
14
|
+
* 전체 영상 다운로드 시 할인율(10%).
|
|
15
|
+
*/
|
|
16
|
+
fullVideoDiscountRate: 0.1
|
|
27
17
|
};
|
|
28
18
|
var MIN_DOWNLOAD_SECONDS = 10;
|
|
29
19
|
function isDownloadDurationAllowed(durationSeconds) {
|
|
@@ -31,67 +21,47 @@ function isDownloadDurationAllowed(durationSeconds) {
|
|
|
31
21
|
}
|
|
32
22
|
function calculateOriginalDownloadCostWon(durationSeconds, options = {}) {
|
|
33
23
|
if (!Number.isFinite(durationSeconds) || durationSeconds <= 0) return 0;
|
|
34
|
-
const {
|
|
35
|
-
const
|
|
36
|
-
const billableSeconds = Math.max(
|
|
24
|
+
const { isFullVideo, angleCount } = options;
|
|
25
|
+
const normalizedAngleCount = Number.isFinite(angleCount) ? Math.max(1, Math.floor(angleCount)) : 1;
|
|
26
|
+
const billableSeconds = Math.max(
|
|
27
|
+
0,
|
|
28
|
+
durationSeconds - ORIGINAL_DOWNLOAD_COST_POLICY.freeSeconds
|
|
29
|
+
);
|
|
37
30
|
if (billableSeconds <= 0) return 0;
|
|
38
|
-
const unitPricePerSecond =
|
|
31
|
+
const unitPricePerSecond = ORIGINAL_DOWNLOAD_COST_POLICY.krwPerMinute / 60;
|
|
39
32
|
const discountMultiplier = isFullVideo ? 1 - ORIGINAL_DOWNLOAD_COST_POLICY.fullVideoDiscountRate : 1;
|
|
40
|
-
const
|
|
41
|
-
|
|
33
|
+
const rawCostPerAngle = billableSeconds * unitPricePerSecond * discountMultiplier;
|
|
34
|
+
const costPerAngle = Math.ceil(Number(rawCostPerAngle.toFixed(6)));
|
|
35
|
+
return costPerAngle * normalizedAngleCount;
|
|
42
36
|
}
|
|
43
37
|
|
|
44
|
-
// src/libs/gym-
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
// src/libs/gym-gold-charge.ts
|
|
39
|
+
var GYM_GOLD_CHARGE_POLICY = {
|
|
40
|
+
minChargeKrw: 1e4,
|
|
41
|
+
chargeUnitKrw: 1e4,
|
|
42
|
+
bonusRate: 0.2,
|
|
43
|
+
bonusRateBps: 2e3
|
|
48
44
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function calculateGymPartnerRegistrationGold(input) {
|
|
52
|
-
const startDate = parseKstDateString(input.startDate, "startDate");
|
|
53
|
-
const endDate = parseKstDateString(input.endDate, "endDate");
|
|
54
|
-
const startDateKey = toUtcDateKey(startDate);
|
|
55
|
-
const endDateKey = toUtcDateKey(endDate);
|
|
56
|
-
if (endDateKey < startDateKey) {
|
|
57
|
-
throw new RangeError("endDate must be on or after startDate");
|
|
58
|
-
}
|
|
59
|
-
const days = Math.floor((endDateKey - startDateKey) / MS_PER_DAY) + 1;
|
|
60
|
-
return {
|
|
61
|
-
days,
|
|
62
|
-
goldAmount: days * GYM_PARTNER_REGISTRATION_GOLD_POLICY.goldPerDay
|
|
63
|
-
};
|
|
45
|
+
function isGymGoldChargeKrwAllowed(chargeKrw) {
|
|
46
|
+
return Number.isFinite(chargeKrw) && Number.isInteger(chargeKrw) && chargeKrw >= GYM_GOLD_CHARGE_POLICY.minChargeKrw && chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw === 0;
|
|
64
47
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
...period,
|
|
70
|
-
...result
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
return {
|
|
74
|
-
totalDays: items.reduce((sum, item) => sum + item.days, 0),
|
|
75
|
-
totalGoldAmount: items.reduce((sum, item) => sum + item.goldAmount, 0),
|
|
76
|
-
items
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function parseKstDateString(input, fieldName) {
|
|
80
|
-
const dateOnlyMatch = DATE_ONLY_PATTERN.exec(input);
|
|
81
|
-
if (dateOnlyMatch === null) {
|
|
82
|
-
throw new RangeError(`${fieldName} must be a YYYY-MM-DD date`);
|
|
48
|
+
function assertValidGymGoldChargeKrw(chargeKrw) {
|
|
49
|
+
if (!Number.isFinite(chargeKrw)) {
|
|
50
|
+
throw new RangeError("chargeKrw must be a finite number");
|
|
83
51
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
52
|
+
if (!Number.isInteger(chargeKrw)) {
|
|
53
|
+
throw new RangeError("chargeKrw must be an integer");
|
|
54
|
+
}
|
|
55
|
+
if (chargeKrw < GYM_GOLD_CHARGE_POLICY.minChargeKrw) {
|
|
56
|
+
throw new RangeError(
|
|
57
|
+
`chargeKrw must be at least ${GYM_GOLD_CHARGE_POLICY.minChargeKrw}`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
if (chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw !== 0) {
|
|
61
|
+
throw new RangeError(
|
|
62
|
+
`chargeKrw must be a multiple of ${GYM_GOLD_CHARGE_POLICY.chargeUnitKrw}`
|
|
63
|
+
);
|
|
90
64
|
}
|
|
91
|
-
return { year, month, day };
|
|
92
|
-
}
|
|
93
|
-
function toUtcDateKey(date) {
|
|
94
|
-
return Date.UTC(date.year, date.month - 1, date.day);
|
|
95
65
|
}
|
|
96
66
|
|
|
97
67
|
// src/styles/color.ts
|
|
@@ -338,15 +308,15 @@ var mobileTypo = {
|
|
|
338
308
|
}
|
|
339
309
|
};
|
|
340
310
|
export {
|
|
341
|
-
|
|
311
|
+
GYM_GOLD_CHARGE_POLICY,
|
|
342
312
|
MIN_DOWNLOAD_SECONDS,
|
|
343
313
|
ORIGINAL_DOWNLOAD_COST_POLICY,
|
|
344
|
-
|
|
345
|
-
calculateGymPartnerRegistrationGoldTotal,
|
|
314
|
+
assertValidGymGoldChargeKrw,
|
|
346
315
|
calculateOriginalDownloadCostWon,
|
|
347
316
|
color,
|
|
348
317
|
colorV2,
|
|
349
318
|
isDownloadDurationAllowed,
|
|
319
|
+
isGymGoldChargeKrwAllowed,
|
|
350
320
|
mobileTypo,
|
|
351
321
|
typo
|
|
352
322
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/libs/cost.ts","../src/libs/gym-registration-gold.ts","../src/styles/color.ts","../src/styles/typo.ts"],"sourcesContent":["import type { TicketCode } from '../types/membership';\n\nexport const ORIGINAL_DOWNLOAD_COST_POLICY = {\n baseDurationSeconds: 600,\n baseCostWon: 2000,\n fullVideoDiscountRate: 0.1,\n /**\n * v14 신정책: 멤버십 plan별 분당 KRW 요율.\n * `calculateOriginalDownloadCostWon(duration, { plan })`로 호출 시 적용된다.\n * plan 미지정 시 `baseCostWon/baseDurationSeconds` 기반 단일 단가(레거시 200원/분)로 폴백 — 기존 호출자 호환.\n */\n perPlanKrwPerMinute: {\n FREE: 100,\n PLUS: 50,\n PRO: 25,\n },\n /**\n * 멤버십 plan별 무료 다운로드 구간(초).\n * 다운로드 길이 중 앞 `freeSecondsByPlan[plan]`초는 과금에서 제외하고,\n * 이를 초과한 구간에만 `perPlanKrwPerMinute[plan]` 요율을 적용한다 (초과분 과금).\n * plan 미지정(레거시 단일 단가) 경로에는 무료 구간을 적용하지 않는다.\n */\n freeSecondsByPlan: {\n FREE: 10,\n PLUS: 20,\n PRO: 30,\n },\n} as const;\n\n/**\n * 다운로드 가능한 최소 길이(초).\n * 이보다 짧은 구간은 다운로드 요청 자체를 허용하지 않는다 (server·FE 공용 제약).\n */\nexport const MIN_DOWNLOAD_SECONDS = 10;\n\n/**\n * 다운로드 요청 길이가 허용되는지 검사한다.\n * `durationSeconds >= MIN_DOWNLOAD_SECONDS`일 때만 true.\n */\nexport function isDownloadDurationAllowed(durationSeconds: number): boolean {\n return (\n Number.isFinite(durationSeconds) && durationSeconds >= MIN_DOWNLOAD_SECONDS\n );\n}\n\nexport interface OriginalDownloadCostOptions {\n isFullVideo?: boolean;\n /**\n * 멤버십 plan. 지정 시 `perPlanKrwPerMinute[plan]`을 단가로,\n * `freeSecondsByPlan[plan]`을 무료 구간으로 적용한다.\n * 미지정(undefined) 시 레거시 단일 단가(`baseCostWon/baseDurationSeconds`) + 무료 구간 없음.\n */\n plan?: TicketCode;\n}\n\nexport function calculateOriginalDownloadCostWon(\n durationSeconds: number,\n options: OriginalDownloadCostOptions = {},\n): number {\n if (!Number.isFinite(durationSeconds) || durationSeconds <= 0) return 0;\n\n const { plan, isFullVideo } = options;\n\n // plan 지정 시 앞 freeSeconds 구간은 과금에서 제외하고 초과분만 과금한다.\n // 레거시 경로(plan 미지정)는 무료 구간 0으로 기존 동작을 유지한다.\n const freeSeconds =\n plan !== undefined\n ? ORIGINAL_DOWNLOAD_COST_POLICY.freeSecondsByPlan[plan]\n : 0;\n const billableSeconds = Math.max(0, durationSeconds - freeSeconds);\n if (billableSeconds <= 0) return 0;\n\n const unitPricePerSecond =\n plan !== undefined\n ? ORIGINAL_DOWNLOAD_COST_POLICY.perPlanKrwPerMinute[plan] / 60\n : ORIGINAL_DOWNLOAD_COST_POLICY.baseCostWon /\n ORIGINAL_DOWNLOAD_COST_POLICY.baseDurationSeconds;\n\n const discountMultiplier = isFullVideo\n ? 1 - ORIGINAL_DOWNLOAD_COST_POLICY.fullVideoDiscountRate\n : 1;\n\n // 부동소수점 drift(예: 30.000000000000004) 때문에 1원 과다 청구되는 것을 막기 위해\n // 원 단위 미만 노이즈를 보정한 뒤 올림한다.\n const rawCost = billableSeconds * unitPricePerSecond * discountMultiplier;\n return Math.ceil(Number(rawCost.toFixed(6)));\n}\n","export const GYM_PARTNER_REGISTRATION_GOLD_POLICY = {\n goldPerDay: 350,\n timeZone: 'Asia/Seoul',\n} as const;\n\nexport interface GymPartnerRegistrationGoldInput {\n /**\n * KST calendar date in YYYY-MM-DD format.\n */\n startDate: string;\n /**\n * KST calendar date in YYYY-MM-DD format.\n */\n endDate: string;\n}\n\nexport interface GymPartnerRegistrationGoldResult {\n days: number;\n goldAmount: number;\n}\n\nexport interface GymPartnerRegistrationGoldTotalItem\n extends GymPartnerRegistrationGoldInput,\n GymPartnerRegistrationGoldResult {}\n\nexport interface GymPartnerRegistrationGoldTotalResult {\n totalDays: number;\n totalGoldAmount: number;\n items: GymPartnerRegistrationGoldTotalItem[];\n}\n\ninterface KstDateParts {\n year: number;\n month: number;\n day: number;\n}\n\nconst DATE_ONLY_PATTERN = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst MS_PER_DAY = 24 * 60 * 60 * 1000;\n\nexport function calculateGymPartnerRegistrationGold(\n input: GymPartnerRegistrationGoldInput,\n): GymPartnerRegistrationGoldResult {\n const startDate = parseKstDateString(input.startDate, 'startDate');\n const endDate = parseKstDateString(input.endDate, 'endDate');\n\n const startDateKey = toUtcDateKey(startDate);\n const endDateKey = toUtcDateKey(endDate);\n\n if (endDateKey < startDateKey) {\n throw new RangeError('endDate must be on or after startDate');\n }\n\n const days = Math.floor((endDateKey - startDateKey) / MS_PER_DAY) + 1;\n\n return {\n days,\n goldAmount: days * GYM_PARTNER_REGISTRATION_GOLD_POLICY.goldPerDay,\n };\n}\n\nexport function calculateGymPartnerRegistrationGoldTotal(\n periods: GymPartnerRegistrationGoldInput[],\n): GymPartnerRegistrationGoldTotalResult {\n const items = periods.map((period) => {\n const result = calculateGymPartnerRegistrationGold(period);\n\n return {\n ...period,\n ...result,\n };\n });\n\n return {\n totalDays: items.reduce((sum, item) => sum + item.days, 0),\n totalGoldAmount: items.reduce((sum, item) => sum + item.goldAmount, 0),\n items,\n };\n}\n\nfunction parseKstDateString(\n input: string,\n fieldName: 'startDate' | 'endDate',\n): KstDateParts {\n const dateOnlyMatch = DATE_ONLY_PATTERN.exec(input);\n if (dateOnlyMatch === null) {\n throw new RangeError(`${fieldName} must be a YYYY-MM-DD date`);\n }\n\n const year = Number(dateOnlyMatch[1]);\n const month = Number(dateOnlyMatch[2]);\n const day = Number(dateOnlyMatch[3]);\n const utcDate = new Date(Date.UTC(year, month - 1, day));\n\n if (\n utcDate.getUTCFullYear() !== year ||\n utcDate.getUTCMonth() + 1 !== month ||\n utcDate.getUTCDate() !== day\n ) {\n throw new RangeError(`${fieldName} must be a valid date`);\n }\n\n return { year, month, day };\n}\n\nfunction toUtcDateKey(date: KstDateParts): number {\n return Date.UTC(date.year, date.month - 1, date.day);\n}\n","const color = {\n primary: '#242535',\n primaryB: '#515265',\n primary2: '#9335FB',\n primary2B: '#6323AA',\n secondary: '#FADD32',\n bgColor: '#F3F4F6',\n error: '#EA2E2E',\n\n white: '#FFFFFF',\n black: '#111111',\n gray1: '#424242',\n gray2: '#616161',\n gray3: '#8E8E8E',\n gray4: '#BDBDBD',\n gray5: '#E0E0E0',\n gray6: '#EDEDED',\n\n sub: '#A3A4BD',\n sub3: '#5561E8',\n sub3b: '#F1F7FF',\n sub4: '#1D1A1A',\n\n point: '#FADD32',\n} as const;\n\n/**\n * @deprecated use color instead (작명 실수 ㅠ)\n */\n\nconst colorV2 = color;\n\nexport { colorV2, color };\n","type TypographyKey =\n | 'h1-24b'\n | 'h1-24m'\n | 'h1-24'\n | 'h2-20b'\n | 'h2-20m'\n | 'h2-20'\n | 'h3-18b'\n | 'h3-18m'\n | 'h3-18'\n | 'b1-16b'\n | 'b1-16m'\n | 'b1-16'\n | 'b2-14b'\n | 'b2-14m'\n | 'b2-14'\n | 'b3-12b'\n | 'b3-12m'\n | 'b3-12'\n | 's1-10b'\n | 's1-10m'\n | 's1-10';\n\nconst typo = {\n 'h1-24b': {\n fontSize: 24,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h1-24m': {\n fontSize: 24,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h1-24': {\n fontSize: 24,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'h2-20b': {\n fontSize: 20,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h2-20m': {\n fontSize: 20,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h2-20': {\n fontSize: 20,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18b': {\n fontSize: 18,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18m': {\n fontSize: 18,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18': {\n fontSize: 18,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16b': {\n fontSize: 16,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16m': {\n fontSize: 16,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16': {\n fontSize: 16,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'b2-14b': {\n fontSize: 14,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b2-14m': {\n fontSize: 14,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b2-14': {\n fontSize: 14,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'b3-12b': {\n fontSize: 12,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b3-12m': {\n fontSize: 12,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b3-12': {\n fontSize: 12,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 's1-10b': {\n fontSize: 10,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 's1-10m': {\n fontSize: 10,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 's1-10': {\n fontSize: 10,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n} as const;\n\nconst transformLineheight = (key: TypographyKey) => {\n return typo[key].lineHeight * typo[key].fontSize;\n};\n\nconst mobileTypo = {\n 'h1-24b': {\n ...typo['h1-24b'],\n lineHeight: transformLineheight('h1-24b'),\n },\n\n 'h1-24m': {\n ...typo['h1-24m'],\n lineHeight: transformLineheight('h1-24m'),\n },\n\n 'h1-24': {\n ...typo['h1-24'],\n lineHeight: transformLineheight('h1-24'),\n },\n\n 'h2-20b': {\n ...typo['h2-20b'],\n lineHeight: transformLineheight('h2-20b'),\n },\n\n 'h2-20m': {\n ...typo['h2-20m'],\n lineHeight: transformLineheight('h2-20m'),\n },\n\n 'h2-20': {\n ...typo['h2-20'],\n lineHeight: transformLineheight('h2-20'),\n },\n\n 'h3-18b': {\n ...typo['h3-18b'],\n lineHeight: transformLineheight('h3-18b'),\n },\n\n 'h3-18m': {\n ...typo['h3-18m'],\n lineHeight: transformLineheight('h3-18m'),\n },\n\n 'h3-18': {\n ...typo['h3-18'],\n lineHeight: transformLineheight('h3-18'),\n },\n\n 'b1-16b': {\n ...typo['b1-16b'],\n lineHeight: transformLineheight('b1-16b'),\n },\n\n 'b1-16m': {\n ...typo['b1-16m'],\n lineHeight: transformLineheight('b1-16m'),\n },\n\n 'b1-16': {\n ...typo['b1-16'],\n lineHeight: transformLineheight('b1-16'),\n },\n\n 'b2-14b': {\n ...typo['b2-14b'],\n lineHeight: transformLineheight('b2-14b'),\n },\n\n 'b2-14m': {\n ...typo['b2-14m'],\n lineHeight: transformLineheight('b2-14m'),\n },\n\n 'b2-14': {\n ...typo['b2-14'],\n lineHeight: transformLineheight('b2-14'),\n },\n\n 'b3-12b': {\n ...typo['b3-12b'],\n lineHeight: transformLineheight('b3-12b'),\n },\n\n 'b3-12m': {\n ...typo['b3-12m'],\n lineHeight: transformLineheight('b3-12m'),\n },\n\n 'b3-12': {\n ...typo['b3-12'],\n lineHeight: transformLineheight('b3-12'),\n },\n\n 's1-10b': {\n ...typo['s1-10b'],\n lineHeight: transformLineheight('s1-10b'),\n },\n\n 's1-10m': {\n ...typo['s1-10m'],\n lineHeight: transformLineheight('s1-10m'),\n },\n\n 's1-10': {\n ...typo['s1-10'],\n lineHeight: transformLineheight('s1-10'),\n },\n} as const;\n\nexport { typo, mobileTypo };\n"],"mappings":";AAEO,IAAM,gCAAgC;AAAA,EAC3C,qBAAqB;AAAA,EACrB,aAAa;AAAA,EACb,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMvB,qBAAqB;AAAA,IACnB,MAAM;AAAA,IACN,MAAM;AAAA,IACN,KAAK;AAAA,EACP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,mBAAmB;AAAA,IACjB,MAAM;AAAA,IACN,MAAM;AAAA,IACN,KAAK;AAAA,EACP;AACF;AAMO,IAAM,uBAAuB;AAM7B,SAAS,0BAA0B,iBAAkC;AAC1E,SACE,OAAO,SAAS,eAAe,KAAK,mBAAmB;AAE3D;AAYO,SAAS,iCACd,iBACA,UAAuC,CAAC,GAChC;AACR,MAAI,CAAC,OAAO,SAAS,eAAe,KAAK,mBAAmB,EAAG,QAAO;AAEtE,QAAM,EAAE,MAAM,YAAY,IAAI;AAI9B,QAAM,cACJ,SAAS,SACL,8BAA8B,kBAAkB,IAAI,IACpD;AACN,QAAM,kBAAkB,KAAK,IAAI,GAAG,kBAAkB,WAAW;AACjE,MAAI,mBAAmB,EAAG,QAAO;AAEjC,QAAM,qBACJ,SAAS,SACL,8BAA8B,oBAAoB,IAAI,IAAI,KAC1D,8BAA8B,cAC9B,8BAA8B;AAEpC,QAAM,qBAAqB,cACvB,IAAI,8BAA8B,wBAClC;AAIJ,QAAM,UAAU,kBAAkB,qBAAqB;AACvD,SAAO,KAAK,KAAK,OAAO,QAAQ,QAAQ,CAAC,CAAC,CAAC;AAC7C;;;ACtFO,IAAM,uCAAuC;AAAA,EAClD,YAAY;AAAA,EACZ,UAAU;AACZ;AAkCA,IAAM,oBAAoB;AAC1B,IAAM,aAAa,KA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;AAAA,EAC1C;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/libs/cost.ts","../src/libs/gym-gold-charge.ts","../src/styles/color.ts","../src/styles/typo.ts"],"sourcesContent":["export const ORIGINAL_DOWNLOAD_COST_POLICY = {\n /**\n * 무료 다운로드 구간(초). 멤버십 구분 없이 모든 사용자에게 동일하게 적용한다.\n * 다운로드 길이 중 앞 `freeSeconds`초는 과금에서 제외하고,\n * 이를 초과한 구간에만 `krwPerMinute` 요율을 적용한다 (초과분 과금).\n */\n freeSeconds: 30,\n /**\n * 무료 구간 초과분에 적용하는 분당 KRW 요율. 멤버십 구분 없는 단일 요율.\n */\n krwPerMinute: 100,\n /**\n * 전체 영상 다운로드 시 할인율(10%).\n */\n fullVideoDiscountRate: 0.1,\n} as const;\n\n/**\n * 다운로드 가능한 최소 길이(초).\n * 이보다 짧은 구간은 다운로드 요청 자체를 허용하지 않는다 (server·FE 공용 제약).\n */\nexport const MIN_DOWNLOAD_SECONDS = 10;\n\n/**\n * 다운로드 요청 길이가 허용되는지 검사한다.\n * `durationSeconds >= MIN_DOWNLOAD_SECONDS`일 때만 true.\n */\nexport function isDownloadDurationAllowed(durationSeconds: number): boolean {\n return (\n Number.isFinite(durationSeconds) && durationSeconds >= MIN_DOWNLOAD_SECONDS\n );\n}\n\nexport interface OriginalDownloadCostOptions {\n isFullVideo?: boolean;\n /**\n * 동시에 다운로드할 화각(camera angle) 수. 최소 1, 기본 1.\n * 모든 화각은 동일한 길이로 함께 받으므로 단일 화각 비용 × 화각 수로 과금한다.\n * 1 미만이거나 유한하지 않은 값은 1로 보정한다.\n */\n angleCount?: number;\n}\n\nexport function calculateOriginalDownloadCostWon(\n durationSeconds: number,\n options: OriginalDownloadCostOptions = {},\n): number {\n if (!Number.isFinite(durationSeconds) || durationSeconds <= 0) return 0;\n\n const { isFullVideo, angleCount } = options;\n\n // 화각 수는 최소 1로 보정한다. 정수가 아닌 값은 내림 처리.\n const normalizedAngleCount = Number.isFinite(angleCount)\n ? Math.max(1, Math.floor(angleCount as number))\n : 1;\n\n // 앞 freeSeconds 구간은 과금에서 제외하고 초과분만 과금한다.\n const billableSeconds = Math.max(\n 0,\n durationSeconds - ORIGINAL_DOWNLOAD_COST_POLICY.freeSeconds,\n );\n if (billableSeconds <= 0) return 0;\n\n const unitPricePerSecond = ORIGINAL_DOWNLOAD_COST_POLICY.krwPerMinute / 60;\n\n const discountMultiplier = isFullVideo\n ? 1 - ORIGINAL_DOWNLOAD_COST_POLICY.fullVideoDiscountRate\n : 1;\n\n // 부동소수점 drift(예: 30.000000000000004) 때문에 1원 과다 청구되는 것을 막기 위해\n // 원 단위 미만 노이즈를 보정한 뒤 올림한다. 단일 화각 비용을 원 단위로 확정한 뒤\n // 화각 수만큼 곱한다 (각 화각을 개별 다운로드 건으로 과금).\n const rawCostPerAngle =\n billableSeconds * unitPricePerSecond * discountMultiplier;\n const costPerAngle = Math.ceil(Number(rawCostPerAngle.toFixed(6)));\n\n return costPerAngle * normalizedAngleCount;\n}\n","export const GYM_GOLD_CHARGE_POLICY = {\n minChargeKrw: 10_000,\n chargeUnitKrw: 10_000,\n bonusRate: 0.2,\n bonusRateBps: 2_000,\n} as const;\n\nexport function isGymGoldChargeKrwAllowed(chargeKrw: number): boolean {\n return (\n Number.isFinite(chargeKrw) &&\n Number.isInteger(chargeKrw) &&\n chargeKrw >= GYM_GOLD_CHARGE_POLICY.minChargeKrw &&\n chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw === 0\n );\n}\n\nexport function assertValidGymGoldChargeKrw(chargeKrw: number): void {\n if (!Number.isFinite(chargeKrw)) {\n throw new RangeError('chargeKrw must be a finite number');\n }\n\n if (!Number.isInteger(chargeKrw)) {\n throw new RangeError('chargeKrw must be an integer');\n }\n\n if (chargeKrw < GYM_GOLD_CHARGE_POLICY.minChargeKrw) {\n throw new RangeError(\n `chargeKrw must be at least ${GYM_GOLD_CHARGE_POLICY.minChargeKrw}`,\n );\n }\n\n if (chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw !== 0) {\n throw new RangeError(\n `chargeKrw must be a multiple of ${GYM_GOLD_CHARGE_POLICY.chargeUnitKrw}`,\n );\n }\n}\n","const color = {\n primary: '#242535',\n primaryB: '#515265',\n primary2: '#9335FB',\n primary2B: '#6323AA',\n secondary: '#FADD32',\n bgColor: '#F3F4F6',\n error: '#EA2E2E',\n\n white: '#FFFFFF',\n black: '#111111',\n gray1: '#424242',\n gray2: '#616161',\n gray3: '#8E8E8E',\n gray4: '#BDBDBD',\n gray5: '#E0E0E0',\n gray6: '#EDEDED',\n\n sub: '#A3A4BD',\n sub3: '#5561E8',\n sub3b: '#F1F7FF',\n sub4: '#1D1A1A',\n\n point: '#FADD32',\n} as const;\n\n/**\n * @deprecated use color instead (작명 실수 ㅠ)\n */\n\nconst colorV2 = color;\n\nexport { colorV2, color };\n","type TypographyKey =\n | 'h1-24b'\n | 'h1-24m'\n | 'h1-24'\n | 'h2-20b'\n | 'h2-20m'\n | 'h2-20'\n | 'h3-18b'\n | 'h3-18m'\n | 'h3-18'\n | 'b1-16b'\n | 'b1-16m'\n | 'b1-16'\n | 'b2-14b'\n | 'b2-14m'\n | 'b2-14'\n | 'b3-12b'\n | 'b3-12m'\n | 'b3-12'\n | 's1-10b'\n | 's1-10m'\n | 's1-10';\n\nconst typo = {\n 'h1-24b': {\n fontSize: 24,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h1-24m': {\n fontSize: 24,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h1-24': {\n fontSize: 24,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'h2-20b': {\n fontSize: 20,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h2-20m': {\n fontSize: 20,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h2-20': {\n fontSize: 20,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18b': {\n fontSize: 18,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18m': {\n fontSize: 18,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'h3-18': {\n fontSize: 18,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16b': {\n fontSize: 16,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16m': {\n fontSize: 16,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b1-16': {\n fontSize: 16,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'b2-14b': {\n fontSize: 14,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b2-14m': {\n fontSize: 14,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b2-14': {\n fontSize: 14,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 'b3-12b': {\n fontSize: 12,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b3-12m': {\n fontSize: 12,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 'b3-12': {\n fontSize: 12,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n\n 's1-10b': {\n fontSize: 10,\n fontWeight: 700,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 's1-10m': {\n fontSize: 10,\n fontWeight: 500,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n 's1-10': {\n fontSize: 10,\n fontWeight: 400,\n lineHeight: 1.5,\n letterSpacing: 0,\n },\n} as const;\n\nconst transformLineheight = (key: TypographyKey) => {\n return typo[key].lineHeight * typo[key].fontSize;\n};\n\nconst mobileTypo = {\n 'h1-24b': {\n ...typo['h1-24b'],\n lineHeight: transformLineheight('h1-24b'),\n },\n\n 'h1-24m': {\n ...typo['h1-24m'],\n lineHeight: transformLineheight('h1-24m'),\n },\n\n 'h1-24': {\n ...typo['h1-24'],\n lineHeight: transformLineheight('h1-24'),\n },\n\n 'h2-20b': {\n ...typo['h2-20b'],\n lineHeight: transformLineheight('h2-20b'),\n },\n\n 'h2-20m': {\n ...typo['h2-20m'],\n lineHeight: transformLineheight('h2-20m'),\n },\n\n 'h2-20': {\n ...typo['h2-20'],\n lineHeight: transformLineheight('h2-20'),\n },\n\n 'h3-18b': {\n ...typo['h3-18b'],\n lineHeight: transformLineheight('h3-18b'),\n },\n\n 'h3-18m': {\n ...typo['h3-18m'],\n lineHeight: transformLineheight('h3-18m'),\n },\n\n 'h3-18': {\n ...typo['h3-18'],\n lineHeight: transformLineheight('h3-18'),\n },\n\n 'b1-16b': {\n ...typo['b1-16b'],\n lineHeight: transformLineheight('b1-16b'),\n },\n\n 'b1-16m': {\n ...typo['b1-16m'],\n lineHeight: transformLineheight('b1-16m'),\n },\n\n 'b1-16': {\n ...typo['b1-16'],\n lineHeight: transformLineheight('b1-16'),\n },\n\n 'b2-14b': {\n ...typo['b2-14b'],\n lineHeight: transformLineheight('b2-14b'),\n },\n\n 'b2-14m': {\n ...typo['b2-14m'],\n lineHeight: transformLineheight('b2-14m'),\n },\n\n 'b2-14': {\n ...typo['b2-14'],\n lineHeight: transformLineheight('b2-14'),\n },\n\n 'b3-12b': {\n ...typo['b3-12b'],\n lineHeight: transformLineheight('b3-12b'),\n },\n\n 'b3-12m': {\n ...typo['b3-12m'],\n lineHeight: transformLineheight('b3-12m'),\n },\n\n 'b3-12': {\n ...typo['b3-12'],\n lineHeight: transformLineheight('b3-12'),\n },\n\n 's1-10b': {\n ...typo['s1-10b'],\n lineHeight: transformLineheight('s1-10b'),\n },\n\n 's1-10m': {\n ...typo['s1-10m'],\n lineHeight: transformLineheight('s1-10m'),\n },\n\n 's1-10': {\n ...typo['s1-10'],\n lineHeight: transformLineheight('s1-10'),\n },\n} as const;\n\nexport { typo, mobileTypo };\n"],"mappings":";AAAO,IAAM,gCAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3C,aAAa;AAAA;AAAA;AAAA;AAAA,EAIb,cAAc;AAAA;AAAA;AAAA;AAAA,EAId,uBAAuB;A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Q;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,UAAU;AAAA,IACR,GAAG,KAAK,QAAQ;AAAA,IAChB,YAAY,oBAAoB,QAAQ;AAAA,EAC1C;AAAA,EAEA,SAAS;AAAA,IACP,GAAG,KAAK,OAAO;AAAA,IACf,YAAY,oBAAoB,OAAO;AAAA,EACzC;AACF;","names":[]}
|
package/dist/libs.cjs
CHANGED
|
@@ -20,42 +20,32 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/libs/index.ts
|
|
21
21
|
var libs_exports = {};
|
|
22
22
|
__export(libs_exports, {
|
|
23
|
-
|
|
23
|
+
GYM_GOLD_CHARGE_POLICY: () => GYM_GOLD_CHARGE_POLICY,
|
|
24
24
|
MIN_DOWNLOAD_SECONDS: () => MIN_DOWNLOAD_SECONDS,
|
|
25
25
|
ORIGINAL_DOWNLOAD_COST_POLICY: () => ORIGINAL_DOWNLOAD_COST_POLICY,
|
|
26
|
-
|
|
27
|
-
calculateGymPartnerRegistrationGoldTotal: () => calculateGymPartnerRegistrationGoldTotal,
|
|
26
|
+
assertValidGymGoldChargeKrw: () => assertValidGymGoldChargeKrw,
|
|
28
27
|
calculateOriginalDownloadCostWon: () => calculateOriginalDownloadCostWon,
|
|
29
|
-
isDownloadDurationAllowed: () => isDownloadDurationAllowed
|
|
28
|
+
isDownloadDurationAllowed: () => isDownloadDurationAllowed,
|
|
29
|
+
isGymGoldChargeKrwAllowed: () => isGymGoldChargeKrwAllowed
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(libs_exports);
|
|
32
32
|
|
|
33
33
|
// src/libs/cost.ts
|
|
34
34
|
var ORIGINAL_DOWNLOAD_COST_POLICY = {
|
|
35
|
-
baseDurationSeconds: 600,
|
|
36
|
-
baseCostWon: 2e3,
|
|
37
|
-
fullVideoDiscountRate: 0.1,
|
|
38
35
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
36
|
+
* 무료 다운로드 구간(초). 멤버십 구분 없이 모든 사용자에게 동일하게 적용한다.
|
|
37
|
+
* 다운로드 길이 중 앞 `freeSeconds`초는 과금에서 제외하고,
|
|
38
|
+
* 이를 초과한 구간에만 `krwPerMinute` 요율을 적용한다 (초과분 과금).
|
|
42
39
|
*/
|
|
43
|
-
|
|
44
|
-
FREE: 100,
|
|
45
|
-
PLUS: 50,
|
|
46
|
-
PRO: 25
|
|
47
|
-
},
|
|
40
|
+
freeSeconds: 30,
|
|
48
41
|
/**
|
|
49
|
-
* 멤버십
|
|
50
|
-
* 다운로드 길이 중 앞 `freeSecondsByPlan[plan]`초는 과금에서 제외하고,
|
|
51
|
-
* 이를 초과한 구간에만 `perPlanKrwPerMinute[plan]` 요율을 적용한다 (초과분 과금).
|
|
52
|
-
* plan 미지정(레거시 단일 단가) 경로에는 무료 구간을 적용하지 않는다.
|
|
42
|
+
* 무료 구간 초과분에 적용하는 분당 KRW 요율. 멤버십 구분 없는 단일 요율.
|
|
53
43
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
krwPerMinute: 100,
|
|
45
|
+
/**
|
|
46
|
+
* 전체 영상 다운로드 시 할인율(10%).
|
|
47
|
+
*/
|
|
48
|
+
fullVideoDiscountRate: 0.1
|
|
59
49
|
};
|
|
60
50
|
var MIN_DOWNLOAD_SECONDS = 10;
|
|
61
51
|
function isDownloadDurationAllowed(durationSeconds) {
|
|
@@ -63,76 +53,56 @@ function isDownloadDurationAllowed(durationSeconds) {
|
|
|
63
53
|
}
|
|
64
54
|
function calculateOriginalDownloadCostWon(durationSeconds, options = {}) {
|
|
65
55
|
if (!Number.isFinite(durationSeconds) || durationSeconds <= 0) return 0;
|
|
66
|
-
const {
|
|
67
|
-
const
|
|
68
|
-
const billableSeconds = Math.max(
|
|
56
|
+
const { isFullVideo, angleCount } = options;
|
|
57
|
+
const normalizedAngleCount = Number.isFinite(angleCount) ? Math.max(1, Math.floor(angleCount)) : 1;
|
|
58
|
+
const billableSeconds = Math.max(
|
|
59
|
+
0,
|
|
60
|
+
durationSeconds - ORIGINAL_DOWNLOAD_COST_POLICY.freeSeconds
|
|
61
|
+
);
|
|
69
62
|
if (billableSeconds <= 0) return 0;
|
|
70
|
-
const unitPricePerSecond =
|
|
63
|
+
const unitPricePerSecond = ORIGINAL_DOWNLOAD_COST_POLICY.krwPerMinute / 60;
|
|
71
64
|
const discountMultiplier = isFullVideo ? 1 - ORIGINAL_DOWNLOAD_COST_POLICY.fullVideoDiscountRate : 1;
|
|
72
|
-
const
|
|
73
|
-
|
|
65
|
+
const rawCostPerAngle = billableSeconds * unitPricePerSecond * discountMultiplier;
|
|
66
|
+
const costPerAngle = Math.ceil(Number(rawCostPerAngle.toFixed(6)));
|
|
67
|
+
return costPerAngle * normalizedAngleCount;
|
|
74
68
|
}
|
|
75
69
|
|
|
76
|
-
// src/libs/gym-
|
|
77
|
-
var
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
// src/libs/gym-gold-charge.ts
|
|
71
|
+
var GYM_GOLD_CHARGE_POLICY = {
|
|
72
|
+
minChargeKrw: 1e4,
|
|
73
|
+
chargeUnitKrw: 1e4,
|
|
74
|
+
bonusRate: 0.2,
|
|
75
|
+
bonusRateBps: 2e3
|
|
80
76
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
function calculateGymPartnerRegistrationGold(input) {
|
|
84
|
-
const startDate = parseKstDateString(input.startDate, "startDate");
|
|
85
|
-
const endDate = parseKstDateString(input.endDate, "endDate");
|
|
86
|
-
const startDateKey = toUtcDateKey(startDate);
|
|
87
|
-
const endDateKey = toUtcDateKey(endDate);
|
|
88
|
-
if (endDateKey < startDateKey) {
|
|
89
|
-
throw new RangeError("endDate must be on or after startDate");
|
|
90
|
-
}
|
|
91
|
-
const days = Math.floor((endDateKey - startDateKey) / MS_PER_DAY) + 1;
|
|
92
|
-
return {
|
|
93
|
-
days,
|
|
94
|
-
goldAmount: days * GYM_PARTNER_REGISTRATION_GOLD_POLICY.goldPerDay
|
|
95
|
-
};
|
|
77
|
+
function isGymGoldChargeKrwAllowed(chargeKrw) {
|
|
78
|
+
return Number.isFinite(chargeKrw) && Number.isInteger(chargeKrw) && chargeKrw >= GYM_GOLD_CHARGE_POLICY.minChargeKrw && chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw === 0;
|
|
96
79
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
...period,
|
|
102
|
-
...result
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
return {
|
|
106
|
-
totalDays: items.reduce((sum, item) => sum + item.days, 0),
|
|
107
|
-
totalGoldAmount: items.reduce((sum, item) => sum + item.goldAmount, 0),
|
|
108
|
-
items
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function parseKstDateString(input, fieldName) {
|
|
112
|
-
const dateOnlyMatch = DATE_ONLY_PATTERN.exec(input);
|
|
113
|
-
if (dateOnlyMatch === null) {
|
|
114
|
-
throw new RangeError(`${fieldName} must be a YYYY-MM-DD date`);
|
|
80
|
+
function assertValidGymGoldChargeKrw(chargeKrw) {
|
|
81
|
+
if (!Number.isFinite(chargeKrw)) {
|
|
82
|
+
throw new RangeError("chargeKrw must be a finite number");
|
|
115
83
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
84
|
+
if (!Number.isInteger(chargeKrw)) {
|
|
85
|
+
throw new RangeError("chargeKrw must be an integer");
|
|
86
|
+
}
|
|
87
|
+
if (chargeKrw < GYM_GOLD_CHARGE_POLICY.minChargeKrw) {
|
|
88
|
+
throw new RangeError(
|
|
89
|
+
`chargeKrw must be at least ${GYM_GOLD_CHARGE_POLICY.minChargeKrw}`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw !== 0) {
|
|
93
|
+
throw new RangeError(
|
|
94
|
+
`chargeKrw must be a multiple of ${GYM_GOLD_CHARGE_POLICY.chargeUnitKrw}`
|
|
95
|
+
);
|
|
122
96
|
}
|
|
123
|
-
return { year, month, day };
|
|
124
|
-
}
|
|
125
|
-
function toUtcDateKey(date) {
|
|
126
|
-
return Date.UTC(date.year, date.month - 1, date.day);
|
|
127
97
|
}
|
|
128
98
|
// Annotate the CommonJS export names for ESM import in node:
|
|
129
99
|
0 && (module.exports = {
|
|
130
|
-
|
|
100
|
+
GYM_GOLD_CHARGE_POLICY,
|
|
131
101
|
MIN_DOWNLOAD_SECONDS,
|
|
132
102
|
ORIGINAL_DOWNLOAD_COST_POLICY,
|
|
133
|
-
|
|
134
|
-
calculateGymPartnerRegistrationGoldTotal,
|
|
103
|
+
assertValidGymGoldChargeKrw,
|
|
135
104
|
calculateOriginalDownloadCostWon,
|
|
136
|
-
isDownloadDurationAllowed
|
|
105
|
+
isDownloadDurationAllowed,
|
|
106
|
+
isGymGoldChargeKrwAllowed
|
|
137
107
|
});
|
|
138
108
|
//# sourceMappingURL=libs.cjs.map
|
package/dist/libs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/libs/index.ts","../src/libs/cost.ts","../src/libs/gym-
|
|
1
|
+
{"version":3,"sources":["../src/libs/index.ts","../src/libs/cost.ts","../src/libs/gym-gold-charge.ts"],"sourcesContent":["export * from './cost';\nexport * from './gym-gold-charge';\n","export const ORIGINAL_DOWNLOAD_COST_POLICY = {\n /**\n * 무료 다운로드 구간(초). 멤버십 구분 없이 모든 사용자에게 동일하게 적용한다.\n * 다운로드 길이 중 앞 `freeSeconds`초는 과금에서 제외하고,\n * 이를 초과한 구간에만 `krwPerMinute` 요율을 적용한다 (초과분 과금).\n */\n freeSeconds: 30,\n /**\n * 무료 구간 초과분에 적용하는 분당 KRW 요율. 멤버십 구분 없는 단일 요율.\n */\n krwPerMinute: 100,\n /**\n * 전체 영상 다운로드 시 할인율(10%).\n */\n fullVideoDiscountRate: 0.1,\n} as const;\n\n/**\n * 다운로드 가능한 최소 길이(초).\n * 이보다 짧은 구간은 다운로드 요청 자체를 허용하지 않는다 (server·FE 공용 제약).\n */\nexport const MIN_DOWNLOAD_SECONDS = 10;\n\n/**\n * 다운로드 요청 길이가 허용되는지 검사한다.\n * `durationSeconds >= MIN_DOWNLOAD_SECONDS`일 때만 true.\n */\nexport function isDownloadDurationAllowed(durationSeconds: number): boolean {\n return (\n Number.isFinite(durationSeconds) && durationSeconds >= MIN_DOWNLOAD_SECONDS\n );\n}\n\nexport interface OriginalDownloadCostOptions {\n isFullVideo?: boolean;\n /**\n * 동시에 다운로드할 화각(camera angle) 수. 최소 1, 기본 1.\n * 모든 화각은 동일한 길이로 함께 받으므로 단일 화각 비용 × 화각 수로 과금한다.\n * 1 미만이거나 유한하지 않은 값은 1로 보정한다.\n */\n angleCount?: number;\n}\n\nexport function calculateOriginalDownloadCostWon(\n durationSeconds: number,\n options: OriginalDownloadCostOptions = {},\n): number {\n if (!Number.isFinite(durationSeconds) || durationSeconds <= 0) return 0;\n\n const { isFullVideo, angleCount } = options;\n\n // 화각 수는 최소 1로 보정한다. 정수가 아닌 값은 내림 처리.\n const normalizedAngleCount = Number.isFinite(angleCount)\n ? Math.max(1, Math.floor(angleCount as number))\n : 1;\n\n // 앞 freeSeconds 구간은 과금에서 제외하고 초과분만 과금한다.\n const billableSeconds = Math.max(\n 0,\n durationSeconds - ORIGINAL_DOWNLOAD_COST_POLICY.freeSeconds,\n );\n if (billableSeconds <= 0) return 0;\n\n const unitPricePerSecond = ORIGINAL_DOWNLOAD_COST_POLICY.krwPerMinute / 60;\n\n const discountMultiplier = isFullVideo\n ? 1 - ORIGINAL_DOWNLOAD_COST_POLICY.fullVideoDiscountRate\n : 1;\n\n // 부동소수점 drift(예: 30.000000000000004) 때문에 1원 과다 청구되는 것을 막기 위해\n // 원 단위 미만 노이즈를 보정한 뒤 올림한다. 단일 화각 비용을 원 단위로 확정한 뒤\n // 화각 수만큼 곱한다 (각 화각을 개별 다운로드 건으로 과금).\n const rawCostPerAngle =\n billableSeconds * unitPricePerSecond * discountMultiplier;\n const costPerAngle = Math.ceil(Number(rawCostPerAngle.toFixed(6)));\n\n return costPerAngle * normalizedAngleCount;\n}\n","export const GYM_GOLD_CHARGE_POLICY = {\n minChargeKrw: 10_000,\n chargeUnitKrw: 10_000,\n bonusRate: 0.2,\n bonusRateBps: 2_000,\n} as const;\n\nexport function isGymGoldChargeKrwAllowed(chargeKrw: number): boolean {\n return (\n Number.isFinite(chargeKrw) &&\n Number.isInteger(chargeKrw) &&\n chargeKrw >= GYM_GOLD_CHARGE_POLICY.minChargeKrw &&\n chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw === 0\n );\n}\n\nexport function assertValidGymGoldChargeKrw(chargeKrw: number): void {\n if (!Number.isFinite(chargeKrw)) {\n throw new RangeError('chargeKrw must be a finite number');\n }\n\n if (!Number.isInteger(chargeKrw)) {\n throw new RangeError('chargeKrw must be an integer');\n }\n\n if (chargeKrw < GYM_GOLD_CHARGE_POLICY.minChargeKrw) {\n throw new RangeError(\n `chargeKrw must be at least ${GYM_GOLD_CHARGE_POLICY.minChargeKrw}`,\n );\n }\n\n if (chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw !== 0) {\n throw new RangeError(\n `chargeKrw must be a multiple of ${GYM_GOLD_CHARGE_POLICY.chargeUnitKrw}`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gCAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3C,aAAa;AAAA;AAAA;AAAA;AAAA,EAIb,cAAc;AAAA;AAAA;AAAA;AAAA,EAId,uBAAuB;AACzB;AAMO,IAAM,uBAAuB;AAM7B,SAAS,0BAA0B,iBAAkC;AAC1E,SACE,OAAO,SAAS,eAAe,KAAK,mBAAmB;AAE3D;AAYO,SAAS,iCACd,iBACA,UAAuC,CAAC,GAChC;AACR,MAAI,CAAC,OAAO,SAAS,eAAe,KAAK,mBAAmB,EAAG,QAAO;AAEtE,QAAM,EAAE,aAAa,WAAW,IAAI;AAGpC,QAAM,uBAAuB,OAAO,SAAS,UAAU,IACnD,KAAK,IAAI,GAAG,KAAK,MAAM,UAAoB,CAAC,IAC5C;AAGJ,QAAM,kBAAkB,KAAK;AAAA,IAC3B;AAAA,IACA,kBAAkB,8BAA8B;AAAA,EAClD;AACA,MAAI,mBAAmB,EAAG,QAAO;AAEjC,QAAM,qBAAqB,8BAA8B,eAAe;AAExE,QAAM,qBAAqB,cACvB,IAAI,8BAA8B,wBAClC;AAKJ,QAAM,kBACJ,kBAAkB,qBAAqB;AACzC,QAAM,eAAe,KAAK,KAAK,OAAO,gBAAgB,QAAQ,CAAC,CAAC,CAAC;AAEjE,SAAO,eAAe;AACxB;;;AC7EO,IAAM,yBAAyB;AAAA,EACpC,cAAc;AAAA,EACd,eAAe;AAAA,EACf,WAAW;AAAA,EACX,cAAc;AAChB;AAEO,SAAS,0BAA0B,WAA4B;AACpE,SACE,OAAO,SAAS,SAAS,KACzB,OAAO,UAAU,SAAS,KAC1B,aAAa,uBAAuB,gBACpC,YAAY,uBAAuB,kBAAkB;AAEzD;AAEO,SAAS,4BAA4B,WAAyB;AACnE,MAAI,CAAC,OAAO,SAAS,SAAS,GAAG;AAC/B,UAAM,IAAI,WAAW,mCAAmC;AAAA,EAC1D;AAEA,MAAI,CAAC,OAAO,UAAU,SAAS,GAAG;AAChC,UAAM,IAAI,WAAW,8BAA8B;AAAA,EACrD;AAEA,MAAI,YAAY,uBAAuB,cAAc;AACnD,UAAM,IAAI;AAAA,MACR,8BAA8B,uBAAuB,YAAY;AAAA,IACnE;AAAA,EACF;AAEA,MAAI,YAAY,uBAAuB,kBAAkB,GAAG;AAC1D,UAAM,IAAI;AAAA,MACR,mCAAmC,uBAAuB,aAAa;AAAA,IACzE;AAAA,EACF;AACF;","names":[]}
|
package/dist/libs.d.cts
CHANGED
|
@@ -1,30 +1,18 @@
|
|
|
1
|
-
import { T as TicketCode } from './membership-C_ziSHS0.cjs';
|
|
2
|
-
|
|
3
1
|
declare const ORIGINAL_DOWNLOAD_COST_POLICY: {
|
|
4
|
-
readonly baseDurationSeconds: 600;
|
|
5
|
-
readonly baseCostWon: 2000;
|
|
6
|
-
readonly fullVideoDiscountRate: 0.1;
|
|
7
2
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
3
|
+
* 무료 다운로드 구간(초). 멤버십 구분 없이 모든 사용자에게 동일하게 적용한다.
|
|
4
|
+
* 다운로드 길이 중 앞 `freeSeconds`초는 과금에서 제외하고,
|
|
5
|
+
* 이를 초과한 구간에만 `krwPerMinute` 요율을 적용한다 (초과분 과금).
|
|
6
|
+
*/
|
|
7
|
+
readonly freeSeconds: 30;
|
|
8
|
+
/**
|
|
9
|
+
* 무료 구간 초과분에 적용하는 분당 KRW 요율. 멤버십 구분 없는 단일 요율.
|
|
11
10
|
*/
|
|
12
|
-
readonly
|
|
13
|
-
readonly FREE: 100;
|
|
14
|
-
readonly PLUS: 50;
|
|
15
|
-
readonly PRO: 25;
|
|
16
|
-
};
|
|
11
|
+
readonly krwPerMinute: 100;
|
|
17
12
|
/**
|
|
18
|
-
*
|
|
19
|
-
* 다운로드 길이 중 앞 `freeSecondsByPlan[plan]`초는 과금에서 제외하고,
|
|
20
|
-
* 이를 초과한 구간에만 `perPlanKrwPerMinute[plan]` 요율을 적용한다 (초과분 과금).
|
|
21
|
-
* plan 미지정(레거시 단일 단가) 경로에는 무료 구간을 적용하지 않는다.
|
|
13
|
+
* 전체 영상 다운로드 시 할인율(10%).
|
|
22
14
|
*/
|
|
23
|
-
readonly
|
|
24
|
-
readonly FREE: 10;
|
|
25
|
-
readonly PLUS: 20;
|
|
26
|
-
readonly PRO: 30;
|
|
27
|
-
};
|
|
15
|
+
readonly fullVideoDiscountRate: 0.1;
|
|
28
16
|
};
|
|
29
17
|
/**
|
|
30
18
|
* 다운로드 가능한 최소 길이(초).
|
|
@@ -39,40 +27,21 @@ declare function isDownloadDurationAllowed(durationSeconds: number): boolean;
|
|
|
39
27
|
interface OriginalDownloadCostOptions {
|
|
40
28
|
isFullVideo?: boolean;
|
|
41
29
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
30
|
+
* 동시에 다운로드할 화각(camera angle) 수. 최소 1, 기본 1.
|
|
31
|
+
* 모든 화각은 동일한 길이로 함께 받으므로 단일 화각 비용 × 화각 수로 과금한다.
|
|
32
|
+
* 1 미만이거나 유한하지 않은 값은 1로 보정한다.
|
|
45
33
|
*/
|
|
46
|
-
|
|
34
|
+
angleCount?: number;
|
|
47
35
|
}
|
|
48
36
|
declare function calculateOriginalDownloadCostWon(durationSeconds: number, options?: OriginalDownloadCostOptions): number;
|
|
49
37
|
|
|
50
|
-
declare const
|
|
51
|
-
readonly
|
|
52
|
-
readonly
|
|
38
|
+
declare const GYM_GOLD_CHARGE_POLICY: {
|
|
39
|
+
readonly minChargeKrw: 10000;
|
|
40
|
+
readonly chargeUnitKrw: 10000;
|
|
41
|
+
readonly bonusRate: 0.2;
|
|
42
|
+
readonly bonusRateBps: 2000;
|
|
53
43
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* KST calendar date in YYYY-MM-DD format.
|
|
57
|
-
*/
|
|
58
|
-
startDate: string;
|
|
59
|
-
/**
|
|
60
|
-
* KST calendar date in YYYY-MM-DD format.
|
|
61
|
-
*/
|
|
62
|
-
endDate: string;
|
|
63
|
-
}
|
|
64
|
-
interface GymPartnerRegistrationGoldResult {
|
|
65
|
-
days: number;
|
|
66
|
-
goldAmount: number;
|
|
67
|
-
}
|
|
68
|
-
interface GymPartnerRegistrationGoldTotalItem extends GymPartnerRegistrationGoldInput, GymPartnerRegistrationGoldResult {
|
|
69
|
-
}
|
|
70
|
-
interface GymPartnerRegistrationGoldTotalResult {
|
|
71
|
-
totalDays: number;
|
|
72
|
-
totalGoldAmount: number;
|
|
73
|
-
items: GymPartnerRegistrationGoldTotalItem[];
|
|
74
|
-
}
|
|
75
|
-
declare function calculateGymPartnerRegistrationGold(input: GymPartnerRegistrationGoldInput): GymPartnerRegistrationGoldResult;
|
|
76
|
-
declare function calculateGymPartnerRegistrationGoldTotal(periods: GymPartnerRegistrationGoldInput[]): GymPartnerRegistrationGoldTotalResult;
|
|
44
|
+
declare function isGymGoldChargeKrwAllowed(chargeKrw: number): boolean;
|
|
45
|
+
declare function assertValidGymGoldChargeKrw(chargeKrw: number): void;
|
|
77
46
|
|
|
78
|
-
export {
|
|
47
|
+
export { GYM_GOLD_CHARGE_POLICY, MIN_DOWNLOAD_SECONDS, ORIGINAL_DOWNLOAD_COST_POLICY, type OriginalDownloadCostOptions, assertValidGymGoldChargeKrw, calculateOriginalDownloadCostWon, isDownloadDurationAllowed, isGymGoldChargeKrwAllowed };
|
package/dist/libs.d.ts
CHANGED
|
@@ -1,30 +1,18 @@
|
|
|
1
|
-
import { T as TicketCode } from './membership-C_ziSHS0.js';
|
|
2
|
-
|
|
3
1
|
declare const ORIGINAL_DOWNLOAD_COST_POLICY: {
|
|
4
|
-
readonly baseDurationSeconds: 600;
|
|
5
|
-
readonly baseCostWon: 2000;
|
|
6
|
-
readonly fullVideoDiscountRate: 0.1;
|
|
7
2
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
3
|
+
* 무료 다운로드 구간(초). 멤버십 구분 없이 모든 사용자에게 동일하게 적용한다.
|
|
4
|
+
* 다운로드 길이 중 앞 `freeSeconds`초는 과금에서 제외하고,
|
|
5
|
+
* 이를 초과한 구간에만 `krwPerMinute` 요율을 적용한다 (초과분 과금).
|
|
6
|
+
*/
|
|
7
|
+
readonly freeSeconds: 30;
|
|
8
|
+
/**
|
|
9
|
+
* 무료 구간 초과분에 적용하는 분당 KRW 요율. 멤버십 구분 없는 단일 요율.
|
|
11
10
|
*/
|
|
12
|
-
readonly
|
|
13
|
-
readonly FREE: 100;
|
|
14
|
-
readonly PLUS: 50;
|
|
15
|
-
readonly PRO: 25;
|
|
16
|
-
};
|
|
11
|
+
readonly krwPerMinute: 100;
|
|
17
12
|
/**
|
|
18
|
-
*
|
|
19
|
-
* 다운로드 길이 중 앞 `freeSecondsByPlan[plan]`초는 과금에서 제외하고,
|
|
20
|
-
* 이를 초과한 구간에만 `perPlanKrwPerMinute[plan]` 요율을 적용한다 (초과분 과금).
|
|
21
|
-
* plan 미지정(레거시 단일 단가) 경로에는 무료 구간을 적용하지 않는다.
|
|
13
|
+
* 전체 영상 다운로드 시 할인율(10%).
|
|
22
14
|
*/
|
|
23
|
-
readonly
|
|
24
|
-
readonly FREE: 10;
|
|
25
|
-
readonly PLUS: 20;
|
|
26
|
-
readonly PRO: 30;
|
|
27
|
-
};
|
|
15
|
+
readonly fullVideoDiscountRate: 0.1;
|
|
28
16
|
};
|
|
29
17
|
/**
|
|
30
18
|
* 다운로드 가능한 최소 길이(초).
|
|
@@ -39,40 +27,21 @@ declare function isDownloadDurationAllowed(durationSeconds: number): boolean;
|
|
|
39
27
|
interface OriginalDownloadCostOptions {
|
|
40
28
|
isFullVideo?: boolean;
|
|
41
29
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
30
|
+
* 동시에 다운로드할 화각(camera angle) 수. 최소 1, 기본 1.
|
|
31
|
+
* 모든 화각은 동일한 길이로 함께 받으므로 단일 화각 비용 × 화각 수로 과금한다.
|
|
32
|
+
* 1 미만이거나 유한하지 않은 값은 1로 보정한다.
|
|
45
33
|
*/
|
|
46
|
-
|
|
34
|
+
angleCount?: number;
|
|
47
35
|
}
|
|
48
36
|
declare function calculateOriginalDownloadCostWon(durationSeconds: number, options?: OriginalDownloadCostOptions): number;
|
|
49
37
|
|
|
50
|
-
declare const
|
|
51
|
-
readonly
|
|
52
|
-
readonly
|
|
38
|
+
declare const GYM_GOLD_CHARGE_POLICY: {
|
|
39
|
+
readonly minChargeKrw: 10000;
|
|
40
|
+
readonly chargeUnitKrw: 10000;
|
|
41
|
+
readonly bonusRate: 0.2;
|
|
42
|
+
readonly bonusRateBps: 2000;
|
|
53
43
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* KST calendar date in YYYY-MM-DD format.
|
|
57
|
-
*/
|
|
58
|
-
startDate: string;
|
|
59
|
-
/**
|
|
60
|
-
* KST calendar date in YYYY-MM-DD format.
|
|
61
|
-
*/
|
|
62
|
-
endDate: string;
|
|
63
|
-
}
|
|
64
|
-
interface GymPartnerRegistrationGoldResult {
|
|
65
|
-
days: number;
|
|
66
|
-
goldAmount: number;
|
|
67
|
-
}
|
|
68
|
-
interface GymPartnerRegistrationGoldTotalItem extends GymPartnerRegistrationGoldInput, GymPartnerRegistrationGoldResult {
|
|
69
|
-
}
|
|
70
|
-
interface GymPartnerRegistrationGoldTotalResult {
|
|
71
|
-
totalDays: number;
|
|
72
|
-
totalGoldAmount: number;
|
|
73
|
-
items: GymPartnerRegistrationGoldTotalItem[];
|
|
74
|
-
}
|
|
75
|
-
declare function calculateGymPartnerRegistrationGold(input: GymPartnerRegistrationGoldInput): GymPartnerRegistrationGoldResult;
|
|
76
|
-
declare function calculateGymPartnerRegistrationGoldTotal(periods: GymPartnerRegistrationGoldInput[]): GymPartnerRegistrationGoldTotalResult;
|
|
44
|
+
declare function isGymGoldChargeKrwAllowed(chargeKrw: number): boolean;
|
|
45
|
+
declare function assertValidGymGoldChargeKrw(chargeKrw: number): void;
|
|
77
46
|
|
|
78
|
-
export {
|
|
47
|
+
export { GYM_GOLD_CHARGE_POLICY, MIN_DOWNLOAD_SECONDS, ORIGINAL_DOWNLOAD_COST_POLICY, type OriginalDownloadCostOptions, assertValidGymGoldChargeKrw, calculateOriginalDownloadCostWon, isDownloadDurationAllowed, isGymGoldChargeKrwAllowed };
|
package/dist/libs.js
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
// src/libs/cost.ts
|
|
2
2
|
var ORIGINAL_DOWNLOAD_COST_POLICY = {
|
|
3
|
-
baseDurationSeconds: 600,
|
|
4
|
-
baseCostWon: 2e3,
|
|
5
|
-
fullVideoDiscountRate: 0.1,
|
|
6
3
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* 무료 다운로드 구간(초). 멤버십 구분 없이 모든 사용자에게 동일하게 적용한다.
|
|
5
|
+
* 다운로드 길이 중 앞 `freeSeconds`초는 과금에서 제외하고,
|
|
6
|
+
* 이를 초과한 구간에만 `krwPerMinute` 요율을 적용한다 (초과분 과금).
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
FREE: 100,
|
|
13
|
-
PLUS: 50,
|
|
14
|
-
PRO: 25
|
|
15
|
-
},
|
|
8
|
+
freeSeconds: 30,
|
|
16
9
|
/**
|
|
17
|
-
* 멤버십
|
|
18
|
-
* 다운로드 길이 중 앞 `freeSecondsByPlan[plan]`초는 과금에서 제외하고,
|
|
19
|
-
* 이를 초과한 구간에만 `perPlanKrwPerMinute[plan]` 요율을 적용한다 (초과분 과금).
|
|
20
|
-
* plan 미지정(레거시 단일 단가) 경로에는 무료 구간을 적용하지 않는다.
|
|
10
|
+
* 무료 구간 초과분에 적용하는 분당 KRW 요율. 멤버십 구분 없는 단일 요율.
|
|
21
11
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
krwPerMinute: 100,
|
|
13
|
+
/**
|
|
14
|
+
* 전체 영상 다운로드 시 할인율(10%).
|
|
15
|
+
*/
|
|
16
|
+
fullVideoDiscountRate: 0.1
|
|
27
17
|
};
|
|
28
18
|
var MIN_DOWNLOAD_SECONDS = 10;
|
|
29
19
|
function isDownloadDurationAllowed(durationSeconds) {
|
|
@@ -31,75 +21,55 @@ function isDownloadDurationAllowed(durationSeconds) {
|
|
|
31
21
|
}
|
|
32
22
|
function calculateOriginalDownloadCostWon(durationSeconds, options = {}) {
|
|
33
23
|
if (!Number.isFinite(durationSeconds) || durationSeconds <= 0) return 0;
|
|
34
|
-
const {
|
|
35
|
-
const
|
|
36
|
-
const billableSeconds = Math.max(
|
|
24
|
+
const { isFullVideo, angleCount } = options;
|
|
25
|
+
const normalizedAngleCount = Number.isFinite(angleCount) ? Math.max(1, Math.floor(angleCount)) : 1;
|
|
26
|
+
const billableSeconds = Math.max(
|
|
27
|
+
0,
|
|
28
|
+
durationSeconds - ORIGINAL_DOWNLOAD_COST_POLICY.freeSeconds
|
|
29
|
+
);
|
|
37
30
|
if (billableSeconds <= 0) return 0;
|
|
38
|
-
const unitPricePerSecond =
|
|
31
|
+
const unitPricePerSecond = ORIGINAL_DOWNLOAD_COST_POLICY.krwPerMinute / 60;
|
|
39
32
|
const discountMultiplier = isFullVideo ? 1 - ORIGINAL_DOWNLOAD_COST_POLICY.fullVideoDiscountRate : 1;
|
|
40
|
-
const
|
|
41
|
-
|
|
33
|
+
const rawCostPerAngle = billableSeconds * unitPricePerSecond * discountMultiplier;
|
|
34
|
+
const costPerAngle = Math.ceil(Number(rawCostPerAngle.toFixed(6)));
|
|
35
|
+
return costPerAngle * normalizedAngleCount;
|
|
42
36
|
}
|
|
43
37
|
|
|
44
|
-
// src/libs/gym-
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
// src/libs/gym-gold-charge.ts
|
|
39
|
+
var GYM_GOLD_CHARGE_POLICY = {
|
|
40
|
+
minChargeKrw: 1e4,
|
|
41
|
+
chargeUnitKrw: 1e4,
|
|
42
|
+
bonusRate: 0.2,
|
|
43
|
+
bonusRateBps: 2e3
|
|
48
44
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function calculateGymPartnerRegistrationGold(input) {
|
|
52
|
-
const startDate = parseKstDateString(input.startDate, "startDate");
|
|
53
|
-
const endDate = parseKstDateString(input.endDate, "endDate");
|
|
54
|
-
const startDateKey = toUtcDateKey(startDate);
|
|
55
|
-
const endDateKey = toUtcDateKey(endDate);
|
|
56
|
-
if (endDateKey < startDateKey) {
|
|
57
|
-
throw new RangeError("endDate must be on or after startDate");
|
|
58
|
-
}
|
|
59
|
-
const days = Math.floor((endDateKey - startDateKey) / MS_PER_DAY) + 1;
|
|
60
|
-
return {
|
|
61
|
-
days,
|
|
62
|
-
goldAmount: days * GYM_PARTNER_REGISTRATION_GOLD_POLICY.goldPerDay
|
|
63
|
-
};
|
|
45
|
+
function isGymGoldChargeKrwAllowed(chargeKrw) {
|
|
46
|
+
return Number.isFinite(chargeKrw) && Number.isInteger(chargeKrw) && chargeKrw >= GYM_GOLD_CHARGE_POLICY.minChargeKrw && chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw === 0;
|
|
64
47
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
...period,
|
|
70
|
-
...result
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
return {
|
|
74
|
-
totalDays: items.reduce((sum, item) => sum + item.days, 0),
|
|
75
|
-
totalGoldAmount: items.reduce((sum, item) => sum + item.goldAmount, 0),
|
|
76
|
-
items
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function parseKstDateString(input, fieldName) {
|
|
80
|
-
const dateOnlyMatch = DATE_ONLY_PATTERN.exec(input);
|
|
81
|
-
if (dateOnlyMatch === null) {
|
|
82
|
-
throw new RangeError(`${fieldName} must be a YYYY-MM-DD date`);
|
|
48
|
+
function assertValidGymGoldChargeKrw(chargeKrw) {
|
|
49
|
+
if (!Number.isFinite(chargeKrw)) {
|
|
50
|
+
throw new RangeError("chargeKrw must be a finite number");
|
|
83
51
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
52
|
+
if (!Number.isInteger(chargeKrw)) {
|
|
53
|
+
throw new RangeError("chargeKrw must be an integer");
|
|
54
|
+
}
|
|
55
|
+
if (chargeKrw < GYM_GOLD_CHARGE_POLICY.minChargeKrw) {
|
|
56
|
+
throw new RangeError(
|
|
57
|
+
`chargeKrw must be at least ${GYM_GOLD_CHARGE_POLICY.minChargeKrw}`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
if (chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw !== 0) {
|
|
61
|
+
throw new RangeError(
|
|
62
|
+
`chargeKrw must be a multiple of ${GYM_GOLD_CHARGE_POLICY.chargeUnitKrw}`
|
|
63
|
+
);
|
|
90
64
|
}
|
|
91
|
-
return { year, month, day };
|
|
92
|
-
}
|
|
93
|
-
function toUtcDateKey(date) {
|
|
94
|
-
return Date.UTC(date.year, date.month - 1, date.day);
|
|
95
65
|
}
|
|
96
66
|
export {
|
|
97
|
-
|
|
67
|
+
GYM_GOLD_CHARGE_POLICY,
|
|
98
68
|
MIN_DOWNLOAD_SECONDS,
|
|
99
69
|
ORIGINAL_DOWNLOAD_COST_POLICY,
|
|
100
|
-
|
|
101
|
-
calculateGymPartnerRegistrationGoldTotal,
|
|
70
|
+
assertValidGymGoldChargeKrw,
|
|
102
71
|
calculateOriginalDownloadCostWon,
|
|
103
|
-
isDownloadDurationAllowed
|
|
72
|
+
isDownloadDurationAllowed,
|
|
73
|
+
isGymGoldChargeKrwAllowed
|
|
104
74
|
};
|
|
105
75
|
//# sourceMappingURL=libs.js.map
|
package/dist/libs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/libs/cost.ts","../src/libs/gym-
|
|
1
|
+
{"version":3,"sources":["../src/libs/cost.ts","../src/libs/gym-gold-charge.ts"],"sourcesContent":["export const ORIGINAL_DOWNLOAD_COST_POLICY = {\n /**\n * 무료 다운로드 구간(초). 멤버십 구분 없이 모든 사용자에게 동일하게 적용한다.\n * 다운로드 길이 중 앞 `freeSeconds`초는 과금에서 제외하고,\n * 이를 초과한 구간에만 `krwPerMinute` 요율을 적용한다 (초과분 과금).\n */\n freeSeconds: 30,\n /**\n * 무료 구간 초과분에 적용하는 분당 KRW 요율. 멤버십 구분 없는 단일 요율.\n */\n krwPerMinute: 100,\n /**\n * 전체 영상 다운로드 시 할인율(10%).\n */\n fullVideoDiscountRate: 0.1,\n} as const;\n\n/**\n * 다운로드 가능한 최소 길이(초).\n * 이보다 짧은 구간은 다운로드 요청 자체를 허용하지 않는다 (server·FE 공용 제약).\n */\nexport const MIN_DOWNLOAD_SECONDS = 10;\n\n/**\n * 다운로드 요청 길이가 허용되는지 검사한다.\n * `durationSeconds >= MIN_DOWNLOAD_SECONDS`일 때만 true.\n */\nexport function isDownloadDurationAllowed(durationSeconds: number): boolean {\n return (\n Number.isFinite(durationSeconds) && durationSeconds >= MIN_DOWNLOAD_SECONDS\n );\n}\n\nexport interface OriginalDownloadCostOptions {\n isFullVideo?: boolean;\n /**\n * 동시에 다운로드할 화각(camera angle) 수. 최소 1, 기본 1.\n * 모든 화각은 동일한 길이로 함께 받으므로 단일 화각 비용 × 화각 수로 과금한다.\n * 1 미만이거나 유한하지 않은 값은 1로 보정한다.\n */\n angleCount?: number;\n}\n\nexport function calculateOriginalDownloadCostWon(\n durationSeconds: number,\n options: OriginalDownloadCostOptions = {},\n): number {\n if (!Number.isFinite(durationSeconds) || durationSeconds <= 0) return 0;\n\n const { isFullVideo, angleCount } = options;\n\n // 화각 수는 최소 1로 보정한다. 정수가 아닌 값은 내림 처리.\n const normalizedAngleCount = Number.isFinite(angleCount)\n ? Math.max(1, Math.floor(angleCount as number))\n : 1;\n\n // 앞 freeSeconds 구간은 과금에서 제외하고 초과분만 과금한다.\n const billableSeconds = Math.max(\n 0,\n durationSeconds - ORIGINAL_DOWNLOAD_COST_POLICY.freeSeconds,\n );\n if (billableSeconds <= 0) return 0;\n\n const unitPricePerSecond = ORIGINAL_DOWNLOAD_COST_POLICY.krwPerMinute / 60;\n\n const discountMultiplier = isFullVideo\n ? 1 - ORIGINAL_DOWNLOAD_COST_POLICY.fullVideoDiscountRate\n : 1;\n\n // 부동소수점 drift(예: 30.000000000000004) 때문에 1원 과다 청구되는 것을 막기 위해\n // 원 단위 미만 노이즈를 보정한 뒤 올림한다. 단일 화각 비용을 원 단위로 확정한 뒤\n // 화각 수만큼 곱한다 (각 화각을 개별 다운로드 건으로 과금).\n const rawCostPerAngle =\n billableSeconds * unitPricePerSecond * discountMultiplier;\n const costPerAngle = Math.ceil(Number(rawCostPerAngle.toFixed(6)));\n\n return costPerAngle * normalizedAngleCount;\n}\n","export const GYM_GOLD_CHARGE_POLICY = {\n minChargeKrw: 10_000,\n chargeUnitKrw: 10_000,\n bonusRate: 0.2,\n bonusRateBps: 2_000,\n} as const;\n\nexport function isGymGoldChargeKrwAllowed(chargeKrw: number): boolean {\n return (\n Number.isFinite(chargeKrw) &&\n Number.isInteger(chargeKrw) &&\n chargeKrw >= GYM_GOLD_CHARGE_POLICY.minChargeKrw &&\n chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw === 0\n );\n}\n\nexport function assertValidGymGoldChargeKrw(chargeKrw: number): void {\n if (!Number.isFinite(chargeKrw)) {\n throw new RangeError('chargeKrw must be a finite number');\n }\n\n if (!Number.isInteger(chargeKrw)) {\n throw new RangeError('chargeKrw must be an integer');\n }\n\n if (chargeKrw < GYM_GOLD_CHARGE_POLICY.minChargeKrw) {\n throw new RangeError(\n `chargeKrw must be at least ${GYM_GOLD_CHARGE_POLICY.minChargeKrw}`,\n );\n }\n\n if (chargeKrw % GYM_GOLD_CHARGE_POLICY.chargeUnitKrw !== 0) {\n throw new RangeError(\n `chargeKrw must be a multiple of ${GYM_GOLD_CHARGE_POLICY.chargeUnitKrw}`,\n );\n }\n}\n"],"mappings":";AAAO,IAAM,gCAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3C,aAAa;AAAA;AAAA;AAAA;AAAA,EAIb,cAAc;AAAA;AAAA;AAAA;AAAA,EAId,uBAAuB;AACzB;AAMO,IAAM,uBAAuB;AAM7B,SAAS,0BAA0B,iBAAkC;AAC1E,SACE,OAAO,SAAS,eAAe,KAAK,mBAAmB;AAE3D;AAYO,SAAS,iCACd,iBACA,UAAuC,CAAC,GAChC;AACR,MAAI,CAAC,OAAO,SAAS,eAAe,KAAK,mBAAmB,EAAG,QAAO;AAEtE,QAAM,EAAE,aAAa,WAAW,IAAI;AAGpC,QAAM,uBAAuB,OAAO,SAAS,UAAU,IACnD,KAAK,IAAI,GAAG,KAAK,MAAM,UAAoB,CAAC,IAC5C;AAGJ,QAAM,kBAAkB,KAAK;AAAA,IAC3B;AAAA,IACA,kBAAkB,8BAA8B;AAAA,EAClD;AACA,MAAI,mBAAmB,EAAG,QAAO;AAEjC,QAAM,qBAAqB,8BAA8B,eAAe;AAExE,QAAM,qBAAqB,cACvB,IAAI,8BAA8B,wBAClC;AAKJ,QAAM,kBACJ,kBAAkB,qBAAqB;AACzC,QAAM,eAAe,KAAK,KAAK,OAAO,gBAAgB,QAAQ,CAAC,CAAC,CAAC;AAEjE,SAAO,eAAe;AACxB;;;AC7EO,IAAM,yBAAyB;AAAA,EACpC,cAAc;AAAA,EACd,eAAe;AAAA,EACf,WAAW;AAAA,EACX,cAAc;AAChB;AAEO,SAAS,0BAA0B,WAA4B;AACpE,SACE,OAAO,SAAS,SAAS,KACzB,OAAO,UAAU,SAAS,KAC1B,aAAa,uBAAuB,gBACpC,YAAY,uBAAuB,kBAAkB;AAEzD;AAEO,SAAS,4BAA4B,WAAyB;AACnE,MAAI,CAAC,OAAO,SAAS,SAAS,GAAG;AAC/B,UAAM,IAAI,WAAW,mCAAmC;AAAA,EAC1D;AAEA,MAAI,CAAC,OAAO,UAAU,SAAS,GAAG;AAChC,UAAM,IAAI,WAAW,8BAA8B;AAAA,EACrD;AAEA,MAAI,YAAY,uBAAuB,cAAc;AACnD,UAAM,IAAI;AAAA,MACR,8BAA8B,uBAAuB,YAAY;AAAA,IACnE;AAAA,EACF;AAEA,MAAI,YAAY,uBAAuB,kBAAkB,GAAG;AAC1D,UAAM,IAAI;AAAA,MACR,mCAAmC,uBAAuB,aAAa;AAAA,IACzE;AAAA,EACF;AACF;","names":[]}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/index.ts"],"sourcesContent":["export * from './
|
|
1
|
+
{"version":3,"sources":["../src/types/index.ts"],"sourcesContent":["export * from './api';\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/types.d.cts
CHANGED
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED