@ancha-labs/cli 0.1.5 → 0.1.6
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/lib/ancha.mjs +485 -258
- package/lib/assets/docs/cloud.md +3 -3
- package/lib/assets/docs/run.md +7 -1
- package/lib/assets/harbor/companion.mjs +257 -195
- package/lib/assets/ui/app.js +28 -18
- package/lib/assets/ui/style.css +2 -0
- package/lib/mcp-entry.mjs +74 -12
- package/lib/worker.mjs +332 -210
- package/lib/world-server.mjs +257 -195
- package/package.json +1 -1
|
@@ -18,9 +18,9 @@ var __commonJS = (cb, mod) => function __require2() {
|
|
|
18
18
|
throw mod = 0, e;
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
var __export = (target4,
|
|
22
|
-
for (var name5 in
|
|
23
|
-
__defProp(target4, name5, { get:
|
|
21
|
+
var __export = (target4, all8) => {
|
|
22
|
+
for (var name5 in all8)
|
|
23
|
+
__defProp(target4, name5, { get: all8[name5], enumerable: true });
|
|
24
24
|
};
|
|
25
25
|
var __copyProps = (to, from, except, desc) => {
|
|
26
26
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -56497,6 +56497,68 @@ function toErrorJson(e) {
|
|
|
56497
56497
|
return { code: "INTERNAL", message: e instanceof Error ? e.message : String(e) };
|
|
56498
56498
|
}
|
|
56499
56499
|
|
|
56500
|
+
// packages/core/src/execution-support.ts
|
|
56501
|
+
var all = { local: true, container: true, managed: true };
|
|
56502
|
+
var sceneOnly = { local: true, container: true, managed: false };
|
|
56503
|
+
var EXECUTION_SUPPORT = {
|
|
56504
|
+
"input.scene": { ...sceneOnly, reason: "scene worlds cannot be imported without changing their semantics" },
|
|
56505
|
+
"input.test": { ...sceneOnly, reason: "local test worlds cannot be equated with saved managed worlds" },
|
|
56506
|
+
"input.managed-task": { local: false, container: false, managed: true, reason: "explicit saved-world tasks use runs start or the console" },
|
|
56507
|
+
"managed.world-reference": { local: false, container: false, managed: true, reason: "an explicit reference to an existing managed world, not an imported local world" },
|
|
56508
|
+
"id": all,
|
|
56509
|
+
"title": all,
|
|
56510
|
+
"task": sceneOnly,
|
|
56511
|
+
"start.task": all,
|
|
56512
|
+
"attempts": all,
|
|
56513
|
+
"twins": sceneOnly,
|
|
56514
|
+
"world": sceneOnly,
|
|
56515
|
+
"start_time": sceneOnly,
|
|
56516
|
+
"time_scale": sceneOnly,
|
|
56517
|
+
"seed": sceneOnly,
|
|
56518
|
+
"world_rules": sceneOnly,
|
|
56519
|
+
"people": sceneOnly,
|
|
56520
|
+
"until": sceneOnly,
|
|
56521
|
+
"deadline": sceneOnly,
|
|
56522
|
+
"start.message": sceneOnly,
|
|
56523
|
+
"pass": sceneOnly,
|
|
56524
|
+
"scene.timeout": sceneOnly,
|
|
56525
|
+
"test.timeout": all,
|
|
56526
|
+
"checks.state": all,
|
|
56527
|
+
"checks.trace": all,
|
|
56528
|
+
"checks.process": all,
|
|
56529
|
+
"checks.judge": sceneOnly,
|
|
56530
|
+
"agent.input.command": all,
|
|
56531
|
+
"agent.input.per_event": sceneOnly,
|
|
56532
|
+
"agent.input.events": { local: true, container: false, managed: false },
|
|
56533
|
+
"agent.input.http": all,
|
|
56534
|
+
"agent.endpoint": { local: true, container: false, managed: false },
|
|
56535
|
+
"agent.slack_transport.feed": sceneOnly,
|
|
56536
|
+
"agent.slack_transport.http": { local: true, container: false, managed: false },
|
|
56537
|
+
"agent.slack_transport.socket": { local: true, container: false, managed: false },
|
|
56538
|
+
"agent.env": sceneOnly,
|
|
56539
|
+
"agent.pass_env": sceneOnly,
|
|
56540
|
+
"agent.execution": sceneOnly,
|
|
56541
|
+
"judge": sceneOnly,
|
|
56542
|
+
"min_pass_rate": sceneOnly,
|
|
56543
|
+
"--agent": all,
|
|
56544
|
+
"--trials": all,
|
|
56545
|
+
"--parallel": all,
|
|
56546
|
+
"--idempotency-key": all,
|
|
56547
|
+
"--on": all,
|
|
56548
|
+
"--json": all,
|
|
56549
|
+
"--agent-url": { local: true, container: false, managed: false },
|
|
56550
|
+
"--compare": sceneOnly,
|
|
56551
|
+
"--min-pass-rate": sceneOnly,
|
|
56552
|
+
"--strict": sceneOnly,
|
|
56553
|
+
"--seed": sceneOnly,
|
|
56554
|
+
"--out": sceneOnly,
|
|
56555
|
+
"--detach": sceneOnly,
|
|
56556
|
+
"--pass-env": sceneOnly,
|
|
56557
|
+
"--inherit-env": sceneOnly,
|
|
56558
|
+
"--upload": sceneOnly,
|
|
56559
|
+
"--upload-required": sceneOnly
|
|
56560
|
+
};
|
|
56561
|
+
|
|
56500
56562
|
// packages/core/src/relay.ts
|
|
56501
56563
|
function relayRefusal(status4, body6) {
|
|
56502
56564
|
const error63 = typeof body6 === "object" && body6 !== null ? body6.error : void 0;
|
|
@@ -79505,15 +79567,15 @@ var NotionSeedSchema = external_exports.strictObject({
|
|
|
79505
79567
|
databases: external_exports.array(database).max(200).default([])
|
|
79506
79568
|
}).superRefine((seed40, ctx) => {
|
|
79507
79569
|
const issue5 = (path4, message6) => ctx.addIssue({ code: "custom", path: path4, message: message6 });
|
|
79508
|
-
const users4 = /* @__PURE__ */ new Set(), pages = /* @__PURE__ */ new Set(),
|
|
79570
|
+
const users4 = /* @__PURE__ */ new Set(), pages = /* @__PURE__ */ new Set(), all8 = /* @__PURE__ */ new Set();
|
|
79509
79571
|
seed40.users.forEach((u, i) => {
|
|
79510
79572
|
if (users4.has(u.ref)) issue5(["users", i, "ref"], "duplicate user ref");
|
|
79511
79573
|
users4.add(u.ref);
|
|
79512
79574
|
});
|
|
79513
79575
|
const declare = (r, path4) => {
|
|
79514
79576
|
if (r === void 0) return;
|
|
79515
|
-
if (
|
|
79516
|
-
|
|
79577
|
+
if (all8.has(r) || users4.has(r)) issue5(path4, `duplicate ref ${r}`);
|
|
79578
|
+
all8.add(r);
|
|
79517
79579
|
};
|
|
79518
79580
|
seed40.pages.forEach((p2, i) => {
|
|
79519
79581
|
declare(p2.ref, ["pages", i, "ref"]);
|
|
@@ -88007,9 +88069,9 @@ function inspectPredicate(env, predicate, atMs) {
|
|
|
88007
88069
|
const expected = predicateWords(predicate);
|
|
88008
88070
|
const outcome3 = (passed, actual, explanation = actual) => ({ passed, expected, actual, explanation });
|
|
88009
88071
|
if ("all" in predicate || "any" in predicate) {
|
|
88010
|
-
const
|
|
88011
|
-
const children2 = (
|
|
88012
|
-
return outcome3(
|
|
88072
|
+
const all8 = "all" in predicate;
|
|
88073
|
+
const children2 = (all8 ? predicate.all : predicate.any).map((child2) => inspectPredicate(env, child2, atMs));
|
|
88074
|
+
return outcome3(all8 ? children2.every((child2) => child2.passed) : children2.some((child2) => child2.passed), children2.map((child2) => child2.actual).join("; "));
|
|
88013
88075
|
}
|
|
88014
88076
|
if ("not" in predicate) {
|
|
88015
88077
|
const child2 = inspectPredicate(env, predicate.not, atMs);
|
|
@@ -92345,10 +92407,10 @@ var bufferToFormData = (arrayBuffer, contentType) => {
|
|
|
92345
92407
|
var MAX_NESTED_OBJECTS = 1e4;
|
|
92346
92408
|
var isRawRequest = (request4) => "headers" in request4;
|
|
92347
92409
|
var parseBody = async (request4, options3 = /* @__PURE__ */ Object.create(null)) => {
|
|
92348
|
-
const { all:
|
|
92410
|
+
const { all: all8 = false, dot = false } = options3;
|
|
92349
92411
|
const mediaType2 = (isRawRequest(request4) ? request4.headers : request4.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
|
|
92350
92412
|
if (mediaType2 === "multipart/form-data" || mediaType2 === "application/x-www-form-urlencoded") return parseFormData(request4, {
|
|
92351
|
-
all:
|
|
92413
|
+
all: all8,
|
|
92352
92414
|
dot
|
|
92353
92415
|
});
|
|
92354
92416
|
return {};
|
|
@@ -94253,8 +94315,8 @@ function properties(type, record8) {
|
|
|
94253
94315
|
function project2(ctx, type, record8, selected2, historyFields, associationObjects) {
|
|
94254
94316
|
const names3 = selected2 ?? defaultProperties[type];
|
|
94255
94317
|
for (const name5 of [...names3, ...historyFields ?? []]) checkProperty(type, name5);
|
|
94256
|
-
const
|
|
94257
|
-
const output2 = { id: record8.id, properties: Object.fromEntries(keys5.filter((key3) =>
|
|
94318
|
+
const all8 = properties(type, record8), keys5 = [.../* @__PURE__ */ new Set([...names3, "hs_object_id", "createdate", type === "contacts" ? "lastmodifieddate" : "hs_lastmodifieddate"])];
|
|
94319
|
+
const output2 = { id: record8.id, properties: Object.fromEntries(keys5.filter((key3) => all8[key3] !== void 0).map((key3) => [key3, all8[key3]])), createdAt: record8.createdAt, updatedAt: record8.updatedAt, archived: record8.archived, ...record8.archived && { archivedAt: record8.archivedAt } };
|
|
94258
94320
|
if (historyFields?.length) {
|
|
94259
94321
|
const versions2 = ctx.store.db.prepare("SELECT data,operation FROM hubspot_versions WHERE type=? AND id=? ORDER BY ordinal").all(type, record8.id).map((row) => ({ ...row, record: JSON.parse(row.data) }));
|
|
94260
94322
|
output2.propertiesWithHistory = Object.fromEntries(historyFields.map((name5) => {
|
|
@@ -94670,9 +94732,9 @@ function dispatch(ctx, method2, url3, body6) {
|
|
|
94670
94732
|
permission3(ctx, type2);
|
|
94671
94733
|
queryParams(url3, ["archived"]);
|
|
94672
94734
|
if (boolean5(url3.searchParams.get("archived"))) unsupported3("archived pipelines");
|
|
94673
|
-
const
|
|
94674
|
-
if (!match2[2]) return { status: 200, body: { results:
|
|
94675
|
-
const pipeline =
|
|
94735
|
+
const all8 = config2(ctx).pipelines;
|
|
94736
|
+
if (!match2[2]) return { status: 200, body: { results: all8.map((p2) => ({ ...p2, archived: false })) } };
|
|
94737
|
+
const pipeline = all8.find((p2) => p2.id === decodeURIComponent(match2[2]));
|
|
94676
94738
|
if (!pipeline) throw new HubError(404, "OBJECT_NOT_FOUND", "Pipeline not found.");
|
|
94677
94739
|
if (path4.includes("/stages")) {
|
|
94678
94740
|
if (!match2[3]) return { status: 200, body: { results: pipeline.stages.map((stage2) => ({ ...stage2, createdAt: pipeline.createdAt, updatedAt: pipeline.updatedAt, archived: false })) } };
|
|
@@ -95108,7 +95170,7 @@ function initializeCatalogIntegrations(env) {
|
|
|
95108
95170
|
}
|
|
95109
95171
|
function reconcileCatalogIntegrations(env) {
|
|
95110
95172
|
if (!hasTable5(env, "world_catalog_cursor")) return { activity: false };
|
|
95111
|
-
const
|
|
95173
|
+
const all8 = entries(env), before = env.events.tail;
|
|
95112
95174
|
let cursor4 = env.store.db.prepare("SELECT cursor FROM world_catalog_cursor WHERE id = 1").get().cursor;
|
|
95113
95175
|
let activity2 = false;
|
|
95114
95176
|
scan: for (let batch3 = env.events.list(cursor4, 100); batch3.length; batch3 = env.events.list(cursor4, 100)) {
|
|
@@ -95120,7 +95182,7 @@ function reconcileCatalogIntegrations(env) {
|
|
|
95120
95182
|
}
|
|
95121
95183
|
cursor4 = event3.cursor;
|
|
95122
95184
|
const view3 = catalogEvent(event3);
|
|
95123
|
-
for (const entry2 of
|
|
95185
|
+
for (const entry2 of all8) {
|
|
95124
95186
|
if (!matches(entry2.integration, view3)) continue;
|
|
95125
95187
|
const delay = entry2.integration.delay === void 0 ? 0 : parseDuration(entry2.integration.delay);
|
|
95126
95188
|
if (delay > 0) env.scheduler.enqueue({ atMs: env.clock.elapsedMs() + delay, kind: "integration.catalog", payload: { integration: entry2.ordinal, event: event3.cursor } });
|
|
@@ -105662,11 +105724,11 @@ function listPermissions(call2) {
|
|
|
105662
105724
|
const pageSize2 = integerParameter(params9, "pageSize", 100, 1, 100);
|
|
105663
105725
|
const binding2 = JSON.stringify(["permissions", file3.id]);
|
|
105664
105726
|
const offset16 = readPageToken(params9.get("pageToken"), binding2);
|
|
105665
|
-
const
|
|
105727
|
+
const all8 = effectivePermissions(call2.ctx, file3);
|
|
105666
105728
|
return json8(project7({
|
|
105667
105729
|
kind: "drive#permissionList",
|
|
105668
|
-
...offset16 + pageSize2 <
|
|
105669
|
-
permissions:
|
|
105730
|
+
...offset16 + pageSize2 < all8.length && { nextPageToken: pageToken(offset16 + pageSize2, binding2) },
|
|
105731
|
+
permissions: all8.slice(offset16, offset16 + pageSize2).map((entry2) => permissionResource(call2.ctx, entry2.grant))
|
|
105670
105732
|
}, mask(params9, "kind,nextPageToken,permissions(kind,id,type,role,allowFileDiscovery)", ["kind", "nextPageToken", "permissions"], { permissions: PERMISSION_FIELDS })));
|
|
105671
105733
|
}
|
|
105672
105734
|
function getPermission(call2) {
|
|
@@ -106404,10 +106466,10 @@ function leaves(part) {
|
|
|
106404
106466
|
return part.parts.length ? part.parts.flatMap(leaves) : [part];
|
|
106405
106467
|
}
|
|
106406
106468
|
function bodyText(root2) {
|
|
106407
|
-
const
|
|
106408
|
-
const plain3 =
|
|
106469
|
+
const all8 = leaves(root2).filter((p2) => !isAttachment(p2));
|
|
106470
|
+
const plain3 = all8.filter((p2) => p2.mimeType === "text/plain");
|
|
106409
106471
|
if (plain3.length) return plain3.map(partText).join("\n");
|
|
106410
|
-
return
|
|
106472
|
+
return all8.filter((p2) => p2.mimeType === "text/html").map((p2) => htmlToText(partText(p2))).join("\n");
|
|
106411
106473
|
}
|
|
106412
106474
|
function htmlToText(html2) {
|
|
106413
106475
|
return html2.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi, " ").replace(/<br\s*\/?>|<\/(p|div|li|h\d)>/gi, "\n").replace(/<[^>]+>/g, " ").replace(/ /g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
@@ -107109,9 +107171,9 @@ function searchFor(r) {
|
|
|
107109
107171
|
function filterFor(r, labelIds = []) {
|
|
107110
107172
|
const search9 = searchFor(r), mailbox2 = r.caller.mailbox.address;
|
|
107111
107173
|
for (const id12 of labelIds) if (!getLabel2(r.ctx, mailbox2, id12)) invalid10(`Invalid label: ${id12}`);
|
|
107112
|
-
const
|
|
107113
|
-
const trashOk =
|
|
107114
|
-
const spamOk =
|
|
107174
|
+
const all8 = bool2(r.query, "includeSpamTrash");
|
|
107175
|
+
const trashOk = all8 || search9.includesTrash || labelIds.includes("TRASH");
|
|
107176
|
+
const spamOk = all8 || search9.includesSpam || labelIds.includes("SPAM");
|
|
107115
107177
|
return (row) => {
|
|
107116
107178
|
const ids2 = labelIdsOf(r.ctx, mailbox2, row.id);
|
|
107117
107179
|
if (!trashOk && ids2.includes("TRASH")) return false;
|
|
@@ -108156,12 +108218,12 @@ function listBuckets(call2) {
|
|
|
108156
108218
|
const limit = max === void 0 ? 1e4 : Number(max);
|
|
108157
108219
|
if (!Number.isInteger(limit) || limit < 1 || limit > 1e4) throw new S3Error("InvalidArgument", "Argument max-buckets must be an integer between 1 and 10000", { ArgumentName: "max-buckets", ArgumentValue: max ?? "" });
|
|
108158
108220
|
const after = token2 === void 0 ? "" : Buffer.from(token2, "base64url").toString("utf8");
|
|
108159
|
-
const
|
|
108160
|
-
const page15 =
|
|
108221
|
+
const all8 = call2.ctx.store.db.prepare("SELECT * FROM s3_buckets ORDER BY name").all().filter((bucket2) => bucket2.name.startsWith(prefix2) && (region === void 0 || bucket2.region === region) && bucket2.name > after);
|
|
108222
|
+
const page15 = all8.slice(0, limit);
|
|
108161
108223
|
return xml(call2, node3("ListAllMyBucketsResult", [
|
|
108162
108224
|
owner(call2.ctx),
|
|
108163
108225
|
node3("Buckets", page15.map((bucket2) => node3("Bucket", [el("Name", bucket2.name), el("CreationDate", iso3(bucket2.created_ms)), el("BucketRegion", bucket2.region)]))),
|
|
108164
|
-
...
|
|
108226
|
+
...all8.length > limit ? [el("ContinuationToken", Buffer.from(page15.at(-1).name).toString("base64url"))] : [],
|
|
108165
108227
|
...prefix2 ? [el("Prefix", prefix2)] : []
|
|
108166
108228
|
], true));
|
|
108167
108229
|
}
|
|
@@ -108800,7 +108862,7 @@ function migrate16(db2) {
|
|
|
108800
108862
|
db2.exec(SCHEMA7);
|
|
108801
108863
|
}
|
|
108802
108864
|
var one = (ctx, sql, ...args) => ctx.store.db.prepare(sql).get(...args);
|
|
108803
|
-
var
|
|
108865
|
+
var all2 = (ctx, sql, ...args) => ctx.store.db.prepare(sql).all(...args);
|
|
108804
108866
|
var org = (ctx) => one(ctx, "SELECT * FROM linear_org");
|
|
108805
108867
|
var userById = (ctx, id12) => one(ctx, "SELECT * FROM linear_users WHERE id = ?", id12);
|
|
108806
108868
|
var teamById = (ctx, id12) => one(ctx, "SELECT * FROM linear_teams WHERE id = ?", id12);
|
|
@@ -108809,17 +108871,17 @@ var labelById = (ctx, id12) => one(ctx, "SELECT * FROM linear_labels WHERE id =
|
|
|
108809
108871
|
var projectById = (ctx, id12) => one(ctx, "SELECT * FROM linear_projects WHERE id = ?", id12);
|
|
108810
108872
|
var issueById = (ctx, id12) => one(ctx, "SELECT * FROM linear_issues WHERE id = ?", id12);
|
|
108811
108873
|
var commentById = (ctx, id12) => one(ctx, "SELECT * FROM linear_comments WHERE id = ?", id12);
|
|
108812
|
-
var allUsers = (ctx) =>
|
|
108813
|
-
var allTeams = (ctx) =>
|
|
108814
|
-
var allStates = (ctx) =>
|
|
108815
|
-
var allLabels = (ctx) =>
|
|
108816
|
-
var allProjects = (ctx) =>
|
|
108817
|
-
var allIssues = (ctx) =>
|
|
108818
|
-
var allComments = (ctx) =>
|
|
108819
|
-
var teamMemberIds = (ctx, teamId) =>
|
|
108820
|
-
var userTeamIds = (ctx, userId) =>
|
|
108821
|
-
var issueLabelIds = (ctx, issueId) =>
|
|
108822
|
-
var projectTeamIds = (ctx, projectId) =>
|
|
108874
|
+
var allUsers = (ctx) => all2(ctx, "SELECT * FROM linear_users ORDER BY rowid");
|
|
108875
|
+
var allTeams = (ctx) => all2(ctx, "SELECT * FROM linear_teams ORDER BY rowid");
|
|
108876
|
+
var allStates = (ctx) => all2(ctx, "SELECT * FROM linear_states ORDER BY rowid");
|
|
108877
|
+
var allLabels = (ctx) => all2(ctx, "SELECT * FROM linear_labels ORDER BY rowid");
|
|
108878
|
+
var allProjects = (ctx) => all2(ctx, "SELECT * FROM linear_projects ORDER BY rowid");
|
|
108879
|
+
var allIssues = (ctx) => all2(ctx, "SELECT * FROM linear_issues ORDER BY rowid");
|
|
108880
|
+
var allComments = (ctx) => all2(ctx, "SELECT * FROM linear_comments ORDER BY rowid");
|
|
108881
|
+
var teamMemberIds = (ctx, teamId) => all2(ctx, "SELECT user_id FROM linear_team_members WHERE team_id = ? ORDER BY rowid", teamId).map((r) => r.user_id);
|
|
108882
|
+
var userTeamIds = (ctx, userId) => all2(ctx, "SELECT team_id FROM linear_team_members WHERE user_id = ? ORDER BY rowid", userId).map((r) => r.team_id);
|
|
108883
|
+
var issueLabelIds = (ctx, issueId) => all2(ctx, "SELECT label_id FROM linear_issue_labels WHERE issue_id = ? ORDER BY rowid", issueId).map((r) => r.label_id);
|
|
108884
|
+
var projectTeamIds = (ctx, projectId) => all2(ctx, "SELECT team_id FROM linear_project_teams WHERE project_id = ? ORDER BY rowid", projectId).map((r) => r.team_id);
|
|
108823
108885
|
function uuid5(ctx) {
|
|
108824
108886
|
const hex5 = ctx.ids.hex(32).split("");
|
|
108825
108887
|
hex5[12] = "4";
|
|
@@ -108861,7 +108923,7 @@ function gap3(what) {
|
|
|
108861
108923
|
var scalar = (comparator, column) => ({ kind: "scalar", comparator, get: (_, row) => row[column] });
|
|
108862
108924
|
var ts = (column) => scalar("date", column);
|
|
108863
108925
|
var db = (r) => r.ctx.store.db;
|
|
108864
|
-
var
|
|
108926
|
+
var all3 = (r, sql, ...args) => db(r).prepare(sql).all(...args);
|
|
108865
108927
|
var SPECS = {
|
|
108866
108928
|
Issue: {
|
|
108867
108929
|
id: scalar("id", "id"),
|
|
@@ -108884,10 +108946,10 @@ ${row.description ?? ""}` },
|
|
|
108884
108946
|
assignee: { kind: "one", type: "User", get: (r, row) => row.assignee_id ? userById(r.ctx, row.assignee_id) : void 0 },
|
|
108885
108947
|
creator: { kind: "one", type: "User", get: (r, row) => row.creator_id ? userById(r.ctx, row.creator_id) : void 0 },
|
|
108886
108948
|
project: { kind: "one", type: "Project", get: (r, row) => row.project_id ? projectById(r.ctx, row.project_id) : void 0 },
|
|
108887
|
-
parent: { kind: "one", type: "Issue", get: (r, row) => row.parent_id ?
|
|
108949
|
+
parent: { kind: "one", type: "Issue", get: (r, row) => row.parent_id ? all3(r, "SELECT * FROM linear_issues WHERE id = ?", row.parent_id)[0] : void 0 },
|
|
108888
108950
|
labels: { kind: "many", type: "IssueLabel", get: (r, row) => issueLabelIds(r.ctx, row.id).map((id12) => labelById(r.ctx, id12)) },
|
|
108889
|
-
children: { kind: "many", type: "Issue", get: (r, row) =>
|
|
108890
|
-
comments: { kind: "many", type: "Comment", get: (r, row) =>
|
|
108951
|
+
children: { kind: "many", type: "Issue", get: (r, row) => all3(r, "SELECT * FROM linear_issues WHERE parent_id = ? ORDER BY rowid", row.id) },
|
|
108952
|
+
comments: { kind: "many", type: "Comment", get: (r, row) => all3(r, "SELECT * FROM linear_comments WHERE issue_id = ? ORDER BY rowid", row.id) }
|
|
108891
108953
|
},
|
|
108892
108954
|
Team: {
|
|
108893
108955
|
id: scalar("id", "id"),
|
|
@@ -108898,7 +108960,7 @@ ${row.description ?? ""}` },
|
|
|
108898
108960
|
createdAt: ts("created_at"),
|
|
108899
108961
|
updatedAt: ts("updated_at"),
|
|
108900
108962
|
members: { kind: "many", type: "User", get: (r, row) => teamMemberIds(r.ctx, row.id).map((id12) => userById(r.ctx, id12)) },
|
|
108901
|
-
issues: { kind: "many", type: "Issue", get: (r, row) =>
|
|
108963
|
+
issues: { kind: "many", type: "Issue", get: (r, row) => all3(r, "SELECT * FROM linear_issues WHERE team_id = ? ORDER BY rowid", row.id) }
|
|
108902
108964
|
},
|
|
108903
108965
|
User: {
|
|
108904
108966
|
id: scalar("id", "id"),
|
|
@@ -108911,7 +108973,7 @@ ${row.description ?? ""}` },
|
|
|
108911
108973
|
app: { kind: "scalar", comparator: "boolean", get: () => false },
|
|
108912
108974
|
createdAt: ts("created_at"),
|
|
108913
108975
|
updatedAt: ts("updated_at"),
|
|
108914
|
-
assignedIssues: { kind: "many", type: "Issue", get: (r, row) =>
|
|
108976
|
+
assignedIssues: { kind: "many", type: "Issue", get: (r, row) => all3(r, "SELECT * FROM linear_issues WHERE assignee_id = ? ORDER BY rowid", row.id) }
|
|
108915
108977
|
},
|
|
108916
108978
|
WorkflowState: {
|
|
108917
108979
|
id: scalar("id", "id"),
|
|
@@ -108922,7 +108984,7 @@ ${row.description ?? ""}` },
|
|
|
108922
108984
|
createdAt: ts("created_at"),
|
|
108923
108985
|
updatedAt: ts("updated_at"),
|
|
108924
108986
|
team: { kind: "one", type: "Team", get: (r, row) => teamById(r.ctx, row.team_id) },
|
|
108925
|
-
issues: { kind: "many", type: "Issue", get: (r, row) =>
|
|
108987
|
+
issues: { kind: "many", type: "Issue", get: (r, row) => all3(r, "SELECT * FROM linear_issues WHERE state_id = ? ORDER BY rowid", row.id) }
|
|
108926
108988
|
},
|
|
108927
108989
|
IssueLabel: {
|
|
108928
108990
|
id: scalar("id", "id"),
|
|
@@ -108938,9 +109000,9 @@ ${row.description ?? ""}` },
|
|
|
108938
109000
|
body: scalar("string", "body"),
|
|
108939
109001
|
createdAt: ts("created_at"),
|
|
108940
109002
|
updatedAt: ts("updated_at"),
|
|
108941
|
-
issue: { kind: "one", type: "Issue", get: (r, row) =>
|
|
109003
|
+
issue: { kind: "one", type: "Issue", get: (r, row) => all3(r, "SELECT * FROM linear_issues WHERE id = ?", row.issue_id)[0] },
|
|
108942
109004
|
user: { kind: "one", type: "User", get: (r, row) => userById(r.ctx, row.user_id) },
|
|
108943
|
-
parent: { kind: "one", type: "Comment", get: (r, row) => row.parent_id ?
|
|
109005
|
+
parent: { kind: "one", type: "Comment", get: (r, row) => row.parent_id ? all3(r, "SELECT * FROM linear_comments WHERE id = ?", row.parent_id)[0] : void 0 }
|
|
108944
109006
|
},
|
|
108945
109007
|
Project: {
|
|
108946
109008
|
id: scalar("id", "id"),
|
|
@@ -108957,7 +109019,7 @@ ${row.description ?? ""}` },
|
|
|
108957
109019
|
searchableContent: { kind: "scalar", comparator: "content", get: (_, row) => `${row.name}
|
|
108958
109020
|
${row.description ?? ""}` },
|
|
108959
109021
|
lead: { kind: "one", type: "User", get: (r, row) => row.lead_id ? userById(r.ctx, row.lead_id) : void 0 },
|
|
108960
|
-
issues: { kind: "many", type: "Issue", get: (r, row) =>
|
|
109022
|
+
issues: { kind: "many", type: "Issue", get: (r, row) => all3(r, "SELECT * FROM linear_issues WHERE project_id = ? ORDER BY rowid", row.id) }
|
|
108961
109023
|
}
|
|
108962
109024
|
};
|
|
108963
109025
|
function dateValue2(r, value4) {
|
|
@@ -109839,8 +109901,8 @@ function seed17(ctx) {
|
|
|
109839
109901
|
states.set(s.name.toLowerCase(), stateId);
|
|
109840
109902
|
db2.prepare("INSERT INTO linear_states (id, team_id, name, type, color, position, description, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)").run(stateId, id12, s.name, s.type, s.color ?? "#bec2c8", position, ("description" in s ? s.description : void 0) ?? null, workspaceCreated, workspaceCreated);
|
|
109841
109903
|
});
|
|
109842
|
-
const
|
|
109843
|
-
const initial = t.default_state ?? (
|
|
109904
|
+
const all8 = t.states ?? LINEAR_DEFAULT_STATES;
|
|
109905
|
+
const initial = t.default_state ?? (all8.find((s) => s.type === "backlog") ?? all8.find((s) => s.type === "unstarted")).name;
|
|
109844
109906
|
db2.prepare("UPDATE linear_teams SET default_state_id = ? WHERE id = ?").run(states.get(initial.toLowerCase()), id12);
|
|
109845
109907
|
for (const l of t.labels) {
|
|
109846
109908
|
const labelId = uuid5(ctx);
|
|
@@ -111068,7 +111130,7 @@ function save6(ctx, value4) {
|
|
|
111068
111130
|
db2.prepare("INSERT OR REPLACE INTO stripe_objects (id, type, seq, created, customer, json) VALUES (?, ?, ?, ?, ?, ?)").run(value4.id, value4.object, seq2, typeof value4.created === "number" ? value4.created : 0, customer3, JSON.stringify(value4));
|
|
111069
111131
|
return value4;
|
|
111070
111132
|
}
|
|
111071
|
-
function
|
|
111133
|
+
function all4(ctx, type) {
|
|
111072
111134
|
return ctx.store.db.prepare("SELECT json FROM stripe_objects WHERE type = ? ORDER BY created DESC, seq DESC").all(type).map((r) => JSON.parse(r.json));
|
|
111073
111135
|
}
|
|
111074
111136
|
var BASE622 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
@@ -112388,7 +112450,7 @@ function markPaid(ctx, inv, at2, amount3 = inv.amount_remaining, offStripe = fal
|
|
|
112388
112450
|
const sub2 = inv.parent?.subscription_details?.subscription ? load(ctx, inv.parent.subscription_details.subscription) : void 0;
|
|
112389
112451
|
if (sub2 && (sub2.status === "past_due" || sub2.status === "unpaid" || sub2.status === "incomplete") && !openInvoices(ctx, sub2.id).some((i) => i.id !== inv.id)) save6(ctx, { ...sub2, status: "active" });
|
|
112390
112452
|
}
|
|
112391
|
-
var openInvoices = (ctx, subscription2) =>
|
|
112453
|
+
var openInvoices = (ctx, subscription2) => all4(ctx, "invoice").filter((i) => i.status === "open" && i.parent?.subscription_details?.subscription === subscription2);
|
|
112392
112454
|
function pay(ctx, inv, o) {
|
|
112393
112455
|
if (inv.status === "paid") invalid11("Invoice is already paid");
|
|
112394
112456
|
if (inv.status === "void") invalid11("You cannot pay a void invoice.");
|
|
@@ -112422,7 +112484,7 @@ function voidInvoice(ctx, inv) {
|
|
|
112422
112484
|
if (inv.status === "void") invalid11("This invoice is already void.", void 0, "invoice_not_editable");
|
|
112423
112485
|
const at2 = nowSeconds(ctx);
|
|
112424
112486
|
Object.assign(inv, { status: "void", amount_remaining: 0, next_payment_attempt: null, auto_advance: false, status_transitions: { ...inv.status_transitions, voided_at: at2 } });
|
|
112425
|
-
for (const item2 of
|
|
112487
|
+
for (const item2 of all4(ctx, "invoiceitem").filter((i) => i.invoice === inv.id)) save6(ctx, item2);
|
|
112426
112488
|
return save6(ctx, inv);
|
|
112427
112489
|
}
|
|
112428
112490
|
function prorate(ctx, sub2, item2, oldPrice, oldQuantity, newPrice, newQuantity) {
|
|
@@ -112509,7 +112571,7 @@ function searchCustomers(ctx, params9, present2) {
|
|
|
112509
112571
|
const limit = int2(params9.limit, "limit") ?? 10;
|
|
112510
112572
|
if (limit < 1 || limit > 100) invalid11("Invalid limit: must be between 1 and 100.", "limit");
|
|
112511
112573
|
const { clauses: tests, or } = clauses(query10);
|
|
112512
|
-
const matches7 =
|
|
112574
|
+
const matches7 = all4(ctx, "customer").filter((c) => !c.deleted && (or ? tests.some((t) => t(c)) : tests.every((t) => t(c))));
|
|
112513
112575
|
const token2 = str(params9.page, "page");
|
|
112514
112576
|
const offset16 = token2 === void 0 ? 0 : Number(/^page_(\d+)$/.exec(token2)?.[1] ?? NaN);
|
|
112515
112577
|
if (!Number.isSafeInteger(offset16)) invalid11(`Invalid page: ${token2}`, "page");
|
|
@@ -112583,7 +112645,7 @@ function customerFields(r, c) {
|
|
|
112583
112645
|
function presentCustomer(ctx, c) {
|
|
112584
112646
|
if (c.deleted) return deletedStub(c);
|
|
112585
112647
|
const now10 = nowSeconds(ctx);
|
|
112586
|
-
return { ...c, delinquent:
|
|
112648
|
+
return { ...c, delinquent: all4(ctx, "invoice").some((i) => i.customer === c.id && i.status === "open" && (i.due_date !== null && i.due_date < now10 || i.attempt_count > 0)) };
|
|
112587
112649
|
}
|
|
112588
112650
|
var read = (path4, supported3, run3, notes6) => ({ method: "GET", path: path4, supported: supported3, run: run3, coverage: notes6 ? { status: "partial", notes: notes6 } : { status: "supported" } });
|
|
112589
112651
|
var write = (method2, path4, supported3, run3, notes6) => ({ method: method2, path: path4, supported: supported3, run: run3, coverage: notes6 ? { status: "partial", notes: notes6 } : { status: "supported" } });
|
|
@@ -112597,7 +112659,7 @@ var stripeRoutes = [
|
|
|
112597
112659
|
}, "invoice_settings supports default_payment_method only; addresses, shipping, tax ids and cash balances are gaps"),
|
|
112598
112660
|
read("/v1/customers", ["email", "created", ...PAGE], (r) => {
|
|
112599
112661
|
const email10 = str(r.params.email, "email", 512);
|
|
112600
|
-
const items = filterCreated(
|
|
112662
|
+
const items = filterCreated(all4(r.ctx, "customer").filter((c) => !c.deleted && (email10 === void 0 || c.email === email10)), r.params);
|
|
112601
112663
|
const result = page4(items, r.params, "/v1/customers", "customer");
|
|
112602
112664
|
return { ...result, data: result.data.map((c) => presentCustomer(r.ctx, c)) };
|
|
112603
112665
|
}),
|
|
@@ -112610,7 +112672,7 @@ var stripeRoutes = [
|
|
|
112610
112672
|
}),
|
|
112611
112673
|
write("DELETE", "/v1/customers/:id", [], (r) => {
|
|
112612
112674
|
const c = liveCustomer(r.ctx, r.id, "id");
|
|
112613
|
-
for (const sub2 of
|
|
112675
|
+
for (const sub2 of all4(r.ctx, "subscription").filter((s) => s.customer === c.id && s.status !== "canceled")) {
|
|
112614
112676
|
const at2 = nowSeconds(r.ctx);
|
|
112615
112677
|
save6(r.ctx, { ...sub2, status: "canceled", canceled_at: at2, ended_at: at2, cancellation_details: { ...sub2.cancellation_details, reason: "cancellation_requested" } });
|
|
112616
112678
|
}
|
|
@@ -112620,20 +112682,20 @@ var stripeRoutes = [
|
|
|
112620
112682
|
/* ----------------------------- products and prices ---------------------------- */
|
|
112621
112683
|
read("/v1/products", ["active", "ids", "created", ...PAGE], (r) => {
|
|
112622
112684
|
const active2 = bool3(r.params.active, "active"), ids2 = list8(r.params.ids, "ids")?.map((v, i) => str(v, `ids[${i}]`));
|
|
112623
|
-
return page4(filterCreated(
|
|
112685
|
+
return page4(filterCreated(all4(r.ctx, "product").filter((p2) => (active2 === void 0 || p2.active === active2) && (!ids2 || ids2.includes(p2.id))), r.params), r.params, "/v1/products", "product");
|
|
112624
112686
|
}),
|
|
112625
112687
|
read("/v1/products/:id", [], (r) => find4(r.ctx, "product", r.id)),
|
|
112626
112688
|
read("/v1/prices", ["product", "active", "type", "currency", "lookup_keys", "created", ...PAGE], (r) => {
|
|
112627
112689
|
const product2 = str(r.params.product, "product"), active2 = bool3(r.params.active, "active"), type = oneOf(r.params.type, "type", ["one_time", "recurring"]);
|
|
112628
112690
|
const currency = str(r.params.currency, "currency")?.toLowerCase(), keys5 = list8(r.params.lookup_keys, "lookup_keys")?.map((v, i) => str(v, `lookup_keys[${i}]`));
|
|
112629
|
-
return page4(filterCreated(
|
|
112691
|
+
return page4(filterCreated(all4(r.ctx, "price").filter((p2) => (!product2 || p2.product === product2) && (active2 === void 0 || p2.active === active2) && (!type || p2.type === type) && (!currency || p2.currency === currency) && (!keys5 || keys5.includes(p2.lookup_key))), r.params), r.params, "/v1/prices", "price");
|
|
112630
112692
|
}),
|
|
112631
112693
|
read("/v1/prices/:id", [], (r) => find4(r.ctx, "price", r.id)),
|
|
112632
112694
|
/* --------------------------------- subscriptions ------------------------------- */
|
|
112633
112695
|
read("/v1/subscriptions", ["customer", "price", "status", "created", ...PAGE], (r) => {
|
|
112634
112696
|
const customer3 = str(r.params.customer, "customer"), priceId = str(r.params.price, "price");
|
|
112635
112697
|
const status4 = oneOf(r.params.status, "status", ["active", "all", "canceled", "ended", "incomplete", "incomplete_expired", "past_due", "paused", "trialing", "unpaid"]);
|
|
112636
|
-
const items =
|
|
112698
|
+
const items = all4(r.ctx, "subscription").filter((s) => (!customer3 || s.customer === customer3) && (!priceId || s.items.data.some((i) => i.price.id === priceId)) && (status4 === "all" || (status4 === void 0 ? s.status !== "canceled" && s.status !== "incomplete_expired" : status4 === "ended" ? s.status === "canceled" : s.status === status4)));
|
|
112637
112699
|
return page4(filterCreated(items, r.params), r.params, "/v1/subscriptions", "subscription");
|
|
112638
112700
|
}, "without status, canceled subscriptions are left out, as Stripe does"),
|
|
112639
112701
|
read("/v1/subscriptions/:id", [], (r) => find4(r.ctx, "subscription", r.id)),
|
|
@@ -112716,7 +112778,7 @@ var stripeRoutes = [
|
|
|
112716
112778
|
read("/v1/invoices", ["customer", "subscription", "status", "collection_method", "created", ...PAGE], (r) => {
|
|
112717
112779
|
const customer3 = str(r.params.customer, "customer"), subscription2 = str(r.params.subscription, "subscription");
|
|
112718
112780
|
const status4 = oneOf(r.params.status, "status", ["draft", "open", "paid", "uncollectible", "void"]), method2 = oneOf(r.params.collection_method, "collection_method", ["charge_automatically", "send_invoice"]);
|
|
112719
|
-
return page4(filterCreated(
|
|
112781
|
+
return page4(filterCreated(all4(r.ctx, "invoice").filter((i) => (!customer3 || i.customer === customer3) && (!subscription2 || i.parent?.subscription_details?.subscription === subscription2) && (!status4 || i.status === status4) && (!method2 || i.collection_method === method2)), r.params), r.params, "/v1/invoices", "invoice");
|
|
112720
112782
|
}),
|
|
112721
112783
|
read("/v1/invoices/:id", [], (r) => find4(r.ctx, "invoice", r.id)),
|
|
112722
112784
|
write("POST", "/v1/invoices", ["customer", "auto_advance", "collection_method", "days_until_due", "due_date", "description", "footer", "custom_fields", "metadata", "currency", "pending_invoice_items_behavior", "subscription"], (r) => {
|
|
@@ -112748,7 +112810,7 @@ var stripeRoutes = [
|
|
|
112748
112810
|
period: { start: now10, end: now10 }
|
|
112749
112811
|
});
|
|
112750
112812
|
save6(r.ctx, inv);
|
|
112751
|
-
if (behavior === "include") for (const item2 of
|
|
112813
|
+
if (behavior === "include") for (const item2 of all4(r.ctx, "invoiceitem").filter((i) => i.customer === c.id && i.invoice === null && (!sub2 || i.parent?.subscription_details?.subscription === sub2.id)).reverse()) addLine(r.ctx, inv, item2);
|
|
112752
112814
|
return save6(r.ctx, recalc(inv));
|
|
112753
112815
|
}, "pending invoice items are included only with pending_invoice_items_behavior=include, the default for new API versions"),
|
|
112754
112816
|
write("POST", "/v1/invoices/:id", ["description", "footer", "custom_fields", "metadata", "auto_advance", "days_until_due", "due_date"], (r) => {
|
|
@@ -112824,7 +112886,7 @@ var stripeRoutes = [
|
|
|
112824
112886
|
read("/v1/invoiceitems", ["customer", "invoice", "pending", "created", ...PAGE], (r) => {
|
|
112825
112887
|
const customer3 = str(r.params.customer, "customer"), invoiceId = str(r.params.invoice, "invoice"), pending = bool3(r.params.pending, "pending");
|
|
112826
112888
|
return page4(
|
|
112827
|
-
filterCreated(
|
|
112889
|
+
filterCreated(all4(r.ctx, "invoiceitem").filter((i) => (!customer3 || i.customer === customer3) && (!invoiceId || i.invoice === invoiceId) && (pending === void 0 || i.invoice === null === pending)), r.params, "date"),
|
|
112828
112890
|
r.params,
|
|
112829
112891
|
"/v1/invoiceitems",
|
|
112830
112892
|
"invoiceitem"
|
|
@@ -112864,7 +112926,7 @@ var stripeRoutes = [
|
|
|
112864
112926
|
}, "card payments with a saved payment method or a test token such as pm_card_visa; pm_card_chargeDeclined* tokens decline; 3D Secure, manual capture and other methods are gaps"),
|
|
112865
112927
|
read("/v1/payment_intents", ["customer", "created", ...PAGE], (r) => {
|
|
112866
112928
|
const customer3 = str(r.params.customer, "customer");
|
|
112867
|
-
return page4(filterCreated(
|
|
112929
|
+
return page4(filterCreated(all4(r.ctx, "payment_intent").filter((pi) => !customer3 || pi.customer === customer3), r.params), r.params, "/v1/payment_intents", "payment_intent");
|
|
112868
112930
|
}),
|
|
112869
112931
|
read("/v1/payment_intents/:id", ["client_secret"], (r) => find4(r.ctx, "payment_intent", r.id)),
|
|
112870
112932
|
write("POST", "/v1/payment_intents/:id/confirm", ["payment_method", "off_session", "receipt_email"], (r) => {
|
|
@@ -112887,7 +112949,7 @@ var stripeRoutes = [
|
|
|
112887
112949
|
/* -------------------------------- charges, refunds ------------------------------- */
|
|
112888
112950
|
read("/v1/charges", ["customer", "payment_intent", "created", ...PAGE], (r) => {
|
|
112889
112951
|
const customer3 = str(r.params.customer, "customer"), intent = str(r.params.payment_intent, "payment_intent");
|
|
112890
|
-
return page4(filterCreated(
|
|
112952
|
+
return page4(filterCreated(all4(r.ctx, "charge").filter((ch) => (!customer3 || ch.customer === customer3) && (!intent || ch.payment_intent === intent)), r.params), r.params, "/v1/charges", "charge");
|
|
112891
112953
|
}),
|
|
112892
112954
|
read("/v1/charges/:id", [], (r) => find4(r.ctx, "charge", r.id)),
|
|
112893
112955
|
write("POST", "/v1/refunds", ["charge", "payment_intent", "amount", "reason", "metadata"], (r) => {
|
|
@@ -112905,7 +112967,7 @@ var stripeRoutes = [
|
|
|
112905
112967
|
}, "card refunds settle at once (status succeeded)"),
|
|
112906
112968
|
read("/v1/refunds", ["charge", "payment_intent", "created", ...PAGE], (r) => {
|
|
112907
112969
|
const chargeId = str(r.params.charge, "charge"), intent = str(r.params.payment_intent, "payment_intent");
|
|
112908
|
-
return page4(filterCreated(
|
|
112970
|
+
return page4(filterCreated(all4(r.ctx, "refund").filter((re) => (!chargeId || re.charge === chargeId) && (!intent || re.payment_intent === intent)), r.params), r.params, "/v1/refunds", "refund");
|
|
112909
112971
|
}),
|
|
112910
112972
|
read("/v1/refunds/:id", [], (r) => find4(r.ctx, "refund", r.id)),
|
|
112911
112973
|
read("/v1/balance", [], (r) => load(r.ctx, "__balance"), "available and pending card funds; payouts and fees are not modeled")
|
|
@@ -113073,7 +113135,7 @@ function seed19(ctx) {
|
|
|
113073
113135
|
save6(ctx, row);
|
|
113074
113136
|
}
|
|
113075
113137
|
}
|
|
113076
|
-
if (sub2) save6(ctx, { ...load(ctx, sub2.id), latest_invoice:
|
|
113138
|
+
if (sub2) save6(ctx, { ...load(ctx, sub2.id), latest_invoice: all4(ctx, "invoice").find((i) => i.parent?.subscription_details?.subscription === sub2.id)?.id ?? null });
|
|
113077
113139
|
}
|
|
113078
113140
|
for (const p2 of data5.payments) {
|
|
113079
113141
|
const cus = p2.customer ? load(ctx, customers.get(p2.customer).id) : null, t = at2(p2.created);
|
|
@@ -113097,7 +113159,7 @@ function credentials18(ctx) {
|
|
|
113097
113159
|
|
|
113098
113160
|
// packages/server/src/twins/stripe/state.ts
|
|
113099
113161
|
function dumpState18(ctx) {
|
|
113100
|
-
const of = (type) => present(
|
|
113162
|
+
const of = (type) => present(all4(ctx, type).reverse());
|
|
113101
113163
|
return {
|
|
113102
113164
|
balance: present(load(ctx, "__balance")),
|
|
113103
113165
|
customers: of("customer"),
|
|
@@ -113729,8 +113791,8 @@ var flagUser = (column, value4) => (call2) => {
|
|
|
113729
113791
|
function userMemberships(call2) {
|
|
113730
113792
|
const query10 = params5(call2, ["limit", "offset"]);
|
|
113731
113793
|
const user8 = userFor2(call2);
|
|
113732
|
-
const
|
|
113733
|
-
return respond3(call2, 200, { data: list9(
|
|
113794
|
+
const all8 = call2.ctx.store.db.prepare("SELECT * FROM clerk_memberships WHERE user_id = ? ORDER BY created_ms, id").all(user8.id);
|
|
113795
|
+
return respond3(call2, 200, { data: list9(all8, query10).map((member4) => membershipJson(call2.ctx, member4)), total_count: all8.length });
|
|
113734
113796
|
}
|
|
113735
113797
|
function orgFor(call2) {
|
|
113736
113798
|
const org5 = getOrg(call2.ctx, call2.ids[0]);
|
|
@@ -116116,7 +116178,7 @@ function migrate22(db2) {
|
|
|
116116
116178
|
db2.exec(SCHEMA13);
|
|
116117
116179
|
}
|
|
116118
116180
|
var one2 = (ctx, sql, ...args) => ctx.store.db.prepare(sql).get(...args);
|
|
116119
|
-
var
|
|
116181
|
+
var all5 = (ctx, sql, ...args) => ctx.store.db.prepare(sql).all(...args);
|
|
116120
116182
|
var run2 = (ctx, sql, ...args) => ctx.store.db.prepare(sql).run(...args);
|
|
116121
116183
|
function uuid9(ctx) {
|
|
116122
116184
|
const h = ctx.ids.hex(32).split("");
|
|
@@ -116342,7 +116404,7 @@ function primary(ctx, attr, data5) {
|
|
|
116342
116404
|
}
|
|
116343
116405
|
}
|
|
116344
116406
|
function currentValues(ctx, parentId, attributeId) {
|
|
116345
|
-
return
|
|
116407
|
+
return all5(ctx, "SELECT * FROM attio_values WHERE parent_id = ? AND attribute_id = ? AND active_until IS NULL ORDER BY id", parentId, attributeId);
|
|
116346
116408
|
}
|
|
116347
116409
|
function writeValues(ctx, parentId, attr, items, by2, replace, now10 = attioTime(ctx.clock.nowMs())) {
|
|
116348
116410
|
const current = currentValues(ctx, parentId, attr.id);
|
|
@@ -116418,7 +116480,7 @@ function findObject(ctx, key3) {
|
|
|
116418
116480
|
function findList(ctx, key3) {
|
|
116419
116481
|
return one2(ctx, "SELECT * FROM attio_lists WHERE api_slug = ? OR id = ?", key3, key3) ?? notFound9(`List with slug/ID "${key3}" not found.`);
|
|
116420
116482
|
}
|
|
116421
|
-
var attributesOf = (ctx, parentId) =>
|
|
116483
|
+
var attributesOf = (ctx, parentId) => all5(ctx, "SELECT * FROM attio_attributes WHERE parent_id = ? ORDER BY position", parentId);
|
|
116422
116484
|
var listParent = (list14) => `list:${list14.id}`;
|
|
116423
116485
|
function objectShape(ctx, o) {
|
|
116424
116486
|
return { id: { workspace_id: workspaceId(ctx), object_id: o.id }, api_slug: o.api_slug, singular_noun: o.singular_noun, plural_noun: o.plural_noun, created_at: o.created_at };
|
|
@@ -116448,7 +116510,7 @@ function memberShape(ctx, m) {
|
|
|
116448
116510
|
return { id: { workspace_id: workspaceId(ctx), workspace_member_id: m.id }, first_name: m.first_name, last_name: m.last_name, avatar_url: null, email_address: m.email, created_at: m.created_at, access_level: m.access_level };
|
|
116449
116511
|
}
|
|
116450
116512
|
function valuesOf(ctx, parentId, attributes2, computed) {
|
|
116451
|
-
const rows7 =
|
|
116513
|
+
const rows7 = all5(ctx, "SELECT * FROM attio_values WHERE parent_id = ? AND active_until IS NULL ORDER BY id", parentId);
|
|
116452
116514
|
return Object.fromEntries(attributes2.map((a) => [a.api_slug, computed(a) ?? rows7.filter((r) => r.attribute_id === a.id).map((r) => valueObject(ctx, a, r))]));
|
|
116453
116515
|
}
|
|
116454
116516
|
function recordShape(ctx, r) {
|
|
@@ -116466,7 +116528,7 @@ function recordShape(ctx, r) {
|
|
|
116466
116528
|
if (o.api_slug === "companies" && a.api_slug === "team") {
|
|
116467
116529
|
const people3 = one2(ctx, "SELECT * FROM attio_objects WHERE api_slug = 'people'");
|
|
116468
116530
|
const company = one2(ctx, "SELECT * FROM attio_attributes WHERE parent_id = ? AND api_slug = 'company'", people3.id);
|
|
116469
|
-
return
|
|
116531
|
+
return all5(ctx, "SELECT * FROM attio_values WHERE attribute_id = ? AND active_until IS NULL AND json_extract(data, '$.target_record_id') = ? ORDER BY id", company.id, r.id).map((v) => ({ active_from: v.active_from, active_until: null, created_by_actor: JSON.parse(v.created_by), target_object: "people", target_record_id: v.parent_id, attribute_type: "record-reference" }));
|
|
116470
116532
|
}
|
|
116471
116533
|
return void 0;
|
|
116472
116534
|
})
|
|
@@ -116534,7 +116596,7 @@ function writeAll(r, parentId, attributes2, values2, mode, objectSlug) {
|
|
|
116534
116596
|
const items = list14.map((v) => parseValue(r.ctx, attr, v));
|
|
116535
116597
|
if (attr.is_unique) for (const item2 of items) {
|
|
116536
116598
|
const key4 = primary(r.ctx, attr, item2);
|
|
116537
|
-
const clash =
|
|
116599
|
+
const clash = all5(r.ctx, "SELECT * FROM attio_values WHERE attribute_id = ? AND active_until IS NULL AND parent_id != ?", attr.id, parentId).find((v) => primary(r.ctx, attr, JSON.parse(v.data)) === key4);
|
|
116538
116600
|
if (clash) invalid15(`A record with the value "${String(key4)}" for the unique attribute "${attr.api_slug}" already exists.`, "uniqueness_conflict");
|
|
116539
116601
|
}
|
|
116540
116602
|
writeValues(r.ctx, parentId, attr, items, tokenActor(r), mode !== "append" || !attr.is_multiselect);
|
|
@@ -116586,7 +116648,7 @@ function query7(r, rows7, attributes2) {
|
|
|
116586
116648
|
const { limit, offset: offset16 } = limitOffset(r.body);
|
|
116587
116649
|
return kept.slice(offset16, offset16 + limit);
|
|
116588
116650
|
}
|
|
116589
|
-
var records = (r, object13) =>
|
|
116651
|
+
var records = (r, object13) => all5(r.ctx, "SELECT * FROM attio_records WHERE object_id = ? ORDER BY created_at, rowid", object13.id);
|
|
116590
116652
|
function memberRef(r, value4) {
|
|
116591
116653
|
const key3 = value4?.referenced_actor_id ?? value4?.workspace_member_email_address;
|
|
116592
116654
|
const m = typeof key3 === "string" ? one2(r.ctx, "SELECT * FROM attio_members WHERE id = ? OR lower(email) = lower(?)", key3, key3) : void 0;
|
|
@@ -116628,7 +116690,7 @@ var attioRoutes = [
|
|
|
116628
116690
|
workspace_logo_url: null
|
|
116629
116691
|
};
|
|
116630
116692
|
} },
|
|
116631
|
-
{ method: "GET", path: "/v2/objects", coverage: { status: "supported" }, run: (r) => ({ data:
|
|
116693
|
+
{ method: "GET", path: "/v2/objects", coverage: { status: "supported" }, run: (r) => ({ data: all5(r.ctx, "SELECT * FROM attio_objects ORDER BY rowid").map((o) => objectShape(r.ctx, o)) }) },
|
|
116632
116694
|
{ method: "GET", path: "/v2/objects/:object", coverage: { status: "supported" }, run: (r) => ({ data: objectShape(r.ctx, findObject(r.ctx, r.param("object"))) }) },
|
|
116633
116695
|
{ method: "GET", path: "/v2/:target/:identifier/attributes", query: { known: ["limit", "offset", "show_archived"], supported: ["limit", "offset", "show_archived"] }, coverage: { status: "supported" }, run: (r) => {
|
|
116634
116696
|
const target4 = r.param("target");
|
|
@@ -116669,7 +116731,7 @@ var attioRoutes = [
|
|
|
116669
116731
|
const given = (r.data.values ?? {})[attr.api_slug] ?? (r.data.values ?? {})[attr.id];
|
|
116670
116732
|
if (given === void 0) invalid15(`The values must include the matching attribute "${attr.api_slug}".`, "missing_value");
|
|
116671
116733
|
const wanted = (Array.isArray(given) ? given : [given]).map((v) => primary(r.ctx, attr, parseValue(r.ctx, attr, v)));
|
|
116672
|
-
const owners = new Set(
|
|
116734
|
+
const owners = new Set(all5(r.ctx, "SELECT * FROM attio_values WHERE attribute_id = ? AND active_until IS NULL", attr.id).filter((v) => wanted.includes(primary(r.ctx, attr, JSON.parse(v.data)))).map((v) => v.parent_id));
|
|
116673
116735
|
if (owners.size > 1) invalid15("More than one record matches the given value.", "multiple_match_results");
|
|
116674
116736
|
if (!owners.size) return { data: recordShape(r.ctx, createRecord3(r, object13, r.data.values)) };
|
|
116675
116737
|
const id12 = [...owners][0];
|
|
@@ -116702,7 +116764,7 @@ var attioRoutes = [
|
|
|
116702
116764
|
},
|
|
116703
116765
|
{ method: "DELETE", path: RECORD_PATH, coverage: { status: "supported" }, run: (r) => {
|
|
116704
116766
|
const rec = findRecord(r, findObject(r.ctx, r.param("object")));
|
|
116705
|
-
for (const e of
|
|
116767
|
+
for (const e of all5(r.ctx, "SELECT * FROM attio_entries WHERE record_id = ?", rec.id)) {
|
|
116706
116768
|
run2(r.ctx, "DELETE FROM attio_values WHERE parent_id = ?", e.id);
|
|
116707
116769
|
run2(r.ctx, "DELETE FROM attio_entries WHERE id = ?", e.id);
|
|
116708
116770
|
}
|
|
@@ -116719,7 +116781,7 @@ var attioRoutes = [
|
|
|
116719
116781
|
const object13 = findObject(r.ctx, r.param("object")), rec = findRecord(r, object13);
|
|
116720
116782
|
const attr = attributesOf(r.ctx, object13.id).find((a) => a.api_slug === r.param("attribute") || a.id === r.param("attribute")) ?? notFound9(`Attribute with slug/ID "${r.param("attribute")}" not found.`);
|
|
116721
116783
|
const historic = r.query.get("show_historic") === "true";
|
|
116722
|
-
const rows7 =
|
|
116784
|
+
const rows7 = all5(r.ctx, `SELECT * FROM attio_values WHERE parent_id = ? AND attribute_id = ? ${historic ? "" : "AND active_until IS NULL"} ORDER BY id`, rec.id, attr.id);
|
|
116723
116785
|
const { limit, offset: offset16 } = limitOffset({ limit: r.query.get("limit") ?? void 0, offset: r.query.get("offset") ?? void 0 });
|
|
116724
116786
|
return { data: rows7.slice(offset16, offset16 + limit).map((v) => valueObject(r.ctx, attr, v)) };
|
|
116725
116787
|
}
|
|
@@ -116731,11 +116793,11 @@ var attioRoutes = [
|
|
|
116731
116793
|
coverage: { status: "supported" },
|
|
116732
116794
|
run: (r) => {
|
|
116733
116795
|
const rec = findRecord(r, findObject(r.ctx, r.param("object")));
|
|
116734
|
-
return { data:
|
|
116796
|
+
return { data: all5(r.ctx, "SELECT e.*, l.api_slug FROM attio_entries e JOIN attio_lists l ON l.id = e.list_id WHERE e.record_id = ? ORDER BY e.created_at", rec.id).map((e) => ({ list_id: e.list_id, list_api_slug: e.api_slug, entry_id: e.id, created_at: e.created_at })) };
|
|
116735
116797
|
}
|
|
116736
116798
|
},
|
|
116737
116799
|
/* ------------------------------------ lists ------------------------------------ */
|
|
116738
|
-
{ method: "GET", path: "/v2/lists", coverage: { status: "supported" }, run: (r) => ({ data:
|
|
116800
|
+
{ method: "GET", path: "/v2/lists", coverage: { status: "supported" }, run: (r) => ({ data: all5(r.ctx, "SELECT * FROM attio_lists ORDER BY rowid").map((l) => listShape(r.ctx, l)) }) },
|
|
116739
116801
|
{ method: "GET", path: "/v2/lists/:list", coverage: { status: "supported" }, run: (r) => ({ data: listShape(r.ctx, findList(r.ctx, r.param("list"))) }) },
|
|
116740
116802
|
{
|
|
116741
116803
|
method: "POST",
|
|
@@ -116743,7 +116805,7 @@ var attioRoutes = [
|
|
|
116743
116805
|
coverage: { status: "partial", notes: "filters and sorts on the list's own attributes" },
|
|
116744
116806
|
run: (r) => {
|
|
116745
116807
|
const list14 = findList(r.ctx, r.param("list"));
|
|
116746
|
-
return { data: query7(r,
|
|
116808
|
+
return { data: query7(r, all5(r.ctx, "SELECT * FROM attio_entries WHERE list_id = ? ORDER BY created_at, rowid", list14.id), attributesOf(r.ctx, listParent(list14))).map((e) => entryShape(r.ctx, e)) };
|
|
116747
116809
|
}
|
|
116748
116810
|
},
|
|
116749
116811
|
{
|
|
@@ -116782,7 +116844,7 @@ var attioRoutes = [
|
|
|
116782
116844
|
return {};
|
|
116783
116845
|
} },
|
|
116784
116846
|
/* ------------------------------- members, notes, tasks ----------------------------- */
|
|
116785
|
-
{ method: "GET", path: "/v2/workspace_members", coverage: { status: "supported" }, run: (r) => ({ data:
|
|
116847
|
+
{ method: "GET", path: "/v2/workspace_members", coverage: { status: "supported" }, run: (r) => ({ data: all5(r.ctx, "SELECT * FROM attio_members ORDER BY rowid").map((m) => memberShape(r.ctx, m)) }) },
|
|
116786
116848
|
{
|
|
116787
116849
|
method: "GET",
|
|
116788
116850
|
path: "/v2/workspace_members/:id",
|
|
@@ -116797,7 +116859,7 @@ var attioRoutes = [
|
|
|
116797
116859
|
run: (r) => {
|
|
116798
116860
|
const object13 = r.query.get("parent_object"), record8 = r.query.get("parent_record_id");
|
|
116799
116861
|
const objectSlug = object13 ? findObject(r.ctx, object13).api_slug : void 0;
|
|
116800
|
-
const notes6 =
|
|
116862
|
+
const notes6 = all5(r.ctx, "SELECT * FROM attio_notes ORDER BY created_at, rowid").filter((n) => (!objectSlug || n.parent_object === objectSlug) && (!record8 || n.parent_record_id === record8));
|
|
116801
116863
|
const { limit, offset: offset16 } = limitOffset({ limit: r.query.get("limit") ?? void 0, offset: r.query.get("offset") ?? void 0 }, 10);
|
|
116802
116864
|
return { data: notes6.slice(offset16, offset16 + limit).map((n) => noteShape2(r.ctx, n)) };
|
|
116803
116865
|
}
|
|
@@ -116849,7 +116911,7 @@ var attioRoutes = [
|
|
|
116849
116911
|
const linkedObject = q.get("linked_object") ? findObject(r.ctx, q.get("linked_object")).id : void 0;
|
|
116850
116912
|
const assignee = q.get("assignee") ? one2(r.ctx, "SELECT * FROM attio_members WHERE id = ? OR lower(email) = lower(?)", q.get("assignee"), q.get("assignee"))?.id ?? "__none__" : void 0;
|
|
116851
116913
|
const done = q.get("is_completed");
|
|
116852
|
-
let tasks =
|
|
116914
|
+
let tasks = all5(r.ctx, "SELECT * FROM attio_tasks ORDER BY created_at, rowid").filter((t) => {
|
|
116853
116915
|
const linked = JSON.parse(t.linked);
|
|
116854
116916
|
return (!linkedObject || linked.some((l) => l.target_object_id === linkedObject)) && (!q.get("linked_record_id") || linked.some((l) => l.target_record_id === q.get("linked_record_id"))) && (!assignee || JSON.parse(t.assignees).some((a) => a.referenced_actor_id === assignee)) && (done === null || String(!!t.is_completed) === done);
|
|
116855
116917
|
});
|
|
@@ -117025,7 +117087,7 @@ function seed23(ctx) {
|
|
|
117025
117087
|
run2(ctx, "INSERT INTO attio_records (id, object_id, created_at, created_by) VALUES (?, ?, ?, ?)", id12, objectIds.get(slug10), at2(r.created), JSON.stringify(actor(members4.get(data5.agent))));
|
|
117026
117088
|
}
|
|
117027
117089
|
const write4 = (parentId, parent2, values2, when11, by2) => {
|
|
117028
|
-
const attributes2 =
|
|
117090
|
+
const attributes2 = all5(ctx, "SELECT * FROM attio_attributes WHERE parent_id = ? ORDER BY position", parent2);
|
|
117029
117091
|
for (const [slug10, raw3] of Object.entries(values2)) {
|
|
117030
117092
|
const attr = attributes2.find((a) => a.api_slug === slug10);
|
|
117031
117093
|
if (!attr) throw new AnchaError("SCENE_INVALID", `seed.attio: no attribute "${slug10}"`);
|
|
@@ -117083,9 +117145,9 @@ function credentials22(ctx) {
|
|
|
117083
117145
|
function dumpState22(ctx) {
|
|
117084
117146
|
const flat2 = (parentId, attributes2) => Object.fromEntries(attributes2.map((a) => [
|
|
117085
117147
|
a.api_slug,
|
|
117086
|
-
|
|
117148
|
+
all5(ctx, "SELECT * FROM attio_values WHERE parent_id = ? AND attribute_id = ? AND active_until IS NULL ORDER BY id", parentId, a.id).map((v) => primary(ctx, a, JSON.parse(v.data)))
|
|
117087
117149
|
]).filter(([, v]) => v.length));
|
|
117088
|
-
const objects =
|
|
117150
|
+
const objects = all5(ctx, "SELECT * FROM attio_objects ORDER BY rowid");
|
|
117089
117151
|
const name5 = (recordId) => {
|
|
117090
117152
|
const r = one2(ctx, "SELECT * FROM attio_records WHERE id = ?", recordId);
|
|
117091
117153
|
if (!r) return recordId;
|
|
@@ -117097,18 +117159,18 @@ function dumpState22(ctx) {
|
|
|
117097
117159
|
return m ? `${m.first_name} ${m.last_name}`.trim() : id12;
|
|
117098
117160
|
};
|
|
117099
117161
|
return {
|
|
117100
|
-
members:
|
|
117162
|
+
members: all5(ctx, "SELECT id, first_name, last_name, email, access_level FROM attio_members ORDER BY rowid"),
|
|
117101
117163
|
objects: objects.map((o) => ({ id: o.id, api_slug: o.api_slug, attributes: attributesOf(ctx, o.id).map((a) => ({ api_slug: a.api_slug, type: a.type })) })),
|
|
117102
|
-
records:
|
|
117103
|
-
lists:
|
|
117164
|
+
records: all5(ctx, "SELECT * FROM attio_records ORDER BY created_at, rowid").map((r) => ({ id: r.id, object: objects.find((o) => o.id === r.object_id).api_slug, created_at: r.created_at, values: flat2(r.id, attributesOf(ctx, r.object_id)) })),
|
|
117165
|
+
lists: all5(ctx, "SELECT * FROM attio_lists ORDER BY rowid").map((l) => ({
|
|
117104
117166
|
id: l.id,
|
|
117105
117167
|
api_slug: l.api_slug,
|
|
117106
117168
|
name: l.name,
|
|
117107
117169
|
parent_object: l.parent_object,
|
|
117108
|
-
entries:
|
|
117170
|
+
entries: all5(ctx, "SELECT * FROM attio_entries WHERE list_id = ? ORDER BY created_at, rowid", l.id).map((e) => ({ id: e.id, record_id: e.record_id, record: name5(e.record_id), values: flat2(e.id, attributesOf(ctx, listParent(l))) }))
|
|
117109
117171
|
})),
|
|
117110
|
-
notes:
|
|
117111
|
-
tasks:
|
|
117172
|
+
notes: all5(ctx, "SELECT * FROM attio_notes ORDER BY created_at, rowid").map((n) => ({ ...noteShape2(ctx, n), parent_label: name5(n.parent_record_id), author: member4(JSON.parse(n.created_by).id) })),
|
|
117173
|
+
tasks: all5(ctx, "SELECT * FROM attio_tasks ORDER BY created_at, rowid").map((t) => taskShape(ctx, t))
|
|
117112
117174
|
};
|
|
117113
117175
|
}
|
|
117114
117176
|
|
|
@@ -117391,7 +117453,7 @@ function listing(ctx, cursor4) {
|
|
|
117391
117453
|
}
|
|
117392
117454
|
function page6(ctx, cursor4) {
|
|
117393
117455
|
if (cursor4.o >= 0) {
|
|
117394
|
-
const
|
|
117456
|
+
const all8 = listing(ctx, cursor4), slice = all8.slice(cursor4.o, cursor4.o + cursor4.l), more = cursor4.o + cursor4.l < all8.length;
|
|
117395
117457
|
return json15({ entries: slice, cursor: encodeCursor3(more ? { ...cursor4, o: cursor4.o + cursor4.l } : { ...cursor4, o: -1 }), has_more: more });
|
|
117396
117458
|
}
|
|
117397
117459
|
const changed = ctx.store.db.prepare("SELECT path_lower, MAX(seq) AS seq FROM dbx_changes WHERE seq > ? GROUP BY path_lower ORDER BY MAX(seq)").all(cursor4.s).map((row) => row.path_lower).filter((key3) => cursor4.p === "" ? cursor4.r || !key3.slice(1).includes("/") : key3.startsWith(`${cursor4.p}/`) && (cursor4.r || !key3.slice(cursor4.p.length + 1).includes("/")));
|
|
@@ -119428,15 +119490,15 @@ function search6(call2, query10) {
|
|
|
119428
119490
|
odata(call2, ["$top", "$skiptoken", "$orderby"]);
|
|
119429
119491
|
const tokens2 = query10.toLowerCase().split(/\s+/).filter(Boolean);
|
|
119430
119492
|
if (!tokens2.length) throw invalid17("The search query is empty.");
|
|
119431
|
-
const scope2 = target3(call2),
|
|
119493
|
+
const scope2 = target3(call2), all8 = [];
|
|
119432
119494
|
const visit3 = (node5) => {
|
|
119433
119495
|
for (const child2 of childrenOf2(call2.ctx, node5.id)) {
|
|
119434
|
-
|
|
119496
|
+
all8.push(child2);
|
|
119435
119497
|
if (child2.kind === "folder") visit3(child2);
|
|
119436
119498
|
}
|
|
119437
119499
|
};
|
|
119438
119500
|
visit3(scope2);
|
|
119439
|
-
const matches7 =
|
|
119501
|
+
const matches7 = all8.filter((item2) => {
|
|
119440
119502
|
const text21 = `${item2.name}
|
|
119441
119503
|
${textOf2(item2) ?? ""}`.toLowerCase();
|
|
119442
119504
|
return tokens2.every((token2) => text21.includes(token2));
|
|
@@ -119697,7 +119759,7 @@ function save8(ctx, kind, doc, parent2 = null) {
|
|
|
119697
119759
|
ctx.store.db.prepare("INSERT INTO shopify_objects (gid, kind, num, parent, json) VALUES (?, ?, ?, ?, ?) ON CONFLICT (gid) DO UPDATE SET json = excluded.json").run(doc.gid, kind, numOf(doc.gid) ?? 0, parent2, JSON.stringify(doc));
|
|
119698
119760
|
return doc;
|
|
119699
119761
|
}
|
|
119700
|
-
function
|
|
119762
|
+
function all6(ctx, kind) {
|
|
119701
119763
|
return ctx.store.db.prepare("SELECT json FROM shopify_objects WHERE kind = ? ORDER BY num").all(kind).map((r) => JSON.parse(r.json));
|
|
119702
119764
|
}
|
|
119703
119765
|
function childrenOf3(ctx, parent2, kind) {
|
|
@@ -119771,7 +119833,7 @@ function level2(ctx, item2, location) {
|
|
|
119771
119833
|
}
|
|
119772
119834
|
function committed(ctx, item2, location) {
|
|
119773
119835
|
let n = 0;
|
|
119774
|
-
for (const fo of
|
|
119836
|
+
for (const fo of all6(ctx, "FulfillmentOrder")) {
|
|
119775
119837
|
if (fo.location !== location) continue;
|
|
119776
119838
|
const order4 = load3(ctx, fo.order);
|
|
119777
119839
|
if (order4.cancelled_ms !== null) continue;
|
|
@@ -120045,7 +120107,7 @@ function connection2(items, args, key3, shape3) {
|
|
|
120045
120107
|
var byNum = (d) => ({ id: numOf(d.gid) });
|
|
120046
120108
|
var pathOf2 = (path4) => path4 ? [...pathOf2(path4.prev), path4.key] : [];
|
|
120047
120109
|
var firstOf = (items, n) => typeof n === "number" ? items.slice(0, Math.max(0, n)) : items;
|
|
120048
|
-
var currencyOf = (ctx) =>
|
|
120110
|
+
var currencyOf = (ctx) => all6(ctx, "Shop")[0].currency;
|
|
120049
120111
|
var bag = (ctx, c) => {
|
|
120050
120112
|
const m = { amount: decimal2(c), currencyCode: currencyOf(ctx) };
|
|
120051
120113
|
return { shopMoney: m, presentmentMoney: m };
|
|
@@ -120145,7 +120207,7 @@ function distance(ms) {
|
|
|
120145
120207
|
return years === 1 ? "about 1 year" : `about ${years} years`;
|
|
120146
120208
|
}
|
|
120147
120209
|
function shopShape(req) {
|
|
120148
|
-
const s =
|
|
120210
|
+
const s = all6(req.ctx, "Shop")[0], host = `${s.domain}.myshopify.com`;
|
|
120149
120211
|
return {
|
|
120150
120212
|
__typename: "Shop",
|
|
120151
120213
|
id: s.gid,
|
|
@@ -120172,7 +120234,7 @@ function shopShape(req) {
|
|
|
120172
120234
|
};
|
|
120173
120235
|
}
|
|
120174
120236
|
function locationShape(req, l) {
|
|
120175
|
-
const primary3 =
|
|
120237
|
+
const primary3 = all6(req.ctx, "Location")[0].gid === l.gid, a = l.address, country = a.country_code ?? "US";
|
|
120176
120238
|
return {
|
|
120177
120239
|
__typename: "Location",
|
|
120178
120240
|
id: l.gid,
|
|
@@ -120252,7 +120314,7 @@ function itemShape(req, item2) {
|
|
|
120252
120314
|
};
|
|
120253
120315
|
}
|
|
120254
120316
|
function variantStock(req, v) {
|
|
120255
|
-
const levels3 = levelsOf(req.ctx, { item: v.item }), locations = new Map(
|
|
120317
|
+
const levels3 = levelsOf(req.ctx, { item: v.item }), locations = new Map(all6(req.ctx, "Location").map((l) => [l.gid, l]));
|
|
120256
120318
|
const active2 = levels3.filter((l) => locations.get(l.location)?.active);
|
|
120257
120319
|
return { available: active2.reduce((n, l) => n + l.available, 0), online: active2.filter((l) => locations.get(l.location).fulfills_online_orders).reduce((n, l) => n + Math.max(0, l.available), 0) };
|
|
120258
120320
|
}
|
|
@@ -120307,7 +120369,7 @@ function productShape(req, p2) {
|
|
|
120307
120369
|
const variants = () => childrenOf3(req.ctx, p2.gid, "ProductVariant");
|
|
120308
120370
|
const tracked2 = () => variants().filter((v) => load3(req.ctx, v.item).tracked);
|
|
120309
120371
|
const prices = () => variants().map((v) => v.price_cents);
|
|
120310
|
-
const host = `${
|
|
120372
|
+
const host = `${all6(req.ctx, "Shop")[0].domain}.myshopify.com`;
|
|
120311
120373
|
return {
|
|
120312
120374
|
__typename: "Product",
|
|
120313
120375
|
id: p2.gid,
|
|
@@ -120351,7 +120413,7 @@ function productShape(req, p2) {
|
|
|
120351
120413
|
};
|
|
120352
120414
|
}
|
|
120353
120415
|
function customerShape(req, c) {
|
|
120354
|
-
const orders = () =>
|
|
120416
|
+
const orders = () => all6(req.ctx, "Order").filter((o) => o.customer === c.gid);
|
|
120355
120417
|
const name5 = [c.first_name, c.last_name].filter(Boolean).join(" ");
|
|
120356
120418
|
return {
|
|
120357
120419
|
__typename: "Customer",
|
|
@@ -120389,7 +120451,7 @@ function orderShape(req, o) {
|
|
|
120389
120451
|
let cached2;
|
|
120390
120452
|
const facts = () => cached2 ??= orderFacts(req.ctx, o);
|
|
120391
120453
|
const sm = (pick4) => () => bag(req.ctx, pick4(facts()));
|
|
120392
|
-
const shop =
|
|
120454
|
+
const shop = all6(req.ctx, "Shop")[0];
|
|
120393
120455
|
const fos = () => childrenOf3(req.ctx, o.gid, "FulfillmentOrder");
|
|
120394
120456
|
return {
|
|
120395
120457
|
__typename: "Order",
|
|
@@ -120760,7 +120822,7 @@ function ordersConnection(req, orders, args, path4) {
|
|
|
120760
120822
|
function productsConnection(req, args, path4) {
|
|
120761
120823
|
const variants = (p2) => childrenOf3(req.ctx, p2.gid, "ProductVariant");
|
|
120762
120824
|
const inventory = (p2) => variants(p2).filter((v) => load3(req.ctx, v.item).tracked).reduce((n, v) => n + variantStock(req, v).available, 0);
|
|
120763
|
-
let found = filter3(req, "products",
|
|
120825
|
+
let found = filter3(req, "products", all6(req.ctx, "Product"), args, path4, {
|
|
120764
120826
|
default: { text: (p2) => [p2.title, p2.vendor, p2.product_type, p2.handle, ...p2.tags, ...variants(p2).map((v) => v.sku)] },
|
|
120765
120827
|
id: { number: num2 },
|
|
120766
120828
|
title: { text: (p2) => [p2.title], words: true },
|
|
@@ -120798,7 +120860,7 @@ function productsConnection(req, args, path4) {
|
|
|
120798
120860
|
}
|
|
120799
120861
|
function variantsConnection(req, args, path4) {
|
|
120800
120862
|
const product2 = (v) => load3(req.ctx, v.product);
|
|
120801
|
-
const found = filter3(req, "productVariants",
|
|
120863
|
+
const found = filter3(req, "productVariants", all6(req.ctx, "ProductVariant"), args, path4, {
|
|
120802
120864
|
default: { text: (v) => [product2(v).title, variantTitle(v), v.sku, v.barcode] },
|
|
120803
120865
|
id: { number: num2 },
|
|
120804
120866
|
sku: { text: (v) => [v.sku] },
|
|
@@ -120827,9 +120889,9 @@ function variantsConnection(req, args, path4) {
|
|
|
120827
120889
|
return connection2(items, args, (v) => ({ id: num2(v), value: key3(v) }), (v) => variantShape(req, v));
|
|
120828
120890
|
}
|
|
120829
120891
|
function customersConnection(req, args, path4) {
|
|
120830
|
-
const orders = (c) =>
|
|
120892
|
+
const orders = (c) => all6(req.ctx, "Order").filter((o) => o.customer === c.gid);
|
|
120831
120893
|
const fullName = (c) => [c.first_name, c.last_name].filter(Boolean).join(" ");
|
|
120832
|
-
const found = filter3(req, "customers",
|
|
120894
|
+
const found = filter3(req, "customers", all6(req.ctx, "Customer"), args, path4, {
|
|
120833
120895
|
default: { text: (c) => [fullName(c), c.email, c.phone, c.address?.company ?? null, ...c.tags] },
|
|
120834
120896
|
id: { number: num2 },
|
|
120835
120897
|
email: { text: (c) => [c.email] },
|
|
@@ -120856,7 +120918,7 @@ function customersConnection(req, args, path4) {
|
|
|
120856
120918
|
return connection2(items, args, (c) => ({ id: num2(c), value: key3(c) }), (c) => customerShape(req, c));
|
|
120857
120919
|
}
|
|
120858
120920
|
function locationsConnection(req, args, path4) {
|
|
120859
|
-
const found = filter3(req, "locations",
|
|
120921
|
+
const found = filter3(req, "locations", all6(req.ctx, "Location").filter((l) => args.includeInactive || l.active), args, path4, {
|
|
120860
120922
|
default: { text: (l) => [l.name, l.address.city, l.address.address1, l.address.zip] },
|
|
120861
120923
|
id: { number: num2 },
|
|
120862
120924
|
location_id: { number: num2 },
|
|
@@ -120906,7 +120968,7 @@ function queryRoot(req) {
|
|
|
120906
120968
|
};
|
|
120907
120969
|
return {
|
|
120908
120970
|
shop: () => shopShape(req),
|
|
120909
|
-
orders: (args, _r, info) => ordersConnection(req,
|
|
120971
|
+
orders: (args, _r, info) => ordersConnection(req, all6(ctx, "Order"), args, pathOf2(info.path)),
|
|
120910
120972
|
order: one7("Order", orderShape),
|
|
120911
120973
|
products: (args, _r, info) => productsConnection(req, args, pathOf2(info.path)),
|
|
120912
120974
|
product: one7("Product", productShape),
|
|
@@ -120917,7 +120979,7 @@ function queryRoot(req) {
|
|
|
120917
120979
|
locations: (args, _r, info) => locationsConnection(req, args, pathOf2(info.path)),
|
|
120918
120980
|
// Without an id, Shopify returns the primary location.
|
|
120919
120981
|
location: ({ id: id12 }) => {
|
|
120920
|
-
const d = id12 === void 0 || id12 === null ?
|
|
120982
|
+
const d = id12 === void 0 || id12 === null ? all6(ctx, "Location")[0] : loadKind(ctx, "Location", checkId(id12));
|
|
120921
120983
|
return d ? locationShape(req, d) : null;
|
|
120922
120984
|
},
|
|
120923
120985
|
inventoryItem: one7("InventoryItem", itemShape),
|
|
@@ -121108,7 +121170,7 @@ function mutationRoot(req) {
|
|
|
121108
121170
|
}
|
|
121109
121171
|
if (data5.handle !== void 0 && data5.handle !== null) {
|
|
121110
121172
|
const handle30 = slug6(data5.handle);
|
|
121111
|
-
if (
|
|
121173
|
+
if (all6(ctx, "Product").some((x) => x.gid !== p2.gid && x.handle === handle30)) errors2.push({ field: ["handle"], message: `Handle '${handle30}' already in use. Please provide a new handle.` });
|
|
121112
121174
|
else next2.handle = handle30;
|
|
121113
121175
|
}
|
|
121114
121176
|
if (errors2.length) return { product: null, userErrors: errors2 };
|
|
@@ -121165,7 +121227,7 @@ function refundCreate(req, input2) {
|
|
|
121165
121227
|
const found = orderOrError(req, input2.orderId, ["orderId"]);
|
|
121166
121228
|
if ("errors" in found) return fail6(found.errors);
|
|
121167
121229
|
const o = found.order, facts = orderFacts(ctx, o);
|
|
121168
|
-
if (input2.currency && input2.currency !==
|
|
121230
|
+
if (input2.currency && input2.currency !== all6(ctx, "Shop")[0].currency) gap4("refunds in a presentment currency");
|
|
121169
121231
|
const errors2 = [];
|
|
121170
121232
|
const items = [];
|
|
121171
121233
|
(input2.refundLineItems ?? []).forEach((i, n) => {
|
|
@@ -121371,7 +121433,7 @@ function customerWrite(req, input2, create2) {
|
|
|
121371
121433
|
updated_ms: at2
|
|
121372
121434
|
};
|
|
121373
121435
|
const errors2 = [];
|
|
121374
|
-
const others =
|
|
121436
|
+
const others = all6(ctx, "Customer").filter((x) => x.gid !== c.gid);
|
|
121375
121437
|
if (input2.email !== void 0) {
|
|
121376
121438
|
if (input2.email !== null && !EMAIL17.test(input2.email)) errors2.push({ field: ["email"], message: "Email is invalid" });
|
|
121377
121439
|
else if (input2.email !== null && others.some((x) => x.email?.toLowerCase() === input2.email.toLowerCase())) errors2.push({ field: ["email"], message: "Email has already been taken" });
|
|
@@ -121783,13 +121845,13 @@ function credentials26(ctx) {
|
|
|
121783
121845
|
var when8 = (ms) => ms === null ? null : iso8(ms);
|
|
121784
121846
|
var oneLine = (a) => a ? [a.company, a.address1, a.address2, a.city, [a.province_code, a.zip].filter(Boolean).join(" "), a.country_code].filter(Boolean).join(", ") : null;
|
|
121785
121847
|
function dumpState26(ctx) {
|
|
121786
|
-
const shop =
|
|
121848
|
+
const shop = all6(ctx, "Shop")[0], locations = all6(ctx, "Location");
|
|
121787
121849
|
const locationName = (id12) => id12 ? locations.find((l) => l.gid === id12)?.name ?? null : null;
|
|
121788
121850
|
const sku = (lineId) => load3(ctx, lineId)?.sku ?? null;
|
|
121789
121851
|
return {
|
|
121790
121852
|
shop: { name: shop.name, domain: `${shop.domain}.myshopify.com`, email: shop.email, currency: shop.currency },
|
|
121791
121853
|
locations: locations.map((l) => ({ id: l.gid, name: l.name, city: l.address.city, active: l.active, fulfills_online_orders: l.fulfills_online_orders })),
|
|
121792
|
-
products:
|
|
121854
|
+
products: all6(ctx, "Product").map((p2) => ({
|
|
121793
121855
|
id: p2.gid,
|
|
121794
121856
|
title: p2.title,
|
|
121795
121857
|
handle: p2.handle,
|
|
@@ -121816,7 +121878,7 @@ function dumpState26(ctx) {
|
|
|
121816
121878
|
};
|
|
121817
121879
|
})
|
|
121818
121880
|
})),
|
|
121819
|
-
customers:
|
|
121881
|
+
customers: all6(ctx, "Customer").map((c) => ({
|
|
121820
121882
|
id: c.gid,
|
|
121821
121883
|
name: [c.first_name, c.last_name].filter(Boolean).join(" ") || null,
|
|
121822
121884
|
email: c.email,
|
|
@@ -121825,9 +121887,9 @@ function dumpState26(ctx) {
|
|
|
121825
121887
|
note: c.note,
|
|
121826
121888
|
state: c.state,
|
|
121827
121889
|
accepts_marketing: c.accepts_marketing,
|
|
121828
|
-
orders:
|
|
121890
|
+
orders: all6(ctx, "Order").filter((o) => o.customer === c.gid).length
|
|
121829
121891
|
})),
|
|
121830
|
-
orders:
|
|
121892
|
+
orders: all6(ctx, "Order").map((o) => {
|
|
121831
121893
|
const f = orderFacts(ctx, o), customer3 = o.customer ? load3(ctx, o.customer) : void 0;
|
|
121832
121894
|
return {
|
|
121833
121895
|
id: o.gid,
|
|
@@ -121883,7 +121945,7 @@ function dumpState26(ctx) {
|
|
|
121883
121945
|
transactions: f.transactions.map((t) => ({ id: t.gid, kind: t.kind, status: t.status, gateway: t.gateway, amount: decimal2(t.cents), created_at: iso8(t.created_ms), error_code: t.error_code }))
|
|
121884
121946
|
};
|
|
121885
121947
|
}),
|
|
121886
|
-
inventory_adjustments:
|
|
121948
|
+
inventory_adjustments: all6(ctx, "InventoryAdjustmentGroup").map((g) => ({
|
|
121887
121949
|
id: g.gid,
|
|
121888
121950
|
reason: g.reason,
|
|
121889
121951
|
reference: g.reference,
|
|
@@ -124058,14 +124120,14 @@ var billingRoutes = [
|
|
|
124058
124120
|
path: "/v1/catalogs/products",
|
|
124059
124121
|
coverage: { status: "supported" },
|
|
124060
124122
|
run: (r) => {
|
|
124061
|
-
const { size, n, total } = page8(r, 20),
|
|
124062
|
-
return { products:
|
|
124123
|
+
const { size, n, total } = page8(r, 20), all8 = allOf2(r.ctx, "product");
|
|
124124
|
+
return { products: all8.slice((n - 1) * size, n * size).map((p2) => ({
|
|
124063
124125
|
id: p2.id,
|
|
124064
124126
|
name: p2.name,
|
|
124065
124127
|
description: p2.description ?? void 0,
|
|
124066
124128
|
create_time: iso10(p2.create_ms),
|
|
124067
124129
|
links: [link4(`${r.base}/v1/catalogs/products/${p2.id}`, "self")]
|
|
124068
|
-
})), ...total && { total_items:
|
|
124130
|
+
})), ...total && { total_items: all8.length, total_pages: Math.ceil(all8.length / size) }, links: [] };
|
|
124069
124131
|
}
|
|
124070
124132
|
},
|
|
124071
124133
|
{
|
|
@@ -124092,10 +124154,10 @@ var billingRoutes = [
|
|
|
124092
124154
|
coverage: { status: "supported" },
|
|
124093
124155
|
run: (r) => {
|
|
124094
124156
|
const { size, n, total } = page8(r, 20), ids2 = r.query.get("plan_ids")?.split(",").filter(Boolean), product2 = r.query.get("product_id");
|
|
124095
|
-
const
|
|
124157
|
+
const all8 = allOf2(r.ctx, "plan").filter((p2) => (!product2 || p2.product_id === product2) && (!ids2 || ids2.includes(p2.id)));
|
|
124096
124158
|
return {
|
|
124097
|
-
plans:
|
|
124098
|
-
...total && { total_items:
|
|
124159
|
+
plans: all8.slice((n - 1) * size, n * size).map((p2) => planShape(r, p2, false)),
|
|
124160
|
+
...total && { total_items: all8.length, total_pages: Math.ceil(all8.length / size) },
|
|
124099
124161
|
links: [link4(`${r.base}/v1/billing/plans?page_size=${size}&page=${n}`, "self")]
|
|
124100
124162
|
};
|
|
124101
124163
|
}
|
|
@@ -124165,8 +124227,8 @@ var billingRoutes = [
|
|
|
124165
124227
|
run: (r) => {
|
|
124166
124228
|
const { size, n } = page8(r, 20), plans = r.query.get("plan_ids")?.split(",").filter(Boolean), statuses = r.query.get("statuses")?.split(",").filter(Boolean);
|
|
124167
124229
|
for (const key3 of ["created_after", "created_before", "status_updated_after", "status_updated_before", "filter", "customer_ids"]) if (r.query.get(key3)) unsupported23(`the ${key3} filter on subscriptions`);
|
|
124168
|
-
const
|
|
124169
|
-
return { subscriptions:
|
|
124230
|
+
const all8 = allOf2(r.ctx, "subscription").filter((s) => (!plans || plans.includes(s.plan_id)) && (!statuses || statuses.includes(s.status)));
|
|
124231
|
+
return { subscriptions: all8.slice((n - 1) * size, n * size).map((s) => subscriptionShape(r, s)), total_items: all8.length, total_pages: Math.ceil(all8.length / size), links: [] };
|
|
124170
124232
|
}
|
|
124171
124233
|
},
|
|
124172
124234
|
{ method: "GET", path: "/v1/billing/subscriptions/:id", coverage: { status: "supported" }, run: (r) => subscriptionShape(r, subscriptionOr404(r)) },
|
|
@@ -127920,7 +127982,7 @@ function load5(ctx, kind, id12) {
|
|
|
127920
127982
|
const row = ctx.store.db.prepare("SELECT json FROM intercom_objects WHERE kind = ? AND id = ?").get(kind, id12);
|
|
127921
127983
|
return row && JSON.parse(row.json);
|
|
127922
127984
|
}
|
|
127923
|
-
function
|
|
127985
|
+
function all7(ctx, kind) {
|
|
127924
127986
|
return ctx.store.db.prepare("SELECT json FROM intercom_objects WHERE kind = ? ORDER BY seq").all(kind).map((r) => JSON.parse(r.json));
|
|
127925
127987
|
}
|
|
127926
127988
|
function save10(ctx, kind, doc) {
|
|
@@ -128044,7 +128106,7 @@ function byPage(items, r, dflt, key3, body6) {
|
|
|
128044
128106
|
}
|
|
128045
128107
|
var numeric2 = (id12) => id12 === null ? null : Number(id12);
|
|
128046
128108
|
function adminShape(r, a) {
|
|
128047
|
-
const teams =
|
|
128109
|
+
const teams = all7(r.ctx, "team").filter((t) => t.admin_ids.includes(a.id)).map((t) => Number(t.id));
|
|
128048
128110
|
return {
|
|
128049
128111
|
type: "admin",
|
|
128050
128112
|
id: a.id,
|
|
@@ -128074,7 +128136,7 @@ var tagRef = (r, t) => {
|
|
|
128074
128136
|
};
|
|
128075
128137
|
function contactShape2(r, c) {
|
|
128076
128138
|
const list14 = (type, ids2, path4) => ({ type: "list", data: ids2.map((id12) => ({ type, id: id12, url: `/${type === "company" ? "companies" : `${type}s`}/${id12}` })), url: `/contacts/${c.id}/${path4}`, total_count: ids2.length, has_more: false });
|
|
128077
|
-
const notes6 =
|
|
128139
|
+
const notes6 = all7(r.ctx, "note").filter((n) => n.contact_id === c.id).map((n) => n.id);
|
|
128078
128140
|
return {
|
|
128079
128141
|
type: "contact",
|
|
128080
128142
|
id: c.id,
|
|
@@ -128133,7 +128195,7 @@ function contactShape2(r, c) {
|
|
|
128133
128195
|
};
|
|
128134
128196
|
}
|
|
128135
128197
|
function companyShape(r, co) {
|
|
128136
|
-
const users4 =
|
|
128198
|
+
const users4 = all7(r.ctx, "contact").filter((c) => c.companies.includes(co.id)).length;
|
|
128137
128199
|
return {
|
|
128138
128200
|
type: "company",
|
|
128139
128201
|
id: co.id,
|
|
@@ -128401,9 +128463,9 @@ function applyContact(r, c, b) {
|
|
|
128401
128463
|
}
|
|
128402
128464
|
}
|
|
128403
128465
|
function conflictOnEmail(r, c) {
|
|
128404
|
-
const dup = c.email &&
|
|
128466
|
+
const dup = c.email && all7(r.ctx, "contact").find((x) => x.id !== c.id && x.role === "user" && c.role === "user" && x.email?.toLowerCase() === c.email.toLowerCase());
|
|
128405
128467
|
if (dup) fail3(409, "conflict", `A contact matching those details already exists with id=${dup.id}`);
|
|
128406
|
-
const ext = c.external_id &&
|
|
128468
|
+
const ext = c.external_id && all7(r.ctx, "contact").find((x) => x.id !== c.id && x.external_id === c.external_id);
|
|
128407
128469
|
if (ext) fail3(409, "conflict", `A contact matching those details already exists with id=${ext.id}`);
|
|
128408
128470
|
}
|
|
128409
128471
|
function tagOn(r, doc, tagId, adminId) {
|
|
@@ -128425,7 +128487,7 @@ var intercomRoutes = [
|
|
|
128425
128487
|
return { ...adminShape(r, r.me), app: { type: "app", id_code: w.id, name: w.name, created_at: w.created_at, secure: false, identity_verification: false, timezone: "America/Los_Angeles", region: "US" } };
|
|
128426
128488
|
}
|
|
128427
128489
|
},
|
|
128428
|
-
{ method: "GET", path: "/admins", coverage: { status: "supported" }, run: (r) => ({ type: "admin.list", admins:
|
|
128490
|
+
{ method: "GET", path: "/admins", coverage: { status: "supported" }, run: (r) => ({ type: "admin.list", admins: all7(r.ctx, "admin").map((a) => adminShape(r, a)) }) },
|
|
128429
128491
|
{ method: "GET", path: "/admins/:id", coverage: { status: "supported" }, run: (r) => adminShape(r, load5(r.ctx, "admin", r.param("id")) ?? notFound15("Admin")) },
|
|
128430
128492
|
{
|
|
128431
128493
|
method: "PUT",
|
|
@@ -128437,7 +128499,7 @@ var intercomRoutes = [
|
|
|
128437
128499
|
return adminShape(r, save10(r.ctx, "admin", { ...a, away: r.body.away_mode_enabled, reassign: !!r.body.away_mode_reassign }));
|
|
128438
128500
|
}
|
|
128439
128501
|
},
|
|
128440
|
-
{ method: "GET", path: "/teams", coverage: { status: "supported" }, run: (r) => ({ type: "team.list", teams:
|
|
128502
|
+
{ method: "GET", path: "/teams", coverage: { status: "supported" }, run: (r) => ({ type: "team.list", teams: all7(r.ctx, "team").map((t) => ({ type: "team", id: t.id, name: t.name, admin_ids: t.admin_ids.map(Number), admin_priority_level: {} })) }) },
|
|
128441
128503
|
{
|
|
128442
128504
|
method: "GET",
|
|
128443
128505
|
path: "/teams/:id",
|
|
@@ -128448,7 +128510,7 @@ var intercomRoutes = [
|
|
|
128448
128510
|
}
|
|
128449
128511
|
},
|
|
128450
128512
|
{ method: "GET", path: "/contacts", coverage: { status: "supported" }, run: (r) => {
|
|
128451
|
-
const l = listOf("list", "data",
|
|
128513
|
+
const l = listOf("list", "data", all7(r.ctx, "contact").filter((c) => !c.archived), r);
|
|
128452
128514
|
return { ...l, data: l.data.map((c) => contactShape2(r, c)) };
|
|
128453
128515
|
} },
|
|
128454
128516
|
{
|
|
@@ -128457,7 +128519,7 @@ var intercomRoutes = [
|
|
|
128457
128519
|
coverage: { status: "partial", notes: "common contact fields, tags, companies and custom attributes; segments and device fields are gaps" },
|
|
128458
128520
|
run: (r) => {
|
|
128459
128521
|
const ok = matcher(contactFields(r), CONTACT_DOCUMENTED, r.body.query, "contacts");
|
|
128460
|
-
const l = listOf("list", "data",
|
|
128522
|
+
const l = listOf("list", "data", all7(r.ctx, "contact").filter((c) => !c.archived && ok(c)), r, 50, r.body);
|
|
128461
128523
|
return { ...l, data: l.data.map((c) => contactShape2(r, c)) };
|
|
128462
128524
|
}
|
|
128463
128525
|
},
|
|
@@ -128498,7 +128560,7 @@ var intercomRoutes = [
|
|
|
128498
128560
|
method: "GET",
|
|
128499
128561
|
path: "/contacts/find_by_external_id/:id",
|
|
128500
128562
|
coverage: { status: "supported" },
|
|
128501
|
-
run: (r) => contactShape2(r,
|
|
128563
|
+
run: (r) => contactShape2(r, all7(r.ctx, "contact").find((c) => c.external_id === r.param("id")) ?? notFound15("User"))
|
|
128502
128564
|
},
|
|
128503
128565
|
{ method: "GET", path: "/contacts/:id", coverage: { status: "supported" }, run: (r) => contactShape2(r, contactOr404(r)) },
|
|
128504
128566
|
{
|
|
@@ -128575,7 +128637,7 @@ var intercomRoutes = [
|
|
|
128575
128637
|
coverage: { status: "supported" },
|
|
128576
128638
|
run: (r) => {
|
|
128577
128639
|
const c = contactOr404(r);
|
|
128578
|
-
const l = byPage(
|
|
128640
|
+
const l = byPage(all7(r.ctx, "note").filter((n) => n.contact_id === c.id).reverse(), r, 50, "data");
|
|
128579
128641
|
return { ...l, data: l.data.map((n) => noteShape3(r, n)) };
|
|
128580
128642
|
}
|
|
128581
128643
|
},
|
|
@@ -128628,13 +128690,13 @@ var intercomRoutes = [
|
|
|
128628
128690
|
run: (r) => {
|
|
128629
128691
|
const id12 = r.query.get("company_id"), name5 = r.query.get("name");
|
|
128630
128692
|
for (const key3 of ["segment_id", "tag_id"]) if (r.query.get(key3)) unsupported26(`listing companies by ${key3}`);
|
|
128631
|
-
if (id12 || name5) return companyShape(r,
|
|
128632
|
-
const l = byPage(
|
|
128693
|
+
if (id12 || name5) return companyShape(r, all7(r.ctx, "company").find((co) => id12 && co.company_id === id12 || name5 && co.name.toLowerCase() === name5.toLowerCase()) ?? notFound15("Company"));
|
|
128694
|
+
const l = byPage(all7(r.ctx, "company"), r, 15, "data");
|
|
128633
128695
|
return { ...l, data: l.data.map((co) => companyShape(r, co)) };
|
|
128634
128696
|
}
|
|
128635
128697
|
},
|
|
128636
128698
|
{ method: "POST", path: "/companies/list", coverage: { status: "supported" }, run: (r) => {
|
|
128637
|
-
const l = byPage(
|
|
128699
|
+
const l = byPage(all7(r.ctx, "company"), r, 15, "data", { page: r.body.page ?? r.query.get("page") ?? 1, per_page: r.body.per_page ?? r.query.get("per_page") ?? 15 });
|
|
128638
128700
|
return { ...l, data: l.data.map((co) => companyShape(r, co)) };
|
|
128639
128701
|
} },
|
|
128640
128702
|
{
|
|
@@ -128644,7 +128706,7 @@ var intercomRoutes = [
|
|
|
128644
128706
|
run: (r) => {
|
|
128645
128707
|
const b = r.body;
|
|
128646
128708
|
if (!b.company_id && !b.name) fail3(400, "parameter_invalid", "company_id or name is required");
|
|
128647
|
-
const at2 = now8(r), existing2 =
|
|
128709
|
+
const at2 = now8(r), existing2 = all7(r.ctx, "company").find((co2) => co2.company_id === (b.company_id ?? b.name));
|
|
128648
128710
|
const co = existing2 ?? { id: r.ctx.ids.hex(24), company_id: b.company_id ?? b.name, name: b.name ?? b.company_id, plan: null, plan_id: null, size: null, website: null, industry: null, monthly_spend: 0, custom_attributes: {}, created_at: b.remote_created_at ?? at2, updated_at: at2 };
|
|
128649
128711
|
for (const key3 of ["name", "size", "website", "industry", "monthly_spend"]) if (b[key3] !== void 0) co[key3] = b[key3];
|
|
128650
128712
|
if (b.plan !== void 0) {
|
|
@@ -128676,7 +128738,7 @@ var intercomRoutes = [
|
|
|
128676
128738
|
coverage: { status: "supported" },
|
|
128677
128739
|
run: (r) => {
|
|
128678
128740
|
const co = load5(r.ctx, "company", r.param("id")) ?? notFound15("Company");
|
|
128679
|
-
const l = listOf("list", "data",
|
|
128741
|
+
const l = listOf("list", "data", all7(r.ctx, "contact").filter((c) => c.companies.includes(co.id)), r);
|
|
128680
128742
|
return { ...l, data: l.data.map((c) => contactShape2(r, c)) };
|
|
128681
128743
|
}
|
|
128682
128744
|
},
|
|
@@ -128685,7 +128747,7 @@ var intercomRoutes = [
|
|
|
128685
128747
|
path: "/conversations",
|
|
128686
128748
|
coverage: { status: "supported", notes: "newest activity first" },
|
|
128687
128749
|
run: (r) => {
|
|
128688
|
-
const l = listOf("conversation.list", "conversations",
|
|
128750
|
+
const l = listOf("conversation.list", "conversations", all7(r.ctx, "conversation").sort((a, b) => b.updated_at - a.updated_at), r, 20);
|
|
128689
128751
|
return { ...l, conversations: l.conversations.map((c) => conversationShape(r, c, false)) };
|
|
128690
128752
|
}
|
|
128691
128753
|
},
|
|
@@ -128695,7 +128757,7 @@ var intercomRoutes = [
|
|
|
128695
128757
|
coverage: { status: "partial", notes: "state, assignment, tags, contacts, source and timestamps; ratings, AI agent and statistics fields are gaps" },
|
|
128696
128758
|
run: (r) => {
|
|
128697
128759
|
const ok = matcher(conversationFields(), CONVERSATION_DOCUMENTED, r.body.query, "conversations");
|
|
128698
|
-
const l = listOf("conversation.list", "conversations",
|
|
128760
|
+
const l = listOf("conversation.list", "conversations", all7(r.ctx, "conversation").filter(ok).sort((a, b) => b.updated_at - a.updated_at), r, 20, r.body);
|
|
128699
128761
|
return { ...l, conversations: l.conversations.map((c) => conversationShape(r, c, false)) };
|
|
128700
128762
|
}
|
|
128701
128763
|
},
|
|
@@ -128766,7 +128828,7 @@ var intercomRoutes = [
|
|
|
128766
128828
|
}
|
|
128767
128829
|
} else if (b.type === "user") {
|
|
128768
128830
|
if (b.message_type !== "comment") fail3(400, "parameter_invalid", "a contact can only reply with a comment");
|
|
128769
|
-
const contact = load5(r.ctx, "contact", String(b.intercom_user_id ?? "")) ??
|
|
128831
|
+
const contact = load5(r.ctx, "contact", String(b.intercom_user_id ?? "")) ?? all7(r.ctx, "contact").find((c) => b.user_id && c.external_id === b.user_id || b.email && c.email?.toLowerCase() === String(b.email).toLowerCase());
|
|
128770
128832
|
if (!contact || contact.id !== conv.contact_id) fail3(404, "not_found", "User Not Found");
|
|
128771
128833
|
addPart(r, conv, { type: "comment", body: html(b.body), author: { type: "user", id: contact.id } });
|
|
128772
128834
|
if (conv.state !== "open") {
|
|
@@ -128847,7 +128909,7 @@ var intercomRoutes = [
|
|
|
128847
128909
|
return { type: "tag", id: tag3.id, name: tag3.name };
|
|
128848
128910
|
}
|
|
128849
128911
|
},
|
|
128850
|
-
{ method: "GET", path: "/tags", coverage: { status: "supported" }, run: (r) => ({ type: "list", data:
|
|
128912
|
+
{ method: "GET", path: "/tags", coverage: { status: "supported" }, run: (r) => ({ type: "list", data: all7(r.ctx, "tag").map((t) => ({ type: "tag", id: t.id, name: t.name })) }) },
|
|
128851
128913
|
{
|
|
128852
128914
|
method: "POST",
|
|
128853
128915
|
path: "/tags",
|
|
@@ -128861,7 +128923,7 @@ var intercomRoutes = [
|
|
|
128861
128923
|
save10(r.ctx, "tag", { ...t2, name: b.name });
|
|
128862
128924
|
return { type: "tag", id: t2.id, name: b.name };
|
|
128863
128925
|
}
|
|
128864
|
-
const existing2 =
|
|
128926
|
+
const existing2 = all7(r.ctx, "tag").find((t2) => t2.name.toLowerCase() === b.name.toLowerCase());
|
|
128865
128927
|
const t = existing2 ?? save10(r.ctx, "tag", { id: nextId5(r.ctx, "tag"), name: b.name });
|
|
128866
128928
|
return { type: "tag", id: t.id, name: t.name };
|
|
128867
128929
|
}
|
|
@@ -128876,14 +128938,14 @@ var intercomRoutes = [
|
|
|
128876
128938
|
coverage: { status: "supported" },
|
|
128877
128939
|
run: (r) => {
|
|
128878
128940
|
const t = load5(r.ctx, "tag", r.param("id")) ?? notFound15("Tag");
|
|
128879
|
-
const used = [...
|
|
128941
|
+
const used = [...all7(r.ctx, "contact"), ...all7(r.ctx, "conversation")].some((x) => x.tags.some((y) => y.id === t.id));
|
|
128880
128942
|
if (used) fail3(400, "tag_has_dependent_objects", "Unable to delete Tag with dependent objects.");
|
|
128881
128943
|
remove3(r.ctx, "tag", t.id);
|
|
128882
128944
|
return void 0;
|
|
128883
128945
|
}
|
|
128884
128946
|
},
|
|
128885
128947
|
{ method: "GET", path: "/articles", coverage: { status: "supported" }, run: (r) => {
|
|
128886
|
-
const l = byPage(
|
|
128948
|
+
const l = byPage(all7(r.ctx, "article"), r, 50, "data");
|
|
128887
128949
|
return { ...l, data: l.data.map((a) => articleShape(r, a)) };
|
|
128888
128950
|
} },
|
|
128889
128951
|
{
|
|
@@ -128893,7 +128955,7 @@ var intercomRoutes = [
|
|
|
128893
128955
|
run: (r) => {
|
|
128894
128956
|
const words4 = (r.query.get("phrase") ?? "").toLowerCase().split(/\W+/).filter(Boolean), state2 = r.query.get("state");
|
|
128895
128957
|
if (r.query.get("help_center_id")) unsupported26("searching one help center of several");
|
|
128896
|
-
const found =
|
|
128958
|
+
const found = all7(r.ctx, "article").filter((a) => (!state2 || state2 === "all" || a.state === state2) && words4.every((w) => `${a.title} ${a.description} ${plain2(a.body)}`.toLowerCase().includes(w)));
|
|
128897
128959
|
return { type: "list", total_count: found.length, data: { articles: found.map((a) => articleShape(r, a)), highlights: [] }, pages: { type: "pages", page: 1, per_page: Math.max(found.length, 1), total_pages: 1 } };
|
|
128898
128960
|
}
|
|
128899
128961
|
},
|
|
@@ -129069,11 +129131,11 @@ function dumpState31(ctx) {
|
|
|
129069
129131
|
const contact = (id12) => load5(ctx, "contact", id12);
|
|
129070
129132
|
return {
|
|
129071
129133
|
workspace: workspace(ctx).name,
|
|
129072
|
-
admins:
|
|
129073
|
-
teams:
|
|
129074
|
-
tags:
|
|
129075
|
-
companies:
|
|
129076
|
-
contacts:
|
|
129134
|
+
admins: all7(ctx, "admin").map((a) => ({ id: a.id, name: a.name, email: a.email, away: a.away })),
|
|
129135
|
+
teams: all7(ctx, "team").map((t) => ({ id: t.id, name: t.name, members: t.admin_ids.map(admin) })),
|
|
129136
|
+
tags: all7(ctx, "tag").map((t) => t.name),
|
|
129137
|
+
companies: all7(ctx, "company").map((co) => ({ id: co.id, name: co.name, company_id: co.company_id, plan: co.plan })),
|
|
129138
|
+
contacts: all7(ctx, "contact").map((c) => ({
|
|
129077
129139
|
id: c.id,
|
|
129078
129140
|
name: c.name,
|
|
129079
129141
|
email: c.email,
|
|
@@ -129085,9 +129147,9 @@ function dumpState31(ctx) {
|
|
|
129085
129147
|
companies: c.companies.map((id12) => load5(ctx, "company", id12)?.name ?? null),
|
|
129086
129148
|
tags: c.tags.map(tag3),
|
|
129087
129149
|
custom_attributes: c.custom_attributes,
|
|
129088
|
-
notes:
|
|
129150
|
+
notes: all7(ctx, "note").filter((n) => n.contact_id === c.id).map((n) => ({ author: admin(n.author), body: plain2(n.body), created_at: iso13(n.created_at) }))
|
|
129089
129151
|
})),
|
|
129090
|
-
conversations:
|
|
129152
|
+
conversations: all7(ctx, "conversation").map((v) => ({
|
|
129091
129153
|
id: v.id,
|
|
129092
129154
|
contact: contact(v.contact_id)?.name ?? null,
|
|
129093
129155
|
contact_email: contact(v.contact_id)?.email ?? null,
|
|
@@ -129111,7 +129173,7 @@ function dumpState31(ctx) {
|
|
|
129111
129173
|
...p2.assigned_to && { assigned_to: p2.assigned_to.type === "admin" ? admin(p2.assigned_to.id) : load5(ctx, "team", p2.assigned_to.id)?.name ?? null }
|
|
129112
129174
|
}))
|
|
129113
129175
|
})),
|
|
129114
|
-
articles:
|
|
129176
|
+
articles: all7(ctx, "article").map((a) => ({ id: a.id, title: a.title, state: a.state }))
|
|
129115
129177
|
};
|
|
129116
129178
|
}
|
|
129117
129179
|
|
|
@@ -129611,9 +129673,9 @@ function macroJson(ctx, macro2) {
|
|
|
129611
129673
|
};
|
|
129612
129674
|
}
|
|
129613
129675
|
function viewJson(ctx, view3) {
|
|
129614
|
-
const
|
|
129676
|
+
const all8 = [{ field: "status", operator: "less_than", value: "solved" }], statuses = JSON.parse(view3.statuses);
|
|
129615
129677
|
const conditions = [
|
|
129616
|
-
...statuses.join() === "new,open,pending,hold" ?
|
|
129678
|
+
...statuses.join() === "new,open,pending,hold" ? all8 : statuses.map((status4) => ({ field: "status", operator: "is", value: status4 })),
|
|
129617
129679
|
...view3.assignee === "none" ? [{ field: "assignee_id", operator: "is", value: null }] : view3.assignee === "me" ? [{ field: "assignee_id", operator: "is", value: "current_user" }] : [],
|
|
129618
129680
|
...view3.group_id === null ? [] : [{ field: "group_id", operator: "is", value: String(view3.group_id) }]
|
|
129619
129681
|
];
|
|
@@ -132849,9 +132911,9 @@ function permissionsIn(ctx, userId, channel3) {
|
|
|
132849
132911
|
if (ctx.store.meta.get("discord.owner") === userId) return ALL;
|
|
132850
132912
|
const member4 = getMember(ctx, userId);
|
|
132851
132913
|
if (!member4) return 0n;
|
|
132852
|
-
const
|
|
132914
|
+
const all8 = roles(ctx), mine = new Set(JSON.parse(member4.roles)), everyone = guildId(ctx);
|
|
132853
132915
|
let permissions = 0n;
|
|
132854
|
-
for (const role3 of
|
|
132916
|
+
for (const role3 of all8) if (role3.id === everyone || mine.has(role3.id)) permissions |= BigInt(role3.permissions);
|
|
132855
132917
|
if (permissions & BITS.ADMINISTRATOR) return ALL;
|
|
132856
132918
|
const target4 = channel3?.type === PUBLIC_THREAD ? getChannel(ctx, channel3.parent_id) : channel3;
|
|
132857
132919
|
if (!target4 || target4.type === DM) return permissions;
|
|
@@ -133182,8 +133244,8 @@ function members3(call2) {
|
|
|
133182
133244
|
guildFor(call2);
|
|
133183
133245
|
const params9 = call2.url.searchParams, limit = Number(params9.get("limit") ?? 1), after = params9.get("after") ?? "0";
|
|
133184
133246
|
if (!Number.isInteger(limit) || limit < 1 || limit > 1e3) throw invalidForm("limit", "NUMBER_TYPE_MAX", "int value should be between 1 and 1000");
|
|
133185
|
-
const
|
|
133186
|
-
return json27(
|
|
133247
|
+
const all8 = call2.ctx.store.db.prepare("SELECT * FROM dc_members").all().sort((a, b) => BigInt(a.user_id) < BigInt(b.user_id) ? -1 : 1);
|
|
133248
|
+
return json27(all8.filter((member4) => BigInt(member4.user_id) > BigInt(after)).slice(0, limit).map((member4) => memberJson(call2.ctx, member4)));
|
|
133187
133249
|
}
|
|
133188
133250
|
function member2(call2) {
|
|
133189
133251
|
guildFor(call2);
|
|
@@ -133207,15 +133269,15 @@ function listMessages2(call2) {
|
|
|
133207
133269
|
const anchors = ["before", "after", "around"].filter((name5) => params9.has(name5));
|
|
133208
133270
|
if (anchors.length > 1) throw invalidForm(anchors[1], "BASE_TYPE_BAD_ARGUMENT", "Only one of before, after or around may be given");
|
|
133209
133271
|
if (!canRead(call2, channel3)) return json27([]);
|
|
133210
|
-
const
|
|
133272
|
+
const all8 = call2.ctx.store.db.prepare("SELECT * FROM dc_messages WHERE channel_id = ? AND deleted_ms IS NULL").all(channel3.id).sort((a, b) => BigInt(b.id) > BigInt(a.id) ? 1 : -1);
|
|
133211
133273
|
const at2 = (name5) => BigInt(params9.get(name5));
|
|
133212
133274
|
let page15;
|
|
133213
|
-
if (params9.has("before")) page15 =
|
|
133214
|
-
else if (params9.has("after")) page15 =
|
|
133275
|
+
if (params9.has("before")) page15 = all8.filter((row) => BigInt(row.id) < at2("before")).slice(0, limit);
|
|
133276
|
+
else if (params9.has("after")) page15 = all8.filter((row) => BigInt(row.id) > at2("after")).slice(-limit);
|
|
133215
133277
|
else if (params9.has("around")) {
|
|
133216
|
-
const older =
|
|
133278
|
+
const older = all8.filter((row) => BigInt(row.id) <= at2("around")).slice(0, Math.ceil(limit / 2)), newer = all8.filter((row) => BigInt(row.id) > at2("around")).slice(-Math.floor(limit / 2));
|
|
133217
133279
|
page15 = [...newer, ...older];
|
|
133218
|
-
} else page15 =
|
|
133280
|
+
} else page15 = all8.slice(0, limit);
|
|
133219
133281
|
return json27(page15.map((row) => messageJson2(call2.ctx, row)));
|
|
133220
133282
|
}
|
|
133221
133283
|
function showMessage(call2) {
|
|
@@ -135611,8 +135673,8 @@ var AirtableBase = class _AirtableBase {
|
|
|
135611
135673
|
}
|
|
135612
135674
|
/** A table by id or name, as the URL gives it. */
|
|
135613
135675
|
table(ref20) {
|
|
135614
|
-
const
|
|
135615
|
-
const found =
|
|
135676
|
+
const all8 = this.tables();
|
|
135677
|
+
const found = all8.find((item2) => item2.id === ref20) ?? all8.find((item2) => item2.name === ref20) ?? all8.find((item2) => item2.name.toLowerCase() === ref20.toLowerCase());
|
|
135616
135678
|
if (!found) throw modelNotFound();
|
|
135617
135679
|
return found;
|
|
135618
135680
|
}
|
|
@@ -135626,8 +135688,8 @@ var AirtableBase = class _AirtableBase {
|
|
|
135626
135688
|
}
|
|
135627
135689
|
/** A field by id or exact name; `loose` also matches names regardless of case (as formulas do). */
|
|
135628
135690
|
field(tableId, ref20, loose = false) {
|
|
135629
|
-
const
|
|
135630
|
-
return
|
|
135691
|
+
const all8 = this.fields(tableId);
|
|
135692
|
+
return all8.find((item2) => item2.id === ref20) ?? all8.find((item2) => item2.name === ref20) ?? (loose ? all8.find((item2) => item2.name.toLowerCase() === ref20.toLowerCase()) : void 0);
|
|
135631
135693
|
}
|
|
135632
135694
|
fieldById(id12) {
|
|
135633
135695
|
for (const table3 of this.tables()) {
|
|
@@ -136012,13 +136074,13 @@ var AirtableBase = class _AirtableBase {
|
|
|
136012
136074
|
}
|
|
136013
136075
|
}
|
|
136014
136076
|
#person(value4, typecast, bad3) {
|
|
136015
|
-
const
|
|
136077
|
+
const all8 = this.users(), lower4 = (text21) => String(text21).trim().toLowerCase();
|
|
136016
136078
|
let found;
|
|
136017
136079
|
if (value4 && typeof value4 === "object" && !Array.isArray(value4)) {
|
|
136018
136080
|
const ref20 = value4;
|
|
136019
|
-
found = ref20.id !== void 0 ?
|
|
136081
|
+
found = ref20.id !== void 0 ? all8.find((item2) => item2.id === ref20.id) : ref20.email !== void 0 ? all8.find((item2) => item2.email.toLowerCase() === lower4(ref20.email)) : void 0;
|
|
136020
136082
|
} else if (typeof value4 === "string") {
|
|
136021
|
-
found =
|
|
136083
|
+
found = all8.find((item2) => item2.id === value4) ?? all8.find((item2) => item2.email.toLowerCase() === lower4(value4)) ?? (typecast ? all8.find((item2) => item2.name.toLowerCase() === lower4(value4)) : void 0);
|
|
136022
136084
|
}
|
|
136023
136085
|
if (!found) throw bad3();
|
|
136024
136086
|
return found.id;
|
|
@@ -136359,11 +136421,11 @@ function commentsOf3(call2, writing) {
|
|
|
136359
136421
|
var liveComments = (ctx, recordId) => ctx.store.db.prepare("SELECT * FROM at_comments WHERE record_id = ? AND deleted_ms IS NULL ORDER BY created_ms DESC, id DESC").all(recordId);
|
|
136360
136422
|
function listComments3(call2) {
|
|
136361
136423
|
const { model, record: record8 } = commentsOf3(call2, false), pageSize2 = whole(call2.url.searchParams.get("pageSize") ?? void 0, "pageSize", 1, 100) ?? 100;
|
|
136362
|
-
const
|
|
136363
|
-
const from = offset16 === null ? 0 :
|
|
136424
|
+
const all8 = liveComments(call2.ctx, record8.id), offset16 = call2.url.searchParams.get("offset");
|
|
136425
|
+
const from = offset16 === null ? 0 : all8.findIndex((row) => row.id === offset16);
|
|
136364
136426
|
if (from < 0) throw new AirtableError(422, "LIST_RECORDS_ITERATOR_NOT_AVAILABLE");
|
|
136365
|
-
const page15 =
|
|
136366
|
-
return json29({ comments: page15.map((row) => commentJson2(model, row)), offset:
|
|
136427
|
+
const page15 = all8.slice(from, from + pageSize2);
|
|
136428
|
+
return json29({ comments: page15.map((row) => commentJson2(model, row)), offset: all8[from + pageSize2]?.id ?? null });
|
|
136367
136429
|
}
|
|
136368
136430
|
function commentText(body6) {
|
|
136369
136431
|
if (typeof body6.text !== "string" || !body6.text.trim()) throw invalidRequest("Invalid request: text is required");
|
|
@@ -138954,11 +139016,11 @@ var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
|
138954
139016
|
var __getProtoOf2 = Object.getPrototypeOf;
|
|
138955
139017
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
138956
139018
|
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
138957
|
-
var __exportAll = (
|
|
139019
|
+
var __exportAll = (all8, symbols) => {
|
|
138958
139020
|
let target4 = {};
|
|
138959
|
-
for (var name5 in
|
|
139021
|
+
for (var name5 in all8) {
|
|
138960
139022
|
__defProp2(target4, name5, {
|
|
138961
|
-
get:
|
|
139023
|
+
get: all8[name5],
|
|
138962
139024
|
enumerable: true
|
|
138963
139025
|
});
|
|
138964
139026
|
}
|