buckyos 0.7.195 → 0.7.200
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/cli/README.md +20 -0
- package/cli/core/app.ts +1 -0
- package/cli/core/argv.ts +4 -0
- package/cli/dist/cli.mjs +218 -392
- package/cli/dist/cli.mjs.map +1 -1
- package/cli/modules/aiws.ts +11 -3
- package/cli/modules/obj.ts +70 -3
- package/cli/runtime/host.ts +2 -0
- package/cli/version.ts +1 -1
- package/dist/aiworkspace_client.d.ts +20 -2
- package/dist/aiworkspace_client.d.ts.map +1 -1
- package/dist/aiws_bind-4fe77108.js +2 -0
- package/dist/aiws_bind-4fe77108.js.map +1 -0
- package/dist/{aiws_bind-ec6fe2d5.mjs → aiws_bind-b851d4db.mjs} +137 -33
- package/dist/aiws_bind-b851d4db.mjs.map +1 -0
- package/dist/aiws_ext.cjs +1 -1
- package/dist/aiws_ext.mjs +1 -1
- package/dist/aiws_rrule.d.ts +3 -2
- package/dist/aiws_rrule.d.ts.map +1 -1
- package/dist/aiws_schedule.d.ts +16 -2
- package/dist/aiws_schedule.d.ts.map +1 -1
- package/dist/{aiws_write-07562abc.mjs → aiws_write-2f0baa6f.mjs} +2 -2
- package/dist/aiws_write-2f0baa6f.mjs.map +1 -0
- package/dist/{aiws_write-1f179e1c.js → aiws_write-ad97b561.js} +2 -2
- package/dist/aiws_write-ad97b561.js.map +1 -0
- package/dist/aiws_write.d.ts +1 -0
- package/dist/aiws_write.d.ts.map +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.mjs +4 -4
- package/dist/{content_objid-17daaa69.js → content_objid-0e63f1ff.js} +2 -2
- package/dist/{content_objid-17daaa69.js.map → content_objid-0e63f1ff.js.map} +1 -1
- package/dist/{content_objid-7605d166.mjs → content_objid-8ebeead4.mjs} +2 -2
- package/dist/{content_objid-7605d166.mjs.map → content_objid-8ebeead4.mjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +4 -4
- package/dist/node.cjs +1 -1
- package/dist/node.mjs +3 -3
- package/dist/owner-extensions/object_extensions.toml +160 -0
- package/dist/owner-extensions/profiles/bindings.json +165 -0
- package/dist/owner-extensions/profiles/calendar.json +489 -0
- package/dist/owner-extensions/profiles/contacts.json +89 -0
- package/dist/owner-extensions/profiles/person.json +193 -0
- package/dist/owner-extensions/profiles/sharing.json +65 -0
- package/dist/owner-extensions/profiles/todo.json +493 -0
- package/dist/owner-extensions/scripts/bindings.mjs +9 -0
- package/dist/owner-extensions/scripts/calendar.mjs +3 -0
- package/dist/owner-extensions/scripts/contacts.mjs +9 -0
- package/dist/owner-extensions/scripts/free_busy.mjs +666 -0
- package/dist/owner-extensions/scripts/person.mjs +11 -0
- package/dist/owner-extensions/scripts/schedule.mjs +2618 -0
- package/dist/owner-extensions/scripts/sharing.mjs +8 -0
- package/dist/owner-extensions/scripts/todo.mjs +3 -0
- package/dist/owner_availability.d.ts +15 -0
- package/dist/owner_availability.d.ts.map +1 -0
- package/dist/owner_schedule.d.ts +30 -0
- package/dist/owner_schedule.d.ts.map +1 -0
- package/dist/task_mgr_client.d.ts +2 -0
- package/dist/task_mgr_client.d.ts.map +1 -1
- package/package.json +2 -2
- package/cli/modules/aiws_schedule.ts +0 -256
- package/dist/aiws_bind-1a26e3e6.js +0 -2
- package/dist/aiws_bind-1a26e3e6.js.map +0 -1
- package/dist/aiws_bind-ec6fe2d5.mjs.map +0 -1
- package/dist/aiws_write-07562abc.mjs.map +0 -1
- package/dist/aiws_write-1f179e1c.js.map +0 -1
|
@@ -497,7 +497,7 @@ function zonedToUtc(day, minuteOfDay, secondOfMinute, tz) {
|
|
|
497
497
|
const local = day * 864e5 + minuteOfDay * 6e4 + secondOfMinute * 1e3;
|
|
498
498
|
const first = local - offsetMs(local, tz);
|
|
499
499
|
const second = local - offsetMs(first, tz);
|
|
500
|
-
return second;
|
|
500
|
+
return second !== first && local - offsetMs(second, tz) !== second ? Math.max(first, second) : second;
|
|
501
501
|
}
|
|
502
502
|
function localDay(ms, tz) {
|
|
503
503
|
const p = zonedParts(ms, tz);
|
|
@@ -644,7 +644,7 @@ function periodsBefore(rule, startDay, day) {
|
|
|
644
644
|
return Math.max(-1, p - 1);
|
|
645
645
|
}
|
|
646
646
|
function expandSeries(rule, start, window, opts = {}) {
|
|
647
|
-
var _a;
|
|
647
|
+
var _a, _b, _c;
|
|
648
648
|
const limit = opts.limit ?? 2e3;
|
|
649
649
|
const excluded = new Set(opts.exdate ?? []);
|
|
650
650
|
const out = [];
|
|
@@ -682,7 +682,8 @@ function expandSeries(rule, start, window, opts = {}) {
|
|
|
682
682
|
const date = dateOf(day);
|
|
683
683
|
occ = { original: date, date };
|
|
684
684
|
} else {
|
|
685
|
-
const
|
|
685
|
+
const firstMs = Date.parse(start.utc);
|
|
686
|
+
const ms = day === startDay ? firstMs : zonedToUtc(day, minute, second, tz) + new Date(firstMs).getUTCMilliseconds();
|
|
686
687
|
if (untilMs !== void 0 && ms > untilMs)
|
|
687
688
|
return false;
|
|
688
689
|
occ = { original: new Date(ms).toISOString(), startMs: ms };
|
|
@@ -702,16 +703,22 @@ function expandSeries(rule, start, window, opts = {}) {
|
|
|
702
703
|
let period = rule.count === void 0 ? periodsBefore(rule, startDay, fromDay) + 1 : 0;
|
|
703
704
|
for (let guard = 0; guard < MAX_PERIODS && out.length < limit; guard++, period++) {
|
|
704
705
|
if (periodStart(rule, period, startDay) > toDay)
|
|
705
|
-
|
|
706
|
+
return out;
|
|
706
707
|
for (const day of candidates(rule, period, startDay)) {
|
|
707
708
|
if (day <= startDay)
|
|
708
709
|
continue;
|
|
709
710
|
if (day > toDay)
|
|
710
711
|
return out;
|
|
711
|
-
if (!emit(day)
|
|
712
|
+
if (!emit(day))
|
|
713
|
+
return out;
|
|
714
|
+
if (out.length >= limit) {
|
|
715
|
+
(_b = opts.onTruncated) == null ? void 0 : _b.call(opts);
|
|
712
716
|
return out;
|
|
717
|
+
}
|
|
713
718
|
}
|
|
714
719
|
}
|
|
720
|
+
if (periodStart(rule, period, startDay) <= toDay)
|
|
721
|
+
(_c = opts.onTruncated) == null ? void 0 : _c.call(opts);
|
|
715
722
|
return out;
|
|
716
723
|
}
|
|
717
724
|
function seriesStartOf(values, tz, fallbackTz = "UTC") {
|
|
@@ -1052,7 +1059,56 @@ const ru = {
|
|
|
1052
1059
|
yearly: (m, d) => `Каждый год ${d} ${RU_MONTH_GEN[m - 1]}`
|
|
1053
1060
|
}
|
|
1054
1061
|
};
|
|
1055
|
-
const
|
|
1062
|
+
const AR_DAYS = ["الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت", "الأحد"];
|
|
1063
|
+
const AR_MONTHS = ["يناير", "فبراير", "مارس", "أبريل", "مايو", "يونيو", "يوليو", "أغسطس", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"];
|
|
1064
|
+
const arNumber = new Intl.NumberFormat("ar");
|
|
1065
|
+
const arList = (items) => items.join(" و");
|
|
1066
|
+
const arOrdinal = (position) => {
|
|
1067
|
+
const ordinals = ["الأول", "الثاني", "الثالث", "الرابع", "الخامس"];
|
|
1068
|
+
if (position === -1)
|
|
1069
|
+
return "الأخير";
|
|
1070
|
+
const ordinal = ordinals[Math.abs(position) - 1] ?? arNumber.format(Math.abs(position));
|
|
1071
|
+
return position < 0 ? ordinal + " من النهاية" : ordinal;
|
|
1072
|
+
};
|
|
1073
|
+
const arEvery = (n, one, two, few, many) => {
|
|
1074
|
+
if (n === 1)
|
|
1075
|
+
return "كل " + one;
|
|
1076
|
+
if (n === 2)
|
|
1077
|
+
return "كل " + two;
|
|
1078
|
+
return "كل " + arNumber.format(n) + " " + (n % 100 >= 3 && n % 100 <= 10 ? few : many);
|
|
1079
|
+
};
|
|
1080
|
+
const arOn = (frequency, on) => on ? frequency + "، في " + on : frequency;
|
|
1081
|
+
const ar = {
|
|
1082
|
+
day: (wd) => AR_DAYS[wd],
|
|
1083
|
+
nth: (o, wd) => `يوم ${AR_DAYS[wd]} ${arOrdinal(o)}`,
|
|
1084
|
+
nthWorkday: (o) => `يوم العمل ${arOrdinal(o)}`,
|
|
1085
|
+
nthOf: (o, days) => days.length === 1 ? ar.nth(o, days[0]) : `اليوم ${arOrdinal(o)} من بين أيام ${arList(days.map(ar.day))}`,
|
|
1086
|
+
monthlyDays: arList,
|
|
1087
|
+
monthDay: (d) => d === -1 ? "اليوم الأخير" : d < 0 ? `اليوم ${arOrdinal(d)}` : `اليوم ${arNumber.format(d)}`,
|
|
1088
|
+
join: arList,
|
|
1089
|
+
daily: (n) => arEvery(n, "يوم", "يومين", "أيام", "يومًا"),
|
|
1090
|
+
workdays: "من الاثنين إلى الجمعة",
|
|
1091
|
+
weekly: (n, on) => [arEvery(n, "أسبوع", "أسبوعين", "أسابيع", "أسبوعًا"), on].filter(Boolean).join("، "),
|
|
1092
|
+
monthly: (n, on) => arOn(arEvery(n, "شهر", "شهرين", "أشهر", "شهرًا"), on),
|
|
1093
|
+
yearly: (n, months, mdays, days) => {
|
|
1094
|
+
const month = months ? arList(months.map((m) => AR_MONTHS[m - 1])) : "";
|
|
1095
|
+
const day = mdays ? arList(mdays.map(ar.monthDay)) : arList(days ?? []);
|
|
1096
|
+
return arOn(arEvery(n, "سنة", "سنتين", "سنوات", "سنة"), [day, month].filter(Boolean).join(" من "));
|
|
1097
|
+
},
|
|
1098
|
+
count: (n) => `، عدد المرات: ${arNumber.format(n)}`,
|
|
1099
|
+
until: (date) => `، حتى ${date}`,
|
|
1100
|
+
preset: {
|
|
1101
|
+
none: "بلا تكرار",
|
|
1102
|
+
daily: "كل يوم",
|
|
1103
|
+
weekdays: "أيام العمل (من الاثنين إلى الجمعة)",
|
|
1104
|
+
weekly: (wd) => `كل أسبوع يوم ${ar.day(wd)}`,
|
|
1105
|
+
monthlyDay: (d) => ar.monthly(1, ar.monthDay(d)),
|
|
1106
|
+
monthlyNth: (n, wd) => ar.monthly(1, ar.nth(n, wd)),
|
|
1107
|
+
monthlyLast: (wd) => ar.monthly(1, ar.nth(-1, wd)),
|
|
1108
|
+
yearly: (m, d) => `كل سنة في ${arNumber.format(d)} ${AR_MONTHS[m - 1]}`
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
const PHRASEBOOKS = { zh, "zh-TW": zhTW, en, ja, ko, fr, de, es, ru, ar };
|
|
1056
1112
|
const phrasebook = (locale) => PHRASEBOOKS[locale] ?? en;
|
|
1057
1113
|
const isWorkdays = (d) => !!d && d.length === 5 && d.every((x) => x.ordinal === void 0) && [0, 1, 2, 3, 4].every((w) => d.some((x) => x.weekday === w));
|
|
1058
1114
|
function describeRRule(rule, locale = "zh") {
|
|
@@ -1303,6 +1359,29 @@ const LABELS = {
|
|
|
1303
1359
|
workspace: "Mi agenda",
|
|
1304
1360
|
board: "Agenda"
|
|
1305
1361
|
},
|
|
1362
|
+
ar: {
|
|
1363
|
+
title: "العنوان",
|
|
1364
|
+
status: "الحالة",
|
|
1365
|
+
due: "تاريخ الاستحقاق",
|
|
1366
|
+
order: "الترتيب",
|
|
1367
|
+
done_at: "وقت الإكمال",
|
|
1368
|
+
ext: "بيانات إضافية",
|
|
1369
|
+
todo: "قيد الانتظار",
|
|
1370
|
+
doing: "قيد التنفيذ",
|
|
1371
|
+
done: "مكتملة",
|
|
1372
|
+
all_day: "طوال اليوم",
|
|
1373
|
+
start: "البداية",
|
|
1374
|
+
end: "النهاية",
|
|
1375
|
+
start_date: "تاريخ البدء",
|
|
1376
|
+
end_date: "تاريخ الانتهاء",
|
|
1377
|
+
confirmed: "مؤكد",
|
|
1378
|
+
tentative: "مبدئي",
|
|
1379
|
+
cancelled: "ملغى",
|
|
1380
|
+
todo_table: "المهام",
|
|
1381
|
+
calendar_table: "التقويم",
|
|
1382
|
+
workspace: "جدولي",
|
|
1383
|
+
board: "الجدول"
|
|
1384
|
+
},
|
|
1306
1385
|
ru: {
|
|
1307
1386
|
title: "Название",
|
|
1308
1387
|
status: "Статус",
|
|
@@ -1335,7 +1414,7 @@ function todoFields(locale = "zh") {
|
|
|
1335
1414
|
const l = (k) => scheduleLabel(locale, k);
|
|
1336
1415
|
return [
|
|
1337
1416
|
{ field_id: "title", name: l("title"), type: "text", required: true },
|
|
1338
|
-
{ field_id: "status", name: l("status"), type: "select", required: true, options: ["todo", "doing", "done"].map((id) => ({ option_id: id, label: l(id) })) },
|
|
1417
|
+
{ field_id: "status", name: l("status"), type: "select", required: true, default: "todo", options: ["todo", "doing", "done"].map((id) => ({ option_id: id, label: l(id) })) },
|
|
1339
1418
|
{ field_id: "due", name: l("due"), type: "date", nullable: true },
|
|
1340
1419
|
{ field_id: "order", name: l("order"), type: "text", nullable: true },
|
|
1341
1420
|
{ field_id: "done_at", name: l("done_at"), type: "datetime", nullable: true },
|
|
@@ -1504,7 +1583,7 @@ function todoAddOps(sourceId, input, place = {}) {
|
|
|
1504
1583
|
order = orderKeyBetween(last, null);
|
|
1505
1584
|
}
|
|
1506
1585
|
}
|
|
1507
|
-
const status = input.status
|
|
1586
|
+
const status = input.status;
|
|
1508
1587
|
const values = {
|
|
1509
1588
|
title: input.title,
|
|
1510
1589
|
status,
|
|
@@ -1671,7 +1750,7 @@ function calendarOccurrences(rows, window, opts = {}) {
|
|
|
1671
1750
|
if (!start)
|
|
1672
1751
|
continue;
|
|
1673
1752
|
const exdate = originals(ext.exdate);
|
|
1674
|
-
const occs = expandSeries(rule, start, window, { exdate, viewerTz, durationMs: times.allDay ? void 0 : duration, durationDays: times.allDay ? duration : void 0, limit: opts.limit });
|
|
1753
|
+
const occs = expandSeries(rule, start, window, { exdate, viewerTz, durationMs: times.allDay ? void 0 : duration, durationDays: times.allDay ? duration : void 0, limit: opts.limit, onTruncated: opts.onTruncated });
|
|
1675
1754
|
for (const o of occs) {
|
|
1676
1755
|
const s = shift(o);
|
|
1677
1756
|
if (s)
|
|
@@ -1951,20 +2030,31 @@ const ROWS_PAGE = 1e3;
|
|
|
1951
2030
|
class ScheduleClient {
|
|
1952
2031
|
constructor(aiws, opts = {}) {
|
|
1953
2032
|
this.aiws = aiws;
|
|
2033
|
+
this.opts = opts;
|
|
1954
2034
|
this.handle = null;
|
|
1955
2035
|
this.locale = opts.locale ?? "zh";
|
|
1956
2036
|
}
|
|
1957
2037
|
/** The schedule Workspace with its two tables (created when missing; concurrent first uses converge). */
|
|
1958
2038
|
async ensure() {
|
|
1959
|
-
var _a, _b, _c;
|
|
1960
2039
|
if (this.handle)
|
|
1961
2040
|
return this.handle;
|
|
1962
2041
|
const ws = await this.aiws.call("ws.ensure", { name: SCHEDULE_WORKSPACE_NAME, title: scheduleLabel(this.locale, "workspace") });
|
|
1963
|
-
|
|
2042
|
+
return this.open(ws, true);
|
|
2043
|
+
}
|
|
2044
|
+
async open(ws, initialize = false) {
|
|
2045
|
+
var _a, _b, _c;
|
|
2046
|
+
const handle = { workspace_id: ws.workspace_id, epoch: ws.epoch, created: ws.created ?? false, todo: SCHEDULE_TODO_ID, calendar: SCHEDULE_CALENDAR_ID };
|
|
2047
|
+
if (!initialize) {
|
|
2048
|
+
this.handle = handle;
|
|
2049
|
+
return handle;
|
|
2050
|
+
}
|
|
1964
2051
|
const have = /* @__PURE__ */ new Set();
|
|
1965
2052
|
for (const id of [SCHEDULE_TODO_ID, SCHEDULE_CALENDAR_ID, SCHEDULE_SURFACE_ID]) {
|
|
1966
2053
|
try {
|
|
1967
|
-
const read = await this.aiws.call("doc.read", { workspace_id: ws.workspace_id, entity_id: id });
|
|
2054
|
+
const read = await this.aiws.call("doc.read", { workspace_id: ws.workspace_id, entity_id: id, as: "meta" });
|
|
2055
|
+
const schema = id === SCHEDULE_TODO_ID ? TODO_SCHEMA_ID : id === SCHEDULE_CALENDAR_ID ? CALENDAR_SCHEMA_ID : void 0;
|
|
2056
|
+
if (schema && read.schema_id !== schema)
|
|
2057
|
+
throw new AiwsFailure({ code: "RESOURCE_TYPE_MISMATCH", detail: id + " is not the expected schedule table", retryable: false });
|
|
1968
2058
|
if (!read.deleted)
|
|
1969
2059
|
have.add(id);
|
|
1970
2060
|
} catch (error) {
|
|
@@ -1981,20 +2071,29 @@ class ScheduleClient {
|
|
|
1981
2071
|
if (!have.has(SCHEDULE_SURFACE_ID))
|
|
1982
2072
|
ops.push(...scheduleBoardOps(this.locale));
|
|
1983
2073
|
if (ops.length) {
|
|
1984
|
-
const
|
|
2074
|
+
const initKey = `init-${this.opts.idempotencyKey ?? newRecordId("k")}`;
|
|
2075
|
+
const result = await this.commitTo(handle, ops, "create the schedule", "system", initKey);
|
|
1985
2076
|
const idConflict = (result.sub_code ?? ((_b = (_a = result.errors) == null ? void 0 : _a[0]) == null ? void 0 : _b.sub_code) ?? ((_c = result.error) == null ? void 0 : _c.sub_code)) === "ID_CONFLICT";
|
|
1986
|
-
if (result.status !== "accepted"
|
|
1987
|
-
|
|
2077
|
+
if (result.status !== "accepted") {
|
|
2078
|
+
if (!(result.status === "rejected" && idConflict))
|
|
2079
|
+
throw failureOf(result);
|
|
2080
|
+
for (const id of [SCHEDULE_TODO_ID, SCHEDULE_CALENDAR_ID, SCHEDULE_SURFACE_ID]) {
|
|
2081
|
+
const meta = await this.aiws.call("doc.read", { workspace_id: ws.workspace_id, entity_id: id, as: "meta" });
|
|
2082
|
+
if (id !== SCHEDULE_SURFACE_ID && meta.schema_id !== (id === SCHEDULE_TODO_ID ? TODO_SCHEMA_ID : CALENDAR_SCHEMA_ID))
|
|
2083
|
+
throw failureOf(result);
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
1988
2086
|
}
|
|
1989
2087
|
this.handle = handle;
|
|
1990
2088
|
return handle;
|
|
1991
2089
|
}
|
|
1992
|
-
async commitTo(handle, operations, message, origin = "agent") {
|
|
2090
|
+
async commitTo(handle, operations, message, origin = "agent", key = this.opts.idempotencyKey ?? `sched-${newRecordId("k")}`) {
|
|
1993
2091
|
var _a;
|
|
1994
|
-
const key = `sched-${newRecordId("k")}`;
|
|
1995
2092
|
const request = (epoch) => ({ protocol_version: AIWS_PROTOCOL_VERSION, workspace_id: handle.workspace_id, epoch, idempotency_key: key, origin, message, operations });
|
|
1996
2093
|
let result = await this.aiws.call("doc.commit", request(handle.epoch));
|
|
1997
2094
|
if (result.status === "rejected" && (result.code ?? ((_a = result.error) == null ? void 0 : _a.code)) === "EPOCH_MISMATCH") {
|
|
2095
|
+
if (this.opts.idempotencyKey)
|
|
2096
|
+
throw new AiwsFailure({ code: "WRITE_OUTCOME_UNKNOWN", retryable: false, detail: "original workspace epoch changed", data: { workspace_id: handle.workspace_id, idempotency_key: key } });
|
|
1998
2097
|
const info = await this.aiws.call("ws.get_info", { workspace_id: handle.workspace_id });
|
|
1999
2098
|
handle.epoch = info.epoch;
|
|
2000
2099
|
result = await this.aiws.call("doc.commit", request(handle.epoch));
|
|
@@ -2013,7 +2112,7 @@ class ScheduleClient {
|
|
|
2013
2112
|
async rows(sourceId) {
|
|
2014
2113
|
const handle = await this.ensure();
|
|
2015
2114
|
const rows = [];
|
|
2016
|
-
for (let i = 0;
|
|
2115
|
+
for (let i = 0; ; i++) {
|
|
2017
2116
|
const page = await this.aiws.call("doc.query", {
|
|
2018
2117
|
workspace_id: handle.workspace_id,
|
|
2019
2118
|
sql: 'SELECT "_record" FROM t ORDER BY "_id" LIMIT ? OFFSET ?',
|
|
@@ -2045,6 +2144,8 @@ class ScheduleClient {
|
|
|
2045
2144
|
var _a, _b, _c, _d;
|
|
2046
2145
|
const items = sortTodos((await this.rows(SCHEDULE_TODO_ID)).map(todoItem));
|
|
2047
2146
|
const at = (id) => items.find((i) => i.record_id === id);
|
|
2147
|
+
if (place.after && !at(place.after) || place.before && !at(place.before))
|
|
2148
|
+
throw new AiwsFailure({ code: "NOT_FOUND", retryable: false, detail: "placement anchor does not exist" });
|
|
2048
2149
|
let pos = { items };
|
|
2049
2150
|
if (place.after) {
|
|
2050
2151
|
const i = items.findIndex((x) => x.record_id === place.after);
|
|
@@ -2057,17 +2158,22 @@ class ScheduleClient {
|
|
|
2057
2158
|
await this.commit(ops, `add to-do: ${input.title}`);
|
|
2058
2159
|
return todoItem(await this.row(SCHEDULE_TODO_ID, record_id));
|
|
2059
2160
|
}
|
|
2161
|
+
async commitRowChange(source, row, ops, message, field = "title") {
|
|
2162
|
+
if (!ops.length && this.opts.idempotencyKey) {
|
|
2163
|
+
ops = setValuesOps(source, row, { [field]: row.values[field] ?? (field === "status" ? "todo" : row.values.title) });
|
|
2164
|
+
}
|
|
2165
|
+
if (ops.length)
|
|
2166
|
+
await this.commit(ops, message);
|
|
2167
|
+
}
|
|
2060
2168
|
async completeTodo(recordId, done = true) {
|
|
2061
2169
|
const row = await this.row(SCHEDULE_TODO_ID, recordId);
|
|
2062
2170
|
const ops = todoCompleteOps(SCHEDULE_TODO_ID, row, done);
|
|
2063
|
-
|
|
2064
|
-
await this.commit(ops, `${done ? "complete" : "reopen"} to-do ${recordId}`);
|
|
2171
|
+
await this.commitRowChange(SCHEDULE_TODO_ID, row, ops, `${done ? "complete" : "reopen"} to-do ${recordId}`, "status");
|
|
2065
2172
|
}
|
|
2066
2173
|
async updateTodo(recordId, changes) {
|
|
2067
2174
|
const row = await this.row(SCHEDULE_TODO_ID, recordId);
|
|
2068
2175
|
const ops = todoUpdateOps(SCHEDULE_TODO_ID, row, changes);
|
|
2069
|
-
|
|
2070
|
-
await this.commit(ops, `update to-do ${recordId}`);
|
|
2176
|
+
await this.commitRowChange(SCHEDULE_TODO_ID, row, ops, `update to-do ${recordId}`);
|
|
2071
2177
|
}
|
|
2072
2178
|
/** Move a to-do before / after another one, and / or into another status. */
|
|
2073
2179
|
async moveTodo(recordId, to) {
|
|
@@ -2084,8 +2190,7 @@ class ScheduleClient {
|
|
|
2084
2190
|
order = orderAt(others, to.before ? anchor : anchor + 1);
|
|
2085
2191
|
}
|
|
2086
2192
|
const ops = todoMoveOps(SCHEDULE_TODO_ID, row, { status: to.status, order });
|
|
2087
|
-
|
|
2088
|
-
await this.commit(ops, `move to-do ${recordId}`);
|
|
2193
|
+
await this.commitRowChange(SCHEDULE_TODO_ID, row, ops, `move to-do ${recordId}`, "status");
|
|
2089
2194
|
}
|
|
2090
2195
|
async removeTodos(recordIds) {
|
|
2091
2196
|
const rows = await Promise.all(recordIds.map((id) => this.row(SCHEDULE_TODO_ID, id)));
|
|
@@ -2110,9 +2215,8 @@ class ScheduleClient {
|
|
|
2110
2215
|
}
|
|
2111
2216
|
async editEvent(id, change, scope = "one") {
|
|
2112
2217
|
const { occ, rows } = await this.occurrence(id);
|
|
2113
|
-
const { ops, record_id } = eventEditOps(SCHEDULE_CALENDAR_ID, occ, change, scope, { rows });
|
|
2114
|
-
|
|
2115
|
-
await this.commit(ops, `edit event ${id} (${scope})`);
|
|
2218
|
+
const { ops, record_id } = eventEditOps(SCHEDULE_CALENDAR_ID, occ, change, scope, { rows, newRecordId: this.opts.newRecordId });
|
|
2219
|
+
await this.commitRowChange(SCHEDULE_CALENDAR_ID, occ.row, ops, `edit event ${id} (${scope})`);
|
|
2116
2220
|
return record_id;
|
|
2117
2221
|
}
|
|
2118
2222
|
async deleteEvent(id, scope = "one") {
|
|
@@ -2154,11 +2258,11 @@ function findOccurrence(rows, id) {
|
|
|
2154
2258
|
throw new AiwsFailure({ code: "INVALID_OPERATION", retryable: false, detail: `event ${recordId} has no time` });
|
|
2155
2259
|
if (override)
|
|
2156
2260
|
return occurrenceOf(override, rowTimes(override), { id, master: row, original, recurring: true, override: true });
|
|
2157
|
-
const
|
|
2158
|
-
const
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
return
|
|
2261
|
+
const fromMs = Date.parse(times.allDay ? original + "T00:00:00Z" : original);
|
|
2262
|
+
const instance = Number.isFinite(fromMs) && calendarOccurrences([row], { fromMs, toMs: fromMs + 1 }, { viewerTz: "UTC" }).find((o) => o.original === original);
|
|
2263
|
+
if (!instance)
|
|
2264
|
+
throw new AiwsFailure({ code: "NOT_FOUND", retryable: false, detail: "occurrence is outside the series or was removed" });
|
|
2265
|
+
return instance;
|
|
2162
2266
|
}
|
|
2163
2267
|
function scheduleBoardOps(locale = "zh") {
|
|
2164
2268
|
const folder = `${SCHEDULE_SURFACE_ID}-content`;
|
|
@@ -2696,4 +2800,4 @@ export {
|
|
|
2696
2800
|
ymdOf as y,
|
|
2697
2801
|
zonedParts as z
|
|
2698
2802
|
};
|
|
2699
|
-
//# sourceMappingURL=aiws_bind-
|
|
2803
|
+
//# sourceMappingURL=aiws_bind-b851d4db.mjs.map
|