@eidos.space/eidos-file 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/DEVELOPER_PLATFORM.md +49 -53
  2. package/README.md +66 -99
  3. package/dist/adapter-contract-B3p-48Yb.d.mts +1149 -0
  4. package/dist/adapter-contract-B3p-48Yb.d.mts.map +1 -0
  5. package/dist/better-sqlite3.d.mts +64 -3
  6. package/dist/better-sqlite3.d.mts.map +1 -1
  7. package/dist/better-sqlite3.mjs +387 -14
  8. package/dist/better-sqlite3.mjs.map +1 -1
  9. package/dist/browser.d.mts +4 -3
  10. package/dist/browser.d.mts.map +1 -1
  11. package/dist/browser.mjs +30 -11
  12. package/dist/browser.mjs.map +1 -1
  13. package/dist/csv-WEud-i_H.mjs +376 -0
  14. package/dist/csv-WEud-i_H.mjs.map +1 -0
  15. package/dist/csv.d.mts +1 -1
  16. package/dist/csv.d.mts.map +1 -1
  17. package/dist/csv.mjs +1 -248
  18. package/dist/index.d.mts +312 -18
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.mjs +3237 -4
  21. package/dist/index.mjs.map +1 -0
  22. package/dist/runtime-CMdfE7Gx.mjs +5476 -0
  23. package/dist/runtime-CMdfE7Gx.mjs.map +1 -0
  24. package/dist/runtime-DCo5E0Kr.d.mts +668 -0
  25. package/dist/runtime-DCo5E0Kr.d.mts.map +1 -0
  26. package/dist/select-options-DihMTuoa.mjs +518 -0
  27. package/dist/select-options-DihMTuoa.mjs.map +1 -0
  28. package/dist/sqlite-wasm-B86yaLG6.mjs +2000 -0
  29. package/dist/sqlite-wasm-B86yaLG6.mjs.map +1 -0
  30. package/dist/temporal-CVzLU63l.d.mts +517 -0
  31. package/dist/temporal-CVzLU63l.d.mts.map +1 -0
  32. package/package.json +2 -3
  33. package/dist/csv.mjs.map +0 -1
  34. package/dist/host-CqP1MeMK.d.mts +0 -213
  35. package/dist/host-CqP1MeMK.d.mts.map +0 -1
  36. package/dist/host-D5kZAhga.mjs +0 -478
  37. package/dist/host-D5kZAhga.mjs.map +0 -1
  38. package/dist/relation-values-B0JhHBjZ.mjs +0 -232
  39. package/dist/relation-values-B0JhHBjZ.mjs.map +0 -1
  40. package/dist/runtime-C3bstvB8.d.mts +0 -465
  41. package/dist/runtime-C3bstvB8.d.mts.map +0 -1
  42. package/dist/runtime-CWC5y95G.mjs +0 -2907
  43. package/dist/runtime-CWC5y95G.mjs.map +0 -1
@@ -1,232 +0,0 @@
1
- //#region src/errors.ts
2
- var EidosFileError = class extends Error {
3
- constructor(code, message) {
4
- super(message);
5
- this.code = code;
6
- this.name = "EidosFileError";
7
- }
8
- };
9
- //#endregion
10
- //#region src/json-array-values.ts
11
- function decodeEidosFileJsonArray(value) {
12
- if (typeof value !== "string" || value.length === 0) return [];
13
- try {
14
- const parsed = JSON.parse(value);
15
- if (!Array.isArray(parsed)) return [];
16
- return parsed.filter((entry) => entry === null || typeof entry === "string" || typeof entry === "number" || typeof entry === "boolean");
17
- } catch {
18
- return [];
19
- }
20
- }
21
- function decodeEidosFileStringArray(value) {
22
- return decodeEidosFileJsonArray(value).filter((entry) => typeof entry === "string");
23
- }
24
- function encodeEidosFileJsonArray(values) {
25
- return values.length > 0 ? JSON.stringify(values) : null;
26
- }
27
- //#endregion
28
- //#region src/file-values.ts
29
- const EXTERNAL_REFERENCE = /^(?:https?:|data:)/i;
30
- function normalizeEidosFileAttachmentPath(value) {
31
- const trimmed = value.trim();
32
- if (!trimmed || trimmed.includes("\0")) return null;
33
- if (EXTERNAL_REFERENCE.test(trimmed)) return trimmed;
34
- if (/^[a-z][a-z\d+.-]*:/i.test(trimmed)) return null;
35
- const parts = trimmed.replace(/\\/g, "/").split("/");
36
- const normalized = [];
37
- for (const part of parts) {
38
- if (!part || part === ".") continue;
39
- if (part === "..") {
40
- if (normalized.length === 0) return null;
41
- normalized.pop();
42
- continue;
43
- }
44
- normalized.push(part);
45
- }
46
- return normalized.length > 0 ? normalized.join("/") : null;
47
- }
48
- function decodeEidosFileAttachmentPaths(value) {
49
- const candidates = decodeEidosFileStringArray(value);
50
- const seen = /* @__PURE__ */ new Set();
51
- return candidates.flatMap((candidate) => {
52
- const normalized = normalizeEidosFileAttachmentPath(candidate);
53
- if (!normalized || seen.has(normalized)) return [];
54
- seen.add(normalized);
55
- return [normalized];
56
- });
57
- }
58
- function encodeEidosFileAttachmentPaths(paths) {
59
- const normalized = decodeEidosFileAttachmentPaths(JSON.stringify(paths));
60
- return normalized.length > 0 ? JSON.stringify(normalized) : null;
61
- }
62
- //#endregion
63
- //#region src/select-options.ts
64
- function parseEidosFileSelectOptions(property) {
65
- const options = property?.options;
66
- if (!Array.isArray(options)) return [];
67
- return options.flatMap((option) => {
68
- if (typeof option !== "object" || option === null || !("value" in option) || typeof option.value !== "string") return [];
69
- return [{
70
- value: option.value,
71
- color: "color" in option && typeof option.color === "string" ? option.color : "default"
72
- }];
73
- });
74
- }
75
- function assertEidosFileSelectOptions(property) {
76
- const rawOptions = property?.options;
77
- if (!Array.isArray(rawOptions)) throw new EidosFileError("invalid-schema", "Select fields require an options array");
78
- const options = parseEidosFileSelectOptions(property);
79
- if (options.length !== rawOptions.length) throw new EidosFileError("invalid-schema", "Every select option requires a string value");
80
- const values = /* @__PURE__ */ new Set();
81
- for (const option of options) {
82
- if (!option.value.trim()) throw new EidosFileError("invalid-schema", "Select option values cannot be empty");
83
- if (values.has(option.value)) throw new EidosFileError("invalid-schema", `Duplicate select option value: ${option.value}`);
84
- values.add(option.value);
85
- }
86
- return options;
87
- }
88
- //#endregion
89
- //#region src/field-conversion.ts
90
- const MUTABLE_BASE_FIELD_TYPES = [
91
- "text",
92
- "number",
93
- "checkbox",
94
- "date",
95
- "datetime",
96
- "file",
97
- "multi-select",
98
- "rating",
99
- "select",
100
- "url"
101
- ];
102
- const MUTABLE_TYPE_SET = new Set(MUTABLE_BASE_FIELD_TYPES);
103
- const OPTION_COLORS = [
104
- "gray",
105
- "brown",
106
- "pink",
107
- "red",
108
- "orange",
109
- "yellow",
110
- "green",
111
- "cyan",
112
- "blue",
113
- "purple"
114
- ];
115
- function isMutableEidosFileFieldType(type) {
116
- return MUTABLE_TYPE_SET.has(type);
117
- }
118
- function decodeEidosFileMultiSelectValues(value) {
119
- return Array.from(new Set(decodeEidosFileStringArray(value).filter(Boolean)));
120
- }
121
- function encodeEidosFileMultiSelectValues(values) {
122
- return encodeEidosFileJsonArray(Array.from(new Set(values.filter(Boolean))));
123
- }
124
- function eidosFileFieldDisplayValues(field, value) {
125
- if (value === null) return [];
126
- const primitiveValue = typeof value === "boolean" ? value ? 1 : 0 : value;
127
- if (field.type === "file") return decodeEidosFileAttachmentPaths(primitiveValue);
128
- if (field.type === "select") return [String(primitiveValue)].filter(Boolean);
129
- if (field.type === "multi-select") return decodeEidosFileMultiSelectValues(primitiveValue);
130
- if (field.storageCodec === "json_array") return decodeEidosFileJsonArray(primitiveValue).flatMap((entry) => entry === null ? [] : [String(entry)]);
131
- if (field.type === "checkbox") return [value === true || value === 1 || value === "1" ? "true" : "false"];
132
- if (primitiveValue instanceof Uint8Array) return [];
133
- const text = String(primitiveValue).trim();
134
- return text ? [text] : [];
135
- }
136
- function optionPlan(field, rows) {
137
- const existingByName = new Map(parseEidosFileSelectOptions(field.property).map((option) => [option.value, option]));
138
- return Array.from(new Set(rows.flatMap((row) => eidosFileFieldDisplayValues(field, row.value)))).map((name, index) => existingByName.get(name) ?? {
139
- value: name,
140
- color: OPTION_COLORS[index % OPTION_COLORS.length]
141
- });
142
- }
143
- function defaultProperty(type, options) {
144
- if (type === "select" || type === "multi-select") return { options };
145
- if (type === "number") return {
146
- format: "number",
147
- showAs: "number",
148
- color: "purple",
149
- divideBy: 100,
150
- showNumber: true
151
- };
152
- return null;
153
- }
154
- function storageCodec(type) {
155
- if (type === "multi-select" || type === "file") return "json_array";
156
- return "scalar";
157
- }
158
- function numericValue(values) {
159
- if (values.length === 0) return null;
160
- const parsed = Number(values[0]);
161
- return Number.isFinite(parsed) ? parsed : null;
162
- }
163
- function checkboxValue(sourceValue, values) {
164
- if (sourceValue === null) return null;
165
- if (typeof sourceValue === "number" || typeof sourceValue === "bigint") return sourceValue === 0 || sourceValue === 0n ? 0 : 1;
166
- const normalized = values[0]?.trim().toLowerCase();
167
- if (!normalized) return 0;
168
- if ([
169
- "0",
170
- "false",
171
- "no",
172
- "off",
173
- "unchecked"
174
- ].includes(normalized)) return 0;
175
- return 1;
176
- }
177
- function convertedValue(type, sourceValue, values) {
178
- if (sourceValue === null) return null;
179
- if (type === "number") return numericValue(values);
180
- if (type === "checkbox") return checkboxValue(sourceValue, values);
181
- if (type === "rating") {
182
- const value = numericValue(values);
183
- return value === null ? null : Math.min(5, Math.max(0, Math.round(value)));
184
- }
185
- if (type === "file") return encodeEidosFileAttachmentPaths(values);
186
- if (type === "select") return values[0] || null;
187
- if (type === "multi-select") return encodeEidosFileMultiSelectValues(values);
188
- return values.length > 0 ? values.join(", ") : null;
189
- }
190
- function planEidosFileFieldConversion(field, rows, targetType) {
191
- return {
192
- property: defaultProperty(targetType, targetType === "select" || targetType === "multi-select" ? optionPlan(field, rows) : []),
193
- storageCodec: storageCodec(targetType),
194
- values: rows.map((row) => {
195
- const values = eidosFileFieldDisplayValues(field, row.value);
196
- return {
197
- id: row.id,
198
- value: convertedValue(targetType, row.value, values)
199
- };
200
- })
201
- };
202
- }
203
- //#endregion
204
- //#region src/relation-values.ts
205
- const MAX_RELATION_VALUES = 500;
206
- function decodeEidosFileRelationIds(value) {
207
- return Array.from(new Set(decodeEidosFileStringArray(value).map((entry) => entry.trim()).filter(Boolean).slice(0, MAX_RELATION_VALUES)));
208
- }
209
- function encodeEidosFileRelationIds(ids) {
210
- const normalized = Array.from(new Set(ids.map((id) => id.trim()).filter(Boolean))).slice(0, MAX_RELATION_VALUES);
211
- return normalized.length > 0 ? JSON.stringify(normalized) : null;
212
- }
213
- function decodeEidosFileRelationDisplay(value) {
214
- if (typeof value !== "string" || value.length === 0) return [];
215
- try {
216
- const parsed = JSON.parse(value);
217
- if (!Array.isArray(parsed)) return [];
218
- return parsed.slice(0, MAX_RELATION_VALUES).flatMap((entry) => {
219
- if (typeof entry !== "object" || entry === null || !("id" in entry) || !("title" in entry) || typeof entry.id !== "string" || typeof entry.title !== "string") return [];
220
- return [{
221
- id: entry.id,
222
- title: entry.title
223
- }];
224
- });
225
- } catch {
226
- return [];
227
- }
228
- }
229
- //#endregion
230
- export { encodeEidosFileJsonArray as _, decodeEidosFileMultiSelectValues as a, isMutableEidosFileFieldType as c, parseEidosFileSelectOptions as d, decodeEidosFileAttachmentPaths as f, decodeEidosFileStringArray as g, decodeEidosFileJsonArray as h, MUTABLE_BASE_FIELD_TYPES as i, planEidosFileFieldConversion as l, normalizeEidosFileAttachmentPath as m, decodeEidosFileRelationIds as n, eidosFileFieldDisplayValues as o, encodeEidosFileAttachmentPaths as p, encodeEidosFileRelationIds as r, encodeEidosFileMultiSelectValues as s, decodeEidosFileRelationDisplay as t, assertEidosFileSelectOptions as u, EidosFileError as v };
231
-
232
- //# sourceMappingURL=relation-values-B0JhHBjZ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"relation-values-B0JhHBjZ.mjs","names":[],"sources":["../src/errors.ts","../src/json-array-values.ts","../src/file-values.ts","../src/select-options.ts","../src/field-conversion.ts","../src/relation-values.ts"],"sourcesContent":["export type EidosFileErrorCode =\n | \"invalid-sqlite\"\n | \"not-eidos-file\"\n | \"unsupported-format\"\n | \"invalid-schema\"\n | \"invalid-identifier\"\n | \"invalid-query\"\n | \"invalid-range\"\n | \"invalid-csv\"\n | \"protected-field\"\n | \"protected-view\"\n | \"relation-in-use\"\n | \"formula-in-use\"\n | \"lookup-in-use\"\n | \"table-not-found\"\n | \"row-not-found\"\n | \"field-not-found\"\n | \"view-not-found\"\n | \"file-exists\"\n | \"file-not-found\"\n\nexport class EidosFileError extends Error {\n constructor(\n readonly code: EidosFileErrorCode,\n message: string\n ) {\n super(message)\n this.name = \"EidosFileError\"\n }\n}\n","import type { EidosFileRowValue } from \"./types\"\n\nexport type EidosFileJsonArrayValue = string | number | boolean | null\n\nexport function decodeEidosFileJsonArray(\n value: EidosFileRowValue | undefined\n): EidosFileJsonArrayValue[] {\n if (typeof value !== \"string\" || value.length === 0) return []\n try {\n const parsed: unknown = JSON.parse(value)\n if (!Array.isArray(parsed)) return []\n return parsed.filter(\n (entry): entry is EidosFileJsonArrayValue =>\n entry === null ||\n typeof entry === \"string\" ||\n typeof entry === \"number\" ||\n typeof entry === \"boolean\"\n )\n } catch {\n return []\n }\n}\n\nexport function decodeEidosFileStringArray(\n value: EidosFileRowValue | undefined\n): string[] {\n return decodeEidosFileJsonArray(value).filter(\n (entry): entry is string => typeof entry === \"string\"\n )\n}\n\nexport function encodeEidosFileJsonArray(\n values: readonly EidosFileJsonArrayValue[]\n): string | null {\n return values.length > 0 ? JSON.stringify(values) : null\n}\n","import type { EidosFileRowValue } from \"./types\"\nimport { decodeEidosFileStringArray } from \"./json-array-values\"\n\nconst EXTERNAL_REFERENCE = /^(?:https?:|data:)/i\n\nexport function normalizeEidosFileAttachmentPath(value: string): string | null {\n const trimmed = value.trim()\n if (!trimmed || trimmed.includes(\"\\0\")) return null\n if (EXTERNAL_REFERENCE.test(trimmed)) return trimmed\n if (/^[a-z][a-z\\d+.-]*:/i.test(trimmed)) return null\n\n const parts = trimmed.replace(/\\\\/g, \"/\").split(\"/\")\n const normalized: string[] = []\n for (const part of parts) {\n if (!part || part === \".\") continue\n if (part === \"..\") {\n if (normalized.length === 0) return null\n normalized.pop()\n continue\n }\n normalized.push(part)\n }\n return normalized.length > 0 ? normalized.join(\"/\") : null\n}\n\nexport function decodeEidosFileAttachmentPaths(\n value: EidosFileRowValue | undefined\n): string[] {\n const candidates = decodeEidosFileStringArray(value)\n const seen = new Set<string>()\n return candidates.flatMap((candidate) => {\n const normalized = normalizeEidosFileAttachmentPath(candidate)\n if (!normalized || seen.has(normalized)) return []\n seen.add(normalized)\n return [normalized]\n })\n}\n\nexport function encodeEidosFileAttachmentPaths(\n paths: readonly string[]\n): string | null {\n const normalized = decodeEidosFileAttachmentPaths(JSON.stringify(paths))\n return normalized.length > 0 ? JSON.stringify(normalized) : null\n}\n","import { EidosFileError } from \"./errors\"\nimport type { EidosFileSelectOption } from \"./types\"\n\nexport function parseEidosFileSelectOptions(\n property: Record<string, unknown> | null | undefined\n): EidosFileSelectOption[] {\n const options = property?.options\n if (!Array.isArray(options)) return []\n return options.flatMap((option) => {\n if (\n typeof option !== \"object\" ||\n option === null ||\n !(\"value\" in option) ||\n typeof option.value !== \"string\"\n ) {\n return []\n }\n return [\n {\n value: option.value,\n color:\n \"color\" in option && typeof option.color === \"string\"\n ? option.color\n : \"default\",\n },\n ]\n })\n}\n\nexport function assertEidosFileSelectOptions(\n property: Record<string, unknown> | null | undefined\n): EidosFileSelectOption[] {\n const rawOptions = property?.options\n if (!Array.isArray(rawOptions)) {\n throw new EidosFileError(\n \"invalid-schema\",\n \"Select fields require an options array\"\n )\n }\n const options = parseEidosFileSelectOptions(property)\n if (options.length !== rawOptions.length) {\n throw new EidosFileError(\n \"invalid-schema\",\n \"Every select option requires a string value\"\n )\n }\n const values = new Set<string>()\n for (const option of options) {\n if (!option.value.trim()) {\n throw new EidosFileError(\n \"invalid-schema\",\n \"Select option values cannot be empty\"\n )\n }\n if (values.has(option.value)) {\n throw new EidosFileError(\n \"invalid-schema\",\n `Duplicate select option value: ${option.value}`\n )\n }\n values.add(option.value)\n }\n return options\n}\n","import type { EidosFileSqlPrimitive } from \"./connection\"\nimport {\n decodeEidosFileAttachmentPaths,\n encodeEidosFileAttachmentPaths,\n} from \"./file-values\"\nimport {\n decodeEidosFileJsonArray,\n decodeEidosFileStringArray,\n encodeEidosFileJsonArray,\n} from \"./json-array-values\"\nimport { parseEidosFileSelectOptions } from \"./select-options\"\nimport type {\n EidosFileFieldInfo,\n EidosFileFieldType,\n EidosFileSelectOption,\n EidosFileStorageCodec,\n} from \"./types\"\n\nexport const MUTABLE_BASE_FIELD_TYPES = [\n \"text\",\n \"number\",\n \"checkbox\",\n \"date\",\n \"datetime\",\n \"file\",\n \"multi-select\",\n \"rating\",\n \"select\",\n \"url\",\n] as const satisfies readonly EidosFileFieldType[]\n\nexport type MutableEidosFileFieldType =\n (typeof MUTABLE_BASE_FIELD_TYPES)[number]\n\nconst MUTABLE_TYPE_SET = new Set<EidosFileFieldType>(MUTABLE_BASE_FIELD_TYPES)\nconst OPTION_COLORS = [\n \"gray\",\n \"brown\",\n \"pink\",\n \"red\",\n \"orange\",\n \"yellow\",\n \"green\",\n \"cyan\",\n \"blue\",\n \"purple\",\n]\n\nexport interface EidosFileFieldValueRow {\n id: string\n value: EidosFileSqlPrimitive\n}\n\nexport interface EidosFileFieldConversionPlan {\n property: Record<string, unknown> | null\n storageCodec: EidosFileStorageCodec\n values: Array<{ id: string; value: EidosFileSqlPrimitive }>\n}\n\nexport function isMutableEidosFileFieldType(\n type: EidosFileFieldType\n): type is MutableEidosFileFieldType {\n return MUTABLE_TYPE_SET.has(type)\n}\n\nexport function decodeEidosFileMultiSelectValues(\n value: EidosFileSqlPrimitive\n): string[] {\n return Array.from(new Set(decodeEidosFileStringArray(value).filter(Boolean)))\n}\n\nexport function encodeEidosFileMultiSelectValues(\n values: readonly string[]\n): string | null {\n return encodeEidosFileJsonArray(Array.from(new Set(values.filter(Boolean))))\n}\n\nexport function eidosFileFieldDisplayValues(\n field: EidosFileFieldInfo,\n value: EidosFileSqlPrimitive | boolean\n): string[] {\n if (value === null) return []\n const primitiveValue: EidosFileSqlPrimitive =\n typeof value === \"boolean\" ? (value ? 1 : 0) : value\n if (field.type === \"file\")\n return decodeEidosFileAttachmentPaths(primitiveValue)\n if (field.type === \"select\") {\n return [String(primitiveValue)].filter(Boolean)\n }\n if (field.type === \"multi-select\") {\n return decodeEidosFileMultiSelectValues(primitiveValue)\n }\n if (field.storageCodec === \"json_array\") {\n return decodeEidosFileJsonArray(primitiveValue).flatMap((entry) =>\n entry === null ? [] : [String(entry)]\n )\n }\n if (field.type === \"checkbox\") {\n return [value === true || value === 1 || value === \"1\" ? \"true\" : \"false\"]\n }\n if (primitiveValue instanceof Uint8Array) return []\n const text = String(primitiveValue).trim()\n return text ? [text] : []\n}\n\nfunction optionPlan(\n field: EidosFileFieldInfo,\n rows: EidosFileFieldValueRow[]\n): EidosFileSelectOption[] {\n const existingByName = new Map(\n parseEidosFileSelectOptions(field.property).map((option) => [\n option.value,\n option,\n ])\n )\n const names = Array.from(\n new Set(\n rows.flatMap((row) => eidosFileFieldDisplayValues(field, row.value))\n )\n )\n return names.map(\n (name, index) =>\n existingByName.get(name) ?? {\n value: name,\n color: OPTION_COLORS[index % OPTION_COLORS.length],\n }\n )\n}\n\nfunction defaultProperty(\n type: MutableEidosFileFieldType,\n options: EidosFileSelectOption[]\n): Record<string, unknown> | null {\n if (type === \"select\" || type === \"multi-select\") return { options }\n if (type === \"number\") {\n return {\n format: \"number\",\n showAs: \"number\",\n color: \"purple\",\n divideBy: 100,\n showNumber: true,\n }\n }\n return null\n}\n\nfunction storageCodec(type: MutableEidosFileFieldType): EidosFileStorageCodec {\n if (type === \"multi-select\" || type === \"file\") return \"json_array\"\n return \"scalar\"\n}\n\nfunction numericValue(values: string[]): number | null {\n if (values.length === 0) return null\n const parsed = Number(values[0])\n return Number.isFinite(parsed) ? parsed : null\n}\n\nfunction checkboxValue(\n sourceValue: EidosFileSqlPrimitive,\n values: string[]\n): number | null {\n if (sourceValue === null) return null\n if (typeof sourceValue === \"number\" || typeof sourceValue === \"bigint\") {\n return sourceValue === 0 || sourceValue === 0n ? 0 : 1\n }\n const normalized = values[0]?.trim().toLowerCase()\n if (!normalized) return 0\n if ([\"0\", \"false\", \"no\", \"off\", \"unchecked\"].includes(normalized)) return 0\n return 1\n}\n\nfunction convertedValue(\n type: MutableEidosFileFieldType,\n sourceValue: EidosFileSqlPrimitive,\n values: string[]\n): EidosFileSqlPrimitive {\n if (sourceValue === null) return null\n if (type === \"number\") return numericValue(values)\n if (type === \"checkbox\") return checkboxValue(sourceValue, values)\n if (type === \"rating\") {\n const value = numericValue(values)\n return value === null ? null : Math.min(5, Math.max(0, Math.round(value)))\n }\n if (type === \"file\") return encodeEidosFileAttachmentPaths(values)\n if (type === \"select\") {\n return values[0] || null\n }\n if (type === \"multi-select\") {\n return encodeEidosFileMultiSelectValues(values)\n }\n return values.length > 0 ? values.join(\", \") : null\n}\n\nexport function planEidosFileFieldConversion(\n field: EidosFileFieldInfo,\n rows: EidosFileFieldValueRow[],\n targetType: MutableEidosFileFieldType\n): EidosFileFieldConversionPlan {\n const options =\n targetType === \"select\" || targetType === \"multi-select\"\n ? optionPlan(field, rows)\n : []\n return {\n property: defaultProperty(targetType, options),\n storageCodec: storageCodec(targetType),\n values: rows.map((row) => {\n const values = eidosFileFieldDisplayValues(field, row.value)\n return {\n id: row.id,\n value: convertedValue(targetType, row.value, values),\n }\n }),\n }\n}\n","import type { EidosFileRelationValue, EidosFileRowValue } from \"./types\"\nimport { decodeEidosFileStringArray } from \"./json-array-values\"\n\nconst MAX_RELATION_VALUES = 500\n\nexport function decodeEidosFileRelationIds(\n value: EidosFileRowValue | undefined\n): string[] {\n return Array.from(\n new Set(\n decodeEidosFileStringArray(value)\n .map((entry) => entry.trim())\n .filter(Boolean)\n .slice(0, MAX_RELATION_VALUES)\n )\n )\n}\n\nexport function encodeEidosFileRelationIds(\n ids: readonly string[]\n): string | null {\n const normalized = Array.from(\n new Set(ids.map((id) => id.trim()).filter(Boolean))\n ).slice(0, MAX_RELATION_VALUES)\n return normalized.length > 0 ? JSON.stringify(normalized) : null\n}\n\nexport function decodeEidosFileRelationDisplay(\n value: EidosFileRowValue | undefined\n): EidosFileRelationValue[] {\n if (typeof value !== \"string\" || value.length === 0) return []\n try {\n const parsed: unknown = JSON.parse(value)\n if (!Array.isArray(parsed)) return []\n return parsed.slice(0, MAX_RELATION_VALUES).flatMap((entry) => {\n if (\n typeof entry !== \"object\" ||\n entry === null ||\n !(\"id\" in entry) ||\n !(\"title\" in entry) ||\n typeof entry.id !== \"string\" ||\n typeof entry.title !== \"string\"\n ) {\n return []\n }\n return [{ id: entry.id, title: entry.title }]\n })\n } catch {\n return []\n }\n}\n"],"mappings":";AAqBA,IAAa,iBAAb,cAAoC,MAAM;CACxC,YACE,MACA,SACA;AACA,QAAM,QAAQ;AAHL,OAAA,OAAA;AAIT,OAAK,OAAO;;;;;ACvBhB,SAAgB,yBACd,OAC2B;AAC3B,KAAI,OAAO,UAAU,YAAY,MAAM,WAAW,EAAG,QAAO,EAAE;AAC9D,KAAI;EACF,MAAM,SAAkB,KAAK,MAAM,MAAM;AACzC,MAAI,CAAC,MAAM,QAAQ,OAAO,CAAE,QAAO,EAAE;AACrC,SAAO,OAAO,QACX,UACC,UAAU,QACV,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,UACpB;SACK;AACN,SAAO,EAAE;;;AAIb,SAAgB,2BACd,OACU;AACV,QAAO,yBAAyB,MAAM,CAAC,QACpC,UAA2B,OAAO,UAAU,SAC9C;;AAGH,SAAgB,yBACd,QACe;AACf,QAAO,OAAO,SAAS,IAAI,KAAK,UAAU,OAAO,GAAG;;;;AC/BtD,MAAM,qBAAqB;AAE3B,SAAgB,iCAAiC,OAA8B;CAC7E,MAAM,UAAU,MAAM,MAAM;AAC5B,KAAI,CAAC,WAAW,QAAQ,SAAS,KAAK,CAAE,QAAO;AAC/C,KAAI,mBAAmB,KAAK,QAAQ,CAAE,QAAO;AAC7C,KAAI,sBAAsB,KAAK,QAAQ,CAAE,QAAO;CAEhD,MAAM,QAAQ,QAAQ,QAAQ,OAAO,IAAI,CAAC,MAAM,IAAI;CACpD,MAAM,aAAuB,EAAE;AAC/B,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,CAAC,QAAQ,SAAS,IAAK;AAC3B,MAAI,SAAS,MAAM;AACjB,OAAI,WAAW,WAAW,EAAG,QAAO;AACpC,cAAW,KAAK;AAChB;;A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