@diphyx/harlemify 2.0.0 → 3.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/README.md +38 -112
- package/dist/module.json +1 -1
- package/dist/runtime/composables/use.d.ts +12 -20
- package/dist/runtime/composables/use.js +6 -17
- package/dist/runtime/core/api.d.ts +1 -1
- package/dist/runtime/core/api.js +3 -9
- package/dist/runtime/core/store.d.ts +43 -49
- package/dist/runtime/core/store.js +486 -226
- package/dist/runtime/index.d.ts +13 -9
- package/dist/runtime/index.js +5 -4
- package/dist/runtime/shared.d.ts +1 -1
- package/dist/runtime/{core → utils}/adapter.d.ts +1 -10
- package/dist/runtime/{core → utils}/adapter.js +3 -1
- package/dist/runtime/utils/cache.d.ts +10 -0
- package/dist/runtime/utils/cache.js +26 -0
- package/dist/runtime/utils/endpoint.d.ts +21 -23
- package/dist/runtime/utils/endpoint.js +32 -23
- package/dist/runtime/utils/memory.d.ts +40 -0
- package/dist/runtime/utils/memory.js +87 -0
- package/dist/runtime/utils/schema.d.ts +10 -4
- package/dist/runtime/utils/schema.js +35 -3
- package/dist/runtime/utils/transform.js +6 -4
- package/package.json +4 -2
- /package/dist/runtime/{core → utils}/errors.d.ts +0 -0
- /package/dist/runtime/{core → utils}/errors.js +0 -0
package/README.md
CHANGED
|
@@ -2,25 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
> Schema-driven state management for Nuxt powered by [Harlem](https://harlemjs.com/)
|
|
4
4
|
|
|
5
|
-

|
|
6
|
-
|
|
7
|
-
Define your data schema once with Zod, and Harlemify handles the rest: type-safe API calls, reactive state, request monitoring, and automatic memory management. Your schema becomes the single source of truth for types, validation, and API payloads.
|
|
8
|
-
|
|
9
5
|
## Features
|
|
10
6
|
|
|
11
7
|
- **Schema-Driven** - Zod schema defines types, validation, and API payloads
|
|
12
|
-
- **
|
|
13
|
-
- **
|
|
14
|
-
- **
|
|
15
|
-
- **
|
|
8
|
+
- **Free-form Actions** - Define any action with custom naming
|
|
9
|
+
- **Chainable Builders** - Fluent `Endpoint` and `Memory` APIs
|
|
10
|
+
- **Function-based Monitor** - Track status with `pending()`, `success()`, `failed()`, `idle()`
|
|
11
|
+
- **Custom Adapters** - Override HTTP at module, store, endpoint, or call-time
|
|
12
|
+
- **SSR Support** - Server-side rendering with automatic hydration
|
|
16
13
|
|
|
17
|
-
##
|
|
14
|
+
## Install
|
|
18
15
|
|
|
19
16
|
```bash
|
|
20
17
|
npm install @diphyx/harlemify
|
|
21
18
|
```
|
|
22
19
|
|
|
23
|
-
##
|
|
20
|
+
## Setup
|
|
24
21
|
|
|
25
22
|
```typescript
|
|
26
23
|
// nuxt.config.ts
|
|
@@ -30,130 +27,59 @@ export default defineNuxtConfig({
|
|
|
30
27
|
api: {
|
|
31
28
|
adapter: {
|
|
32
29
|
baseURL: "https://api.example.com",
|
|
33
|
-
timeout: 10000,
|
|
34
30
|
},
|
|
35
31
|
},
|
|
36
32
|
},
|
|
37
33
|
});
|
|
38
34
|
```
|
|
39
35
|
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
40
38
|
```typescript
|
|
41
39
|
// stores/user.ts
|
|
42
40
|
import { z } from "zod";
|
|
43
|
-
import { createStore, Endpoint, EndpointMethod } from "@diphyx/harlemify";
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}),
|
|
50
|
-
});
|
|
42
|
+
enum UserAction {
|
|
43
|
+
LIST = "list",
|
|
44
|
+
CREATE = "create",
|
|
45
|
+
}
|
|
51
46
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
[Endpoint.POST_UNITS]: { method: EndpointMethod.POST, url: "/users" },
|
|
57
|
-
[Endpoint.PATCH_UNITS]: { method: EndpointMethod.PATCH, url: (p) => `/users/${p.id}` },
|
|
58
|
-
[Endpoint.DELETE_UNITS]: { method: EndpointMethod.DELETE, url: (p) => `/users/${p.id}` },
|
|
47
|
+
const userSchema = z.object({
|
|
48
|
+
id: z.number().meta({ indicator: true }),
|
|
49
|
+
name: z.string().meta({ actions: [UserAction.CREATE] }),
|
|
50
|
+
email: z.string().meta({ actions: [UserAction.CREATE] }),
|
|
59
51
|
});
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Custom Adapters
|
|
63
52
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Adapters are resolved in the following order (highest to lowest priority):
|
|
69
|
-
|
|
70
|
-
1. **Endpoint adapter** - Per-endpoint custom adapter
|
|
71
|
-
2. **Store adapter** - Store-level adapter option
|
|
72
|
-
3. **Module adapter** - Global config in `nuxt.config.ts`
|
|
73
|
-
4. **Default adapter** - Built-in fetch adapter
|
|
74
|
-
|
|
75
|
-
### Built-in Adapter
|
|
76
|
-
|
|
77
|
-
Use `defineApiAdapter` to create an adapter with custom options:
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
import { defineApiAdapter } from "@diphyx/harlemify";
|
|
81
|
-
|
|
82
|
-
const customAdapter = defineApiAdapter({
|
|
83
|
-
baseURL: "/api",
|
|
84
|
-
timeout: 5000,
|
|
85
|
-
retry: 3,
|
|
86
|
-
retryDelay: 1000,
|
|
87
|
-
retryStatusCodes: [500, 502, 503],
|
|
88
|
-
});
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Custom Adapter
|
|
92
|
-
|
|
93
|
-
Create a fully custom adapter for advanced scenarios:
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
import type { ApiAdapter, ApiAdapterRequest } from "@diphyx/harlemify";
|
|
97
|
-
|
|
98
|
-
const streamingAdapter: ApiAdapter<MyType> = async (request: ApiAdapterRequest) => {
|
|
99
|
-
// Custom fetch logic with streaming, progress, etc.
|
|
100
|
-
const response = await fetch(request.url, {
|
|
101
|
-
method: request.method,
|
|
102
|
-
headers: request.headers,
|
|
103
|
-
body: JSON.stringify(request.body),
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const data = await response.json();
|
|
107
|
-
return { data, status: response.status };
|
|
108
|
-
};
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Using Adapters
|
|
112
|
-
|
|
113
|
-
**Store-level adapter:**
|
|
114
|
-
|
|
115
|
-
```typescript
|
|
116
|
-
export const userStore = createStore(
|
|
117
|
-
"user",
|
|
118
|
-
UserSchema,
|
|
119
|
-
{
|
|
120
|
-
[Endpoint.GET_UNITS]: { method: EndpointMethod.GET, url: "/users" },
|
|
53
|
+
export const userStore = createStore("user", userSchema, {
|
|
54
|
+
[UserAction.LIST]: {
|
|
55
|
+
endpoint: Endpoint.get("/users"),
|
|
56
|
+
memory: Memory.units(),
|
|
121
57
|
},
|
|
122
|
-
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
);
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
**Endpoint-level adapter:**
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
export const userStore = createStore("user", UserSchema, {
|
|
132
|
-
[Endpoint.GET_UNIT]: {
|
|
133
|
-
method: EndpointMethod.GET,
|
|
134
|
-
url: (p) => `/users/${p.id}`,
|
|
135
|
-
adapter: detailAdapter, // Custom adapter for this endpoint only
|
|
136
|
-
},
|
|
137
|
-
[Endpoint.GET_UNITS]: {
|
|
138
|
-
method: EndpointMethod.GET,
|
|
139
|
-
url: "/users",
|
|
140
|
-
// Uses store or global adapter
|
|
58
|
+
[UserAction.CREATE]: {
|
|
59
|
+
endpoint: Endpoint.post("/users"),
|
|
60
|
+
memory: Memory.units().add(),
|
|
141
61
|
},
|
|
142
62
|
});
|
|
143
63
|
```
|
|
144
64
|
|
|
145
|
-
|
|
65
|
+
```vue
|
|
66
|
+
<script setup>
|
|
67
|
+
const { users, listUser, userMonitor } = useStoreAlias(userStore);
|
|
146
68
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
69
|
+
await listUser();
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<div v-if="userMonitor.list.pending()">Loading...</div>
|
|
74
|
+
<ul v-else>
|
|
75
|
+
<li v-for="user in users" :key="user.id">{{ user.name }}</li>
|
|
76
|
+
</ul>
|
|
77
|
+
</template>
|
|
78
|
+
```
|
|
153
79
|
|
|
154
80
|
## Documentation
|
|
155
81
|
|
|
156
|
-
|
|
82
|
+
[https://diphyx.github.io/harlemify/](https://diphyx.github.io/harlemify/)
|
|
157
83
|
|
|
158
84
|
## License
|
|
159
85
|
|
package/dist/module.json
CHANGED
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
import type { ComputedRef } from "vue";
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import type { Pluralize, Capitalize } from "../utils/transform.js";
|
|
5
|
-
import type { EndpointStatusFlag } from "../utils/endpoint.js";
|
|
6
|
-
type Indicator<T, I extends keyof T> = Required<Pick<T, I>>;
|
|
7
|
-
type PartialWithIndicator<T, I extends keyof T> = Indicator<T, I> & Partial<T>;
|
|
2
|
+
import type { ActionFunction, ActionStatus, ActionsConfig, Store, StoreMemory } from "../core/store.js";
|
|
3
|
+
import type { Capitalize, Pluralize } from "../utils/transform.js";
|
|
8
4
|
type MemoryState<E extends string, T> = {
|
|
9
5
|
[P in E]: ComputedRef<T | null>;
|
|
10
6
|
} & {
|
|
11
7
|
[P in Pluralize<E>]: ComputedRef<T[]>;
|
|
12
8
|
};
|
|
13
|
-
type
|
|
14
|
-
[K in `${
|
|
15
|
-
} & {
|
|
16
|
-
[K in `${A}${Capitalize<Pluralize<E>>}`]: (units: U[]) => void;
|
|
9
|
+
type AliasActions<E extends string, A extends ActionsConfig<S>, S> = {
|
|
10
|
+
[K in keyof A as `${K & string}${Capitalize<E>}`]: ActionFunction<S>;
|
|
17
11
|
};
|
|
18
|
-
type
|
|
19
|
-
[
|
|
20
|
-
} & {
|
|
21
|
-
[M in EndpointMethod as `${M}${Capitalize<Pluralize<E>>}`]: (units?: Partial<T>[]) => Promise<T[]>;
|
|
12
|
+
type AliasMemory<E extends string, S, I extends keyof S> = {
|
|
13
|
+
[K in `${E}Memory`]: StoreMemory<S, I>;
|
|
22
14
|
};
|
|
23
|
-
type
|
|
24
|
-
[
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
type AliasMonitor<E extends string, A extends ActionsConfig<any>> = {
|
|
16
|
+
[K in `${E}Monitor`]: {
|
|
17
|
+
[ActionName in keyof A]: ActionStatus;
|
|
18
|
+
};
|
|
27
19
|
};
|
|
28
|
-
type StoreAlias<E extends string,
|
|
29
|
-
export declare function useStoreAlias<E extends string,
|
|
20
|
+
export type StoreAlias<E extends string, S, I extends keyof S, A extends ActionsConfig<S>> = MemoryState<E, S> & AliasActions<E, A, S> & AliasMemory<E, S, I> & AliasMonitor<E, A>;
|
|
21
|
+
export declare function useStoreAlias<E extends string, S, I extends keyof S, A extends ActionsConfig<S>>(store: Store<E, S, I, A>): StoreAlias<E, S, I, A>;
|
|
30
22
|
export {};
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
import { capitalize } from "../utils/transform.js";
|
|
2
|
-
import { EndpointMethod, EndpointStatus, makeEndpointStatusFlag } from "../utils/endpoint.js";
|
|
3
|
-
import { StoreMemoryAction } from "../core/store.js";
|
|
4
2
|
export function useStoreAlias(store) {
|
|
5
|
-
const
|
|
6
|
-
const capitalizedUnits = capitalize(store.alias.units);
|
|
3
|
+
const capitalizedEntity = capitalize(store.alias.unit);
|
|
7
4
|
const output = {
|
|
8
5
|
[store.alias.unit]: store.unit,
|
|
9
|
-
[store.alias.units]: store.units
|
|
6
|
+
[store.alias.units]: store.units,
|
|
7
|
+
[`${store.alias.unit}Memory`]: store.memory,
|
|
8
|
+
[`${store.alias.unit}Monitor`]: store.monitor
|
|
10
9
|
};
|
|
11
|
-
for (const
|
|
12
|
-
output[`${
|
|
13
|
-
output[`${action}${capitalizedUnits}`] = store.memory[`${action}Units`];
|
|
14
|
-
}
|
|
15
|
-
for (const method of Object.values(EndpointMethod)) {
|
|
16
|
-
output[`${method}${capitalizedUnit}`] = store.endpoint[`${method}Unit`];
|
|
17
|
-
output[`${method}${capitalizedUnits}`] = store.endpoint[`${method}Units`];
|
|
18
|
-
for (const status of Object.values(EndpointStatus)) {
|
|
19
|
-
const statusFlag = makeEndpointStatusFlag(status);
|
|
20
|
-
output[`${method}${capitalizedUnit}${statusFlag}`] = store.monitor[`${method}Unit${statusFlag}`];
|
|
21
|
-
output[`${method}${capitalizedUnits}${statusFlag}`] = store.monitor[`${method}Units${statusFlag}`];
|
|
22
|
-
}
|
|
10
|
+
for (const actionName in store.action) {
|
|
11
|
+
output[`${actionName}${capitalizedEntity}`] = store.action[actionName];
|
|
23
12
|
}
|
|
24
13
|
return output;
|
|
25
14
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MaybeRefOrGetter } from "vue";
|
|
2
2
|
import { EndpointMethod } from "../utils/endpoint.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { ApiAdapter } from "../utils/adapter.js";
|
|
4
4
|
export type ApiRequestHeader = MaybeRefOrGetter<Record<string, unknown>>;
|
|
5
5
|
export type ApiRequestQuery = MaybeRefOrGetter<Record<string, unknown>>;
|
|
6
6
|
export type ApiRequestBody = MaybeRefOrGetter<string | number | ArrayBuffer | FormData | Blob | Record<string, any>>;
|
package/dist/runtime/core/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toValue } from "vue";
|
|
2
|
+
import { defineApiAdapter } from "../utils/adapter.js";
|
|
2
3
|
import { EndpointMethod } from "../utils/endpoint.js";
|
|
3
|
-
import { defineApiAdapter } from "./adapter.js";
|
|
4
4
|
export function createApi(options) {
|
|
5
5
|
const defaultAdapter = options?.adapter ?? defineApiAdapter();
|
|
6
6
|
async function request(url, requestOptions) {
|
|
@@ -9,14 +9,8 @@ export function createApi(options) {
|
|
|
9
9
|
method: requestOptions?.action ?? EndpointMethod.GET,
|
|
10
10
|
url,
|
|
11
11
|
body: toValue(requestOptions?.body),
|
|
12
|
-
query: {
|
|
13
|
-
|
|
14
|
-
...toValue(requestOptions?.query)
|
|
15
|
-
},
|
|
16
|
-
headers: {
|
|
17
|
-
...toValue(options?.headers),
|
|
18
|
-
...toValue(requestOptions?.headers)
|
|
19
|
-
},
|
|
12
|
+
query: Object.assign({}, toValue(options?.query), toValue(requestOptions?.query)),
|
|
13
|
+
headers: Object.assign({}, toValue(options?.headers), toValue(requestOptions?.headers)),
|
|
20
14
|
signal: requestOptions?.signal
|
|
21
15
|
};
|
|
22
16
|
const response = await adapter(adapterRequest);
|
|
@@ -1,75 +1,69 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import type { ComputedRef } from "vue";
|
|
3
3
|
import type { Extension, BaseState } from "@harlem/core";
|
|
4
|
-
import {
|
|
5
|
-
import type {
|
|
6
|
-
import type { ApiAdapter } from "./adapter.js";
|
|
7
|
-
import type { EndpointDefinition, EndpointStatusName } from "../utils/endpoint.js";
|
|
4
|
+
import { EndpointStatus } from "../utils/endpoint.js";
|
|
5
|
+
import type { ApiAdapter } from "../utils/adapter.js";
|
|
8
6
|
import type { Pluralize } from "../utils/transform.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
import type { EndpointDefinition } from "../utils/endpoint.js";
|
|
8
|
+
import type { MemoryDefinition } from "../utils/memory.js";
|
|
9
|
+
export interface ActionDefinition<S = Record<string, unknown>> {
|
|
10
|
+
endpoint: EndpointDefinition<S>;
|
|
11
|
+
memory?: MemoryDefinition;
|
|
13
12
|
}
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
export interface ActionOptions {
|
|
14
|
+
query?: Record<string, unknown>;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
body?: unknown;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
validate?: boolean;
|
|
19
|
+
adapter?: ApiAdapter<any>;
|
|
20
|
+
}
|
|
21
|
+
export interface ActionStatus {
|
|
22
|
+
current: () => EndpointStatus;
|
|
23
|
+
pending: () => boolean;
|
|
24
|
+
success: () => boolean;
|
|
25
|
+
failed: () => boolean;
|
|
26
|
+
idle: () => boolean;
|
|
17
27
|
}
|
|
18
28
|
export interface StoreHooks {
|
|
19
29
|
before?: () => Promise<void> | void;
|
|
20
30
|
after?: (error?: Error) => Promise<void> | void;
|
|
21
31
|
}
|
|
22
|
-
export interface StoreOptions {
|
|
32
|
+
export interface StoreOptions<_A extends ActionsConfig<any> = ActionsConfig<any>> {
|
|
23
33
|
adapter?: ApiAdapter<any>;
|
|
24
34
|
indicator?: string;
|
|
25
35
|
hooks?: StoreHooks;
|
|
26
36
|
extensions?: Extension<BaseState>[];
|
|
27
37
|
}
|
|
28
|
-
type
|
|
29
|
-
type
|
|
30
|
-
type
|
|
31
|
-
|
|
32
|
-
type StoreEndpointWriteOptions = EndpointMethodOptions<any> & {
|
|
33
|
-
validate?: boolean;
|
|
34
|
-
};
|
|
35
|
-
type StoreEndpointWriteMultipleOptions = StoreEndpointWriteOptions & {
|
|
36
|
-
position?: StoreMemoryPosition;
|
|
37
|
-
};
|
|
38
|
-
type StoreMemory<T = unknown, I extends keyof T = keyof T> = {
|
|
39
|
-
setUnit: (unit: T | null) => void;
|
|
40
|
-
setUnits: (units: T[]) => void;
|
|
41
|
-
editUnit: (unit: PartialWithIndicator<T, I>) => void;
|
|
42
|
-
editUnits: (units: PartialWithIndicator<T, I>[]) => void;
|
|
43
|
-
dropUnit: (unit: PartialWithIndicator<T, I>) => void;
|
|
44
|
-
dropUnits: (units: PartialWithIndicator<T, I>[]) => void;
|
|
38
|
+
export type ActionsConfig<S = Record<string, unknown>> = Record<string, ActionDefinition<S>>;
|
|
39
|
+
export type ActionFunction<S> = (params?: Partial<S>, options?: ActionOptions) => Promise<S | S[] | boolean>;
|
|
40
|
+
export type StoreActions<A extends ActionsConfig<S>, S> = {
|
|
41
|
+
[K in keyof A]: ActionFunction<S>;
|
|
45
42
|
};
|
|
46
|
-
type
|
|
47
|
-
|
|
48
|
-
getUnits: (options?: StoreEndpointReadOptions) => Promise<T[]>;
|
|
49
|
-
postUnit: (unit: WithIndicator<T, I>, options?: StoreEndpointWriteOptions) => Promise<T>;
|
|
50
|
-
postUnits: (units: WithIndicator<T, I>[], options?: StoreEndpointWriteMultipleOptions) => Promise<T[]>;
|
|
51
|
-
putUnit: (unit: WithIndicator<T, I>, options?: StoreEndpointWriteOptions) => Promise<T>;
|
|
52
|
-
putUnits: (units: WithIndicator<T, I>[], options?: StoreEndpointWriteOptions) => Promise<T[]>;
|
|
53
|
-
patchUnit: (unit: PartialWithIndicator<T, I>, options?: StoreEndpointWriteOptions) => Promise<Partial<T>>;
|
|
54
|
-
patchUnits: (units: PartialWithIndicator<T, I>[], options?: StoreEndpointWriteOptions) => Promise<Partial<T>[]>;
|
|
55
|
-
deleteUnit: (unit: PartialWithIndicator<T, I>, options?: StoreEndpointReadOptions) => Promise<boolean>;
|
|
56
|
-
deleteUnits: (units: PartialWithIndicator<T, I>[], options?: StoreEndpointReadOptions) => Promise<boolean>;
|
|
43
|
+
export type StoreMonitor<A extends ActionsConfig<any>> = {
|
|
44
|
+
[K in keyof A]: ActionStatus;
|
|
57
45
|
};
|
|
58
|
-
type
|
|
59
|
-
|
|
46
|
+
export type StoreMemory<T, I extends keyof T> = {
|
|
47
|
+
set: (data: T | T[] | null) => void;
|
|
48
|
+
edit: (data: PartialWithIndicator<T, I> | PartialWithIndicator<T, I>[], options?: {
|
|
49
|
+
deep?: boolean;
|
|
50
|
+
}) => void;
|
|
51
|
+
drop: (data: PartialWithIndicator<T, I> | PartialWithIndicator<T, I>[]) => void;
|
|
60
52
|
};
|
|
61
|
-
export type Store<E extends string = string,
|
|
53
|
+
export type Store<E extends string = string, S = unknown, I extends keyof S = keyof S, A extends ActionsConfig<S> = ActionsConfig<S>> = {
|
|
62
54
|
store: any;
|
|
63
55
|
alias: {
|
|
64
56
|
unit: E;
|
|
65
57
|
units: Pluralize<E>;
|
|
66
58
|
};
|
|
67
59
|
indicator: I;
|
|
68
|
-
unit: ComputedRef<
|
|
69
|
-
units: ComputedRef<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
monitor: StoreMonitor
|
|
60
|
+
unit: ComputedRef<S | null>;
|
|
61
|
+
units: ComputedRef<S[]>;
|
|
62
|
+
action: StoreActions<A, S>;
|
|
63
|
+
memory: StoreMemory<S, I>;
|
|
64
|
+
monitor: StoreMonitor<A>;
|
|
73
65
|
};
|
|
74
|
-
|
|
66
|
+
type Indicator<T, I extends keyof T> = Required<Pick<T, I>>;
|
|
67
|
+
type PartialWithIndicator<T, I extends keyof T> = Indicator<T, I> & Partial<T>;
|
|
68
|
+
export declare function createStore<E extends string, T extends z.ZodRawShape, A extends ActionsConfig<z.infer<z.ZodObject<T>>>, S extends z.infer<z.ZodObject<T>> = z.infer<z.ZodObject<T>>, I extends keyof S = "id" & keyof S>(entity: E, schema: z.ZodObject<T>, actions: A, options?: StoreOptions<A>): Store<E, S, I, A>;
|
|
75
69
|
export {};
|