@eskais/app-sdk 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +74 -2
- package/dist/action/action.d.ts +133 -0
- package/dist/action/action.js +224 -0
- package/dist/action/bulk.d.ts +24 -0
- package/dist/action/bulk.js +24 -0
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.js +51 -0
- package/dist/cli/routes.d.ts +17 -0
- package/dist/cli/routes.js +36 -0
- package/dist/core/assume.d.ts +1 -0
- package/dist/core/assume.js +8 -0
- package/dist/core/constants.d.ts +359 -0
- package/dist/core/constants.js +187 -0
- package/dist/core/contracts.d.ts +107 -0
- package/dist/core/contracts.js +3 -0
- package/dist/core/data-labels.d.ts +210 -0
- package/dist/core/data-labels.js +385 -0
- package/dist/core/errors.d.ts +52 -0
- package/dist/core/errors.js +209 -0
- package/dist/core/guards.d.ts +9 -0
- package/dist/core/guards.js +14 -0
- package/dist/core/refusal.d.ts +30 -0
- package/dist/core/refusal.js +53 -0
- package/dist/dialogs/dialogs.d.ts +75 -0
- package/dist/dialogs/dialogs.js +66 -0
- package/dist/draft/draft.d.ts +36 -0
- package/dist/draft/draft.js +87 -0
- package/dist/errors/adapters.d.ts +21 -0
- package/dist/errors/adapters.js +81 -0
- package/dist/errors/define-errors.d.ts +88 -0
- package/dist/errors/define-errors.js +168 -0
- package/dist/errors/idempotency.d.ts +2 -0
- package/dist/errors/idempotency.js +13 -0
- package/dist/export/csv.d.ts +25 -0
- package/dist/export/csv.js +59 -0
- package/dist/i18n/adapters.d.ts +53 -0
- package/dist/i18n/adapters.js +56 -0
- package/dist/i18n/format.d.ts +10 -0
- package/dist/i18n/format.js +273 -0
- package/dist/i18n/labels.d.ts +10 -0
- package/dist/i18n/labels.js +227 -0
- package/dist/i18n/locale.d.ts +73 -0
- package/dist/i18n/locale.js +74 -0
- package/dist/i18n/messages.d.ts +93 -0
- package/dist/i18n/messages.js +16 -0
- package/dist/import/csv-parse.d.ts +11 -0
- package/dist/import/csv-parse.js +70 -0
- package/dist/import/import.d.ts +104 -0
- package/dist/import/import.js +266 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +45 -0
- package/dist/navigation/nav.d.ts +128 -0
- package/dist/navigation/nav.js +301 -0
- package/dist/navigation/router.d.ts +81 -0
- package/dist/navigation/router.js +249 -0
- package/dist/navigation/shortcuts.d.ts +37 -0
- package/dist/navigation/shortcuts.js +93 -0
- package/dist/next/index.d.ts +3 -0
- package/dist/next/index.js +3 -0
- package/dist/next/screen-hydration.d.ts +12 -0
- package/dist/next/screen-hydration.js +26 -0
- package/dist/next/screen.d.ts +25 -0
- package/dist/next/screen.js +44 -0
- package/dist/next/server/handler.d.ts +39 -0
- package/dist/next/server/handler.js +190 -0
- package/dist/next/server/index.d.ts +6 -0
- package/dist/next/server/index.js +6 -0
- package/dist/next/server/page.d.ts +63 -0
- package/dist/next/server/page.js +110 -0
- package/dist/next/server/prefetch.d.ts +29 -0
- package/dist/next/server/prefetch.js +97 -0
- package/dist/next/server/session.d.ts +25 -0
- package/dist/next/server/session.js +23 -0
- package/dist/next/use-next-router.d.ts +21 -0
- package/dist/next/use-next-router.js +104 -0
- package/dist/permissions/permissions.d.ts +134 -0
- package/dist/permissions/permissions.js +121 -0
- package/dist/react/data-layer.d.ts +68 -0
- package/dist/react/data-layer.js +76 -0
- package/dist/react/hooks/use-action-dialog.d.ts +25 -0
- package/dist/react/hooks/use-action-dialog.js +31 -0
- package/dist/react/hooks/use-action.d.ts +37 -0
- package/dist/react/hooks/use-action.js +125 -0
- package/dist/react/hooks/use-better-auth.d.ts +12 -0
- package/dist/react/hooks/use-better-auth.js +11 -0
- package/dist/react/hooks/use-bulk-action.d.ts +20 -0
- package/dist/react/hooks/use-bulk-action.js +24 -0
- package/dist/react/hooks/use-dialogs.d.ts +14 -0
- package/dist/react/hooks/use-dialogs.js +20 -0
- package/dist/react/hooks/use-draft.d.ts +5 -0
- package/dist/react/hooks/use-draft.js +17 -0
- package/dist/react/hooks/use-nav.d.ts +17 -0
- package/dist/react/hooks/use-nav.js +35 -0
- package/dist/react/hooks/use-new-rows.d.ts +22 -0
- package/dist/react/hooks/use-new-rows.js +24 -0
- package/dist/react/hooks/use-permissions.d.ts +13 -0
- package/dist/react/hooks/use-permissions.js +19 -0
- package/dist/react/hooks/use-reauthenticate.d.ts +6 -0
- package/dist/react/hooks/use-reauthenticate.js +11 -0
- package/dist/react/hooks/use-resource.d.ts +92 -0
- package/dist/react/hooks/use-resource.js +255 -0
- package/dist/react/hooks/use-view.d.ts +6 -0
- package/dist/react/hooks/use-view.js +24 -0
- package/dist/react/index.d.ts +15 -0
- package/dist/react/index.js +15 -0
- package/dist/react/keys.d.ts +60 -0
- package/dist/react/keys.js +71 -0
- package/dist/react/new-rows.d.ts +22 -0
- package/dist/react/new-rows.js +72 -0
- package/dist/refresh/new-rows.d.ts +13 -0
- package/dist/refresh/new-rows.js +18 -0
- package/dist/resource/form-schema.d.ts +11 -0
- package/dist/resource/form-schema.js +51 -0
- package/dist/resource/relations.d.ts +99 -0
- package/dist/resource/relations.js +194 -0
- package/dist/resource/resource-relations.d.ts +47 -0
- package/dist/resource/resource-relations.js +154 -0
- package/dist/resource/resource-schema.d.ts +9 -0
- package/dist/resource/resource-schema.js +73 -0
- package/dist/resource/resource-texts.d.ts +18 -0
- package/dist/resource/resource-texts.js +13 -0
- package/dist/resource/resource-types.d.ts +420 -0
- package/dist/resource/resource-types.js +1 -0
- package/dist/resource/resource-words.d.ts +25 -0
- package/dist/resource/resource-words.js +221 -0
- package/dist/resource/resource.d.ts +15 -0
- package/dist/resource/resource.js +280 -0
- package/dist/resource/schema.d.ts +57 -0
- package/dist/resource/schema.js +115 -0
- package/dist/services/from-page-source.d.ts +15 -0
- package/dist/services/from-page-source.js +27 -0
- package/dist/services/memory-query.d.ts +8 -0
- package/dist/services/memory-query.js +165 -0
- package/dist/services/memory-service.d.ts +33 -0
- package/dist/services/memory-service.js +291 -0
- package/dist/services/read-only-service.d.ts +18 -0
- package/dist/services/read-only-service.js +25 -0
- package/dist/services/rest-service.d.ts +65 -0
- package/dist/services/rest-service.js +222 -0
- package/dist/services/rng.d.ts +9 -0
- package/dist/services/rng.js +22 -0
- package/dist/services/spring-service.d.ts +58 -0
- package/dist/services/spring-service.js +132 -0
- package/dist/session/better-auth.d.ts +83 -0
- package/dist/session/better-auth.js +86 -0
- package/dist/session/session.d.ts +45 -0
- package/dist/session/session.js +36 -0
- package/dist/view/preferences.d.ts +35 -0
- package/dist/view/preferences.js +93 -0
- package/dist/view/view-types.d.ts +124 -0
- package/dist/view/view-types.js +1 -0
- package/dist/view/view-url.d.ts +7 -0
- package/dist/view/view-url.js +54 -0
- package/dist/view/view.d.ts +4 -0
- package/dist/view/view.js +392 -0
- package/locales/en.json +193 -0
- package/locales/es.json +193 -0
- package/package.json +88 -4
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { DataLabels } from "../core/data-labels.js";
|
|
2
|
+
import type { Resource } from "../resource/resource-types.js";
|
|
3
|
+
/** A resource's grammatical gender, for a `select` in a message: `{gender, select, f {Nueva} other {Nuevo}}`. */
|
|
4
|
+
export declare const Gender: {
|
|
5
|
+
readonly feminine: "f";
|
|
6
|
+
readonly masculine: "m";
|
|
7
|
+
readonly neuter: "n";
|
|
8
|
+
};
|
|
9
|
+
export type Gender = (typeof Gender)[keyof typeof Gender];
|
|
10
|
+
/** The schema issues a catalog's `issues` words: `"minLength": "Use at least {min} characters."`. */
|
|
11
|
+
export declare const IssueCode: {
|
|
12
|
+
readonly required: "required";
|
|
13
|
+
readonly minLength: "minLength";
|
|
14
|
+
readonly maxLength: "maxLength";
|
|
15
|
+
readonly minItems: "minItems";
|
|
16
|
+
readonly maxItems: "maxItems";
|
|
17
|
+
readonly min: "min";
|
|
18
|
+
readonly max: "max";
|
|
19
|
+
readonly email: "email";
|
|
20
|
+
readonly url: "url";
|
|
21
|
+
readonly pattern: "pattern";
|
|
22
|
+
readonly invalid: "invalid";
|
|
23
|
+
};
|
|
24
|
+
export type IssueCode = (typeof IssueCode)[keyof typeof IssueCode];
|
|
25
|
+
type Words<Labels> = {
|
|
26
|
+
readonly [Key in keyof Labels]: Labels[Key] extends string ? string : Labels[Key] extends (...args: never[]) => unknown ? string : Words<Labels[Key]>;
|
|
27
|
+
};
|
|
28
|
+
/** Every generic message, as `@eskais/app-sdk/locales/en.json` holds them: one ICU message per `DataLabels` text. */
|
|
29
|
+
export type Messages = Words<Omit<DataLabels, "issues">> & {
|
|
30
|
+
readonly issues: Readonly<Record<IssueCode, string>>;
|
|
31
|
+
};
|
|
32
|
+
type DeepPartial<Value> = {
|
|
33
|
+
readonly [Key in keyof Value]?: Value[Key] extends string ? string : DeepPartial<Value[Key]>;
|
|
34
|
+
};
|
|
35
|
+
/** What a catalog says about one resource, under `resources.<key>`. */
|
|
36
|
+
export type ResourceMessages = {
|
|
37
|
+
readonly one?: string;
|
|
38
|
+
readonly other?: string;
|
|
39
|
+
readonly gender?: string;
|
|
40
|
+
/** The New button's text, when "New {one}" doesn't fit. */
|
|
41
|
+
readonly create?: string;
|
|
42
|
+
/** Field and column labels, by key: `"fields": { "placedAt": "Fecha" }`. */
|
|
43
|
+
readonly fields?: Readonly<Record<string, unknown>>;
|
|
44
|
+
/** Field descriptions, by key. */
|
|
45
|
+
readonly descriptions?: Readonly<Record<string, string>>;
|
|
46
|
+
/** Each enum value's text, by field: `"values": { "status": { "pending": "Pendiente" } }`. */
|
|
47
|
+
readonly values?: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
48
|
+
/** Field group legends, by group id. */
|
|
49
|
+
readonly groups?: Readonly<Record<string, string>>;
|
|
50
|
+
/** The resource's actions, by the id after `<key>.`: `"actions": { "cancel": "Cancelar" }`. */
|
|
51
|
+
readonly actions?: Readonly<Record<string, string>>;
|
|
52
|
+
/** The record page's own tabs and sections, by id. */
|
|
53
|
+
readonly tabs?: Readonly<Record<string, string>>;
|
|
54
|
+
readonly sections?: Readonly<Record<string, string>>;
|
|
55
|
+
};
|
|
56
|
+
/** A catalog to merge over a base: any generic message, the app's resources and the app's own keys for `msg()`. */
|
|
57
|
+
export type MessagesInput = DeepPartial<Messages> & {
|
|
58
|
+
readonly resources?: Readonly<Record<string, ResourceMessages>>;
|
|
59
|
+
readonly [key: string]: unknown;
|
|
60
|
+
};
|
|
61
|
+
type Primitive = string | number | boolean | bigint | null | undefined | Date;
|
|
62
|
+
type Literals<Value> = string extends Value ? never : Value extends string ? Value : never;
|
|
63
|
+
type Labelled<Row> = {
|
|
64
|
+
[Key in Exclude<keyof Row & string, "id">]-?: NonNullable<Row[Key]> extends Primitive | readonly Primitive[] ? Key : never;
|
|
65
|
+
}[Exclude<keyof Row & string, "id">];
|
|
66
|
+
type Enums<Row> = {
|
|
67
|
+
[Key in keyof Row & string]-?: [Literals<NonNullable<Row[Key]>>] extends [never] ? never : Key;
|
|
68
|
+
}[keyof Row & string];
|
|
69
|
+
type StrictResource<Row> = Omit<ResourceMessages, "one" | "other" | "fields" | "values"> & {
|
|
70
|
+
readonly one: string;
|
|
71
|
+
readonly other: string;
|
|
72
|
+
readonly fields: {
|
|
73
|
+
readonly [Key in Labelled<Row>]: string;
|
|
74
|
+
} & Readonly<Record<string, unknown>>;
|
|
75
|
+
} & ([Enums<Row>] extends [never] ? {
|
|
76
|
+
readonly values?: ResourceMessages["values"];
|
|
77
|
+
} : {
|
|
78
|
+
readonly values: {
|
|
79
|
+
readonly [Key in Enums<Row>]: Readonly<Record<Literals<NonNullable<Row[Key]>>, string>>;
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
type UnionToIntersection<Union> = (Union extends unknown ? (value: Union) => void : never) extends (value: infer Intersection) => void ? Intersection : never;
|
|
83
|
+
type ResourcesCatalog<Resources extends readonly unknown[]> = UnionToIntersection<{
|
|
84
|
+
[Index in keyof Resources]: Resources[Index] extends Resource<infer Row, infer _Id, infer _Filter, infer Key> ? {
|
|
85
|
+
readonly [Name in Key]: StrictResource<Row>;
|
|
86
|
+
} : never;
|
|
87
|
+
}[number]>;
|
|
88
|
+
/** `defineLocale.strict`'s catalog: every message, and every name, field and enum value of `Resources`. */
|
|
89
|
+
export type StrictMessages<Resources extends readonly unknown[]> = Messages & {
|
|
90
|
+
readonly resources: ResourcesCatalog<Resources>;
|
|
91
|
+
readonly [key: string]: unknown;
|
|
92
|
+
};
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** A resource's grammatical gender, for a `select` in a message: `{gender, select, f {Nueva} other {Nuevo}}`. */
|
|
2
|
+
export const Gender = { feminine: "f", masculine: "m", neuter: "n" };
|
|
3
|
+
/** The schema issues a catalog's `issues` words: `"minLength": "Use at least {min} characters."`. */
|
|
4
|
+
export const IssueCode = {
|
|
5
|
+
required: "required",
|
|
6
|
+
minLength: "minLength",
|
|
7
|
+
maxLength: "maxLength",
|
|
8
|
+
minItems: "minItems",
|
|
9
|
+
maxItems: "maxItems",
|
|
10
|
+
min: "min",
|
|
11
|
+
max: "max",
|
|
12
|
+
email: "email",
|
|
13
|
+
url: "url",
|
|
14
|
+
pattern: "pattern",
|
|
15
|
+
invalid: "invalid",
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** A CSV file read: its header row and the rows under it, each as text cells. */
|
|
2
|
+
export type CsvTable = {
|
|
3
|
+
header: string[];
|
|
4
|
+
rows: string[][];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Reads CSV (RFC 4180): quoted cells with `""` for a quote and line breaks inside, CRLF or LF, a byte order mark,
|
|
8
|
+
* and the delimiter the first line uses most (a comma, the semicolon spreadsheets write in many locales, or a tab).
|
|
9
|
+
* Blank lines are skipped.
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseCsv(input: string, delimiter?: string): CsvTable;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const delimiters = [",", ";", "\t"];
|
|
2
|
+
function delimiterOf(text) {
|
|
3
|
+
const line = text.slice(0, text.search(/\r?\n|$/u));
|
|
4
|
+
let best = delimiters[0];
|
|
5
|
+
let most = -1;
|
|
6
|
+
for (const candidate of delimiters) {
|
|
7
|
+
const found = line.split(candidate).length - 1;
|
|
8
|
+
if (found > most) {
|
|
9
|
+
best = candidate;
|
|
10
|
+
most = found;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return best;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Reads CSV (RFC 4180): quoted cells with `""` for a quote and line breaks inside, CRLF or LF, a byte order mark,
|
|
17
|
+
* and the delimiter the first line uses most (a comma, the semicolon spreadsheets write in many locales, or a tab).
|
|
18
|
+
* Blank lines are skipped.
|
|
19
|
+
*/
|
|
20
|
+
export function parseCsv(input, delimiter = delimiterOf(input)) {
|
|
21
|
+
const text = input.startsWith("") ? input.slice(1) : input;
|
|
22
|
+
const records = [];
|
|
23
|
+
let record = [];
|
|
24
|
+
let cell = "";
|
|
25
|
+
let quoted = false;
|
|
26
|
+
let index = 0;
|
|
27
|
+
const endCell = () => {
|
|
28
|
+
record.push(cell);
|
|
29
|
+
cell = "";
|
|
30
|
+
};
|
|
31
|
+
const endRecord = () => {
|
|
32
|
+
endCell();
|
|
33
|
+
if (record.length > 1 || record[0] !== "")
|
|
34
|
+
records.push(record);
|
|
35
|
+
record = [];
|
|
36
|
+
};
|
|
37
|
+
while (index < text.length) {
|
|
38
|
+
const char = text[index];
|
|
39
|
+
if (quoted) {
|
|
40
|
+
if (char === '"' && text[index + 1] === '"') {
|
|
41
|
+
cell += '"';
|
|
42
|
+
index += 2;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (char === '"')
|
|
46
|
+
quoted = false;
|
|
47
|
+
else
|
|
48
|
+
cell += char;
|
|
49
|
+
index += 1;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (char === '"' && cell === "")
|
|
53
|
+
quoted = true;
|
|
54
|
+
else if (char === delimiter)
|
|
55
|
+
endCell();
|
|
56
|
+
else if (char === "\n")
|
|
57
|
+
endRecord();
|
|
58
|
+
else if (char === "\r") {
|
|
59
|
+
if (text[index + 1] !== "\n")
|
|
60
|
+
endRecord();
|
|
61
|
+
}
|
|
62
|
+
else
|
|
63
|
+
cell += char;
|
|
64
|
+
index += 1;
|
|
65
|
+
}
|
|
66
|
+
if (cell !== "" || record.length > 0)
|
|
67
|
+
endRecord();
|
|
68
|
+
const [header = [], ...rows] = records;
|
|
69
|
+
return { header: header.map((name) => name.trim()), rows };
|
|
70
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { FileFormat, ImportMode } from "../core/constants.js";
|
|
2
|
+
import type { CallContext } from "../core/contracts.js";
|
|
3
|
+
import type { Locale } from "../i18n/locale.js";
|
|
4
|
+
import { type ServiceError } from "../core/errors.js";
|
|
5
|
+
import { type Allowed } from "../core/refusal.js";
|
|
6
|
+
import type { ResolvedField, Resource } from "../resource/resource.js";
|
|
7
|
+
import { type StandardIssue } from "../resource/schema.js";
|
|
8
|
+
import { type RelationContext } from "../resource/relations.js";
|
|
9
|
+
import { type CsvTable } from "./csv-parse.js";
|
|
10
|
+
export type ImportChunkResult = {
|
|
11
|
+
ok: number;
|
|
12
|
+
failed: {
|
|
13
|
+
index: number;
|
|
14
|
+
error: ServiceError;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
export type ImportOptions<T> = {
|
|
18
|
+
/** `FileFormat.csv`, the one read in the browser today. */
|
|
19
|
+
formats?: readonly FileFormat[];
|
|
20
|
+
/** Other names a column may have, to a field: `{ "E-mail": "email" }`. */
|
|
21
|
+
match?: Readonly<Record<string, string>>;
|
|
22
|
+
/** `ImportMode.create` (default) adds every row; `ImportMode.upsert` updates the record whose `key` matches. */
|
|
23
|
+
mode?: ImportMode;
|
|
24
|
+
/** The natural key for `ImportMode.upsert`, like `email`. */
|
|
25
|
+
key?: string;
|
|
26
|
+
/** Rows per batch. Default 100. */
|
|
27
|
+
chunk?: number;
|
|
28
|
+
/** The fields a file may fill; the create form's by default. */
|
|
29
|
+
fields?: readonly string[];
|
|
30
|
+
/** Saves one batch your way (a bulk endpoint); by default each row is created through the service. */
|
|
31
|
+
run?: (rows: Partial<T>[], context: CallContext) => Promise<ImportChunkResult>;
|
|
32
|
+
};
|
|
33
|
+
/** Which field each column goes to, by the column's header; `undefined` leaves the column out. */
|
|
34
|
+
export type ImportMapping = Readonly<Record<string, string | undefined>>;
|
|
35
|
+
export type ImportIssue = {
|
|
36
|
+
field: string;
|
|
37
|
+
message: string;
|
|
38
|
+
};
|
|
39
|
+
/** A row read and checked: its line in the file (the header is line 1), its values and what's wrong with them. */
|
|
40
|
+
/**
|
|
41
|
+
* A row read and checked: its line in the file (the header is line 1), its values, what's wrong with them, and the
|
|
42
|
+
* titles of the records its relation fields point at (`{ countryId: "España" }`).
|
|
43
|
+
*/
|
|
44
|
+
export type ImportRow<T> = {
|
|
45
|
+
line: number;
|
|
46
|
+
values: Partial<T>;
|
|
47
|
+
issues: readonly ImportIssue[];
|
|
48
|
+
titles?: Readonly<Record<string, string>>;
|
|
49
|
+
};
|
|
50
|
+
export type ImportCheckOptions = {
|
|
51
|
+
/** The text of a schema issue, in the app's language; the schema's own message by default. */
|
|
52
|
+
describe?: (issue: StandardIssue, values: unknown) => string;
|
|
53
|
+
/** The text for an id no related record has. */
|
|
54
|
+
missing?: (id: string) => string;
|
|
55
|
+
/** Reads the related records, one `getMany` per relation; without it, relation ids aren't checked. */
|
|
56
|
+
context?: RelationContext;
|
|
57
|
+
};
|
|
58
|
+
export type ImportPreview<T> = {
|
|
59
|
+
rows: readonly ImportRow<T>[];
|
|
60
|
+
valid: readonly ImportRow<T>[];
|
|
61
|
+
invalid: readonly ImportRow<T>[];
|
|
62
|
+
};
|
|
63
|
+
export type ImportSummary = {
|
|
64
|
+
total: number;
|
|
65
|
+
created: number;
|
|
66
|
+
updated: number;
|
|
67
|
+
failed: readonly {
|
|
68
|
+
line: number;
|
|
69
|
+
error: ServiceError;
|
|
70
|
+
}[];
|
|
71
|
+
/** Stopped by the signal: the rows after the batch that was running weren't sent. */
|
|
72
|
+
cancelled: boolean;
|
|
73
|
+
};
|
|
74
|
+
export type ImportRunOptions = CallContext & {
|
|
75
|
+
onProgress?: (done: number, total: number) => void;
|
|
76
|
+
};
|
|
77
|
+
export type Import<T, Id = unknown, F = unknown> = {
|
|
78
|
+
readonly resource: Resource<T, Id, F>;
|
|
79
|
+
readonly options: ImportOptions<T>;
|
|
80
|
+
readonly formats: readonly FileFormat[];
|
|
81
|
+
readonly mode: ImportMode;
|
|
82
|
+
/** Whether a file of this format can be read. */
|
|
83
|
+
checkFormat(format: FileFormat): Allowed;
|
|
84
|
+
/** The fields rows go to, labelled in `locale`. */
|
|
85
|
+
fields(locale?: Locale): ResolvedField<T>[];
|
|
86
|
+
read(text: string): CsvTable;
|
|
87
|
+
/** Pairs columns with fields by key, label and `match`, ignoring case, accents and punctuation. */
|
|
88
|
+
match(header: readonly string[], locale?: Locale): ImportMapping;
|
|
89
|
+
/** The rows as records of the fields they go to, each text turned into the field's type. */
|
|
90
|
+
recordsOf(table: CsvTable, mapping: ImportMapping): Record<string, unknown>[];
|
|
91
|
+
/** Checks records against the resource's create schema; `firstLine` numbers them (2 under a header). */
|
|
92
|
+
check(records: readonly unknown[], firstLine?: number, options?: ImportCheckOptions): Promise<ImportPreview<T>>;
|
|
93
|
+
/** Saves the rows in batches, reporting progress, and stops between batches once `signal` aborts. */
|
|
94
|
+
run(rows: readonly ImportRow<T>[], options: ImportRunOptions): Promise<ImportSummary>;
|
|
95
|
+
/** The invalid rows as CSV, with a column that says what's wrong, to fix and import again. */
|
|
96
|
+
errorsCsv(invalid: readonly ImportRow<T>[], errorColumn: string, lineColumn: string): string;
|
|
97
|
+
};
|
|
98
|
+
/** Rows that don't pass, in a sentence: how many, and the first three with their fields. */
|
|
99
|
+
export declare function invalidRowsText(invalid: readonly ImportRow<unknown>[]): string;
|
|
100
|
+
/**
|
|
101
|
+
* Declares how a resource imports rows: read a CSV file, pair its columns with fields, check every row with the
|
|
102
|
+
* resource's create schema, and save the valid ones in batches, with progress and cancellation (the `signal`).
|
|
103
|
+
*/
|
|
104
|
+
export declare function defineImport<T, Id, F>(resource: Resource<T, Id, F>, options?: ImportOptions<T>): Import<T, Id, F>;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { FieldKind, FileFormat, FormStage, ImportMode, JsonType, RelationKind, ServiceErrorKind, } from "../core/constants.js";
|
|
2
|
+
import { toServiceError } from "../core/errors.js";
|
|
3
|
+
import { isNumber, isObject, isRecord, isString } from "../core/guards.js";
|
|
4
|
+
import { refuse } from "../core/refusal.js";
|
|
5
|
+
import { toCsv } from "../export/csv.js";
|
|
6
|
+
import { formSchemaOf } from "../resource/form-schema.js";
|
|
7
|
+
import { issuePath, validate } from "../resource/schema.js";
|
|
8
|
+
import { resolveRelations } from "../resource/relations.js";
|
|
9
|
+
import { valueAt } from "../services/memory-query.js";
|
|
10
|
+
import { parseCsv } from "./csv-parse.js";
|
|
11
|
+
const Saved = { created: "created", updated: "updated" };
|
|
12
|
+
const plain = (text) => text
|
|
13
|
+
.normalize("NFD")
|
|
14
|
+
.replace(/\p{M}/gu, "")
|
|
15
|
+
.toLowerCase()
|
|
16
|
+
.replace(/[^\p{L}\p{N}]/gu, "");
|
|
17
|
+
const truthy = new Set(["true", "1", "yes", "y", "si", "x", "on"]);
|
|
18
|
+
const falsy = new Set(["false", "0", "no", "n", "off"]);
|
|
19
|
+
function convert(field, text) {
|
|
20
|
+
const value = text.trim();
|
|
21
|
+
if (value === "")
|
|
22
|
+
return undefined;
|
|
23
|
+
const list = field.multiple || field.kind === FieldKind.tags || field.valueType === JsonType.array;
|
|
24
|
+
if (list)
|
|
25
|
+
return value
|
|
26
|
+
.split(/[;|,]/u)
|
|
27
|
+
.map((entry) => entry.trim())
|
|
28
|
+
.filter((entry) => entry !== "");
|
|
29
|
+
const numeric = field.valueType === JsonType.number ||
|
|
30
|
+
(field.kind === FieldKind.resource && /^-?\d+$/u.test(value)) ||
|
|
31
|
+
field.valueType === JsonType.integer ||
|
|
32
|
+
field.kind === FieldKind.number ||
|
|
33
|
+
field.kind === FieldKind.currency;
|
|
34
|
+
if (numeric) {
|
|
35
|
+
const number = Number(value.replace(/\s/gu, ""));
|
|
36
|
+
return Number.isNaN(number) ? value : number;
|
|
37
|
+
}
|
|
38
|
+
if (field.valueType === JsonType.boolean || field.kind === FieldKind.switch || field.kind === FieldKind.checkbox) {
|
|
39
|
+
const word = plain(value);
|
|
40
|
+
return truthy.has(word) ? true : falsy.has(word) ? false : value;
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
async function settleChunk(rows, save) {
|
|
45
|
+
return Promise.all(rows.map(async (row) => {
|
|
46
|
+
try {
|
|
47
|
+
return { line: row.line, outcome: { ok: true, value: await save(row) } };
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return { line: row.line, outcome: { ok: false, error } };
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
/** Rows that don't pass, in a sentence: how many, and the first three with their fields. */
|
|
55
|
+
export function invalidRowsText(invalid) {
|
|
56
|
+
const first = invalid
|
|
57
|
+
.slice(0, 3)
|
|
58
|
+
.map((row) => `row ${String(row.line)} (${row.issues.map((issue) => (issue.field === "" ? issue.message : `${issue.field}: ${issue.message}`)).join(", ")})`);
|
|
59
|
+
const count = invalid.length === 1 ? "1 row isn't valid" : `${String(invalid.length)} rows aren't valid`;
|
|
60
|
+
return `${count}: ${first.join("; ")}`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Declares how a resource imports rows: read a CSV file, pair its columns with fields, check every row with the
|
|
64
|
+
* resource's create schema, and save the valid ones in batches, with progress and cancellation (the `signal`).
|
|
65
|
+
*/
|
|
66
|
+
export function defineImport(resource, options = {}) {
|
|
67
|
+
const formats = options.formats ?? [FileFormat.csv];
|
|
68
|
+
const mode = options.mode ?? ImportMode.create;
|
|
69
|
+
const chunk = Math.max(1, options.chunk ?? 100);
|
|
70
|
+
const fields = (locale) => {
|
|
71
|
+
const all = resource
|
|
72
|
+
.in(locale)
|
|
73
|
+
.fields(FormStage.create)
|
|
74
|
+
.filter((field) => !field.readOnly(undefined));
|
|
75
|
+
return options.fields ? all.filter((field) => options.fields?.includes(field.key) === true) : all;
|
|
76
|
+
};
|
|
77
|
+
async function saveRow(row, context) {
|
|
78
|
+
if (mode === ImportMode.upsert && options.key !== undefined) {
|
|
79
|
+
const keyValue = valueAt(row.values, options.key);
|
|
80
|
+
if (keyValue !== undefined) {
|
|
81
|
+
const found = await resource.service.list({
|
|
82
|
+
filter: resource.filterOf({ [options.key]: keyValue }),
|
|
83
|
+
sort: [],
|
|
84
|
+
size: 1,
|
|
85
|
+
position: { page: 1 },
|
|
86
|
+
}, context);
|
|
87
|
+
const existing = found.items[0];
|
|
88
|
+
if (existing !== undefined) {
|
|
89
|
+
await resource.service.update(resource.idOf(existing), row.values, {
|
|
90
|
+
...context,
|
|
91
|
+
version: resource.service.versionOf?.(existing),
|
|
92
|
+
});
|
|
93
|
+
return Saved.updated;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
await resource.service.create(row.values, context);
|
|
98
|
+
return Saved.created;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
resource,
|
|
102
|
+
options,
|
|
103
|
+
formats,
|
|
104
|
+
mode,
|
|
105
|
+
checkFormat(format) {
|
|
106
|
+
if (format !== FileFormat.csv)
|
|
107
|
+
return refuse(`${format} files can't be read in the browser yet`);
|
|
108
|
+
return formats.includes(format) ? true : refuse(`this import takes ${formats.join(", ")} files`);
|
|
109
|
+
},
|
|
110
|
+
fields,
|
|
111
|
+
read: (text) => parseCsv(text),
|
|
112
|
+
match(header, locale) {
|
|
113
|
+
const aliases = new Map(Object.entries(options.match ?? {}).map(([name, key]) => [plain(name), key]));
|
|
114
|
+
const known = fields(locale);
|
|
115
|
+
const taken = new Set();
|
|
116
|
+
return Object.fromEntries(header.map((name) => {
|
|
117
|
+
const wanted = plain(name);
|
|
118
|
+
const key = aliases.get(wanted) ??
|
|
119
|
+
known.find((field) => plain(field.key) === wanted || plain(field.label) === wanted)?.key;
|
|
120
|
+
if (key === undefined || taken.has(key))
|
|
121
|
+
return [name, undefined];
|
|
122
|
+
taken.add(key);
|
|
123
|
+
return [name, key];
|
|
124
|
+
}));
|
|
125
|
+
},
|
|
126
|
+
recordsOf(table, mapping) {
|
|
127
|
+
const byKey = new Map(fields().map((field) => [field.key, field]));
|
|
128
|
+
return table.rows.map((cells) => {
|
|
129
|
+
const record = {};
|
|
130
|
+
for (const [index, name] of table.header.entries()) {
|
|
131
|
+
const key = mapping[name];
|
|
132
|
+
const field = key === undefined ? undefined : byKey.get(key);
|
|
133
|
+
if (key === undefined || field === undefined)
|
|
134
|
+
continue;
|
|
135
|
+
const value = convert(field, cells[index] ?? "");
|
|
136
|
+
if (value !== undefined)
|
|
137
|
+
record[key] = value;
|
|
138
|
+
}
|
|
139
|
+
return record;
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
async check(records, firstLine = 2, checking = {}) {
|
|
143
|
+
const describe = checking.describe ?? ((issue) => issue.message);
|
|
144
|
+
const schema = formSchemaOf(resource, FormStage.create, fields().map((field) => field.key));
|
|
145
|
+
const checked = await Promise.all(records.map(async (record, index) => {
|
|
146
|
+
const line = index + firstLine;
|
|
147
|
+
if (!isRecord(record))
|
|
148
|
+
return { line, values: {}, issues: [{ field: "", message: "not a record" }] };
|
|
149
|
+
if (!schema)
|
|
150
|
+
return { line, values: resource.inputOf(record), issues: [] };
|
|
151
|
+
const result = await validate(schema, record);
|
|
152
|
+
if (result.issues === undefined)
|
|
153
|
+
return { line, values: resource.inputOf(result.value), issues: [] };
|
|
154
|
+
const issues = result.issues.map((issue) => ({ field: issuePath(issue), message: describe(issue, record) }));
|
|
155
|
+
return { line, values: resource.inputOf(record), issues };
|
|
156
|
+
}));
|
|
157
|
+
const rows = checking.context
|
|
158
|
+
? await withRelated(fields(), checked, checking.context, checking.missing ?? ((id) => `no record ${id}`))
|
|
159
|
+
: checked;
|
|
160
|
+
return {
|
|
161
|
+
rows,
|
|
162
|
+
valid: rows.filter((row) => row.issues.length === 0),
|
|
163
|
+
invalid: rows.filter((row) => row.issues.length > 0),
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
async run(rows, { onProgress, ...context }) {
|
|
167
|
+
const failed = [];
|
|
168
|
+
const summary = { total: rows.length, created: 0, updated: 0, failed };
|
|
169
|
+
let done = 0;
|
|
170
|
+
onProgress?.(0, rows.length);
|
|
171
|
+
for (let start = 0; start < rows.length; start += chunk) {
|
|
172
|
+
if (context.signal.aborted)
|
|
173
|
+
return { ...summary, cancelled: true };
|
|
174
|
+
const batch = rows.slice(start, start + chunk);
|
|
175
|
+
if (options.run) {
|
|
176
|
+
try {
|
|
177
|
+
// Perf: one batch at a time, so a large file doesn't flood the server.
|
|
178
|
+
// oxlint-disable-next-line no-await-in-loop -- each batch waits for the one before, by design
|
|
179
|
+
const result = await options.run(batch.map((row) => row.values), context);
|
|
180
|
+
summary.created += result.ok;
|
|
181
|
+
for (const failure of result.failed)
|
|
182
|
+
summary.failed.push({ line: batch[failure.index]?.line ?? 0, error: failure.error });
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
const failure = toServiceError(error);
|
|
186
|
+
if (failure.kind === ServiceErrorKind.aborted)
|
|
187
|
+
return { ...summary, cancelled: true };
|
|
188
|
+
for (const row of batch)
|
|
189
|
+
summary.failed.push({ line: row.line, error: failure });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
// oxlint-disable-next-line no-await-in-loop -- each batch waits for the one before, by design
|
|
194
|
+
const outcomes = await settleChunk(batch, (row) => saveRow(row, context));
|
|
195
|
+
for (const { outcome, line } of outcomes) {
|
|
196
|
+
if (outcome.ok)
|
|
197
|
+
summary[outcome.value] += 1;
|
|
198
|
+
else
|
|
199
|
+
summary.failed.push({ line, error: toServiceError(outcome.error) });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
done += batch.length;
|
|
203
|
+
onProgress?.(done, rows.length);
|
|
204
|
+
}
|
|
205
|
+
return { ...summary, cancelled: context.signal.aborted && done < rows.length };
|
|
206
|
+
},
|
|
207
|
+
errorsCsv(invalid, errorColumn, lineColumn) {
|
|
208
|
+
const keys = [...new Set(invalid.flatMap((row) => Object.keys(isRecord(row.values) ? row.values : {})))];
|
|
209
|
+
return toCsv(invalid, [
|
|
210
|
+
{ key: "line", label: lineColumn, format: (row) => String(row.line) },
|
|
211
|
+
...keys.map((key) => ({ key, label: key, format: (row) => cellOf(valueAt(row.values, key)) })),
|
|
212
|
+
{
|
|
213
|
+
key: "issues",
|
|
214
|
+
label: errorColumn,
|
|
215
|
+
format: (row) => row.issues
|
|
216
|
+
.map((issue) => (issue.field === "" ? issue.message : `${issue.field}: ${issue.message}`))
|
|
217
|
+
.join("; "),
|
|
218
|
+
},
|
|
219
|
+
]);
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
async function withRelated(fields, rows, context, missing) {
|
|
224
|
+
const related = fields.flatMap((field) => {
|
|
225
|
+
const pointer = field.kind === FieldKind.resource ? (field.relation?.target ?? field.resource) : undefined;
|
|
226
|
+
const target = pointer?.();
|
|
227
|
+
return target ? [{ key: field.key, target }] : [];
|
|
228
|
+
});
|
|
229
|
+
const found = await Promise.all(related.map(async ({ key, target }) => {
|
|
230
|
+
const ids = [...new Set(rows.flatMap((row) => idsAt(row.values, key)))];
|
|
231
|
+
if (ids.length === 0)
|
|
232
|
+
return { key, target, records: new Map() };
|
|
233
|
+
const records = await resolveRelations({ relations: { related: { kind: RelationKind.manyToMany, target: () => target, key } } }, [{ [key]: ids }], ["related"], context);
|
|
234
|
+
const list = isRecord(records[0]) ? records[0].related : undefined;
|
|
235
|
+
const byId = new Map();
|
|
236
|
+
for (const record of Array.isArray(list) ? list : [])
|
|
237
|
+
byId.set(target.idKey(target.idOf(record)), record);
|
|
238
|
+
return { key, target, records: byId };
|
|
239
|
+
}));
|
|
240
|
+
return rows.map((row) => {
|
|
241
|
+
const issues = [...row.issues];
|
|
242
|
+
const titles = {};
|
|
243
|
+
for (const { key, target, records } of found) {
|
|
244
|
+
for (const id of idsAt(row.values, key)) {
|
|
245
|
+
const record = records.get(id);
|
|
246
|
+
if (record === undefined)
|
|
247
|
+
issues.push({ field: key, message: missing(id) });
|
|
248
|
+
else
|
|
249
|
+
titles[key] = titles[key] === undefined ? target.title(record) : `${titles[key]}, ${target.title(record)}`;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return { ...row, issues, ...(Object.keys(titles).length > 0 ? { titles } : {}) };
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
function idsAt(values, key) {
|
|
256
|
+
const raw = valueAt(values, key);
|
|
257
|
+
const list = Array.isArray(raw) ? raw : [raw];
|
|
258
|
+
return list.flatMap((entry) => (isString(entry) || isNumber(entry) ? [String(entry)] : []));
|
|
259
|
+
}
|
|
260
|
+
function cellOf(value) {
|
|
261
|
+
if (value === undefined || value === null)
|
|
262
|
+
return "";
|
|
263
|
+
if (Array.isArray(value))
|
|
264
|
+
return value.map(cellOf).join(", ");
|
|
265
|
+
return isObject(value) ? JSON.stringify(value) : String(value);
|
|
266
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export * from "./core/constants.js";
|
|
2
|
+
export type { CallContext, ExportResult, Page, PagePosition, PageSourceLike, Query, ResourceCapabilities, ResourceService, SortSpec, SourceCapabilities, Target, Version, } from "./core/contracts.js";
|
|
3
|
+
export { isPagePosition } from "./core/contracts.js";
|
|
4
|
+
export { fieldErrorsOf, httpServiceError, isServiceError, kindOfStatus, problemDetailError, ServiceFailure, serviceError, toServiceError, type ServiceError, type ServiceFieldError, } from "./core/errors.js";
|
|
5
|
+
export { AppActionRefusedError, firstRefusal, isRefusal, refuse, refusedError, toAllowed, unavailableError, clause, failedError, type Allowed, type Refusal, } from "./core/refusal.js";
|
|
6
|
+
export { createSession, fromCasl, type CaslAbilityLike, type CaslSessionOptions, type PermissionSubject, type Session, type SessionOptions, } from "./session/session.js";
|
|
7
|
+
export { allows, definePermissions, GrantScope, hasRole, permitted, sessionPayload, type GrantedPermissions, type Grants, type OperationOf, type OperationRules, type Operations, type PermissionAnswer, type PermissionContext, type PermissionRule, type PermissionRules, type Permissions, type PermissionSession, type PermissionSessionOptions, type PermissionsOptions, type PermissionTarget, type PermissionUses, type Register, type RegisteredOperation, type SessionPayload, } from "./permissions/permissions.js";
|
|
8
|
+
export { holdNewRows, type HeldPage } from "./refresh/new-rows.js";
|
|
9
|
+
export { createDialogQueue, DialogKind, type AlertRequest, type ConfirmRequest, type DialogAnswer, type DialogEntry, type DialogQueue, type Dialogs, type DialogsSnapshot, type DialogTexts, type PromptRequest, } from "./dialogs/dialogs.js";
|
|
10
|
+
export { betterAuthPermissions, betterAuthServerSession, betterAuthSession, betterAuthStoreSession, type BetterAuthPermissions, type BetterAuthRoleLike, type BetterAuthServerLike, type BetterAuthSessionData, type BetterAuthSessionOptions, type BetterAuthStoreLike, type BetterAuthUser, } from "./session/better-auth.js";
|
|
11
|
+
export { hashRouter, historyRouter, joinPath, memoryRouter, splitPath, tanstackRouter, type HashRouterOptions, type HistoryRouterOptions, type MemoryRouter, type NavigateOptions, type RouterAdapter, type RouterLocation, type TanstackRouterLike, } from "./navigation/router.js";
|
|
12
|
+
export { localPreferences, localViews, memoryPreferences, remotePreferences, type PreferencesStore, type SavedView, type ViewStore, } from "./view/preferences.js";
|
|
13
|
+
export { createRng, type Rng } from "./services/rng.js";
|
|
14
|
+
export { isStandardSchema, issuePath, jsonSchemaProperties, validate, zodIntrospect, type InferOutput, type Introspect, type SchemaProperty, type StandardIssue, type StandardResult, type StandardSchema, } from "./resource/schema.js";
|
|
15
|
+
export { applyQuery, matchesFilter, matchesSearch, sortRows, valueAt } from "./services/memory-query.js";
|
|
16
|
+
export { memoryService, type MemoryService, type MemoryServiceOptions } from "./services/memory-service.js";
|
|
17
|
+
export { HttpMethod, restService, type RestServiceOptions } from "./services/rest-service.js";
|
|
18
|
+
export { fromPageSource, type PageSourceCrud } from "./services/from-page-source.js";
|
|
19
|
+
export { readOnlyService, type ReadService } from "./services/read-only-service.js";
|
|
20
|
+
export { defineResource, dependentsOf, refreshPolicy, searchKey, type RefreshPolicy, type ResolvedRefresh, type AnyResource, type ColumnDef, type DetailOptions, type DetailSectionDef, type DetailTabDef, type ResolvedDetail, type ResourceScreens, type RoutedScreen, type ScreenComponent, type OptionDef, type FieldDef, type FieldGroup, type FilterDef, type Option, type Path, type ResolvedColumn, type ResolvedField, type ResolvedFilter, type Resource, type ResourceAudit, type ResourceLabel, type ResourceMatch, type ResourceOptions, type ResourceRoutes, type ResourceShortcuts, type DefineResourceOptions, type ResolvedRelation, type ToneName, } from "./resource/resource.js";
|
|
21
|
+
export { actionsOf, defineAction, isAction, messageOf, type Action, type ActionConfirm, type ActionConfirmDef, type ActionMessage, type ActionOptions, type ActionRunOptions, type ActionTarget, type AnyAction, } from "./action/action.js";
|
|
22
|
+
export { defineView, type Selection, type View, type ViewOptions, type ViewPreset, type ViewScope, type ViewSnapshot, type ViewState, } from "./view/view.js";
|
|
23
|
+
export { count, defineNav, isNavCount, navItem, screenUse, type Nav, type NavBadge, type NavCount, type NavGroup, type NavItem, type NavOptions, type NavRouteBuilder, type NavSnapshot, type TrailEntry, } from "./navigation/nav.js";
|
|
24
|
+
export { defineDraft, isStoredDraft, type Draft, type DraftOptions, type DraftSnapshot, type StoredDraft, } from "./draft/draft.js";
|
|
25
|
+
export { fieldsSchema, formSchemaOf, issueText } from "./resource/form-schema.js";
|
|
26
|
+
export { schemaFields } from "./resource/resource-schema.js";
|
|
27
|
+
export { exportCsv, toCsv, type CsvColumn, type CsvExportOptions } from "./export/csv.js";
|
|
28
|
+
export { dataLabelsEn, dataLabelsEs, type ControlLabels, type DataLabels, type ImportCounts, type IssueText, type RowRange, } from "./core/data-labels.js";
|
|
29
|
+
export { isOneOf, isRecord, valuesOf } from "./core/guards.js";
|
|
30
|
+
export { springFilter, springParams, springService, type SpringPage, type SpringServiceOptions, } from "./services/spring-service.js";
|
|
31
|
+
export { appShortcuts, createShortcutRegistry, normalizeShortcut, shortcutConflicts, warnInDevelopment, warnShortcutConflict, type ShortcutConflict, type ShortcutEntry, type ShortcutRegistry, } from "./navigation/shortcuts.js";
|
|
32
|
+
export { parseCsv, type CsvTable } from "./import/csv-parse.js";
|
|
33
|
+
export { defineImport, invalidRowsText, type Import, type ImportCheckOptions, type ImportChunkResult, type ImportIssue, type ImportMapping, type ImportOptions, type ImportPreview, type ImportRow, type ImportRunOptions, type ImportSummary, } from "./import/import.js";
|
|
34
|
+
export { belongsTo, childChanges, chunkIds, embeds, hasMany, includeOf, keyRelation, manyToMany, registerResource, resolveRelations, type BelongsTo, type ChildChanges, type Embeds, type HasMany, type ManyToMany, type Relation, type RelationContext, type RelationRows, type Relations, } from "./resource/relations.js";
|
|
35
|
+
export { isListSchema } from "./resource/schema.js";
|
|
36
|
+
export { defineLocale, flattenCatalog, isMessageRef, lookup, msg, refusalIn, resolveText, type Catalog, type Locale, type LocaleOptions, type MessageRef, type MessageValues, type Text, type TextRefusal, type Translate, } from "./i18n/locale.js";
|
|
37
|
+
export { Gender, IssueCode, type Messages, type MessagesInput, type ResourceMessages, type StrictMessages, } from "./i18n/messages.js";
|
|
38
|
+
export { checkMessage, formatMessage } from "./i18n/format.js";
|
|
39
|
+
export { dataLabelsOf } from "./i18n/labels.js";
|
|
40
|
+
export { fromI18next, fromIntl, fromNextIntl, type AdapterOptions, type I18nextLike, type IntlShapeLike, type NextIntlTranslator, type NextIntlValue, } from "./i18n/adapters.js";
|
|
41
|
+
export { isErrorReason, reasonOf } from "./core/errors.js";
|
|
42
|
+
export { defineErrors, type AppError, type CallOptions, type CodePolicy, type Errors, type ErrorsOptions, type FeedbackOptions, type Reauthenticate, type ReasonPolicy, type RetryOptions, } from "./errors/define-errors.js";
|
|
43
|
+
export { appError, firebaseErrors, responseErrors, type ErrorAdapter } from "./errors/adapters.js";
|
|
44
|
+
export { idempotencyKey } from "./errors/idempotency.js";
|
|
45
|
+
export { defineBulkAction, type BulkActionOptions } from "./action/action.js";
|
|
46
|
+
export { failedTarget, isBulkResult, type BulkFailure, type BulkResult } from "./action/bulk.js";
|