@drhomet/mithaq 0.0.0-stage → 0.1.1
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 +22 -0
- package/LICENSES/payload.txt +22 -0
- package/LICENSES/ponytail.txt +21 -0
- package/dist/asas/actor.d.ts +96 -0
- package/dist/asas/actor.js +114 -0
- package/dist/asas/build.d.ts +231 -0
- package/dist/asas/build.js +787 -0
- package/dist/asas/cli/mithaq.d.ts +2 -0
- package/dist/asas/cli/mithaq.js +145 -0
- package/dist/asas/cli/upgrade.d.ts +20 -0
- package/dist/asas/cli/upgrade.js +147 -0
- package/dist/asas/http/fetch.d.ts +23 -0
- package/dist/asas/http/fetch.js +115 -0
- package/dist/asas/http/orpc.d.ts +43 -0
- package/dist/asas/http/orpc.js +135 -0
- package/dist/asas/runner/bulk.d.ts +20 -0
- package/dist/asas/runner/bulk.js +191 -0
- package/dist/asas/runner/errors.d.ts +60 -0
- package/dist/asas/runner/errors.js +59 -0
- package/dist/asas/runner/read.d.ts +68 -0
- package/dist/asas/runner/read.js +579 -0
- package/dist/asas/runner/runtime.d.ts +21 -0
- package/dist/asas/runner/runtime.js +8 -0
- package/dist/asas/runner/steps.d.ts +400 -0
- package/dist/asas/runner/steps.js +271 -0
- package/dist/asas/runner/tenant.d.ts +54 -0
- package/dist/asas/runner/tenant.js +213 -0
- package/dist/asas/runner/write.d.ts +444 -0
- package/dist/asas/runner/write.js +791 -0
- package/dist/auth/better-auth/access.d.ts +15 -0
- package/dist/auth/better-auth/access.js +71 -0
- package/dist/auth/better-auth/generate.d.ts +29 -0
- package/dist/auth/better-auth/generate.js +310 -0
- package/dist/auth/better-auth/index.d.ts +92 -0
- package/dist/auth/better-auth/index.js +81 -0
- package/dist/auth/better-auth/tenant.d.ts +18 -0
- package/dist/auth/better-auth/tenant.js +26 -0
- package/dist/auth/local/index.d.ts +285 -0
- package/dist/auth/local/index.js +736 -0
- package/dist/base/decimal.d.ts +9 -0
- package/dist/base/decimal.js +16 -0
- package/dist/base/fields.d.ts +123 -0
- package/dist/base/fields.js +51 -0
- package/dist/base/index.d.ts +46 -0
- package/dist/base/index.js +5 -0
- package/dist/base/kinds.d.ts +54 -0
- package/dist/base/kinds.js +78 -0
- package/dist/base/rules.d.ts +73 -0
- package/dist/base/rules.js +80 -0
- package/dist/drizzle/index.d.ts +438 -0
- package/dist/drizzle/index.js +832 -0
- package/dist/drizzle/kinds.d.ts +27 -0
- package/dist/drizzle/kinds.js +41 -0
- package/dist/drizzle/migrate.d.ts +133 -0
- package/dist/drizzle/migrate.js +1285 -0
- package/dist/drizzle/proxy/index.d.ts +1 -0
- package/dist/drizzle/proxy/index.js +1 -0
- package/dist/drizzle/proxy/node-postgres.d.ts +1 -0
- package/dist/drizzle/proxy/node-postgres.js +1 -0
- package/dist/drizzle/proxy/pg-core.d.ts +1 -0
- package/dist/drizzle/proxy/pg-core.js +1 -0
- package/dist/drizzle/rules.d.ts +336 -0
- package/dist/drizzle/rules.js +44 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +36 -0
- package/dist/mithaq/define.d.ts +288 -0
- package/dist/mithaq/define.js +43 -0
- package/dist/mithaq/generate-messages.d.ts +38 -0
- package/dist/mithaq/generate-messages.js +234 -0
- package/dist/mithaq/language.d.ts +335 -0
- package/dist/mithaq/language.js +76 -0
- package/dist/mithaq/lock.d.ts +71 -0
- package/dist/mithaq/lock.js +329 -0
- package/dist/mithaq/messages.d.ts +55 -0
- package/dist/mithaq/messages.js +106 -0
- package/dist/mithaq/refusal.d.ts +6 -0
- package/dist/mithaq/refusal.js +6 -0
- package/dist/mithaq/resolve.d.ts +10 -0
- package/dist/mithaq/resolve.js +954 -0
- package/dist/mithaq/rows.d.ts +87 -0
- package/dist/mithaq/rows.js +174 -0
- package/dist/mithaq/rukn.d.ts +72 -0
- package/dist/mithaq/rukn.js +15 -0
- package/dist/mithaq/standard-schema.d.ts +38 -0
- package/dist/mithaq/standard-schema.js +2 -0
- package/dist/mithaq/types.d.ts +358 -0
- package/dist/mithaq/types.js +15 -0
- package/dist/mithaq/user.d.ts +19 -0
- package/dist/mithaq/user.js +16 -0
- package/dist/mithaq/where.d.ts +32 -0
- package/dist/mithaq/where.js +87 -0
- package/dist/rbac/index.d.ts +105 -0
- package/dist/rbac/index.js +182 -0
- package/dist/rbac/steps.d.ts +22 -0
- package/dist/rbac/steps.js +161 -0
- package/dist/rich-text/index.d.ts +27 -0
- package/dist/rich-text/index.js +58 -0
- package/dist/rich-text/rich-text.d.ts +159 -0
- package/dist/rich-text/rich-text.js +372 -0
- package/dist/screen/client.d.ts +153 -0
- package/dist/screen/client.js +68 -0
- package/dist/screen/generate.d.ts +14 -0
- package/dist/screen/generate.js +226 -0
- package/dist/screen/index.d.ts +479 -0
- package/dist/screen/index.js +645 -0
- package/dist/screen/react.d.ts +95 -0
- package/dist/screen/react.js +58 -0
- package/dist/screen/studio.d.ts +24 -0
- package/dist/screen/studio.js +68 -0
- package/dist/service/index.d.ts +63 -0
- package/dist/service/index.js +15 -0
- package/dist/storage/allowed-type.d.ts +5 -0
- package/dist/storage/allowed-type.js +7 -0
- package/dist/storage/index.d.ts +43 -0
- package/dist/storage/index.js +44 -0
- package/dist/storage/storage.d.ts +384 -0
- package/dist/storage/storage.js +405 -0
- package/dist/versions/index.d.ts +37 -0
- package/dist/versions/index.js +8 -0
- package/dist/versions/versions.d.ts +104 -0
- package/dist/versions/versions.js +160 -0
- package/dist/zod/index.d.ts +184 -0
- package/dist/zod/index.js +121 -0
- package/dist/zod/kinds.d.ts +34 -0
- package/dist/zod/kinds.js +49 -0
- package/dist/zod/rules.d.ts +117 -0
- package/dist/zod/rules.js +67 -0
- package/package.json +63 -4
- package/r/mithaq-cells.json +20 -0
- package/r/mithaq-controls.json +37 -0
- package/r/mithaq-directional-icon.json +15 -0
- package/r/mithaq-expected-updated-at.json +15 -0
- package/r/mithaq-field-shell.json +18 -0
- package/r/mithaq-filter-operators.json +15 -0
- package/r/mithaq-form.json +33 -0
- package/r/mithaq-list-columns.json +23 -0
- package/r/mithaq-list-filters.json +24 -0
- package/r/mithaq-list-pagination.json +24 -0
- package/r/mithaq-list-query.json +18 -0
- package/r/mithaq-list-selection.json +19 -0
- package/r/mithaq-list.json +33 -0
- package/r/mithaq-nav.json +24 -0
- package/r/mithaq-nodes.json +34 -0
- package/r/mithaq-relationship-cell.json +20 -0
- package/r/mithaq-relationship-control.json +20 -0
- package/r/mithaq-rich-text.json +40 -0
- package/r/mithaq-screens-host.json +96 -0
- package/r/mithaq-storage.json +44 -0
- package/r/mithaq-upload.json +29 -0
- package/r/registry.json +550 -0
- package/README.md +0 -3
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { integer, text, uuid } from 'drizzle-orm/pg-core';
|
|
2
|
+
import type { ResolvedField } from '../mithaq/types.ts';
|
|
3
|
+
import type { ColumnBuilder } from './index.ts';
|
|
4
|
+
/** Length is a rule, not a kind: without a maximum a string column is `text`. */
|
|
5
|
+
declare const string: (field: ResolvedField) => import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]> | import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>;
|
|
6
|
+
declare const idColumns: {
|
|
7
|
+
number: typeof integer;
|
|
8
|
+
text: typeof text;
|
|
9
|
+
uuid: typeof uuid;
|
|
10
|
+
};
|
|
11
|
+
export declare const idKinds: (keyof typeof idColumns)[];
|
|
12
|
+
/** One column builder per kind. */
|
|
13
|
+
export declare const kinds: {
|
|
14
|
+
number: (field: ResolvedField) => import("drizzle-orm/pg-core").PgNumericNumberBuilder | import("drizzle-orm/pg-core").PgSerialBuilder;
|
|
15
|
+
integer: (field: ResolvedField) => import("drizzle-orm/pg-core").PgIntegerBuilder;
|
|
16
|
+
decimal: (field: ResolvedField) => import("drizzle-orm/pg-core").PgNumericBuilder;
|
|
17
|
+
text: typeof string;
|
|
18
|
+
email: typeof string;
|
|
19
|
+
checkbox: (field: ResolvedField) => import("drizzle-orm/pg-core").PgBooleanBuilder;
|
|
20
|
+
textArray: (field: ResolvedField) => import("drizzle-orm/pg-core").SetDimensions<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>, 1>;
|
|
21
|
+
uuid: (field: ResolvedField) => import("drizzle-orm/pg-core").PgUUIDBuilder;
|
|
22
|
+
datetime: (field: ResolvedField) => import("drizzle-orm/pg-core").PgTimestampBuilder;
|
|
23
|
+
date: (field: ResolvedField) => import("drizzle-orm/pg-core").PgDateStringBuilder;
|
|
24
|
+
join: (field: ResolvedField) => never;
|
|
25
|
+
relationship: ColumnBuilder;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { boolean, date, integer, numeric, serial, text, timestamp, uuid, varchar } from 'drizzle-orm/pg-core';
|
|
2
|
+
/** Length is a rule, not a kind: without a maximum a string column is `text`. */
|
|
3
|
+
const string = (field) => typeof field.rules?.maxLength !== 'number'
|
|
4
|
+
? text(field.column)
|
|
5
|
+
: varchar(field.column, { length: field.rules.maxLength });
|
|
6
|
+
// A foreign key takes the type of the id it points at: Postgres refuses a
|
|
7
|
+
// `text` column referencing a `uuid` key. The keys are the kinds an id may be.
|
|
8
|
+
const idColumns = { number: integer, text, uuid };
|
|
9
|
+
export const idKinds = Object.keys(idColumns);
|
|
10
|
+
const idColumn = (field) => idColumns[field.target.fields.id.kind](field.column);
|
|
11
|
+
const relationship = (field, tables) => idColumn(field).references(() => tables[field.target.name].id, {
|
|
12
|
+
onDelete: ['cascade', 'restrict', 'set null'].includes(String(field.rules?.onDelete))
|
|
13
|
+
? field.rules?.onDelete
|
|
14
|
+
: undefined,
|
|
15
|
+
});
|
|
16
|
+
/** One column builder per kind. */
|
|
17
|
+
export const kinds = {
|
|
18
|
+
number: (field) => field.name === 'id' ? serial(field.column) : numeric(field.column, { mode: 'number' }),
|
|
19
|
+
integer: (field) => integer(field.column),
|
|
20
|
+
// drizzle's default string mode, so no digit passes through a JS number.
|
|
21
|
+
decimal: (field) => typeof field.rules?.precision === 'number'
|
|
22
|
+
? numeric(field.column, { precision: field.rules.precision, scale: field.rules.scale })
|
|
23
|
+
: numeric(field.column),
|
|
24
|
+
text: string,
|
|
25
|
+
email: string,
|
|
26
|
+
checkbox: (field) => boolean(field.column),
|
|
27
|
+
// Length is not a rule this kind binds, so it is never `varchar(n)[]`.
|
|
28
|
+
textArray: (field) => text(field.column).array(),
|
|
29
|
+
// Only the primary key gets a random default: any other uuid column holds an
|
|
30
|
+
// identifier something else chose.
|
|
31
|
+
uuid: (field) => (field.name === 'id' ? uuid(field.column).defaultRandom() : uuid(field.column)),
|
|
32
|
+
datetime: (field) => timestamp(field.column, { precision: 3, withTimezone: true, mode: 'date' }),
|
|
33
|
+
// `mode: 'string'` keeps the day a day: `'date'` mode hands back a `Date` at
|
|
34
|
+
// local midnight, which another zone reads as the day before.
|
|
35
|
+
date: (field) => date(field.column, { mode: 'string' }),
|
|
36
|
+
// Unreachable: `columnsOfField` answers a join with no column before any builder runs.
|
|
37
|
+
join: (field) => {
|
|
38
|
+
throw new Error(`Field "${field.name}" is a join, whose rows are held by kayan "${field.target?.name}", so this store builds no column for it.`);
|
|
39
|
+
},
|
|
40
|
+
relationship,
|
|
41
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { type NodePgDatabase } from 'drizzle-orm/node-postgres';
|
|
2
|
+
import { type ProdMigrations } from './index.ts';
|
|
3
|
+
import type { ResolvedKayan } from '../mithaq/types.ts';
|
|
4
|
+
export declare const binary: string;
|
|
5
|
+
export declare const header = "// Written by `mithaq migrate`. Commit it.";
|
|
6
|
+
/** One `unresolved` item, and one reply in the hints file, are the same shape. */
|
|
7
|
+
type Hint = {
|
|
8
|
+
type: string;
|
|
9
|
+
kind: string;
|
|
10
|
+
entity: string[];
|
|
11
|
+
reason?: string;
|
|
12
|
+
};
|
|
13
|
+
type Envelope = {
|
|
14
|
+
status: 'ok';
|
|
15
|
+
migration_path?: string;
|
|
16
|
+
statements?: Statement[];
|
|
17
|
+
} | {
|
|
18
|
+
status: 'no_changes';
|
|
19
|
+
} | {
|
|
20
|
+
status: 'missing_hints';
|
|
21
|
+
unresolved: Hint[];
|
|
22
|
+
} | {
|
|
23
|
+
status: 'error';
|
|
24
|
+
error: {
|
|
25
|
+
code: string;
|
|
26
|
+
source?: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
type Statement = {
|
|
30
|
+
type: 'drop_table';
|
|
31
|
+
table: {
|
|
32
|
+
schema: string;
|
|
33
|
+
name: string;
|
|
34
|
+
};
|
|
35
|
+
} | {
|
|
36
|
+
type: 'drop_column';
|
|
37
|
+
column: {
|
|
38
|
+
schema: string;
|
|
39
|
+
table: string;
|
|
40
|
+
name: string;
|
|
41
|
+
};
|
|
42
|
+
} | {
|
|
43
|
+
type: 'drop_pk';
|
|
44
|
+
pk: {
|
|
45
|
+
schema?: string;
|
|
46
|
+
table: string;
|
|
47
|
+
name: string;
|
|
48
|
+
};
|
|
49
|
+
} | {
|
|
50
|
+
type: 'drop_view';
|
|
51
|
+
view: {
|
|
52
|
+
schema: string;
|
|
53
|
+
name: string;
|
|
54
|
+
materialized?: boolean;
|
|
55
|
+
};
|
|
56
|
+
} | {
|
|
57
|
+
type: 'recreate_column';
|
|
58
|
+
diff: {
|
|
59
|
+
$right: {
|
|
60
|
+
schema: string;
|
|
61
|
+
table: string;
|
|
62
|
+
name: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
type: string;
|
|
67
|
+
};
|
|
68
|
+
type Losing = {
|
|
69
|
+
kind: 'table' | 'column' | 'primary_key' | 'view';
|
|
70
|
+
entity: string[];
|
|
71
|
+
};
|
|
72
|
+
export declare const droppedBy: (statement: Statement) => Losing | undefined;
|
|
73
|
+
/** A guard the database enforces and a migration would drop, in the shape its reply names it. */
|
|
74
|
+
type Guarded = {
|
|
75
|
+
kind: 'check' | 'enum' | 'column' | 'sequence';
|
|
76
|
+
entity: string[];
|
|
77
|
+
};
|
|
78
|
+
export declare const guardDroppedBy: (statement: Statement) => Guarded | undefined;
|
|
79
|
+
type Database = {
|
|
80
|
+
execute(query: unknown): Promise<{
|
|
81
|
+
rows: unknown[];
|
|
82
|
+
}>;
|
|
83
|
+
transaction<T>(run: (tx: {
|
|
84
|
+
execute(query: unknown): Promise<{
|
|
85
|
+
rows: unknown[];
|
|
86
|
+
}>;
|
|
87
|
+
}) => Promise<T>, config?: {
|
|
88
|
+
accessMode?: 'read only';
|
|
89
|
+
}): Promise<T>;
|
|
90
|
+
};
|
|
91
|
+
export declare const bootMigrations: ({ db, prodMigrations }: {
|
|
92
|
+
db: NodePgDatabase;
|
|
93
|
+
prodMigrations: ProdMigrations | undefined;
|
|
94
|
+
}) => Promise<void>;
|
|
95
|
+
type Pulled = {
|
|
96
|
+
status: 'ok';
|
|
97
|
+
migrationPath: string;
|
|
98
|
+
snapshotPath: string;
|
|
99
|
+
} | {
|
|
100
|
+
status: 'error';
|
|
101
|
+
error: {
|
|
102
|
+
code: string;
|
|
103
|
+
source?: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export declare const baselineOf: ({ envelope, read, tables }: {
|
|
107
|
+
envelope: Pulled;
|
|
108
|
+
read: (path: string) => string;
|
|
109
|
+
/** The language's tables as `<schema>.<name>`. */
|
|
110
|
+
tables: readonly string[];
|
|
111
|
+
}) => {
|
|
112
|
+
folder: string;
|
|
113
|
+
sql: string;
|
|
114
|
+
snapshot: string;
|
|
115
|
+
};
|
|
116
|
+
export declare const statementsOf: (envelope: Envelope) => Statement[];
|
|
117
|
+
type Target = {
|
|
118
|
+
db: Database;
|
|
119
|
+
tables: Record<string, unknown>;
|
|
120
|
+
schemas: Record<string, unknown>;
|
|
121
|
+
enums: Record<string, {
|
|
122
|
+
schema?: string;
|
|
123
|
+
enumName: string;
|
|
124
|
+
enumValues: string[];
|
|
125
|
+
}>;
|
|
126
|
+
connectionString?: string;
|
|
127
|
+
kayan: readonly ResolvedKayan[];
|
|
128
|
+
};
|
|
129
|
+
export declare const run: ({ target, flags, }: {
|
|
130
|
+
target: Target;
|
|
131
|
+
flags: readonly string[];
|
|
132
|
+
}) => Promise<number>;
|
|
133
|
+
export {};
|