@marktiderman/genesis-core 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.
- package/dist/chunk-65SXNHWE.js +3 -0
- package/dist/chunk-65SXNHWE.js.map +1 -0
- package/dist/chunk-6V2TIN3G.js +202 -0
- package/dist/chunk-6V2TIN3G.js.map +1 -0
- package/dist/chunk-7KOLYF27.js +50 -0
- package/dist/chunk-7KOLYF27.js.map +1 -0
- package/dist/chunk-EL7YGOTY.js +3 -0
- package/dist/chunk-EL7YGOTY.js.map +1 -0
- package/dist/chunk-F4FOTIJI.js +357 -0
- package/dist/chunk-F4FOTIJI.js.map +1 -0
- package/dist/chunk-LQEICXJS.js +122 -0
- package/dist/chunk-LQEICXJS.js.map +1 -0
- package/dist/chunk-PVT6FHAO.js +21 -0
- package/dist/chunk-PVT6FHAO.js.map +1 -0
- package/dist/chunk-RYEXWQFD.js +9 -0
- package/dist/chunk-RYEXWQFD.js.map +1 -0
- package/dist/chunk-XCX2TRBL.js +3 -0
- package/dist/chunk-XCX2TRBL.js.map +1 -0
- package/dist/chunk-ZU72FMDR.js +137 -0
- package/dist/chunk-ZU72FMDR.js.map +1 -0
- package/dist/chunk-ZYJUEJ4Z.js +59 -0
- package/dist/chunk-ZYJUEJ4Z.js.map +1 -0
- package/dist/form-types.d.ts +50 -0
- package/dist/form-types.js +3 -0
- package/dist/form-types.js.map +1 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-one.d.ts +18 -0
- package/dist/hooks/use-one.js +5 -0
- package/dist/hooks/use-one.js.map +1 -0
- package/dist/hooks/use-resource-form.d.ts +38 -0
- package/dist/hooks/use-resource-form.js +7 -0
- package/dist/hooks/use-resource-form.js.map +1 -0
- package/dist/hooks/use-resource.d.ts +46 -0
- package/dist/hooks/use-resource.js +5 -0
- package/dist/hooks/use-resource.js.map +1 -0
- package/dist/hooks/use-wizard.d.ts +25 -0
- package/dist/hooks/use-wizard.js +3 -0
- package/dist/hooks/use-wizard.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/provider/index.d.ts +78 -0
- package/dist/provider/index.js +5 -0
- package/dist/provider/index.js.map +1 -0
- package/dist/storage/index.d.ts +10 -0
- package/dist/storage/index.js +4 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/types-BzcZrTjl.d.ts +119 -0
- package/dist/types-DKcxHXxq.d.ts +17 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +3 -0
- package/dist/utils.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
+
import { ResourceFormFieldDef } from '../form-types.js';
|
|
3
|
+
|
|
4
|
+
interface UseResourceFormOptions {
|
|
5
|
+
resource: string;
|
|
6
|
+
action: "create" | "edit";
|
|
7
|
+
id?: string;
|
|
8
|
+
initialData?: Record<string, unknown>;
|
|
9
|
+
fields?: ResourceFormFieldDef[];
|
|
10
|
+
/** Full dataset used to auto-detect select fields from unique values. */
|
|
11
|
+
listData?: Record<string, unknown>[];
|
|
12
|
+
onSuccess?: (data: Record<string, unknown>) => void;
|
|
13
|
+
onError?: (error: Error) => void;
|
|
14
|
+
/** Pre-fill create form defaults from URL query params. Default true. */
|
|
15
|
+
prefillFromUrl?: boolean;
|
|
16
|
+
/** Validation trigger mode. Default "onBlur". */
|
|
17
|
+
validationMode?: "onBlur" | "onChange" | "onSubmit";
|
|
18
|
+
/** Enable autosave drafts to localStorage for create mode. */
|
|
19
|
+
autosave?: boolean | {
|
|
20
|
+
debounceMs?: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
interface UseResourceFormReturn {
|
|
24
|
+
form: UseFormReturn<Record<string, unknown>>;
|
|
25
|
+
resolvedFields: ResourceFormFieldDef[];
|
|
26
|
+
onSubmit: (e?: {
|
|
27
|
+
preventDefault?: () => void;
|
|
28
|
+
}) => Promise<void>;
|
|
29
|
+
/** Raw save handler — use with form.handleSubmit(handleSave, onInvalid). */
|
|
30
|
+
handleSave: (data: Record<string, unknown>) => Promise<void>;
|
|
31
|
+
isSaving: boolean;
|
|
32
|
+
isLoading: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** Build default values for a single array item from its sub-field definitions */
|
|
35
|
+
declare function buildArrayItemDefaults(arrayFields: ResourceFormFieldDef[]): Record<string, unknown>;
|
|
36
|
+
declare function useResourceForm(options: UseResourceFormOptions): UseResourceFormReturn;
|
|
37
|
+
|
|
38
|
+
export { type UseResourceFormOptions, type UseResourceFormReturn, buildArrayItemDefaults, useResourceForm };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { buildArrayItemDefaults, useResourceForm } from '../chunk-F4FOTIJI.js';
|
|
2
|
+
import '../chunk-RYEXWQFD.js';
|
|
3
|
+
import '../chunk-PVT6FHAO.js';
|
|
4
|
+
import '../chunk-6V2TIN3G.js';
|
|
5
|
+
import '../chunk-ZYJUEJ4Z.js';
|
|
6
|
+
//# sourceMappingURL=use-resource-form.js.map
|
|
7
|
+
//# sourceMappingURL=use-resource-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"use-resource-form.js"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { UseQueryResult, UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import { h as SortParam, F as FilterParam, g as ListResult, L as ListParams, I as Identifier, B as BaseRecord } from '../types-BzcZrTjl.js';
|
|
3
|
+
|
|
4
|
+
interface UseResourceOptions<T> {
|
|
5
|
+
defaultSort?: SortParam;
|
|
6
|
+
defaultFilters?: FilterParam[];
|
|
7
|
+
defaultPerPage?: number;
|
|
8
|
+
/** Supabase select/join syntax, e.g. "*, author:profiles(name)". */
|
|
9
|
+
select?: string;
|
|
10
|
+
/** Fields to search across when setSearch is called. Required for server-side search. */
|
|
11
|
+
searchFields?: string[];
|
|
12
|
+
/** Disable auto-fetching. */
|
|
13
|
+
enabled?: boolean;
|
|
14
|
+
onCreateSuccess?: (data: T) => void;
|
|
15
|
+
onUpdateSuccess?: (data: T) => void;
|
|
16
|
+
onDeleteSuccess?: () => void;
|
|
17
|
+
onError?: (error: Error) => void;
|
|
18
|
+
}
|
|
19
|
+
interface UseResourceReturn<T> {
|
|
20
|
+
/** TanStack Query result for the list query. */
|
|
21
|
+
list: UseQueryResult<ListResult<T>>;
|
|
22
|
+
/** Current list params (pagination, sort, filters, search). */
|
|
23
|
+
params: ListParams;
|
|
24
|
+
setSort: (sort: SortParam | undefined) => void;
|
|
25
|
+
setFilters: (filters: FilterParam[]) => void;
|
|
26
|
+
setPage: (page: number) => void;
|
|
27
|
+
setPerPage: (perPage: number) => void;
|
|
28
|
+
setSearch: (query: string) => void;
|
|
29
|
+
/** Create a new record. Returns the created item. */
|
|
30
|
+
create: (data: Partial<T>) => Promise<T>;
|
|
31
|
+
/** Update an existing record by id. Returns the updated item. */
|
|
32
|
+
update: (id: Identifier, data: Partial<T>) => Promise<T>;
|
|
33
|
+
/** Delete a record by id. */
|
|
34
|
+
remove: (id: Identifier) => Promise<void>;
|
|
35
|
+
/** True when any mutation is in-flight. */
|
|
36
|
+
isMutating: boolean;
|
|
37
|
+
createMutation: UseMutationResult<T, Error, Partial<T>>;
|
|
38
|
+
updateMutation: UseMutationResult<T, Error, {
|
|
39
|
+
id: Identifier;
|
|
40
|
+
data: Partial<T>;
|
|
41
|
+
}>;
|
|
42
|
+
deleteMutation: UseMutationResult<void, Error, Identifier>;
|
|
43
|
+
}
|
|
44
|
+
declare function useResource<T extends BaseRecord = BaseRecord>(resource: string, options?: UseResourceOptions<T>): UseResourceReturn<T>;
|
|
45
|
+
|
|
46
|
+
export { type UseResourceOptions, type UseResourceReturn, useResource };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"use-resource.js"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
+
|
|
3
|
+
interface WizardStep {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
/** Field keys belonging to this step. */
|
|
8
|
+
fields: string[];
|
|
9
|
+
}
|
|
10
|
+
interface UseWizardReturn {
|
|
11
|
+
currentStep: number;
|
|
12
|
+
currentStepDef: WizardStep;
|
|
13
|
+
totalSteps: number;
|
|
14
|
+
/** Progress from 0 to 1. */
|
|
15
|
+
progress: number;
|
|
16
|
+
isFirst: boolean;
|
|
17
|
+
isLast: boolean;
|
|
18
|
+
/** Validate current step fields, advance if valid. Returns true if valid. */
|
|
19
|
+
next: () => Promise<boolean>;
|
|
20
|
+
back: () => void;
|
|
21
|
+
goTo: (step: number) => void;
|
|
22
|
+
}
|
|
23
|
+
declare function useWizard(steps: WizardStep[], form: UseFormReturn<Record<string, unknown>>): UseWizardReturn;
|
|
24
|
+
|
|
25
|
+
export { type UseWizardReturn, type WizardStep, useWizard };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"use-wizard.js"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { A as ArrayFilter, B as BaseRecord, C as CreateParams, a as CreateResult, D as DataProvider, b as DeleteParams, c as DeleteResult, F as FilterParam, G as GetManyParams, d as GetManyResult, e as GetOneParams, f as GetOneResult, I as Identifier, L as ListParams, g as ListResult, N as NullFilter, P as PaginationParam, R as RangeFilter, S as ScalarFilter, h as SortParam, U as UpdateParams, i as UpdateResult } from './types-BzcZrTjl.js';
|
|
2
|
+
export { DataProviderRoot, DataProviderRootProps, GenesisProvider, GenesisProviderProps, MockProviderOptions, SupabaseClient, createMockProvider, createSupabaseProvider, useDataProvider, useStorage } from './provider/index.js';
|
|
3
|
+
export { S as StorageAdapter } from './types-DKcxHXxq.js';
|
|
4
|
+
export { createLocalStorageAdapter, createMemoryStorageAdapter, createNoopStorageAdapter } from './storage/index.js';
|
|
5
|
+
export { UseResourceOptions, UseResourceReturn, useResource } from './hooks/use-resource.js';
|
|
6
|
+
export { UseOneOptions, useOne } from './hooks/use-one.js';
|
|
7
|
+
export { UseResourceFormOptions, UseResourceFormReturn, buildArrayItemDefaults, useResourceForm } from './hooks/use-resource-form.js';
|
|
8
|
+
export { UseWizardReturn, WizardStep, useWizard } from './hooks/use-wizard.js';
|
|
9
|
+
export { FieldType, ResourceFormFieldDef, SelectOption } from './form-types.js';
|
|
10
|
+
export { titleCase } from './utils.js';
|
|
11
|
+
import 'react/jsx-runtime';
|
|
12
|
+
import 'react';
|
|
13
|
+
import '@tanstack/react-query';
|
|
14
|
+
import 'react-hook-form';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { createSupabaseProvider } from './chunk-LQEICXJS.js';
|
|
2
|
+
import './chunk-XCX2TRBL.js';
|
|
3
|
+
import './chunk-65SXNHWE.js';
|
|
4
|
+
import './chunk-EL7YGOTY.js';
|
|
5
|
+
export { buildArrayItemDefaults, useResourceForm } from './chunk-F4FOTIJI.js';
|
|
6
|
+
export { titleCase } from './chunk-RYEXWQFD.js';
|
|
7
|
+
export { useOne } from './chunk-PVT6FHAO.js';
|
|
8
|
+
export { useResource } from './chunk-ZU72FMDR.js';
|
|
9
|
+
export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from './chunk-6V2TIN3G.js';
|
|
10
|
+
export { createLocalStorageAdapter, createMemoryStorageAdapter, createNoopStorageAdapter } from './chunk-ZYJUEJ4Z.js';
|
|
11
|
+
export { useWizard } from './chunk-7KOLYF27.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { D as DataProvider } from '../types-BzcZrTjl.js';
|
|
2
|
+
export { A as ArrayFilter, B as BaseRecord, C as CreateParams, a as CreateResult, b as DeleteParams, c as DeleteResult, F as FilterParam, G as GetManyParams, d as GetManyResult, e as GetOneParams, f as GetOneResult, I as Identifier, L as ListParams, g as ListResult, N as NullFilter, P as PaginationParam, R as RangeFilter, S as ScalarFilter, h as SortParam, U as UpdateParams, i as UpdateResult } from '../types-BzcZrTjl.js';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { S as StorageAdapter } from '../types-DKcxHXxq.js';
|
|
6
|
+
|
|
7
|
+
interface MockProviderOptions {
|
|
8
|
+
/** Simulated latency in ms (default 0). */
|
|
9
|
+
delay?: number;
|
|
10
|
+
}
|
|
11
|
+
type Row$1 = Record<string, unknown>;
|
|
12
|
+
declare function createMockProvider(datasets: Record<string, Row$1[]>, options?: MockProviderOptions): DataProvider;
|
|
13
|
+
|
|
14
|
+
/** A chainable query builder returned by `client.from(table)`. */
|
|
15
|
+
interface SupabaseQueryBuilder {
|
|
16
|
+
select(columns?: string, options?: {
|
|
17
|
+
count?: "exact" | "planned" | "estimated";
|
|
18
|
+
}): SupabaseQueryBuilder;
|
|
19
|
+
insert(data: Record<string, unknown> | Record<string, unknown>[]): SupabaseQueryBuilder;
|
|
20
|
+
update(data: Record<string, unknown>): SupabaseQueryBuilder;
|
|
21
|
+
delete(): SupabaseQueryBuilder;
|
|
22
|
+
eq(column: string, value: unknown): SupabaseQueryBuilder;
|
|
23
|
+
neq(column: string, value: unknown): SupabaseQueryBuilder;
|
|
24
|
+
gt(column: string, value: unknown): SupabaseQueryBuilder;
|
|
25
|
+
lt(column: string, value: unknown): SupabaseQueryBuilder;
|
|
26
|
+
gte(column: string, value: unknown): SupabaseQueryBuilder;
|
|
27
|
+
lte(column: string, value: unknown): SupabaseQueryBuilder;
|
|
28
|
+
ilike(column: string, value: string): SupabaseQueryBuilder;
|
|
29
|
+
in(column: string, values: unknown[]): SupabaseQueryBuilder;
|
|
30
|
+
is(column: string, value: null): SupabaseQueryBuilder;
|
|
31
|
+
not(column: string, operator: string, value: unknown): SupabaseQueryBuilder;
|
|
32
|
+
or(filters: string): SupabaseQueryBuilder;
|
|
33
|
+
order(column: string, options?: {
|
|
34
|
+
ascending?: boolean;
|
|
35
|
+
}): SupabaseQueryBuilder;
|
|
36
|
+
range(from: number, to: number): SupabaseQueryBuilder;
|
|
37
|
+
single(): SupabaseQueryBuilder;
|
|
38
|
+
then: Promise<{
|
|
39
|
+
data: unknown;
|
|
40
|
+
error: unknown;
|
|
41
|
+
count?: number | null;
|
|
42
|
+
}>["then"];
|
|
43
|
+
}
|
|
44
|
+
/** Minimal Supabase client interface accepted by the provider. */
|
|
45
|
+
interface SupabaseClient {
|
|
46
|
+
from(table: string): SupabaseQueryBuilder;
|
|
47
|
+
}
|
|
48
|
+
declare function createSupabaseProvider(client: SupabaseClient): DataProvider;
|
|
49
|
+
|
|
50
|
+
interface DataProviderRootProps {
|
|
51
|
+
provider: DataProvider;
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
declare function DataProviderRoot({ provider, children }: DataProviderRootProps): react_jsx_runtime.JSX.Element;
|
|
55
|
+
declare function useDataProvider(): DataProvider;
|
|
56
|
+
declare function useStorage(): StorageAdapter;
|
|
57
|
+
type Row = Record<string, unknown>;
|
|
58
|
+
type GenesisProviderProps = {
|
|
59
|
+
children: ReactNode;
|
|
60
|
+
/** Pass a ready-made DataProvider. Mutually exclusive with `mock`. */
|
|
61
|
+
provider: DataProvider;
|
|
62
|
+
mock?: never;
|
|
63
|
+
/** Platform-specific storage adapter. Defaults to localStorage (SSR-safe). */
|
|
64
|
+
storage?: StorageAdapter;
|
|
65
|
+
} | {
|
|
66
|
+
children: ReactNode;
|
|
67
|
+
provider?: never;
|
|
68
|
+
/** Pass mock datasets. Mutually exclusive with `provider`. */
|
|
69
|
+
mock: {
|
|
70
|
+
datasets: Record<string, Row[]>;
|
|
71
|
+
options?: MockProviderOptions;
|
|
72
|
+
};
|
|
73
|
+
/** Platform-specific storage adapter. Defaults to localStorage (SSR-safe). */
|
|
74
|
+
storage?: StorageAdapter;
|
|
75
|
+
};
|
|
76
|
+
declare function GenesisProvider({ children, provider, mock, storage, }: GenesisProviderProps): react_jsx_runtime.JSX.Element;
|
|
77
|
+
|
|
78
|
+
export { DataProvider, DataProviderRoot, type DataProviderRootProps, GenesisProvider, type GenesisProviderProps, type MockProviderOptions, type SupabaseClient, createMockProvider, createSupabaseProvider, useDataProvider, useStorage };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createSupabaseProvider } from '../chunk-LQEICXJS.js';
|
|
2
|
+
export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from '../chunk-6V2TIN3G.js';
|
|
3
|
+
import '../chunk-ZYJUEJ4Z.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { S as StorageAdapter } from '../types-DKcxHXxq.js';
|
|
2
|
+
|
|
3
|
+
/** localStorage adapter with SSR safety. */
|
|
4
|
+
declare function createLocalStorageAdapter(): StorageAdapter;
|
|
5
|
+
/** In-memory adapter for testing and SSR. */
|
|
6
|
+
declare function createMemoryStorageAdapter(): StorageAdapter;
|
|
7
|
+
/** No-op adapter — all operations silently do nothing. */
|
|
8
|
+
declare function createNoopStorageAdapter(): StorageAdapter;
|
|
9
|
+
|
|
10
|
+
export { StorageAdapter, createLocalStorageAdapter, createMemoryStorageAdapter, createNoopStorageAdapter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/** Record identifier — supports both string UUIDs and numeric auto-increment IDs. */
|
|
2
|
+
type Identifier = string | number;
|
|
3
|
+
/** Base record type — all resources must have an id. */
|
|
4
|
+
type BaseRecord = {
|
|
5
|
+
id: Identifier;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
/** Pagination parameters (offset-based, with optional cursor for future use). */
|
|
9
|
+
interface PaginationParam {
|
|
10
|
+
page: number;
|
|
11
|
+
perPage: number;
|
|
12
|
+
cursor?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Sort direction for a single field. */
|
|
15
|
+
interface SortParam {
|
|
16
|
+
field: string;
|
|
17
|
+
order: "asc" | "desc";
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Filter expressions — discriminated union by operator.
|
|
21
|
+
* Filters are AND-ed together in queries.
|
|
22
|
+
*/
|
|
23
|
+
/** Operators that compare a field against a single scalar value. */
|
|
24
|
+
interface ScalarFilter {
|
|
25
|
+
field: string;
|
|
26
|
+
operator: "eq" | "neq" | "gt" | "lt" | "gte" | "lte" | "contains";
|
|
27
|
+
value: string | number | boolean;
|
|
28
|
+
}
|
|
29
|
+
/** Operator that checks field membership in a list. */
|
|
30
|
+
interface ArrayFilter {
|
|
31
|
+
field: string;
|
|
32
|
+
operator: "in";
|
|
33
|
+
value: (string | number | boolean)[];
|
|
34
|
+
}
|
|
35
|
+
/** Operator that checks field is within a range. */
|
|
36
|
+
interface RangeFilter {
|
|
37
|
+
field: string;
|
|
38
|
+
operator: "between";
|
|
39
|
+
value: [string | number, string | number];
|
|
40
|
+
}
|
|
41
|
+
/** Operators that check for null/non-null — no value needed. */
|
|
42
|
+
interface NullFilter {
|
|
43
|
+
field: string;
|
|
44
|
+
operator: "is_null" | "is_not_null";
|
|
45
|
+
}
|
|
46
|
+
type FilterParam = ScalarFilter | ArrayFilter | RangeFilter | NullFilter;
|
|
47
|
+
/** Parameters for `getList`. */
|
|
48
|
+
interface ListParams {
|
|
49
|
+
pagination?: PaginationParam;
|
|
50
|
+
sort?: SortParam;
|
|
51
|
+
filters?: FilterParam[];
|
|
52
|
+
/** Supabase select syntax, e.g. "*, author:profiles(name)". Mock provider ignores this. */
|
|
53
|
+
select?: string;
|
|
54
|
+
/** Multi-field text search (case-insensitive). */
|
|
55
|
+
search?: {
|
|
56
|
+
query: string;
|
|
57
|
+
fields: string[];
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** Result of `getList`. */
|
|
61
|
+
interface ListResult<T> {
|
|
62
|
+
data: T[];
|
|
63
|
+
total: number;
|
|
64
|
+
}
|
|
65
|
+
/** Parameters for `getOne`. */
|
|
66
|
+
interface GetOneParams {
|
|
67
|
+
id: Identifier;
|
|
68
|
+
/** Supabase select syntax, e.g. "*, author:profiles(name)". Defaults to "*". */
|
|
69
|
+
select?: string;
|
|
70
|
+
}
|
|
71
|
+
/** Result of `getOne`. */
|
|
72
|
+
interface GetOneResult<T> {
|
|
73
|
+
data: T;
|
|
74
|
+
}
|
|
75
|
+
/** Parameters for `getMany`. */
|
|
76
|
+
interface GetManyParams {
|
|
77
|
+
ids: Identifier[];
|
|
78
|
+
}
|
|
79
|
+
/** Result of `getMany`. */
|
|
80
|
+
interface GetManyResult<T> {
|
|
81
|
+
data: T[];
|
|
82
|
+
}
|
|
83
|
+
/** Parameters for `create`. */
|
|
84
|
+
interface CreateParams<T> {
|
|
85
|
+
data: Partial<T>;
|
|
86
|
+
}
|
|
87
|
+
/** Result of `create`. */
|
|
88
|
+
interface CreateResult<T> {
|
|
89
|
+
data: T;
|
|
90
|
+
}
|
|
91
|
+
/** Parameters for `update`. */
|
|
92
|
+
interface UpdateParams<T> {
|
|
93
|
+
id: Identifier;
|
|
94
|
+
data: Partial<T>;
|
|
95
|
+
}
|
|
96
|
+
/** Result of `update`. */
|
|
97
|
+
interface UpdateResult<T> {
|
|
98
|
+
data: T;
|
|
99
|
+
}
|
|
100
|
+
/** Parameters for `deleteOne`. */
|
|
101
|
+
interface DeleteParams {
|
|
102
|
+
id: Identifier;
|
|
103
|
+
}
|
|
104
|
+
/** Result of `deleteOne`. */
|
|
105
|
+
interface DeleteResult {
|
|
106
|
+
data: {
|
|
107
|
+
id: Identifier;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
interface DataProvider {
|
|
111
|
+
getList<T extends BaseRecord = BaseRecord>(resource: string, params: ListParams): Promise<ListResult<T>>;
|
|
112
|
+
getOne<T extends BaseRecord = BaseRecord>(resource: string, params: GetOneParams): Promise<GetOneResult<T>>;
|
|
113
|
+
getMany<T extends BaseRecord = BaseRecord>(resource: string, params: GetManyParams): Promise<GetManyResult<T>>;
|
|
114
|
+
create<T extends BaseRecord = BaseRecord>(resource: string, params: CreateParams<T>): Promise<CreateResult<T>>;
|
|
115
|
+
update<T extends BaseRecord = BaseRecord>(resource: string, params: UpdateParams<T>): Promise<UpdateResult<T>>;
|
|
116
|
+
deleteOne(resource: string, params: DeleteParams): Promise<DeleteResult>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type { ArrayFilter as A, BaseRecord as B, CreateParams as C, DataProvider as D, FilterParam as F, GetManyParams as G, Identifier as I, ListParams as L, NullFilter as N, PaginationParam as P, RangeFilter as R, ScalarFilter as S, UpdateParams as U, CreateResult as a, DeleteParams as b, DeleteResult as c, GetManyResult as d, GetOneParams as e, GetOneResult as f, ListResult as g, SortParam as h, UpdateResult as i };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic storage adapter interface.
|
|
3
|
+
*
|
|
4
|
+
* Web: backed by localStorage
|
|
5
|
+
* Native: backed by MMKV or AsyncStorage
|
|
6
|
+
* Test/SSR: backed by in-memory map
|
|
7
|
+
*
|
|
8
|
+
* All methods are synchronous — async storage backends (AsyncStorage)
|
|
9
|
+
* should pre-hydrate and provide sync access.
|
|
10
|
+
*/
|
|
11
|
+
interface StorageAdapter {
|
|
12
|
+
getItem(key: string): string | null;
|
|
13
|
+
setItem(key: string, value: string): void;
|
|
14
|
+
removeItem(key: string): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type { StorageAdapter as S };
|
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils.js"}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@marktiderman/genesis-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"description": "Genesis platform-agnostic providers, hooks, and data layer. Part of the Genesis framework.",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/marktiderman/genesis.git",
|
|
11
|
+
"directory": "packages/core"
|
|
12
|
+
},
|
|
13
|
+
"license": "UNLICENSED",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"provenance": false
|
|
17
|
+
},
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./provider": {
|
|
27
|
+
"types": "./dist/provider/index.d.ts",
|
|
28
|
+
"import": "./dist/provider/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./hooks": {
|
|
31
|
+
"types": "./dist/hooks/index.d.ts",
|
|
32
|
+
"import": "./dist/hooks/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./hooks/*": {
|
|
35
|
+
"types": "./dist/hooks/*.d.ts",
|
|
36
|
+
"import": "./dist/hooks/*.js"
|
|
37
|
+
},
|
|
38
|
+
"./storage": {
|
|
39
|
+
"types": "./dist/storage/index.d.ts",
|
|
40
|
+
"import": "./dist/storage/index.js"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"README.md"
|
|
46
|
+
],
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"react": "^19.0.0",
|
|
49
|
+
"@tanstack/react-query": "^5.0.0",
|
|
50
|
+
"react-hook-form": "^7.0.0",
|
|
51
|
+
"zod": "^3.0.0 || ^4.0.0",
|
|
52
|
+
"@hookform/resolvers": "^3.0.0 || ^4.0.0 || ^5.0.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@tanstack/react-query": "^5.75.0",
|
|
56
|
+
"@types/react": "^19.2.14",
|
|
57
|
+
"react-hook-form": "^7.56.4",
|
|
58
|
+
"zod": "^3.25.67",
|
|
59
|
+
"@hookform/resolvers": "^5.0.1",
|
|
60
|
+
"tsup": "^8.3.0",
|
|
61
|
+
"typescript": "^5.9.3"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsup",
|
|
65
|
+
"clean": "rm -rf dist"
|
|
66
|
+
}
|
|
67
|
+
}
|