@lotics/app-sdk 0.115.0 → 0.115.2
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/dist/index.js +800 -518
- package/dist/shared_types.d.ts +1 -1
- package/docs/members_and_options.md +3 -3
- package/docs/queries.md +13 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21561,6 +21561,180 @@ function validateFieldTypeForOperation(fieldType, operation, subject) {
|
|
|
21561
21561
|
throw new Error(`Operation '${operation}' is not valid for field type '${fieldType}'`);
|
|
21562
21562
|
}
|
|
21563
21563
|
|
|
21564
|
+
// ../shared/src/schemas/iam.ts
|
|
21565
|
+
var jsonSchemaSchema = zod_default.string();
|
|
21566
|
+
var organizationSchema = zod_default.object({
|
|
21567
|
+
id: zod_default.string().describe("Unique identifier for the organization"),
|
|
21568
|
+
name: zod_default.string().describe("Display name of the organization"),
|
|
21569
|
+
slug: zod_default.string().nullable().describe("Slug for the organization")
|
|
21570
|
+
});
|
|
21571
|
+
var memberAccountTypeSchema = zod_default.enum(["self_managed", "admin_managed", "service"]).describe(
|
|
21572
|
+
"How the account is credentialed. admin_managed means an admin chose the sign-in name and set the password; the account has NO email address at all, so nothing can be mailed to it until the member claims one they control. service means no credential exists at all \u2014 the membership is an integration's identity, reached only by an API key bound to it."
|
|
21573
|
+
);
|
|
21574
|
+
var ALL_ACCOUNT_TYPES = memberAccountTypeSchema.options;
|
|
21575
|
+
var memberSchema = zod_default.object({
|
|
21576
|
+
member_id: zod_default.string().describe("Unique identifier for the member"),
|
|
21577
|
+
organization_id: zod_default.string().describe("Organization ID the member belongs to"),
|
|
21578
|
+
name: zod_default.string().describe("Display name of the member"),
|
|
21579
|
+
email_address: zod_default.string().nullable().describe(
|
|
21580
|
+
"What the member types to sign in: an email address for a self-managed member, an administrator-issued name (e.g. giamdoc.sunrise) for an admin-managed one. The latter is NOT an address and cannot receive mail \u2014 the field name predates the split. Null for a service identity, which holds no credential and signs in nowhere."
|
|
21581
|
+
),
|
|
21582
|
+
role: zod_default.enum(["owner", "admin", "member"]).describe("Organization role"),
|
|
21583
|
+
image: zod_default.string().nullable().optional().describe("URL to the member's profile picture"),
|
|
21584
|
+
account_type: memberAccountTypeSchema,
|
|
21585
|
+
archived: zod_default.boolean().optional().describe(
|
|
21586
|
+
"True when this person has been removed from the organization. The membership survives removal so records naming them keep resolving; it grants nothing. Optional because an older server omits it \u2014 absent means active."
|
|
21587
|
+
),
|
|
21588
|
+
joined_at: zod_default.string().optional().describe(
|
|
21589
|
+
"ISO timestamp of when this membership began. Optional because an older server omits it \u2014 absent means not told, never 'joined at the epoch'."
|
|
21590
|
+
)
|
|
21591
|
+
});
|
|
21592
|
+
var pendingInvitationSchema = zod_default.object({
|
|
21593
|
+
invitation_id: zod_default.string().describe("Unique identifier for the pending invitation"),
|
|
21594
|
+
organization_id: zod_default.string().describe("Organization the invitee will join on accept"),
|
|
21595
|
+
email: zod_default.string().describe("Email the invitation was sent to"),
|
|
21596
|
+
name: zod_default.string().nullable().describe("Admin-supplied display name (carried onto member.name on accept; invitee can override at accept time)"),
|
|
21597
|
+
role: zod_default.enum(["owner", "admin", "member"]).describe("Role the invitee will receive on accept"),
|
|
21598
|
+
expires_at: zod_default.string().describe("ISO timestamp when the invitation expires")
|
|
21599
|
+
});
|
|
21600
|
+
var ianaTimezoneSchema = zod_default.string().refine(
|
|
21601
|
+
(tz) => {
|
|
21602
|
+
try {
|
|
21603
|
+
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
21604
|
+
return true;
|
|
21605
|
+
} catch {
|
|
21606
|
+
return false;
|
|
21607
|
+
}
|
|
21608
|
+
},
|
|
21609
|
+
{ message: "must be an IANA timezone name, e.g. Asia/Ho_Chi_Minh or America/New_York" }
|
|
21610
|
+
).describe("IANA timezone name (e.g., 'America/New_York', 'Asia/Ho_Chi_Minh')");
|
|
21611
|
+
var currencyCodeSchema = zod_default.string().trim().toUpperCase().regex(/^[A-Z]{3}$/, "must be an ISO 4217 currency code, e.g. VND, USD, EUR").describe("ISO 4217 currency code (e.g. 'VND', 'USD', 'EUR'). Upper-cased.");
|
|
21612
|
+
var workspaceSchema = zod_default.object({
|
|
21613
|
+
id: zod_default.string().describe("Unique identifier for the workspace"),
|
|
21614
|
+
name: zod_default.string().describe("Display name of the workspace"),
|
|
21615
|
+
default_currency: zod_default.string().describe("Default currency code for the workspace"),
|
|
21616
|
+
// Plain string on the way OUT, deliberately. This is a response schema, so
|
|
21617
|
+
// validating here would make the server reject its own stored rows — and on
|
|
21618
|
+
// the workspace LIST one bad row fails the entire array. The zone is enforced
|
|
21619
|
+
// where it is written; a read is too late to do anything about it anyway.
|
|
21620
|
+
timezone: zod_default.string().describe("IANA timezone name (e.g., 'America/New_York', 'Asia/Ho_Chi_Minh')"),
|
|
21621
|
+
organization_id: zod_default.string().describe("Organization ID this workspace belongs to"),
|
|
21622
|
+
created_at: zod_default.string().describe("Timestamp when workspace was created")
|
|
21623
|
+
});
|
|
21624
|
+
var memberGroupSchema = zod_default.object({
|
|
21625
|
+
id: zod_default.string().describe("Unique identifier for the member group"),
|
|
21626
|
+
name: zod_default.string().describe("Display name of the group"),
|
|
21627
|
+
description: zod_default.string().optional().describe("Optional description of the group's purpose"),
|
|
21628
|
+
member_ids: zod_default.array(zod_default.string()).describe("Array of member IDs in this group"),
|
|
21629
|
+
invitation_ids: zod_default.array(zod_default.string()).describe("Array of pending invitation IDs pre-granted membership; migrated to member_ids on accept"),
|
|
21630
|
+
organization_id: zod_default.string().describe("ID of the organization this group belongs to"),
|
|
21631
|
+
created_at: zod_default.string().describe("Timestamp when group was created"),
|
|
21632
|
+
created_by: zod_default.string().describe("Member ID of the user who created this group")
|
|
21633
|
+
});
|
|
21634
|
+
var principalGroupSchema = zod_default.object({
|
|
21635
|
+
id: zod_default.string().describe("Unique identifier for the member group"),
|
|
21636
|
+
name: zod_default.string().describe("Display name of the group"),
|
|
21637
|
+
description: zod_default.string().optional().describe("Optional description of the group's purpose"),
|
|
21638
|
+
member_count: zod_default.number().int().describe("Number of accepted members in the group"),
|
|
21639
|
+
invitation_count: zod_default.number().int().describe("Number of pending invitations pre-granted membership")
|
|
21640
|
+
});
|
|
21641
|
+
var PUBLIC_PRINCIPAL_ID = "public";
|
|
21642
|
+
var principalSchema = zod_default.discriminatedUnion("type", [
|
|
21643
|
+
zod_default.object({
|
|
21644
|
+
type: zod_default.literal("member").describe("Principal type: individual member"),
|
|
21645
|
+
id: zod_default.string().describe("Member ID")
|
|
21646
|
+
}),
|
|
21647
|
+
zod_default.object({
|
|
21648
|
+
type: zod_default.literal("member_group").describe("Principal type: group of members"),
|
|
21649
|
+
id: zod_default.string().describe("Member group ID")
|
|
21650
|
+
}),
|
|
21651
|
+
zod_default.object({
|
|
21652
|
+
type: zod_default.literal("organization").describe("Principal type: all members in organization"),
|
|
21653
|
+
id: zod_default.string().describe("Organization ID")
|
|
21654
|
+
}),
|
|
21655
|
+
zod_default.object({
|
|
21656
|
+
type: zod_default.literal("public").describe("Principal type: anyone, including unauthenticated visitors"),
|
|
21657
|
+
id: zod_default.literal(PUBLIC_PRINCIPAL_ID).describe("Always the `public` sentinel \u2014 no entity")
|
|
21658
|
+
}),
|
|
21659
|
+
// Pending invitation as principal: lets admins pre-grant group membership and
|
|
21660
|
+
// resource access before the invitee accepts. Never resolved as a Subject —
|
|
21661
|
+
// a pending invitee cannot authenticate, so these bindings stay dormant until
|
|
21662
|
+
// accept-time migration rewrites them to type:"member".
|
|
21663
|
+
zod_default.object({
|
|
21664
|
+
type: zod_default.literal("invitation").describe("Principal type: pending invitation (not yet accepted)"),
|
|
21665
|
+
id: zod_default.string().describe("Invitation ID")
|
|
21666
|
+
})
|
|
21667
|
+
]);
|
|
21668
|
+
var subjectSchema = zod_default.discriminatedUnion("type", [
|
|
21669
|
+
zod_default.object({
|
|
21670
|
+
type: zod_default.literal("member").describe("Subject type: authenticated member"),
|
|
21671
|
+
id: zod_default.string().describe("Member ID")
|
|
21672
|
+
}),
|
|
21673
|
+
zod_default.object({
|
|
21674
|
+
type: zod_default.literal("public").describe("Subject type: unauthenticated visitor")
|
|
21675
|
+
})
|
|
21676
|
+
]);
|
|
21677
|
+
var resourceTypeSchema = zod_default.enum(["table", "table_view", "app", "automation", "skill", "document_template", "instruction", "knowledge_doc", "connected_account"]);
|
|
21678
|
+
var RESOURCE_ROLE_ACTIONS = {
|
|
21679
|
+
table: {
|
|
21680
|
+
editor: ["read_data", "write_data"],
|
|
21681
|
+
viewer: ["read_data"]
|
|
21682
|
+
},
|
|
21683
|
+
app: { manager: ["use", "manage"], user: ["use"] },
|
|
21684
|
+
skill: { manager: ["use", "manage"], user: ["use"] },
|
|
21685
|
+
document_template: { manager: ["use", "manage"], user: ["use"] },
|
|
21686
|
+
instruction: { manager: ["use", "manage"], user: ["use"] },
|
|
21687
|
+
knowledge_doc: { manager: ["use", "manage"], user: ["use"] },
|
|
21688
|
+
connected_account: { manager: ["use", "manage"], user: ["use"] },
|
|
21689
|
+
table_view: {},
|
|
21690
|
+
automation: {}
|
|
21691
|
+
};
|
|
21692
|
+
function shareableRolesFor(type) {
|
|
21693
|
+
return Object.keys(RESOURCE_ROLE_ACTIONS[type]);
|
|
21694
|
+
}
|
|
21695
|
+
var SHAREABLE_RESOURCE_TYPES = resourceTypeSchema.options.filter(
|
|
21696
|
+
(type) => shareableRolesFor(type).length > 0
|
|
21697
|
+
);
|
|
21698
|
+
var accessPrincipalSchema = zod_default.discriminatedUnion("type", [
|
|
21699
|
+
zod_default.object({
|
|
21700
|
+
type: zod_default.literal("member").describe("Principal type: an individual member"),
|
|
21701
|
+
id: zod_default.string().describe("Member ID")
|
|
21702
|
+
}),
|
|
21703
|
+
zod_default.object({
|
|
21704
|
+
type: zod_default.literal("member_group").describe("Principal type: a member group"),
|
|
21705
|
+
id: zod_default.string().describe("Group ID")
|
|
21706
|
+
}),
|
|
21707
|
+
zod_default.object({
|
|
21708
|
+
type: zod_default.literal("organization").describe("Principal type: everyone in the organization"),
|
|
21709
|
+
id: zod_default.string().describe("Organization ID")
|
|
21710
|
+
})
|
|
21711
|
+
]);
|
|
21712
|
+
var resourceAccessSchema = zod_default.object({
|
|
21713
|
+
resource_id: zod_default.string().describe("ID of the resource these principals can reach"),
|
|
21714
|
+
principals: zod_default.array(accessPrincipalSchema).describe("Members, groups and the organization that have been granted access")
|
|
21715
|
+
});
|
|
21716
|
+
var contentResourceTypeSchema = zod_default.enum(["knowledge_doc", "document_template"]);
|
|
21717
|
+
var contentItemSchema = zod_default.object({
|
|
21718
|
+
id: zod_default.string().describe("ID of the knowledge doc or template"),
|
|
21719
|
+
name: zod_default.string().describe("Its name"),
|
|
21720
|
+
owner_member_id: zod_default.string().nullable().describe("Member who owns it; null when nobody does"),
|
|
21721
|
+
created_at: zod_default.string().describe("When it was created"),
|
|
21722
|
+
updated_at: zod_default.string().nullable().describe("When a knowledge doc was last changed; null for a template"),
|
|
21723
|
+
hidden_at: zod_default.string().nullable().describe("When a knowledge doc was hidden; null when it is in use, and for a template"),
|
|
21724
|
+
template_type: zod_default.string().nullable().describe("A template's type (html, email, word, excel, pdf-form); null for a knowledge doc"),
|
|
21725
|
+
can_open: zod_default.boolean().describe("Whether the caller may open it; false means it is not shared with them"),
|
|
21726
|
+
principals: zod_default.array(accessPrincipalSchema).describe("Members, groups and the organization it has been shared with, besides its owner")
|
|
21727
|
+
});
|
|
21728
|
+
var resourceRoleBindingSchema = zod_default.object({
|
|
21729
|
+
id: zod_default.string().describe("Unique identifier for the role binding"),
|
|
21730
|
+
principal: principalSchema.describe(
|
|
21731
|
+
"Who this role binding applies to (member, group, or organization)"
|
|
21732
|
+
),
|
|
21733
|
+
resource_type: resourceTypeSchema.describe("Type of resource being accessed"),
|
|
21734
|
+
resource_id: zod_default.string().describe("ID of the specific resource"),
|
|
21735
|
+
role: zod_default.string().describe("Role name (e.g., 'viewer', 'editor', 'manager', 'user')")
|
|
21736
|
+
});
|
|
21737
|
+
|
|
21564
21738
|
// ../shared/src/number_unit.ts
|
|
21565
21739
|
var MEASURED_UNITS = [
|
|
21566
21740
|
{ code: "g", dimension: "mass", factor: 1, label: { vi: "g", en: "g" }, scales: true, spellings: ["gram", "grams", "gam"] },
|
|
@@ -21579,9 +21753,11 @@ var MEASURED_UNITS = [
|
|
|
21579
21753
|
{ code: "day", dimension: "duration", factor: 1440, label: { vi: "ng\xE0y", en: "d" }, scales: true, spellings: ["days"] }
|
|
21580
21754
|
];
|
|
21581
21755
|
var COUNTED_UNIT_MAX_LENGTH = 12;
|
|
21582
|
-
var
|
|
21756
|
+
var UNIT_WORDS = `a measured code (${MEASURED_UNITS.map((unit) => unit.code).join(", ")}), which converts and scales within its dimension, or any other noun of at most ${COUNTED_UNIT_MAX_LENGTH} characters (ki\u1EC7n, pallet, TEU), which never does`;
|
|
21757
|
+
var UNIT_DESCRIPTION = `What a plain figure counts or measures, drawn after it: ${UNIT_WORDS}. Only beside format "number".`;
|
|
21583
21758
|
var UNIT_FIELD_DESCRIPTION = 'A single select on the same row, or a lookup of one through a one-link, whose chosen option is that row\'s unit: every option label is a unit as `unit` takes one. In place of `unit`; only beside format "number".';
|
|
21584
21759
|
var CURRENCY_FIELD_DESCRIPTION = 'A single select on the same row, or a lookup of one through a one-link, whose chosen option is that row\'s currency: every option label is an ISO 4217 code. In place of `currency`; only beside format "currency".';
|
|
21760
|
+
var DEFAULT_CURRENCY = "VND";
|
|
21585
21761
|
function unitKey(text2) {
|
|
21586
21762
|
return text2.normalize("NFC").trim().toLocaleLowerCase("vi").replace(/\s+/g, " ");
|
|
21587
21763
|
}
|
|
@@ -21619,88 +21795,162 @@ function numberUnitRefusal(format2, unit) {
|
|
|
21619
21795
|
if (format2 !== void 0 && format2 !== "number") {
|
|
21620
21796
|
return `a unit is for a plain figure (format "number"), not "${format2}": money states its currency and a percent its sign`;
|
|
21621
21797
|
}
|
|
21798
|
+
return unitRefusalWords(unit);
|
|
21799
|
+
}
|
|
21800
|
+
function unitRefusalWords(unit) {
|
|
21622
21801
|
const refusal = unitRefusal(unit);
|
|
21623
21802
|
return refusal === void 0 ? void 0 : refusalWords(unit, refusal);
|
|
21624
21803
|
}
|
|
21625
|
-
|
|
21626
|
-
|
|
21627
|
-
|
|
21628
|
-
|
|
21629
|
-
|
|
21630
|
-
|
|
21631
|
-
|
|
21632
|
-
|
|
21633
|
-
|
|
21634
|
-
return
|
|
21804
|
+
function currencyCodeRefusal(code) {
|
|
21805
|
+
if (Intl.supportedValuesOf("currency").includes(code)) return void 0;
|
|
21806
|
+
const coded = currencyCodeOf(code);
|
|
21807
|
+
return coded !== void 0 ? `a currency is written as its ISO 4217 code: "${coded}"` : `"${code}" is not an ISO 4217 currency code (USD, EUR, VND)`;
|
|
21808
|
+
}
|
|
21809
|
+
var DONG_SPELLINGS = ["vn\u0111", "\u0111", "\u20AB", "\u0111\u1ED3ng"];
|
|
21810
|
+
function currencyCodeOf(written) {
|
|
21811
|
+
const upper2 = written.trim().toUpperCase();
|
|
21812
|
+
if (Intl.supportedValuesOf("currency").includes(upper2)) return upper2;
|
|
21813
|
+
return DONG_SPELLINGS.includes(unitKey(written)) ? "VND" : void 0;
|
|
21814
|
+
}
|
|
21815
|
+
var EXACT_DIGITS = 15;
|
|
21816
|
+
function convert(value, from, to) {
|
|
21817
|
+
return from.code === to.code ? value : Number((value * from.factor / to.factor).toPrecision(EXACT_DIGITS));
|
|
21818
|
+
}
|
|
21819
|
+
function scaleIn(own, pack) {
|
|
21820
|
+
const kin = MEASURED_UNITS.filter((one) => one.dimension === own.dimension);
|
|
21821
|
+
const rung = (one) => ({ label: one.label[pack], factor: convert(1, one, own) });
|
|
21822
|
+
const names = (one) => [...SPELLED].filter(([, spelled]) => spelled.code === one.code).map(([name]) => name);
|
|
21823
|
+
return {
|
|
21824
|
+
label: own.label[pack],
|
|
21825
|
+
ladder: own.scales ? kin.filter((one) => one.scales && one.factor >= own.factor).map(rung) : [rung(own)],
|
|
21826
|
+
entries: [own, ...kin.filter((one) => one.code !== own.code)].map((one) => ({ ...rung(one), names: names(one) }))
|
|
21827
|
+
};
|
|
21635
21828
|
}
|
|
21829
|
+
var SCALES = new Map(
|
|
21830
|
+
MEASURED_UNITS.map((unit) => [unit.code, { vi: scaleIn(unit, "vi"), en: scaleIn(unit, "en") }])
|
|
21831
|
+
);
|
|
21636
21832
|
|
|
21637
|
-
// ../shared/src/
|
|
21638
|
-
|
|
21639
|
-
|
|
21640
|
-
|
|
21641
|
-
|
|
21833
|
+
// ../shared/src/notation.ts
|
|
21834
|
+
var PERCENT = "percent";
|
|
21835
|
+
var DECIMAL = { style: "decimal" };
|
|
21836
|
+
var NOTATION_DESCRIPTION = `How the figure reads: { "style": "decimal" }; money, { "style": "currency", "currency": an ISO 4217 code (USD, VND) }; or a quantity, { "style": "unit", "unit": "${PERCENT}" (10 reads "10%"), or ${UNIT_WORDS} }. A currency or unit read on each row from a single select of that row is { "per_row": that select }.`;
|
|
21837
|
+
function unitIssue(unit, ctx) {
|
|
21838
|
+
const refused = unit === PERCENT ? void 0 : unitRefusalWords(unit);
|
|
21839
|
+
if (refused !== void 0) ctx.addIssue({ code: "custom", message: refused });
|
|
21642
21840
|
}
|
|
21643
|
-
function
|
|
21841
|
+
function notationSchemaOf(reference) {
|
|
21842
|
+
const perRow = external_exports.object({ per_row: reference.describe("The single select of the same row whose option is each row's currency or unit") }).strict();
|
|
21843
|
+
return external_exports.discriminatedUnion("style", [
|
|
21844
|
+
external_exports.object({ style: external_exports.literal("decimal") }).strict(),
|
|
21845
|
+
external_exports.object({ style: external_exports.literal("currency"), currency: external_exports.union([external_exports.string().min(1), perRow]) }).strict(),
|
|
21846
|
+
external_exports.object({ style: external_exports.literal("unit"), unit: external_exports.union([external_exports.string().superRefine(unitIssue), perRow]) }).strict()
|
|
21847
|
+
]).describe(NOTATION_DESCRIPTION);
|
|
21848
|
+
}
|
|
21849
|
+
var notationSchema = notationSchemaOf(external_exports.string().min(1));
|
|
21850
|
+
function notationOfKeys(keys2) {
|
|
21851
|
+
if (keys2.format === "currency") {
|
|
21852
|
+
return { style: "currency", currency: keys2.currency_field ? { per_row: keys2.currency_field } : keys2.currency || DEFAULT_CURRENCY };
|
|
21853
|
+
}
|
|
21854
|
+
if (keys2.unit_field) return { style: "unit", unit: { per_row: keys2.unit_field } };
|
|
21855
|
+
if (keys2.unit) return { style: "unit", unit: keys2.unit };
|
|
21856
|
+
if (keys2.format === "percentage") return { style: "unit", unit: PERCENT };
|
|
21857
|
+
return DECIMAL;
|
|
21858
|
+
}
|
|
21859
|
+
var KEYS_BEFORE_NOTATION = ["format", "currency", "unit", "unit_field", "currency_field"];
|
|
21860
|
+
function keysStated(keys2) {
|
|
21861
|
+
return KEYS_BEFORE_NOTATION.some((key) => Boolean(keys2[key]));
|
|
21862
|
+
}
|
|
21863
|
+
function sameValue(a, b) {
|
|
21864
|
+
return typeof a === "string" || typeof b === "string" ? a === b : a.per_row === b.per_row;
|
|
21865
|
+
}
|
|
21866
|
+
function sameNotation(a, b) {
|
|
21867
|
+
if (a === void 0 || b === void 0) return a === b;
|
|
21868
|
+
if (a.style === "currency" && b.style === "currency") return sameValue(a.currency, b.currency);
|
|
21869
|
+
if (a.style === "unit" && b.style === "unit") return sameValue(a.unit, b.unit);
|
|
21870
|
+
return a.style === "decimal" && b.style === "decimal";
|
|
21871
|
+
}
|
|
21872
|
+
function storedNotation(notation, keys2) {
|
|
21873
|
+
if (notation == null) return notationOfKeys(keys2);
|
|
21874
|
+
if (!keysStated(keys2)) return notation;
|
|
21875
|
+
const derived = notationOfKeys(keys2);
|
|
21876
|
+
return sameNotation(notation, derived) ? notation : derived;
|
|
21877
|
+
}
|
|
21878
|
+
function fieldNotation(field) {
|
|
21644
21879
|
switch (field.type) {
|
|
21645
21880
|
case "number":
|
|
21646
|
-
return
|
|
21881
|
+
return storedNotation(field.notation, field);
|
|
21647
21882
|
case "formula": {
|
|
21648
|
-
const
|
|
21649
|
-
|
|
21883
|
+
const formula = field.formula;
|
|
21884
|
+
const output = formula?.output_type;
|
|
21885
|
+
return output == null || output === "number" ? storedNotation(formula?.notation, formula ?? {}) : void 0;
|
|
21650
21886
|
}
|
|
21651
21887
|
case "rollup": {
|
|
21652
21888
|
const operation = field.aggregate_option?.operation;
|
|
21653
|
-
|
|
21889
|
+
if (!isAggregateOperation(operation) || rollupOutputType(operation) !== "number") return void 0;
|
|
21890
|
+
return storedNotation(field.aggregate_field_notation, {
|
|
21891
|
+
format: field.aggregate_field_format,
|
|
21892
|
+
currency: field.aggregate_field_currency,
|
|
21893
|
+
unit: field.aggregate_field_unit,
|
|
21894
|
+
unit_field: field.aggregate_field_unit_field,
|
|
21895
|
+
currency_field: field.aggregate_field_currency_field
|
|
21896
|
+
});
|
|
21654
21897
|
}
|
|
21898
|
+
case "lookup":
|
|
21899
|
+
return field.lookup_field_type === "number" ? storedNotation(field.lookup_field_notation, { format: field.lookup_field_format, currency: field.lookup_field_currency, unit: field.lookup_field_unit }) : void 0;
|
|
21655
21900
|
default:
|
|
21656
21901
|
return void 0;
|
|
21657
21902
|
}
|
|
21658
21903
|
}
|
|
21659
|
-
function
|
|
21660
|
-
if (
|
|
21661
|
-
|
|
21662
|
-
if (typeof entry === "string") return entry;
|
|
21663
|
-
const inner = firstOptionKey(entry);
|
|
21664
|
-
if (inner !== void 0) return inner;
|
|
21665
|
-
}
|
|
21904
|
+
function notationRowSelect(notation) {
|
|
21905
|
+
if (notation?.style === "currency" && typeof notation.currency !== "string") return { vocabulary: "currency", key: notation.currency.per_row };
|
|
21906
|
+
if (notation?.style === "unit" && typeof notation.unit !== "string") return { vocabulary: "unit", key: notation.unit.per_row };
|
|
21666
21907
|
return void 0;
|
|
21667
21908
|
}
|
|
21668
|
-
function
|
|
21669
|
-
return
|
|
21909
|
+
function notationCurrency(notation) {
|
|
21910
|
+
return notation?.style === "currency" && typeof notation.currency === "string" ? notation.currency : void 0;
|
|
21670
21911
|
}
|
|
21671
|
-
function
|
|
21672
|
-
return
|
|
21912
|
+
function notationSaid(figure) {
|
|
21913
|
+
return { stated: figure.notation ?? void 0, byKeys: keysStated(figure) ? notationOfKeys(figure) : void 0, keys: figure };
|
|
21673
21914
|
}
|
|
21674
|
-
function
|
|
21675
|
-
|
|
21676
|
-
|
|
21677
|
-
|
|
21678
|
-
|
|
21679
|
-
|
|
21680
|
-
|
|
21681
|
-
|
|
21682
|
-
|
|
21683
|
-
|
|
21684
|
-
|
|
21685
|
-
|
|
21686
|
-
|
|
21687
|
-
|
|
21688
|
-
|
|
21689
|
-
const
|
|
21690
|
-
if (
|
|
21691
|
-
|
|
21915
|
+
function sameReading(a, b) {
|
|
21916
|
+
return a === "link" || b === "link" ? a === b : sameNotation(a, b);
|
|
21917
|
+
}
|
|
21918
|
+
function readingWords(reading) {
|
|
21919
|
+
return reading === "link" ? "a link" : JSON.stringify(reading);
|
|
21920
|
+
}
|
|
21921
|
+
function heldReading(stored) {
|
|
21922
|
+
return stored.byKeys ?? stored.stated;
|
|
21923
|
+
}
|
|
21924
|
+
function leftReading(written, stored) {
|
|
21925
|
+
if (stored === void 0) return { changed: written.stated, left: written.stated };
|
|
21926
|
+
const changed2 = sameReading(written.stated, stored.stated) ? void 0 : written.stated;
|
|
21927
|
+
return { changed: changed2, left: changed2 ?? heldReading(stored) ?? written.stated };
|
|
21928
|
+
}
|
|
21929
|
+
function keysRefusal(written, stored) {
|
|
21930
|
+
const { byKeys } = written;
|
|
21931
|
+
if (byKeys === void 0 || stored !== void 0 && sameReading(byKeys, stored.byKeys)) return void 0;
|
|
21932
|
+
const { changed: changed2, left } = leftReading(written, stored);
|
|
21933
|
+
if (sameReading(byKeys, left ?? DECIMAL)) return void 0;
|
|
21934
|
+
const keys2 = KEYS_BEFORE_NOTATION.flatMap((name) => written.keys[name] ? [`${name} ${JSON.stringify(written.keys[name])}`] : []);
|
|
21935
|
+
if (changed2 !== void 0) {
|
|
21936
|
+
const key = changed2 === "link" ? "link" : "notation";
|
|
21937
|
+
return `"${key}" says ${readingWords(changed2)} and ${keys2.join(", ")} ${keys2.length === 1 ? "says" : "say"} ${readingWords(byKeys)}, and the keys before "notation" are no longer read \u2014 state "${key}" alone`;
|
|
21692
21938
|
}
|
|
21693
|
-
const
|
|
21694
|
-
|
|
21695
|
-
const kin = options.flatMap((candidate) => {
|
|
21696
|
-
const measured = measuredUnit(candidate.name);
|
|
21697
|
-
return measured?.dimension === target.dimension ? [{ key: candidate.key, factor: measured.factor }] : [];
|
|
21698
|
-
});
|
|
21699
|
-
return { ok: true, unit: { select: read2, options: kin, factor: target.factor } };
|
|
21939
|
+
const state = byKeys === "link" ? '"link": true' : `"notation": ${JSON.stringify(byKeys)}`;
|
|
21940
|
+
return `${keys2.join(", ")} ${keys2.length === 1 ? "is" : "are"} no longer read \u2014 state ${state}`;
|
|
21700
21941
|
}
|
|
21701
|
-
function
|
|
21702
|
-
const
|
|
21703
|
-
|
|
21942
|
+
function settledReading(written, stored) {
|
|
21943
|
+
const refused = keysRefusal(written, stored);
|
|
21944
|
+
if (refused !== void 0) return { refusal: refused };
|
|
21945
|
+
return checkedReading(leftReading(written, stored).left ?? written.byKeys, stored === void 0 ? void 0 : heldReading(stored));
|
|
21946
|
+
}
|
|
21947
|
+
function checkedReading(reading, held2) {
|
|
21948
|
+
const refused = changedCurrencyRefusal(reading, held2);
|
|
21949
|
+
return refused === void 0 ? { reading } : { refusal: refused };
|
|
21950
|
+
}
|
|
21951
|
+
function changedCurrencyRefusal(reading, held2) {
|
|
21952
|
+
const currency = reading === "link" || sameReading(reading, held2) ? void 0 : notationCurrency(reading);
|
|
21953
|
+
return currency === void 0 ? void 0 : currencyCodeRefusal(currency);
|
|
21704
21954
|
}
|
|
21705
21955
|
|
|
21706
21956
|
// ../shared/src/icon_names.generated.ts
|
|
@@ -23625,7 +23875,11 @@ var KIT_GLYPH_NAMES = [
|
|
|
23625
23875
|
"align-center",
|
|
23626
23876
|
"align-left",
|
|
23627
23877
|
"align-right",
|
|
23878
|
+
"align-vertical-justify-center",
|
|
23879
|
+
"align-vertical-justify-end",
|
|
23880
|
+
"align-vertical-justify-start",
|
|
23628
23881
|
"arrow-down",
|
|
23882
|
+
"arrow-down-a-z",
|
|
23629
23883
|
"arrow-down-up",
|
|
23630
23884
|
"arrow-down-wide-narrow",
|
|
23631
23885
|
"arrow-left",
|
|
@@ -23636,10 +23890,13 @@ var KIT_GLYPH_NAMES = [
|
|
|
23636
23890
|
"arrow-up",
|
|
23637
23891
|
"arrow-up-down",
|
|
23638
23892
|
"arrow-up-wide-narrow",
|
|
23893
|
+
"arrow-up-z-a",
|
|
23639
23894
|
"ban",
|
|
23640
23895
|
"banknote",
|
|
23641
23896
|
"bed",
|
|
23642
23897
|
"bell",
|
|
23898
|
+
"between-horizontal-start",
|
|
23899
|
+
"between-vertical-start",
|
|
23643
23900
|
"bold",
|
|
23644
23901
|
"bolt",
|
|
23645
23902
|
"book-marked",
|
|
@@ -23667,17 +23924,23 @@ var KIT_GLYPH_NAMES = [
|
|
|
23667
23924
|
"chevrons-up-down",
|
|
23668
23925
|
"circle-alert",
|
|
23669
23926
|
"circle-check",
|
|
23927
|
+
"circle-x",
|
|
23670
23928
|
"clipboard-list",
|
|
23929
|
+
"clipboard-paste",
|
|
23671
23930
|
"clock",
|
|
23672
23931
|
"code",
|
|
23673
23932
|
"code-xml",
|
|
23674
23933
|
"columns-3",
|
|
23675
23934
|
"columns-3-cog",
|
|
23935
|
+
"combine",
|
|
23676
23936
|
"construction",
|
|
23677
23937
|
"container",
|
|
23678
23938
|
"copy",
|
|
23679
23939
|
"credit-card",
|
|
23680
23940
|
"database",
|
|
23941
|
+
"decimals-arrow-left",
|
|
23942
|
+
"decimals-arrow-right",
|
|
23943
|
+
"dollar-sign",
|
|
23681
23944
|
"download",
|
|
23682
23945
|
"ellipsis",
|
|
23683
23946
|
"eraser",
|
|
@@ -23704,9 +23967,11 @@ var KIT_GLYPH_NAMES = [
|
|
|
23704
23967
|
"gauge",
|
|
23705
23968
|
"globe",
|
|
23706
23969
|
"gpu",
|
|
23970
|
+
"grid-2x2",
|
|
23707
23971
|
"grip-vertical",
|
|
23708
23972
|
"group",
|
|
23709
23973
|
"hand-coins",
|
|
23974
|
+
"hash",
|
|
23710
23975
|
"heading",
|
|
23711
23976
|
"heading-1",
|
|
23712
23977
|
"heading-2",
|
|
@@ -23759,6 +24024,7 @@ var KIT_GLYPH_NAMES = [
|
|
|
23759
24024
|
"notepad-text-dashed",
|
|
23760
24025
|
"package",
|
|
23761
24026
|
"paint-bucket",
|
|
24027
|
+
"paintbrush-vertical",
|
|
23762
24028
|
"palette",
|
|
23763
24029
|
"panel-left",
|
|
23764
24030
|
"panel-left-close",
|
|
@@ -23769,6 +24035,7 @@ var KIT_GLYPH_NAMES = [
|
|
|
23769
24035
|
"paperclip",
|
|
23770
24036
|
"pause",
|
|
23771
24037
|
"pencil",
|
|
24038
|
+
"percent",
|
|
23772
24039
|
"phone",
|
|
23773
24040
|
"pin",
|
|
23774
24041
|
"pin-off",
|
|
@@ -23783,7 +24050,9 @@ var KIT_GLYPH_NAMES = [
|
|
|
23783
24050
|
"repeat",
|
|
23784
24051
|
"rotate-ccw",
|
|
23785
24052
|
"rotate-cw",
|
|
24053
|
+
"rows-3",
|
|
23786
24054
|
"scan",
|
|
24055
|
+
"scissors",
|
|
23787
24056
|
"search",
|
|
23788
24057
|
"send",
|
|
23789
24058
|
"settings",
|
|
@@ -23793,9 +24062,11 @@ var KIT_GLYPH_NAMES = [
|
|
|
23793
24062
|
"shield-alert",
|
|
23794
24063
|
"shield-check",
|
|
23795
24064
|
"shopping-cart",
|
|
24065
|
+
"sigma",
|
|
23796
24066
|
"sliders-horizontal",
|
|
23797
24067
|
"smile",
|
|
23798
24068
|
"smile-plus",
|
|
24069
|
+
"snowflake",
|
|
23799
24070
|
"sparkles",
|
|
23800
24071
|
"split",
|
|
23801
24072
|
"square",
|
|
@@ -23804,11 +24075,13 @@ var KIT_GLYPH_NAMES = [
|
|
|
23804
24075
|
"square-sigma",
|
|
23805
24076
|
"stethoscope",
|
|
23806
24077
|
"sticky-note",
|
|
24078
|
+
"strikethrough",
|
|
23807
24079
|
"table",
|
|
23808
24080
|
"table-2",
|
|
23809
24081
|
"tag",
|
|
23810
24082
|
"target",
|
|
23811
24083
|
"text-quote",
|
|
24084
|
+
"text-wrap",
|
|
23812
24085
|
"thumbs-down",
|
|
23813
24086
|
"thumbs-up",
|
|
23814
24087
|
"ticket",
|
|
@@ -23819,6 +24092,7 @@ var KIT_GLYPH_NAMES = [
|
|
|
23819
24092
|
"truck",
|
|
23820
24093
|
"tv-minimal",
|
|
23821
24094
|
"twitter",
|
|
24095
|
+
"type",
|
|
23822
24096
|
"underline",
|
|
23823
24097
|
"undo",
|
|
23824
24098
|
"upload",
|
|
@@ -23831,7 +24105,9 @@ var KIT_GLYPH_NAMES = [
|
|
|
23831
24105
|
"workflow",
|
|
23832
24106
|
"wrench",
|
|
23833
24107
|
"x",
|
|
23834
|
-
"zap"
|
|
24108
|
+
"zap",
|
|
24109
|
+
"zoom-in",
|
|
24110
|
+
"zoom-out"
|
|
23835
24111
|
];
|
|
23836
24112
|
|
|
23837
24113
|
// ../shared/src/icon_names.ts
|
|
@@ -23971,179 +24247,67 @@ function everyOptionMarked(nameOf2) {
|
|
|
23971
24247
|
};
|
|
23972
24248
|
}
|
|
23973
24249
|
|
|
23974
|
-
// ../shared/src/
|
|
23975
|
-
|
|
23976
|
-
|
|
23977
|
-
|
|
23978
|
-
|
|
23979
|
-
|
|
23980
|
-
|
|
23981
|
-
|
|
23982
|
-
|
|
23983
|
-
|
|
23984
|
-
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
|
|
23988
|
-
|
|
23989
|
-
|
|
23990
|
-
|
|
23991
|
-
)
|
|
23992
|
-
|
|
23993
|
-
|
|
23994
|
-
|
|
23995
|
-
|
|
23996
|
-
|
|
23997
|
-
|
|
23998
|
-
|
|
23999
|
-
|
|
24000
|
-
|
|
24001
|
-
|
|
24002
|
-
|
|
24003
|
-
|
|
24004
|
-
|
|
24005
|
-
|
|
24006
|
-
|
|
24007
|
-
|
|
24008
|
-
|
|
24009
|
-
});
|
|
24010
|
-
|
|
24011
|
-
(
|
|
24012
|
-
|
|
24013
|
-
|
|
24014
|
-
|
|
24015
|
-
|
|
24016
|
-
|
|
24017
|
-
}
|
|
24018
|
-
}
|
|
24019
|
-
|
|
24020
|
-
|
|
24021
|
-
|
|
24022
|
-
|
|
24023
|
-
|
|
24024
|
-
|
|
24025
|
-
|
|
24026
|
-
|
|
24027
|
-
|
|
24028
|
-
|
|
24029
|
-
|
|
24030
|
-
|
|
24031
|
-
|
|
24032
|
-
|
|
24033
|
-
|
|
24034
|
-
var memberGroupSchema = zod_default.object({
|
|
24035
|
-
id: zod_default.string().describe("Unique identifier for the member group"),
|
|
24036
|
-
name: zod_default.string().describe("Display name of the group"),
|
|
24037
|
-
description: zod_default.string().optional().describe("Optional description of the group's purpose"),
|
|
24038
|
-
member_ids: zod_default.array(zod_default.string()).describe("Array of member IDs in this group"),
|
|
24039
|
-
invitation_ids: zod_default.array(zod_default.string()).describe("Array of pending invitation IDs pre-granted membership; migrated to member_ids on accept"),
|
|
24040
|
-
organization_id: zod_default.string().describe("ID of the organization this group belongs to"),
|
|
24041
|
-
created_at: zod_default.string().describe("Timestamp when group was created"),
|
|
24042
|
-
created_by: zod_default.string().describe("Member ID of the user who created this group")
|
|
24043
|
-
});
|
|
24044
|
-
var principalGroupSchema = zod_default.object({
|
|
24045
|
-
id: zod_default.string().describe("Unique identifier for the member group"),
|
|
24046
|
-
name: zod_default.string().describe("Display name of the group"),
|
|
24047
|
-
description: zod_default.string().optional().describe("Optional description of the group's purpose"),
|
|
24048
|
-
member_count: zod_default.number().int().describe("Number of accepted members in the group"),
|
|
24049
|
-
invitation_count: zod_default.number().int().describe("Number of pending invitations pre-granted membership")
|
|
24050
|
-
});
|
|
24051
|
-
var PUBLIC_PRINCIPAL_ID = "public";
|
|
24052
|
-
var principalSchema = zod_default.discriminatedUnion("type", [
|
|
24053
|
-
zod_default.object({
|
|
24054
|
-
type: zod_default.literal("member").describe("Principal type: individual member"),
|
|
24055
|
-
id: zod_default.string().describe("Member ID")
|
|
24056
|
-
}),
|
|
24057
|
-
zod_default.object({
|
|
24058
|
-
type: zod_default.literal("member_group").describe("Principal type: group of members"),
|
|
24059
|
-
id: zod_default.string().describe("Member group ID")
|
|
24060
|
-
}),
|
|
24061
|
-
zod_default.object({
|
|
24062
|
-
type: zod_default.literal("organization").describe("Principal type: all members in organization"),
|
|
24063
|
-
id: zod_default.string().describe("Organization ID")
|
|
24064
|
-
}),
|
|
24065
|
-
zod_default.object({
|
|
24066
|
-
type: zod_default.literal("public").describe("Principal type: anyone, including unauthenticated visitors"),
|
|
24067
|
-
id: zod_default.literal(PUBLIC_PRINCIPAL_ID).describe("Always the `public` sentinel \u2014 no entity")
|
|
24068
|
-
}),
|
|
24069
|
-
// Pending invitation as principal: lets admins pre-grant group membership and
|
|
24070
|
-
// resource access before the invitee accepts. Never resolved as a Subject —
|
|
24071
|
-
// a pending invitee cannot authenticate, so these bindings stay dormant until
|
|
24072
|
-
// accept-time migration rewrites them to type:"member".
|
|
24073
|
-
zod_default.object({
|
|
24074
|
-
type: zod_default.literal("invitation").describe("Principal type: pending invitation (not yet accepted)"),
|
|
24075
|
-
id: zod_default.string().describe("Invitation ID")
|
|
24076
|
-
})
|
|
24077
|
-
]);
|
|
24078
|
-
var subjectSchema = zod_default.discriminatedUnion("type", [
|
|
24079
|
-
zod_default.object({
|
|
24080
|
-
type: zod_default.literal("member").describe("Subject type: authenticated member"),
|
|
24081
|
-
id: zod_default.string().describe("Member ID")
|
|
24082
|
-
}),
|
|
24083
|
-
zod_default.object({
|
|
24084
|
-
type: zod_default.literal("public").describe("Subject type: unauthenticated visitor")
|
|
24085
|
-
})
|
|
24086
|
-
]);
|
|
24087
|
-
var resourceTypeSchema = zod_default.enum(["table", "table_view", "app", "automation", "skill", "document_template", "instruction", "knowledge_doc", "connected_account"]);
|
|
24088
|
-
var RESOURCE_ROLE_ACTIONS = {
|
|
24089
|
-
table: {
|
|
24090
|
-
editor: ["read_data", "write_data"],
|
|
24091
|
-
viewer: ["read_data"]
|
|
24092
|
-
},
|
|
24093
|
-
app: { manager: ["use", "manage"], user: ["use"] },
|
|
24094
|
-
skill: { manager: ["use", "manage"], user: ["use"] },
|
|
24095
|
-
document_template: { manager: ["use", "manage"], user: ["use"] },
|
|
24096
|
-
instruction: { manager: ["use", "manage"], user: ["use"] },
|
|
24097
|
-
knowledge_doc: { manager: ["use", "manage"], user: ["use"] },
|
|
24098
|
-
connected_account: { manager: ["use", "manage"], user: ["use"] },
|
|
24099
|
-
table_view: {},
|
|
24100
|
-
automation: {}
|
|
24101
|
-
};
|
|
24102
|
-
function shareableRolesFor(type) {
|
|
24103
|
-
return Object.keys(RESOURCE_ROLE_ACTIONS[type]);
|
|
24250
|
+
// ../shared/src/select_option_enrichment.ts
|
|
24251
|
+
function effectiveSelectOptions(field) {
|
|
24252
|
+
if (field === void 0) return null;
|
|
24253
|
+
if (field.type === "select") return field.options ?? null;
|
|
24254
|
+
if (field.type === "formula") return field.formula?.options ?? null;
|
|
24255
|
+
if (field.type === "lookup" && field.lookup_field_type === "select") {
|
|
24256
|
+
return field.lookup_field_options ?? null;
|
|
24257
|
+
}
|
|
24258
|
+
return null;
|
|
24259
|
+
}
|
|
24260
|
+
|
|
24261
|
+
// ../shared/src/row_figure.ts
|
|
24262
|
+
function figureRowSelect(field) {
|
|
24263
|
+
return notationRowSelect(fieldNotation(field));
|
|
24264
|
+
}
|
|
24265
|
+
function firstOptionKey(cell) {
|
|
24266
|
+
if (!Array.isArray(cell)) return void 0;
|
|
24267
|
+
for (const entry of cell) {
|
|
24268
|
+
if (typeof entry === "string") return entry;
|
|
24269
|
+
const inner = firstOptionKey(entry);
|
|
24270
|
+
if (inner !== void 0) return inner;
|
|
24271
|
+
}
|
|
24272
|
+
return void 0;
|
|
24273
|
+
}
|
|
24274
|
+
function comparesFigure(operator) {
|
|
24275
|
+
return operator !== "is_empty" && operator !== "is_not_empty";
|
|
24276
|
+
}
|
|
24277
|
+
function nameOf(field) {
|
|
24278
|
+
return `"${field.name ?? field.key}"`;
|
|
24279
|
+
}
|
|
24280
|
+
function conditionUnit(condition2, field, fieldOf2) {
|
|
24281
|
+
if (!comparesFigure(condition2.operator)) return { ok: true, unit: void 0 };
|
|
24282
|
+
const stated = condition2.unit_option;
|
|
24283
|
+
const read2 = figureRowSelect(field);
|
|
24284
|
+
if (read2 === void 0) {
|
|
24285
|
+
return stated === void 0 ? { ok: true, unit: void 0 } : { ok: false, reason: `${nameOf(field)} is read in one unit for every row, so a condition on it states no unit_option.` };
|
|
24286
|
+
}
|
|
24287
|
+
const select = fieldOf2(read2.key);
|
|
24288
|
+
const options = effectiveSelectOptions(select) ?? [];
|
|
24289
|
+
const held2 = options.length === 0 ? `${select === void 0 ? `"${read2.key}"` : nameOf(select)} holds no ${read2.vocabulary} yet` : `one of ${options.map((option2) => `${option2.name} (${option2.key})`).join(", ")}`;
|
|
24290
|
+
const reads = `${nameOf(field)} is read in each row's own ${read2.vocabulary} (${select === void 0 ? `"${read2.key}"` : nameOf(select)})`;
|
|
24291
|
+
if (stated === void 0) {
|
|
24292
|
+
const unstated = condition2.value === null || condition2.value === void 0 || condition2.value === "";
|
|
24293
|
+
return unstated ? { ok: true, unit: void 0 } : { ok: false, reason: `${reads}, so '${condition2.operator}' states the ${read2.vocabulary} its value is in as unit_option: ${held2}.` };
|
|
24294
|
+
}
|
|
24295
|
+
const option = typeof stated === "string" ? options.find((candidate) => candidate.key === stated) : void 0;
|
|
24296
|
+
if (option === void 0) {
|
|
24297
|
+
return { ok: false, reason: `${reads}; unit_option ${JSON.stringify(stated)} is none of them: ${held2}.` };
|
|
24298
|
+
}
|
|
24299
|
+
const target = read2.vocabulary === "unit" ? measuredUnit(option.name) : void 0;
|
|
24300
|
+
if (target === void 0) return { ok: true, unit: { select: read2, options: [{ key: option.key, factor: 1 }], factor: 1 } };
|
|
24301
|
+
const kin = options.flatMap((candidate) => {
|
|
24302
|
+
const measured = measuredUnit(candidate.name);
|
|
24303
|
+
return measured?.dimension === target.dimension ? [{ key: candidate.key, factor: measured.factor }] : [];
|
|
24304
|
+
});
|
|
24305
|
+
return { ok: true, unit: { select: read2, options: kin, factor: target.factor } };
|
|
24306
|
+
}
|
|
24307
|
+
function rowUnitFactor(unit, data) {
|
|
24308
|
+
const key = firstOptionKey(data[unit.select.key]);
|
|
24309
|
+
return key === void 0 ? void 0 : unit.options.find((option) => option.key === key)?.factor;
|
|
24104
24310
|
}
|
|
24105
|
-
var SHAREABLE_RESOURCE_TYPES = resourceTypeSchema.options.filter(
|
|
24106
|
-
(type) => shareableRolesFor(type).length > 0
|
|
24107
|
-
);
|
|
24108
|
-
var accessPrincipalSchema = zod_default.discriminatedUnion("type", [
|
|
24109
|
-
zod_default.object({
|
|
24110
|
-
type: zod_default.literal("member").describe("Principal type: an individual member"),
|
|
24111
|
-
id: zod_default.string().describe("Member ID")
|
|
24112
|
-
}),
|
|
24113
|
-
zod_default.object({
|
|
24114
|
-
type: zod_default.literal("member_group").describe("Principal type: a member group"),
|
|
24115
|
-
id: zod_default.string().describe("Group ID")
|
|
24116
|
-
}),
|
|
24117
|
-
zod_default.object({
|
|
24118
|
-
type: zod_default.literal("organization").describe("Principal type: everyone in the organization"),
|
|
24119
|
-
id: zod_default.string().describe("Organization ID")
|
|
24120
|
-
})
|
|
24121
|
-
]);
|
|
24122
|
-
var resourceAccessSchema = zod_default.object({
|
|
24123
|
-
resource_id: zod_default.string().describe("ID of the resource these principals can reach"),
|
|
24124
|
-
principals: zod_default.array(accessPrincipalSchema).describe("Members, groups and the organization that have been granted access")
|
|
24125
|
-
});
|
|
24126
|
-
var contentResourceTypeSchema = zod_default.enum(["knowledge_doc", "document_template"]);
|
|
24127
|
-
var contentItemSchema = zod_default.object({
|
|
24128
|
-
id: zod_default.string().describe("ID of the knowledge doc or template"),
|
|
24129
|
-
name: zod_default.string().describe("Its name"),
|
|
24130
|
-
owner_member_id: zod_default.string().nullable().describe("Member who owns it; null when nobody does"),
|
|
24131
|
-
created_at: zod_default.string().describe("When it was created"),
|
|
24132
|
-
updated_at: zod_default.string().nullable().describe("When a knowledge doc was last changed; null for a template"),
|
|
24133
|
-
hidden_at: zod_default.string().nullable().describe("When a knowledge doc was hidden; null when it is in use, and for a template"),
|
|
24134
|
-
template_type: zod_default.string().nullable().describe("A template's type (html, email, word, excel, pdf-form); null for a knowledge doc"),
|
|
24135
|
-
can_open: zod_default.boolean().describe("Whether the caller may open it; false means it is not shared with them"),
|
|
24136
|
-
principals: zod_default.array(accessPrincipalSchema).describe("Members, groups and the organization it has been shared with, besides its owner")
|
|
24137
|
-
});
|
|
24138
|
-
var resourceRoleBindingSchema = zod_default.object({
|
|
24139
|
-
id: zod_default.string().describe("Unique identifier for the role binding"),
|
|
24140
|
-
principal: principalSchema.describe(
|
|
24141
|
-
"Who this role binding applies to (member, group, or organization)"
|
|
24142
|
-
),
|
|
24143
|
-
resource_type: resourceTypeSchema.describe("Type of resource being accessed"),
|
|
24144
|
-
resource_id: zod_default.string().describe("ID of the specific resource"),
|
|
24145
|
-
role: zod_default.string().describe("Role name (e.g., 'viewer', 'editor', 'manager', 'user')")
|
|
24146
|
-
});
|
|
24147
24311
|
|
|
24148
24312
|
// ../shared/src/diacritics.ts
|
|
24149
24313
|
var COMBINING_MARKS = /[̀-ͯ]/g;
|
|
@@ -24738,22 +24902,35 @@ function perRowRefusals(value) {
|
|
|
24738
24902
|
...currencyField.map((message2) => ({ key: "currency_field", message: message2 }))
|
|
24739
24903
|
];
|
|
24740
24904
|
}
|
|
24905
|
+
function figureKeysRefusals(value) {
|
|
24906
|
+
const refused = numberUnitRefusal(value.format, value.unit);
|
|
24907
|
+
return [...refused === void 0 ? [] : [{ key: "unit", message: refused }], ...perRowRefusals(value)];
|
|
24908
|
+
}
|
|
24741
24909
|
function figureIssue(path) {
|
|
24742
24910
|
return (value, ctx) => {
|
|
24743
|
-
const
|
|
24744
|
-
|
|
24745
|
-
|
|
24911
|
+
for (const { key, message: message2 } of figureKeysRefusals(value)) ctx.addIssue({ code: "custom", message: message2, path: [...path, key] });
|
|
24912
|
+
};
|
|
24913
|
+
}
|
|
24914
|
+
var BEFORE_NOTATION = 'Replaced by "notation", and never read: naming another reading in it is refused.';
|
|
24915
|
+
function notationStatedIssue(path) {
|
|
24916
|
+
return (value, ctx) => {
|
|
24917
|
+
if (value.notation === void 0) return;
|
|
24918
|
+
const settled = settledReading(notationSaid(value), void 0);
|
|
24919
|
+
if ("refusal" in settled) ctx.addIssue({ code: "custom", message: settled.refusal, path: [...path, "notation"] });
|
|
24746
24920
|
};
|
|
24747
24921
|
}
|
|
24748
|
-
var
|
|
24922
|
+
var tableNumberFieldShape = tableFieldBaseSchema.extend({
|
|
24749
24923
|
type: zod_default.literal("number"),
|
|
24750
|
-
|
|
24751
|
-
|
|
24752
|
-
|
|
24753
|
-
|
|
24754
|
-
|
|
24924
|
+
notation: notationSchema.optional(),
|
|
24925
|
+
format: numberFormatSchema.describe(BEFORE_NOTATION),
|
|
24926
|
+
currency: zod_default.string().nullish().describe(`ISO 4217 code. null clears it. ${BEFORE_NOTATION}`),
|
|
24927
|
+
unit: zod_default.string().nullish().describe(`${UNIT_DESCRIPTION} null clears it. ${BEFORE_NOTATION}`),
|
|
24928
|
+
unit_field: zod_default.string().nullish().describe(`${UNIT_FIELD_DESCRIPTION} null clears it. ${BEFORE_NOTATION}`),
|
|
24929
|
+
currency_field: zod_default.string().nullish().describe(`${CURRENCY_FIELD_DESCRIPTION} null clears it. ${BEFORE_NOTATION}`),
|
|
24755
24930
|
default_value: numberDefaultValueSchema
|
|
24756
|
-
})
|
|
24931
|
+
});
|
|
24932
|
+
var tableNumberFieldSchema = tableNumberFieldShape.superRefine(figureIssue([]));
|
|
24933
|
+
var tableNumberFieldInputSchema = tableNumberFieldShape.extend({ format: numberFormatSchema.optional().describe(BEFORE_NOTATION) }).superRefine(figureIssue([]));
|
|
24757
24934
|
var tableTextFieldSchema = tableFieldBaseSchema.extend({
|
|
24758
24935
|
type: zod_default.literal("text"),
|
|
24759
24936
|
unique: zod_default.boolean().optional().describe("Unique values required"),
|
|
@@ -24846,6 +25023,9 @@ var tableRollupFieldSchema = tableFieldBaseSchema.extend({
|
|
|
24846
25023
|
aggregate_field_type: tableFieldTypeNameSchema.optional().describe(
|
|
24847
25024
|
"What this rollup's CELL holds \u2014 'date' for earliest/latest, 'number' for every other operation (counts, sums, percentages). Derived from the operation, not from the aggregated field: a 'filled' count over a files column is a number. Server-derived at write time; ignored on input."
|
|
24848
25025
|
),
|
|
25026
|
+
aggregate_field_notation: notationSchema.optional().describe(
|
|
25027
|
+
`How this rollup's figure reads. Operations that preserve the aggregated value's unit (sum/avg/median/min/max/range) inherit the target field's; counts are a decimal, percentages the unit "percent". Server-derived at write time; ignored on input.`
|
|
25028
|
+
),
|
|
24849
25029
|
aggregate_field_format: zod_default.string().optional().describe(
|
|
24850
25030
|
"The format of this rollup's own value. Operations that preserve the aggregated value's unit (sum/avg/median/min/max/range/earliest/latest) inherit the target field's format; counting operations are 'number', percentages 'percentage'. Server-derived at write time; ignored on input."
|
|
24851
25031
|
),
|
|
@@ -24873,6 +25053,9 @@ var tableLookupFieldSchema = tableFieldBaseSchema.extend({
|
|
|
24873
25053
|
lookup_field_type: tableFieldTypeNameSchema.optional().describe(
|
|
24874
25054
|
"The type of the target lookup field (e.g. 'text', 'number', 'date'). Resolved from the linked table's field definition at read time."
|
|
24875
25055
|
),
|
|
25056
|
+
lookup_field_notation: notationSchema.optional().describe(
|
|
25057
|
+
"How the looked-up figure reads, where the target lookup field holds a number. Resolved from the linked table's field definition at write time."
|
|
25058
|
+
),
|
|
24876
25059
|
lookup_field_format: zod_default.string().optional().describe(
|
|
24877
25060
|
"The format of the target lookup field (e.g. 'currency', 'percentage', 'datetime'). Resolved from the linked table's field definition at read time."
|
|
24878
25061
|
),
|
|
@@ -24885,6 +25068,9 @@ var tableLookupFieldSchema = tableFieldBaseSchema.extend({
|
|
|
24885
25068
|
lookup_field_options: zod_default.array(zod_default.object({ key: zod_default.string(), name: zod_default.string(), color: zod_default.string().optional(), mark: storedOptionMarkSchema.optional() })).optional().describe(
|
|
24886
25069
|
"Options for select-type lookup fields. Synced from the source select field's options."
|
|
24887
25070
|
),
|
|
25071
|
+
lookup_field_autonumber: zod_default.boolean().optional().describe(
|
|
25072
|
+
"True where the looked-up value is an autonumber's text, which sorts by its number where it is a bare one. Synced from the looked-up field."
|
|
25073
|
+
),
|
|
24888
25074
|
order_by: lookupOrderBySchema.optional().describe(
|
|
24889
25075
|
"When set, sort the linked records by this field on the linked table and return ONLY the picked field from the single extreme record (desc=latest, asc=earliest), as a one-element array. Omit to return every linked record's value as an array. field_key must be a field on the linked table."
|
|
24890
25076
|
)
|
|
@@ -24897,25 +25083,36 @@ var formulaInputSchema = zod_default.object({
|
|
|
24897
25083
|
expression: zod_default.string().describe(
|
|
24898
25084
|
"JavaScript expression. Uses {Field Name} for field references."
|
|
24899
25085
|
),
|
|
24900
|
-
|
|
24901
|
-
|
|
24902
|
-
),
|
|
24903
|
-
currency: zod_default.string().optional().describe(
|
|
24904
|
-
unit: zod_default.string().optional().describe(UNIT_DESCRIPTION),
|
|
24905
|
-
unit_field: zod_default.string().optional().describe(UNIT_FIELD_DESCRIPTION),
|
|
24906
|
-
currency_field: zod_default.string().optional().describe(CURRENCY_FIELD_DESCRIPTION),
|
|
25086
|
+
notation: notationSchema.optional().describe(`${NOTATION_DESCRIPTION} For a formula yielding a number.`),
|
|
25087
|
+
link: zod_default.literal(true).optional().describe("The formula yields a URL as text, drawn as a link that opens."),
|
|
25088
|
+
format: zod_default.enum(["number", "currency", "percentage", "link"]).optional().describe(`'number' / 'currency' / 'percentage' for numeric results; 'link' for a URL. ${BEFORE_NOTATION} 'link' is "link": true.`),
|
|
25089
|
+
currency: zod_default.string().optional().describe(`ISO 4217 currency code, e.g. USD, VND, EUR. ${BEFORE_NOTATION}`),
|
|
25090
|
+
unit: zod_default.string().optional().describe(`${UNIT_DESCRIPTION} ${BEFORE_NOTATION}`),
|
|
25091
|
+
unit_field: zod_default.string().optional().describe(`${UNIT_FIELD_DESCRIPTION} ${BEFORE_NOTATION}`),
|
|
25092
|
+
currency_field: zod_default.string().optional().describe(`${CURRENCY_FIELD_DESCRIPTION} ${BEFORE_NOTATION}`),
|
|
24907
25093
|
options: zod_default.array(tableSelectFieldOptionSchema).min(1).optional().describe(
|
|
24908
25094
|
"The categories the formula yields, drawn as a single select's options are. The expression yields one option's `key` (text) or null; a key it does not declare computes an error. Omit for a formula yielding a plain value."
|
|
24909
25095
|
)
|
|
24910
25096
|
});
|
|
25097
|
+
var formulaToolInputSchema = formulaInputSchema.omit({ format: true, currency: true, unit: true, unit_field: true, currency_field: true });
|
|
24911
25098
|
var formulaSchema = formulaInputSchema.extend({
|
|
24912
25099
|
output_type: formulaOutputTypeSchema.optional().describe("Output type of the formula. Inferred by the backend from the expression \u2014 read-only on input. `datetime` when the result carries a time of day (references a datetime field or a time-bearing helper); `select` when the formula declares `options`."),
|
|
24913
25100
|
volatile: zod_default.boolean().optional().describe("Whether the formula's result depends on `now()` or other non-deterministic helpers. Inferred by the backend \u2014 read-only on input.")
|
|
24914
25101
|
});
|
|
24915
|
-
var
|
|
25102
|
+
var tableFormulaFieldShape = tableFieldBaseSchema.extend({
|
|
24916
25103
|
type: zod_default.literal("formula").describe("Field type for calculated values based on expressions"),
|
|
24917
25104
|
formula: formulaSchema.describe("Formula configuration and expression")
|
|
24918
|
-
})
|
|
25105
|
+
});
|
|
25106
|
+
var tableFormulaFieldSchema = tableFormulaFieldShape.superRefine((field, ctx) => figureIssue(["formula"])(field.formula, ctx));
|
|
25107
|
+
function formulaLinks(formula) {
|
|
25108
|
+
return formula.format == null ? formula.link === true : formula.format === "link";
|
|
25109
|
+
}
|
|
25110
|
+
function formulaLinkIssue(formula, ctx) {
|
|
25111
|
+
if (formula.link === true && formula.notation !== void 0) {
|
|
25112
|
+
ctx.addIssue({ code: "custom", message: "a formula yielding a link yields text, which reads in no notation", path: ["formula", "link"] });
|
|
25113
|
+
}
|
|
25114
|
+
}
|
|
25115
|
+
var tableFormulaFieldInputSchema = tableFormulaFieldShape.superRefine((field, ctx) => figureIssue(["formula"])(field.formula, ctx)).superRefine((field, ctx) => formulaLinkIssue(field.formula, ctx));
|
|
24919
25116
|
var workflowMetadataSchema = zod_default.object({
|
|
24920
25117
|
table_ids: zod_default.array(zod_default.string()).describe("IDs of the tables this workflow affects"),
|
|
24921
25118
|
staged_for_app_id: zod_default.string().optional().describe(
|
|
@@ -24971,7 +25168,7 @@ var tableFieldSchema = zod_default.discriminatedUnion("type", [
|
|
|
24971
25168
|
tableAutonumberFieldSchema
|
|
24972
25169
|
]);
|
|
24973
25170
|
var tableFieldInputSchema = zod_default.discriminatedUnion("type", [
|
|
24974
|
-
|
|
25171
|
+
tableNumberFieldInputSchema,
|
|
24975
25172
|
tableTextFieldSchema,
|
|
24976
25173
|
tableDateFieldSchema,
|
|
24977
25174
|
tableBooleanFieldSchema,
|
|
@@ -24981,16 +25178,28 @@ var tableFieldInputSchema = zod_default.discriminatedUnion("type", [
|
|
|
24981
25178
|
tableRollupFieldSchema,
|
|
24982
25179
|
tableLookupFieldSchema,
|
|
24983
25180
|
tableFilesFieldSchema,
|
|
24984
|
-
|
|
25181
|
+
tableFormulaFieldInputSchema,
|
|
24985
25182
|
tableButtonFieldSchema,
|
|
24986
25183
|
tableAutonumberFieldSchema
|
|
24987
25184
|
]);
|
|
24988
25185
|
var tableFieldsSchema = zod_default.array(tableFieldSchema);
|
|
24989
|
-
|
|
24990
|
-
|
|
24991
|
-
|
|
24992
|
-
|
|
24993
|
-
|
|
25186
|
+
var tableFieldsInputSchema = zod_default.array(
|
|
25187
|
+
zod_default.discriminatedUnion("type", [
|
|
25188
|
+
tableNumberFieldInputSchema,
|
|
25189
|
+
tableTextFieldSchema,
|
|
25190
|
+
tableDateFieldSchema,
|
|
25191
|
+
tableBooleanFieldSchema,
|
|
25192
|
+
tableSelectFieldSchema,
|
|
25193
|
+
tableSelectMemberFieldSchema,
|
|
25194
|
+
tableSelectRecordLinkFieldSchema,
|
|
25195
|
+
tableRollupFieldSchema,
|
|
25196
|
+
tableLookupFieldSchema,
|
|
25197
|
+
tableFilesFieldSchema,
|
|
25198
|
+
tableFormulaFieldInputSchema,
|
|
25199
|
+
tableButtonFieldSchema,
|
|
25200
|
+
tableAutonumberFieldSchema
|
|
25201
|
+
])
|
|
25202
|
+
);
|
|
24994
25203
|
var tableFieldCreateBaseSchema = zod_default.object({
|
|
24995
25204
|
name: zod_default.string().describe("Display name"),
|
|
24996
25205
|
description: zod_default.string().describe("Field description"),
|
|
@@ -25004,13 +25213,9 @@ var tableSelectFieldOptionCreateSchema = zod_default.object({
|
|
|
25004
25213
|
var tableFieldTypeConfigSchema = zod_default.discriminatedUnion("type", [
|
|
25005
25214
|
zod_default.object({
|
|
25006
25215
|
type: zod_default.literal("number"),
|
|
25007
|
-
|
|
25008
|
-
currency: currencyCodeSchema.optional(),
|
|
25009
|
-
unit: zod_default.string().optional().describe(UNIT_DESCRIPTION),
|
|
25010
|
-
unit_field: zod_default.string().optional().describe(UNIT_FIELD_DESCRIPTION),
|
|
25011
|
-
currency_field: zod_default.string().optional().describe(CURRENCY_FIELD_DESCRIPTION),
|
|
25216
|
+
notation: notationSchema.optional().describe(`${NOTATION_DESCRIPTION} Omitted, a decimal.`),
|
|
25012
25217
|
default_value: numberDefaultValueSchema
|
|
25013
|
-
}).superRefine(
|
|
25218
|
+
}).superRefine(notationStatedIssue([])),
|
|
25014
25219
|
zod_default.object({
|
|
25015
25220
|
type: zod_default.literal("text"),
|
|
25016
25221
|
unique: zod_default.boolean().optional().describe("Unique values required"),
|
|
@@ -25074,8 +25279,8 @@ var tableFieldTypeConfigSchema = zod_default.discriminatedUnion("type", [
|
|
|
25074
25279
|
}),
|
|
25075
25280
|
zod_default.object({
|
|
25076
25281
|
type: zod_default.literal("formula"),
|
|
25077
|
-
formula:
|
|
25078
|
-
}).superRefine((field, ctx) =>
|
|
25282
|
+
formula: formulaToolInputSchema
|
|
25283
|
+
}).superRefine((field, ctx) => notationStatedIssue(["formula"])(field.formula, ctx)).superRefine((field, ctx) => formulaLinkIssue(field.formula, ctx)),
|
|
25079
25284
|
// `button` is deliberately absent: button fields are legacy — this union
|
|
25080
25285
|
// shapes CREATE input only, and new buttons can no longer be created
|
|
25081
25286
|
// (see LEGACY_FIELD_TYPES). Stored button fields still parse via the
|
|
@@ -28289,6 +28494,9 @@ async function predictWorkflowEffects(input) {
|
|
|
28289
28494
|
}
|
|
28290
28495
|
|
|
28291
28496
|
// ../shared/src/lookup_display.ts
|
|
28497
|
+
function flattenLookupValues(values2) {
|
|
28498
|
+
return values2.flatMap((value) => Array.isArray(value) ? flattenLookupValues(value) : [value]);
|
|
28499
|
+
}
|
|
28292
28500
|
function lookupElementToString(element) {
|
|
28293
28501
|
if (element === null || element === void 0) return "";
|
|
28294
28502
|
if (typeof element === "boolean") return element ? "True" : "False";
|
|
@@ -30027,9 +30235,6 @@ function evaluateCondition(record2, fieldByKey, looseCondition, memberContext, f
|
|
|
30027
30235
|
}
|
|
30028
30236
|
return matchCell(columnValue, field, filterCondition, looseCondition, memberContext, fileFacts);
|
|
30029
30237
|
}
|
|
30030
|
-
function flattenLookupValues(values2) {
|
|
30031
|
-
return values2.flatMap((value) => Array.isArray(value) ? flattenLookupValues(value) : [value]);
|
|
30032
|
-
}
|
|
30033
30238
|
function matchLookup(cell, field, filterCondition, looseCondition, memberContext, fileFacts) {
|
|
30034
30239
|
switch (filterCondition.type) {
|
|
30035
30240
|
case "select":
|
|
@@ -30494,150 +30699,331 @@ function recordFilterTruth(filter2, subject) {
|
|
|
30494
30699
|
}
|
|
30495
30700
|
}
|
|
30496
30701
|
|
|
30497
|
-
// ../shared/src/
|
|
30498
|
-
|
|
30499
|
-
|
|
30500
|
-
|
|
30501
|
-
"date",
|
|
30502
|
-
"boolean",
|
|
30503
|
-
"formula",
|
|
30504
|
-
"rollup",
|
|
30505
|
-
"files"
|
|
30506
|
-
]);
|
|
30507
|
-
function isArrayFieldEmpty(value) {
|
|
30508
|
-
if (value === void 0 || value === null) {
|
|
30509
|
-
return true;
|
|
30702
|
+
// ../shared/src/interpolate.ts
|
|
30703
|
+
function interpolateObject(obj, context) {
|
|
30704
|
+
if (obj === null || obj === void 0) {
|
|
30705
|
+
return obj;
|
|
30510
30706
|
}
|
|
30511
|
-
if (
|
|
30512
|
-
|
|
30707
|
+
if (typeof obj === "string") {
|
|
30708
|
+
const expressionMatches = obj.match(/\{\{.*?\}\}/g);
|
|
30709
|
+
if (expressionMatches && expressionMatches.length > 0) {
|
|
30710
|
+
if (expressionMatches.length === 1 && obj === expressionMatches[0]) {
|
|
30711
|
+
const expression = obj.slice(2, -2).trim();
|
|
30712
|
+
return evaluateJsExpression(expression, context);
|
|
30713
|
+
}
|
|
30714
|
+
const parts = obj.split(/(\{\{.*?\}\})/g);
|
|
30715
|
+
const evaluatedParts = parts.map((part) => {
|
|
30716
|
+
if (part.startsWith("{{") && part.endsWith("}}")) {
|
|
30717
|
+
const expression = part.slice(2, -2).trim();
|
|
30718
|
+
const result = evaluateJsExpression(expression, context);
|
|
30719
|
+
return result != null ? String(result) : "";
|
|
30720
|
+
}
|
|
30721
|
+
return part;
|
|
30722
|
+
});
|
|
30723
|
+
return evaluatedParts.join("");
|
|
30724
|
+
}
|
|
30725
|
+
return obj;
|
|
30513
30726
|
}
|
|
30514
|
-
if (
|
|
30515
|
-
return
|
|
30727
|
+
if (Array.isArray(obj)) {
|
|
30728
|
+
return obj.map((item) => interpolateObject(item, context));
|
|
30729
|
+
}
|
|
30730
|
+
if (typeof obj === "object") {
|
|
30731
|
+
const result = {};
|
|
30732
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
30733
|
+
result[key] = interpolateObject(value, context);
|
|
30734
|
+
}
|
|
30735
|
+
return result;
|
|
30516
30736
|
}
|
|
30517
|
-
return
|
|
30737
|
+
return obj;
|
|
30518
30738
|
}
|
|
30519
|
-
|
|
30520
|
-
|
|
30521
|
-
|
|
30739
|
+
|
|
30740
|
+
// ../shared/src/app_query_ast.ts
|
|
30741
|
+
function collectParamTokens(node, found) {
|
|
30742
|
+
if (typeof node === "string") {
|
|
30743
|
+
for (const tok of node.matchAll(/\{\{(.*?)\}\}/g)) {
|
|
30744
|
+
for (const m of tok[1].matchAll(/\bparams\.([a-zA-Z_$][\w$]*)/g)) {
|
|
30745
|
+
found.add(m[1]);
|
|
30746
|
+
}
|
|
30747
|
+
}
|
|
30748
|
+
return;
|
|
30522
30749
|
}
|
|
30523
|
-
|
|
30524
|
-
|
|
30525
|
-
|
|
30526
|
-
const bSelectArray = Array.isArray(bValue) ? bValue : null;
|
|
30527
|
-
const aSelectValue = aSelectArray?.[0];
|
|
30528
|
-
const bSelectValue = bSelectArray?.[0];
|
|
30529
|
-
const aIsEmpty2 = isArrayFieldEmpty(aSelectArray);
|
|
30530
|
-
const bIsEmpty2 = isArrayFieldEmpty(bSelectArray);
|
|
30531
|
-
if (aIsEmpty2 && bIsEmpty2) {
|
|
30532
|
-
return 0;
|
|
30533
|
-
}
|
|
30534
|
-
if (aIsEmpty2) {
|
|
30535
|
-
return blankPosition === "top" ? -1 : 1;
|
|
30536
|
-
}
|
|
30537
|
-
if (bIsEmpty2) {
|
|
30538
|
-
return blankPosition === "top" ? 1 : -1;
|
|
30539
|
-
}
|
|
30540
|
-
const aIndex = options.findIndex((option) => option.key === aSelectValue);
|
|
30541
|
-
const bIndex = options.findIndex((option) => option.key === bSelectValue);
|
|
30542
|
-
const aPosition = aIndex === -1 ? Number.MAX_SAFE_INTEGER : aIndex;
|
|
30543
|
-
const bPosition = bIndex === -1 ? Number.MAX_SAFE_INTEGER : bIndex;
|
|
30544
|
-
const diff = aPosition - bPosition;
|
|
30545
|
-
return order === "asc" ? diff : -diff;
|
|
30546
|
-
}
|
|
30547
|
-
const aIsEmpty = aValue === void 0 || aValue === null;
|
|
30548
|
-
const bIsEmpty = bValue === void 0 || bValue === null;
|
|
30549
|
-
if (aIsEmpty && bIsEmpty) {
|
|
30550
|
-
return 0;
|
|
30750
|
+
if (Array.isArray(node)) {
|
|
30751
|
+
for (const item of node) collectParamTokens(item, found);
|
|
30752
|
+
return;
|
|
30551
30753
|
}
|
|
30552
|
-
if (
|
|
30553
|
-
|
|
30754
|
+
if (node && typeof node === "object") {
|
|
30755
|
+
for (const value of Object.values(node)) collectParamTokens(value, found);
|
|
30554
30756
|
}
|
|
30555
|
-
|
|
30556
|
-
|
|
30757
|
+
}
|
|
30758
|
+
function paramTokens(node) {
|
|
30759
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
30760
|
+
collectParamTokens(node, tokens);
|
|
30761
|
+
return tokens;
|
|
30762
|
+
}
|
|
30763
|
+
function pruneFilterTree(filter2, survives) {
|
|
30764
|
+
if (filter2.node_type === "group") {
|
|
30765
|
+
const children = filter2.children.map((child) => pruneFilterTree(child, survives)).filter((c) => c !== void 0);
|
|
30766
|
+
if (children.length === 0) return void 0;
|
|
30767
|
+
return { ...filter2, children };
|
|
30768
|
+
}
|
|
30769
|
+
return survives.leaf(filter2) ? filter2 : void 0;
|
|
30770
|
+
}
|
|
30771
|
+
function statedParamNames(params) {
|
|
30772
|
+
return new Set(Object.keys(params).filter((name) => !isUnstatedFilterValue(params[name])));
|
|
30773
|
+
}
|
|
30774
|
+
function statesNothing(leaf, params) {
|
|
30775
|
+
const filled = interpolateObject(leaf.node_type === "traversal" ? leaf.condition : leaf, { params });
|
|
30776
|
+
return isUnstatedConditionValue(filled.operator, filled.value);
|
|
30777
|
+
}
|
|
30778
|
+
function searchStatesNothing(search, params) {
|
|
30779
|
+
const filled = interpolateObject(search, { params });
|
|
30780
|
+
return typeof filled === "string" && searchWords(filled).length === 0;
|
|
30781
|
+
}
|
|
30782
|
+
function survivesCall(params) {
|
|
30783
|
+
const stated = statedParamNames(params);
|
|
30784
|
+
const readsOnlyStated = (node) => {
|
|
30785
|
+
const tokens = paramTokens(node);
|
|
30786
|
+
if (tokens.size === 0) return void 0;
|
|
30787
|
+
return [...tokens].every((name) => stated.has(name));
|
|
30788
|
+
};
|
|
30789
|
+
return {
|
|
30790
|
+
leaf: (leaf) => {
|
|
30791
|
+
const reads = readsOnlyStated(leaf);
|
|
30792
|
+
return reads === void 0 || reads && !statesNothing(leaf, params);
|
|
30793
|
+
},
|
|
30794
|
+
search: (search) => {
|
|
30795
|
+
const reads = readsOnlyStated(search);
|
|
30796
|
+
return reads === void 0 || reads && !searchStatesNothing(search, params);
|
|
30797
|
+
}
|
|
30798
|
+
};
|
|
30799
|
+
}
|
|
30800
|
+
function filterForCall(filter2, params) {
|
|
30801
|
+
const pruned = pruneFilterTree(filter2, survivesCall(params));
|
|
30802
|
+
return pruned === void 0 ? void 0 : interpolateObject(pruned, { params });
|
|
30803
|
+
}
|
|
30804
|
+
|
|
30805
|
+
// ../shared/src/app_query_output_schema.ts
|
|
30806
|
+
function fieldTypeToColumnType(field) {
|
|
30807
|
+
switch (field.type) {
|
|
30808
|
+
case "text":
|
|
30809
|
+
return "text";
|
|
30810
|
+
case "number":
|
|
30811
|
+
return "number";
|
|
30812
|
+
case "boolean":
|
|
30813
|
+
return "boolean";
|
|
30814
|
+
case "date":
|
|
30815
|
+
return field.format === "datetime" || field.format === "datetime_range" ? "datetime" : "date";
|
|
30816
|
+
case "select":
|
|
30817
|
+
return "select";
|
|
30818
|
+
case "select_member":
|
|
30819
|
+
return "select_member";
|
|
30820
|
+
case "select_record_link":
|
|
30821
|
+
return "select_record_link";
|
|
30822
|
+
case "files":
|
|
30823
|
+
return "files";
|
|
30824
|
+
case "rollup":
|
|
30825
|
+
return rollupColumnType(field);
|
|
30826
|
+
case "lookup":
|
|
30827
|
+
return lookupOutputType(field);
|
|
30828
|
+
case "formula":
|
|
30829
|
+
return formulaOutputType(field);
|
|
30830
|
+
case "button":
|
|
30831
|
+
return "json";
|
|
30832
|
+
case "autonumber":
|
|
30833
|
+
return "text";
|
|
30834
|
+
default: {
|
|
30835
|
+
const _exhaustive = field;
|
|
30836
|
+
void _exhaustive;
|
|
30837
|
+
return "json";
|
|
30838
|
+
}
|
|
30557
30839
|
}
|
|
30558
|
-
|
|
30559
|
-
|
|
30560
|
-
|
|
30840
|
+
}
|
|
30841
|
+
function formulaOutputType(field) {
|
|
30842
|
+
switch (field.formula.output_type) {
|
|
30843
|
+
case "number":
|
|
30844
|
+
return "number";
|
|
30845
|
+
case "boolean":
|
|
30846
|
+
return "boolean";
|
|
30847
|
+
case "date":
|
|
30848
|
+
return "date";
|
|
30849
|
+
case "datetime":
|
|
30850
|
+
return "datetime";
|
|
30851
|
+
case "text":
|
|
30852
|
+
return "text";
|
|
30853
|
+
case "select":
|
|
30854
|
+
return "select";
|
|
30855
|
+
default:
|
|
30856
|
+
return "json";
|
|
30857
|
+
}
|
|
30858
|
+
}
|
|
30859
|
+
function rollupColumnType(field) {
|
|
30860
|
+
if (rollupOutputType(field.aggregate_option.operation) === "number") return "number";
|
|
30861
|
+
return field.aggregate_field_format === "datetime" || field.aggregate_field_format === "datetime_range" ? "datetime" : "date";
|
|
30862
|
+
}
|
|
30863
|
+
function lookupOutputType(field) {
|
|
30864
|
+
const t = field.lookup_field_type;
|
|
30865
|
+
if (!t) return "json";
|
|
30866
|
+
switch (t) {
|
|
30867
|
+
case "text":
|
|
30868
|
+
return "text";
|
|
30869
|
+
case "number":
|
|
30870
|
+
return "number";
|
|
30871
|
+
case "boolean":
|
|
30872
|
+
return "boolean";
|
|
30873
|
+
case "date":
|
|
30874
|
+
return field.lookup_field_format === "datetime" || field.lookup_field_format === "datetime_range" ? "datetime" : "date";
|
|
30875
|
+
case "select":
|
|
30876
|
+
return "select";
|
|
30877
|
+
case "select_member":
|
|
30878
|
+
return "select_member";
|
|
30879
|
+
case "select_record_link":
|
|
30880
|
+
return "select_record_link";
|
|
30881
|
+
case "files":
|
|
30882
|
+
return "files";
|
|
30883
|
+
default:
|
|
30884
|
+
return "json";
|
|
30561
30885
|
}
|
|
30562
|
-
|
|
30563
|
-
|
|
30564
|
-
|
|
30565
|
-
|
|
30566
|
-
|
|
30567
|
-
|
|
30568
|
-
|
|
30569
|
-
|
|
30570
|
-
|
|
30571
|
-
|
|
30572
|
-
|
|
30573
|
-
|
|
30574
|
-
|
|
30575
|
-
|
|
30576
|
-
|
|
30577
|
-
|
|
30578
|
-
|
|
30579
|
-
|
|
30580
|
-
|
|
30581
|
-
|
|
30582
|
-
|
|
30583
|
-
|
|
30584
|
-
|
|
30585
|
-
|
|
30586
|
-
|
|
30587
|
-
|
|
30588
|
-
|
|
30589
|
-
|
|
30590
|
-
|
|
30591
|
-
|
|
30592
|
-
|
|
30593
|
-
|
|
30594
|
-
|
|
30595
|
-
|
|
30596
|
-
|
|
30597
|
-
|
|
30598
|
-
|
|
30599
|
-
|
|
30600
|
-
|
|
30601
|
-
}
|
|
30602
|
-
|
|
30603
|
-
|
|
30604
|
-
|
|
30605
|
-
|
|
30606
|
-
|
|
30607
|
-
|
|
30608
|
-
|
|
30609
|
-
|
|
30610
|
-
|
|
30611
|
-
|
|
30612
|
-
|
|
30613
|
-
|
|
30614
|
-
|
|
30615
|
-
|
|
30616
|
-
|
|
30617
|
-
|
|
30618
|
-
|
|
30619
|
-
|
|
30620
|
-
|
|
30621
|
-
|
|
30622
|
-
|
|
30623
|
-
|
|
30624
|
-
|
|
30625
|
-
|
|
30626
|
-
|
|
30627
|
-
|
|
30628
|
-
|
|
30629
|
-
|
|
30630
|
-
|
|
30631
|
-
|
|
30632
|
-
|
|
30633
|
-
|
|
30634
|
-
|
|
30635
|
-
|
|
30636
|
-
|
|
30637
|
-
|
|
30638
|
-
|
|
30639
|
-
|
|
30640
|
-
|
|
30886
|
+
}
|
|
30887
|
+
|
|
30888
|
+
// ../shared/src/field_value.ts
|
|
30889
|
+
function fieldValueInfo(field) {
|
|
30890
|
+
switch (field.type) {
|
|
30891
|
+
case "number":
|
|
30892
|
+
return { type: "number", notation: fieldNotation(field) };
|
|
30893
|
+
case "text":
|
|
30894
|
+
return { type: "text", format: field.format };
|
|
30895
|
+
case "date":
|
|
30896
|
+
return { type: "date", format: field.format };
|
|
30897
|
+
case "select":
|
|
30898
|
+
return { type: "select", options: field.options };
|
|
30899
|
+
case "formula": {
|
|
30900
|
+
const output = field.formula?.output_type;
|
|
30901
|
+
if (field.formula.options !== void 0) return { type: "select", options: field.formula.options };
|
|
30902
|
+
if (output === "date" || output === "datetime") {
|
|
30903
|
+
return { type: "date", format: output === "datetime" ? "datetime" : "date" };
|
|
30904
|
+
}
|
|
30905
|
+
if (output === "boolean") return { type: "boolean" };
|
|
30906
|
+
if (output === "text") return { type: "text", format: formulaLinks(field.formula) ? "link" : void 0 };
|
|
30907
|
+
return { type: "number", notation: fieldNotation(field) };
|
|
30908
|
+
}
|
|
30909
|
+
case "rollup": {
|
|
30910
|
+
const type = rollupOutputType(field.aggregate_option.operation);
|
|
30911
|
+
return type === "number" ? { type, notation: fieldNotation(field) } : { type, format: field.aggregate_field_format };
|
|
30912
|
+
}
|
|
30913
|
+
case "lookup":
|
|
30914
|
+
return {
|
|
30915
|
+
type: field.lookup_field_type ?? "text",
|
|
30916
|
+
...field.lookup_field_type === "number" ? { notation: fieldNotation(field) } : { format: field.lookup_field_format },
|
|
30917
|
+
options: field.lookup_field_options,
|
|
30918
|
+
autonumber: field.lookup_field_autonumber
|
|
30919
|
+
};
|
|
30920
|
+
// The cell stores the composed DISPLAY string ("KH-001"), never the counter.
|
|
30921
|
+
case "autonumber":
|
|
30922
|
+
return { type: "text", autonumber: true };
|
|
30923
|
+
default:
|
|
30924
|
+
return { type: field.type };
|
|
30925
|
+
}
|
|
30926
|
+
}
|
|
30927
|
+
|
|
30928
|
+
// ../shared/src/field_comparison.ts
|
|
30929
|
+
var MemberNamesUnavailableError = class extends Error {
|
|
30930
|
+
constructor(fieldKey) {
|
|
30931
|
+
super(
|
|
30932
|
+
`Comparing "${fieldKey}" orders members by name, and its cells hold member ids \u2014 the workspace's member names must be supplied to compare them.`
|
|
30933
|
+
);
|
|
30934
|
+
this.name = "MemberNamesUnavailableError";
|
|
30935
|
+
}
|
|
30936
|
+
};
|
|
30937
|
+
function firstMember(cell) {
|
|
30938
|
+
const first2 = Array.isArray(cell) ? cell[0] : void 0;
|
|
30939
|
+
return typeof first2 === "string" ? first2 : void 0;
|
|
30940
|
+
}
|
|
30941
|
+
function firstLink(cell) {
|
|
30942
|
+
const first2 = Array.isArray(cell) ? cell[0] : void 0;
|
|
30943
|
+
if (typeof first2 !== "object" || first2 === null || !("id" in first2) || typeof first2.id !== "string") return void 0;
|
|
30944
|
+
const display = "display" in first2 && typeof first2.display === "string" ? first2.display : "";
|
|
30945
|
+
return { name: display, id: first2.id };
|
|
30946
|
+
}
|
|
30947
|
+
function folded(text2) {
|
|
30948
|
+
return text2.trim().toLowerCase();
|
|
30949
|
+
}
|
|
30950
|
+
function compareNamed(a, b) {
|
|
30951
|
+
const byName = folded(a.name).localeCompare(folded(b.name), "en-US");
|
|
30952
|
+
return byName !== 0 ? byName : a.id.localeCompare(b.id, "en-US");
|
|
30953
|
+
}
|
|
30954
|
+
function optionRank(cell, options) {
|
|
30955
|
+
const first2 = Array.isArray(cell) ? cell[0] : void 0;
|
|
30956
|
+
if (first2 === void 0 || first2 === null) return void 0;
|
|
30957
|
+
const at2 = options.findIndex((option) => option.key === first2);
|
|
30958
|
+
return { by: "figure", value: at2 === -1 ? options.length : at2 };
|
|
30959
|
+
}
|
|
30960
|
+
function valueRank(cell, type) {
|
|
30961
|
+
if (cell === void 0 || cell === null) return void 0;
|
|
30962
|
+
switch (type) {
|
|
30963
|
+
case "number":
|
|
30964
|
+
return typeof cell === "number" && Number.isFinite(cell) ? { by: "figure", value: cell } : void 0;
|
|
30965
|
+
case "boolean":
|
|
30966
|
+
return typeof cell === "boolean" ? { by: "figure", value: cell ? 1 : 0 } : void 0;
|
|
30967
|
+
case "date":
|
|
30968
|
+
case "datetime":
|
|
30969
|
+
return typeof cell === "string" && /^\d{4}/.test(cell) ? { by: "day", value: cell } : void 0;
|
|
30970
|
+
case "text":
|
|
30971
|
+
return { by: "text", value: folded(String(cell)) };
|
|
30972
|
+
case "select_member": {
|
|
30973
|
+
const id = firstMember(cell);
|
|
30974
|
+
return id === void 0 ? void 0 : { by: "member", id };
|
|
30975
|
+
}
|
|
30976
|
+
case "select_record_link": {
|
|
30977
|
+
const link2 = firstLink(cell);
|
|
30978
|
+
return link2 === void 0 ? void 0 : { by: "name", value: link2 };
|
|
30979
|
+
}
|
|
30980
|
+
case "files":
|
|
30981
|
+
return Array.isArray(cell) ? { by: "figure", value: cell.length } : void 0;
|
|
30982
|
+
case "select":
|
|
30983
|
+
case "json":
|
|
30984
|
+
return typeof cell === "number" ? { by: "figure", value: cell } : { by: "text", value: folded(String(cell)) };
|
|
30985
|
+
}
|
|
30986
|
+
}
|
|
30987
|
+
function autonumberTerms(cell) {
|
|
30988
|
+
if (cell === void 0 || cell === null) return [void 0, void 0];
|
|
30989
|
+
const text2 = String(cell);
|
|
30990
|
+
return /^-?\d+$/.test(text2) ? [{ by: "figure", value: Number(text2) }, void 0] : [void 0, { by: "text", value: text2 }];
|
|
30991
|
+
}
|
|
30992
|
+
function termsOf(cell, field) {
|
|
30993
|
+
const value = field.type === "lookup" && Array.isArray(cell) ? cell[0] : cell;
|
|
30994
|
+
if (fieldValueInfo(field).autonumber === true) return autonumberTerms(value);
|
|
30995
|
+
const options = effectiveSelectOptions(field);
|
|
30996
|
+
return [options === null ? valueRank(value, fieldTypeToColumnType(field)) : optionRank(value, options)];
|
|
30997
|
+
}
|
|
30998
|
+
function rankText(rank) {
|
|
30999
|
+
if (rank.by === "name") return folded(rank.value.name);
|
|
31000
|
+
if (rank.by === "member") return rank.id;
|
|
31001
|
+
return String(rank.value);
|
|
31002
|
+
}
|
|
31003
|
+
function compareFieldValues(aValue, bValue, field, { blank = "bottom", order = "asc", memberNames } = {}) {
|
|
31004
|
+
if (aValue === bValue) return 0;
|
|
31005
|
+
const a = termsOf(aValue, field);
|
|
31006
|
+
const b = termsOf(bValue, field);
|
|
31007
|
+
const member = (id) => {
|
|
31008
|
+
if (memberNames === void 0) throw new MemberNamesUnavailableError(field.key);
|
|
31009
|
+
return { name: memberNames.get(id) ?? "", id };
|
|
31010
|
+
};
|
|
31011
|
+
for (const [at2, left] of a.entries()) {
|
|
31012
|
+
const right = b[at2];
|
|
31013
|
+
if (left === void 0 && right === void 0) continue;
|
|
31014
|
+
if (left === void 0) return blank === "top" ? -1 : 1;
|
|
31015
|
+
if (right === void 0) return blank === "top" ? 1 : -1;
|
|
31016
|
+
const compared = compareRanks(left, right, member);
|
|
31017
|
+
if (compared !== 0) return order === "asc" ? compared : -compared;
|
|
31018
|
+
}
|
|
31019
|
+
return 0;
|
|
31020
|
+
}
|
|
31021
|
+
function compareRanks(a, b, member) {
|
|
31022
|
+
if (a.by === "figure" && b.by === "figure") return a.value - b.value;
|
|
31023
|
+
if (a.by === "day" && b.by === "day") return a.value < b.value ? -1 : a.value > b.value ? 1 : 0;
|
|
31024
|
+
if (a.by === "name" && b.by === "name") return compareNamed(a.value, b.value);
|
|
31025
|
+
if (a.by === "member" && b.by === "member") return compareNamed(member(a.id), member(b.id));
|
|
31026
|
+
return rankText(a).localeCompare(rankText(b), "en-US");
|
|
30641
31027
|
}
|
|
30642
31028
|
|
|
30643
31029
|
// ../shared/src/formula_references.ts
|
|
@@ -30711,7 +31097,7 @@ function prepareFormulaContext(fields) {
|
|
|
30711
31097
|
nonFormulaFields
|
|
30712
31098
|
};
|
|
30713
31099
|
}
|
|
30714
|
-
function computeFormulaFieldsWithContext(row2, fields, context, linkedTableRecords = /* @__PURE__ */ new Map(), linkedTableFields = /* @__PURE__ */ new Map(), timezone, loadedLinkKeys, linkExpandedTableIds, fileFacts) {
|
|
31100
|
+
function computeFormulaFieldsWithContext(row2, fields, context, linkedTableRecords = /* @__PURE__ */ new Map(), linkedTableFields = /* @__PURE__ */ new Map(), timezone, loadedLinkKeys, linkExpandedTableIds, fileFacts, memberNames) {
|
|
30715
31101
|
const result = { ...row2 };
|
|
30716
31102
|
const mayRecompute = (linkKey) => loadedLinkKeys === void 0 || loadedLinkKeys.has(linkKey) || isEmptyFieldValue(row2[linkKey]);
|
|
30717
31103
|
for (const { field, sourceField } of context.rollupFields) {
|
|
@@ -30776,7 +31162,8 @@ function computeFormulaFieldsWithContext(row2, fields, context, linkedTableRecor
|
|
|
30776
31162
|
field.lookup_field_key,
|
|
30777
31163
|
linkedField,
|
|
30778
31164
|
field.order_by,
|
|
30779
|
-
linkedFieldsArray
|
|
31165
|
+
linkedFieldsArray,
|
|
31166
|
+
memberNames
|
|
30780
31167
|
);
|
|
30781
31168
|
result[field.key] = lookupValue;
|
|
30782
31169
|
} else {
|
|
@@ -31106,7 +31493,7 @@ function calculateRollupValue(value, fieldType, allLinkedTableRecords, aggregate
|
|
|
31106
31493
|
}
|
|
31107
31494
|
return aggregateByField(relevantRecords, fieldType, aggregateOption, subject).result;
|
|
31108
31495
|
}
|
|
31109
|
-
function calculateLookupValue(value, linkedRecords, lookupFieldKey, linkedField, orderBy, linkedFields) {
|
|
31496
|
+
function calculateLookupValue(value, linkedRecords, lookupFieldKey, linkedField, orderBy, linkedFields, memberNames) {
|
|
31110
31497
|
if (!linkedRecords.length || !lookupFieldKey) {
|
|
31111
31498
|
return null;
|
|
31112
31499
|
}
|
|
@@ -31131,13 +31518,11 @@ function calculateLookupValue(value, linkedRecords, lookupFieldKey, linkedField,
|
|
|
31131
31518
|
return null;
|
|
31132
31519
|
}
|
|
31133
31520
|
const picked = [...relevantRecords].sort((a, b) => {
|
|
31134
|
-
const cmp = compareFieldValues(
|
|
31135
|
-
|
|
31136
|
-
|
|
31137
|
-
|
|
31138
|
-
|
|
31139
|
-
orderBy.direction
|
|
31140
|
-
);
|
|
31521
|
+
const cmp = compareFieldValues(a.data[orderField.key], b.data[orderField.key], orderField, {
|
|
31522
|
+
blank: "bottom",
|
|
31523
|
+
order: orderBy.direction,
|
|
31524
|
+
memberNames
|
|
31525
|
+
});
|
|
31141
31526
|
if (cmp !== 0) return cmp;
|
|
31142
31527
|
if (a.created_at !== b.created_at) return a.created_at < b.created_at ? 1 : -1;
|
|
31143
31528
|
return a.id < b.id ? 1 : a.id > b.id ? -1 : 0;
|
|
@@ -31153,109 +31538,6 @@ function calculateLookupValue(value, linkedRecords, lookupFieldKey, linkedField,
|
|
|
31153
31538
|
return values2.length > 0 ? values2 : null;
|
|
31154
31539
|
}
|
|
31155
31540
|
|
|
31156
|
-
// ../shared/src/interpolate.ts
|
|
31157
|
-
function interpolateObject(obj, context) {
|
|
31158
|
-
if (obj === null || obj === void 0) {
|
|
31159
|
-
return obj;
|
|
31160
|
-
}
|
|
31161
|
-
if (typeof obj === "string") {
|
|
31162
|
-
const expressionMatches = obj.match(/\{\{.*?\}\}/g);
|
|
31163
|
-
if (expressionMatches && expressionMatches.length > 0) {
|
|
31164
|
-
if (expressionMatches.length === 1 && obj === expressionMatches[0]) {
|
|
31165
|
-
const expression = obj.slice(2, -2).trim();
|
|
31166
|
-
return evaluateJsExpression(expression, context);
|
|
31167
|
-
}
|
|
31168
|
-
const parts = obj.split(/(\{\{.*?\}\})/g);
|
|
31169
|
-
const evaluatedParts = parts.map((part) => {
|
|
31170
|
-
if (part.startsWith("{{") && part.endsWith("}}")) {
|
|
31171
|
-
const expression = part.slice(2, -2).trim();
|
|
31172
|
-
const result = evaluateJsExpression(expression, context);
|
|
31173
|
-
return result != null ? String(result) : "";
|
|
31174
|
-
}
|
|
31175
|
-
return part;
|
|
31176
|
-
});
|
|
31177
|
-
return evaluatedParts.join("");
|
|
31178
|
-
}
|
|
31179
|
-
return obj;
|
|
31180
|
-
}
|
|
31181
|
-
if (Array.isArray(obj)) {
|
|
31182
|
-
return obj.map((item) => interpolateObject(item, context));
|
|
31183
|
-
}
|
|
31184
|
-
if (typeof obj === "object") {
|
|
31185
|
-
const result = {};
|
|
31186
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
31187
|
-
result[key] = interpolateObject(value, context);
|
|
31188
|
-
}
|
|
31189
|
-
return result;
|
|
31190
|
-
}
|
|
31191
|
-
return obj;
|
|
31192
|
-
}
|
|
31193
|
-
|
|
31194
|
-
// ../shared/src/app_query_ast.ts
|
|
31195
|
-
function collectParamTokens(node, found) {
|
|
31196
|
-
if (typeof node === "string") {
|
|
31197
|
-
for (const tok of node.matchAll(/\{\{(.*?)\}\}/g)) {
|
|
31198
|
-
for (const m of tok[1].matchAll(/\bparams\.([a-zA-Z_$][\w$]*)/g)) {
|
|
31199
|
-
found.add(m[1]);
|
|
31200
|
-
}
|
|
31201
|
-
}
|
|
31202
|
-
return;
|
|
31203
|
-
}
|
|
31204
|
-
if (Array.isArray(node)) {
|
|
31205
|
-
for (const item of node) collectParamTokens(item, found);
|
|
31206
|
-
return;
|
|
31207
|
-
}
|
|
31208
|
-
if (node && typeof node === "object") {
|
|
31209
|
-
for (const value of Object.values(node)) collectParamTokens(value, found);
|
|
31210
|
-
}
|
|
31211
|
-
}
|
|
31212
|
-
function paramTokens(node) {
|
|
31213
|
-
const tokens = /* @__PURE__ */ new Set();
|
|
31214
|
-
collectParamTokens(node, tokens);
|
|
31215
|
-
return tokens;
|
|
31216
|
-
}
|
|
31217
|
-
function pruneFilterTree(filter2, survives) {
|
|
31218
|
-
if (filter2.node_type === "group") {
|
|
31219
|
-
const children = filter2.children.map((child) => pruneFilterTree(child, survives)).filter((c) => c !== void 0);
|
|
31220
|
-
if (children.length === 0) return void 0;
|
|
31221
|
-
return { ...filter2, children };
|
|
31222
|
-
}
|
|
31223
|
-
return survives.leaf(filter2) ? filter2 : void 0;
|
|
31224
|
-
}
|
|
31225
|
-
function statedParamNames(params) {
|
|
31226
|
-
return new Set(Object.keys(params).filter((name) => !isUnstatedFilterValue(params[name])));
|
|
31227
|
-
}
|
|
31228
|
-
function statesNothing(leaf, params) {
|
|
31229
|
-
const filled = interpolateObject(leaf.node_type === "traversal" ? leaf.condition : leaf, { params });
|
|
31230
|
-
return isUnstatedConditionValue(filled.operator, filled.value);
|
|
31231
|
-
}
|
|
31232
|
-
function searchStatesNothing(search, params) {
|
|
31233
|
-
const filled = interpolateObject(search, { params });
|
|
31234
|
-
return typeof filled === "string" && searchWords(filled).length === 0;
|
|
31235
|
-
}
|
|
31236
|
-
function survivesCall(params) {
|
|
31237
|
-
const stated = statedParamNames(params);
|
|
31238
|
-
const readsOnlyStated = (node) => {
|
|
31239
|
-
const tokens = paramTokens(node);
|
|
31240
|
-
if (tokens.size === 0) return void 0;
|
|
31241
|
-
return [...tokens].every((name) => stated.has(name));
|
|
31242
|
-
};
|
|
31243
|
-
return {
|
|
31244
|
-
leaf: (leaf) => {
|
|
31245
|
-
const reads = readsOnlyStated(leaf);
|
|
31246
|
-
return reads === void 0 || reads && !statesNothing(leaf, params);
|
|
31247
|
-
},
|
|
31248
|
-
search: (search) => {
|
|
31249
|
-
const reads = readsOnlyStated(search);
|
|
31250
|
-
return reads === void 0 || reads && !searchStatesNothing(search, params);
|
|
31251
|
-
}
|
|
31252
|
-
};
|
|
31253
|
-
}
|
|
31254
|
-
function filterForCall(filter2, params) {
|
|
31255
|
-
const pruned = pruneFilterTree(filter2, survivesCall(params));
|
|
31256
|
-
return pruned === void 0 ? void 0 : interpolateObject(pruned, { params });
|
|
31257
|
-
}
|
|
31258
|
-
|
|
31259
31541
|
// src/overlay.ts
|
|
31260
31542
|
var NONE2 = /* @__PURE__ */ new Set();
|
|
31261
31543
|
function fieldKeyOf(shape, column, tableId) {
|