@diphyx/harlemify 5.4.2 → 6.1.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 +7 -0
- package/dist/module.json +1 -1
- package/dist/runtime/core/layers/action.js +14 -44
- package/dist/runtime/core/layers/shape.d.ts +15 -2
- package/dist/runtime/core/layers/shape.js +26 -10
- package/dist/runtime/core/types/action.d.ts +27 -19
- package/dist/runtime/core/utils/action.js +52 -36
- package/dist/runtime/core/utils/shape.d.ts +2 -0
- package/dist/runtime/core/utils/shape.js +5 -2
- package/package.json +70 -69
package/README.md
CHANGED
|
@@ -13,6 +13,13 @@ Define your data **shape** once with Zod — get typed **models**, computed **vi
|
|
|
13
13
|
- **Vue composables** — Reactive helpers for actions, models, and views in components
|
|
14
14
|
- **SSR ready** — Server-side rendering with automatic state hydration
|
|
15
15
|
|
|
16
|
+
## For AI Agents
|
|
17
|
+
|
|
18
|
+
If you are an AI coding agent working on a project that uses `@diphyx/harlemify`, read **[`docs/AGENTS.md`](docs/AGENTS.md)** first. It is a single-file, end-to-end reference (shapes, models, views, actions, compose, composables, SSR, lazy stores, concurrency, cancellation, isolated status, logging) designed to give you the full mental model in one read.
|
|
19
|
+
|
|
20
|
+
- Source: [`docs/AGENTS.md`](docs/AGENTS.md)
|
|
21
|
+
- Rendered: [https://diphyx.github.io/harlemify/#/AGENTS](https://diphyx.github.io/harlemify/#/AGENTS)
|
|
22
|
+
|
|
16
23
|
## Install
|
|
17
24
|
|
|
18
25
|
```bash
|
package/dist/module.json
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ActionApiMethod
|
|
4
4
|
} from "../types/action.js";
|
|
5
5
|
export function createActionFactory(config, logger) {
|
|
6
|
-
function apiCall(request,
|
|
6
|
+
function apiCall(request, ...commits) {
|
|
7
7
|
return wrapBaseDefinition({
|
|
8
8
|
request: {
|
|
9
9
|
endpoint: config?.endpoint,
|
|
@@ -13,57 +13,27 @@ export function createActionFactory(config, logger) {
|
|
|
13
13
|
concurrent: config?.concurrent,
|
|
14
14
|
...request
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
commits,
|
|
17
17
|
logger
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
function apiGet(request,
|
|
21
|
-
return apiCall({ ...request, method: ActionApiMethod.GET },
|
|
20
|
+
function apiGet(request, ...commits) {
|
|
21
|
+
return apiCall({ ...request, method: ActionApiMethod.GET }, ...commits);
|
|
22
22
|
}
|
|
23
|
-
function apiHead(request,
|
|
24
|
-
return apiCall(
|
|
25
|
-
{
|
|
26
|
-
...request,
|
|
27
|
-
method: ActionApiMethod.HEAD
|
|
28
|
-
},
|
|
29
|
-
commit
|
|
30
|
-
);
|
|
23
|
+
function apiHead(request, ...commits) {
|
|
24
|
+
return apiCall({ ...request, method: ActionApiMethod.HEAD }, ...commits);
|
|
31
25
|
}
|
|
32
|
-
function apiPost(request,
|
|
33
|
-
return apiCall(
|
|
34
|
-
{
|
|
35
|
-
...request,
|
|
36
|
-
method: ActionApiMethod.POST
|
|
37
|
-
},
|
|
38
|
-
commit
|
|
39
|
-
);
|
|
26
|
+
function apiPost(request, ...commits) {
|
|
27
|
+
return apiCall({ ...request, method: ActionApiMethod.POST }, ...commits);
|
|
40
28
|
}
|
|
41
|
-
function apiPut(request,
|
|
42
|
-
return apiCall(
|
|
43
|
-
{
|
|
44
|
-
...request,
|
|
45
|
-
method: ActionApiMethod.PUT
|
|
46
|
-
},
|
|
47
|
-
commit
|
|
48
|
-
);
|
|
29
|
+
function apiPut(request, ...commits) {
|
|
30
|
+
return apiCall({ ...request, method: ActionApiMethod.PUT }, ...commits);
|
|
49
31
|
}
|
|
50
|
-
function apiPatch(request,
|
|
51
|
-
return apiCall(
|
|
52
|
-
{
|
|
53
|
-
...request,
|
|
54
|
-
method: ActionApiMethod.PATCH
|
|
55
|
-
},
|
|
56
|
-
commit
|
|
57
|
-
);
|
|
32
|
+
function apiPatch(request, ...commits) {
|
|
33
|
+
return apiCall({ ...request, method: ActionApiMethod.PATCH }, ...commits);
|
|
58
34
|
}
|
|
59
|
-
function apiDelete(request,
|
|
60
|
-
return apiCall(
|
|
61
|
-
{
|
|
62
|
-
...request,
|
|
63
|
-
method: ActionApiMethod.DELETE
|
|
64
|
-
},
|
|
65
|
-
commit
|
|
66
|
-
);
|
|
35
|
+
function apiDelete(request, ...commits) {
|
|
36
|
+
return apiCall({ ...request, method: ActionApiMethod.DELETE }, ...commits);
|
|
67
37
|
}
|
|
68
38
|
const api = Object.assign(apiCall, {
|
|
69
39
|
get: apiGet,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type { ShapeFactory, ShapeRawDefinition } from "../types/shape.js";
|
|
2
|
+
import type { ShapeCall, ShapeFactory, ShapeRawDefinition } from "../types/shape.js";
|
|
3
3
|
export declare const primitiveField: {
|
|
4
4
|
string: typeof z.string;
|
|
5
5
|
number: typeof z.number;
|
|
@@ -42,4 +42,17 @@ export declare const specialField: {
|
|
|
42
42
|
nullable: typeof z.nullable;
|
|
43
43
|
optional: typeof z.optional;
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
declare function shapeFn<T extends ShapeRawDefinition>(definition: T | z.ZodObject<T> | ((factory: ShapeFactory) => T)): ShapeCall<T>;
|
|
46
|
+
declare function shapeExtend<B extends ShapeRawDefinition, E extends ShapeRawDefinition>(base: ShapeCall<B>, extension: E): ShapeCall<B & E>;
|
|
47
|
+
declare function shapePick<B extends ShapeRawDefinition, M extends {
|
|
48
|
+
[K in keyof B]?: true;
|
|
49
|
+
}>(base: ShapeCall<B>, mask: M): ShapeCall<Pick<B, Extract<keyof B, keyof M>>>;
|
|
50
|
+
declare function shapeOmit<B extends ShapeRawDefinition, M extends {
|
|
51
|
+
[K in keyof B]?: true;
|
|
52
|
+
}>(base: ShapeCall<B>, mask: M): ShapeCall<Omit<B, Extract<keyof B, keyof M>>>;
|
|
53
|
+
export declare const shape: typeof shapeFn & {
|
|
54
|
+
extend: typeof shapeExtend;
|
|
55
|
+
pick: typeof shapePick;
|
|
56
|
+
omit: typeof shapeOmit;
|
|
57
|
+
};
|
|
58
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { createShape } from "../utils/shape.js";
|
|
2
|
+
import { createShape, decorateShape } from "../utils/shape.js";
|
|
3
3
|
export const primitiveField = {
|
|
4
4
|
string: z.string,
|
|
5
5
|
number: z.number,
|
|
@@ -42,16 +42,32 @@ export const specialField = {
|
|
|
42
42
|
nullable: z.nullable,
|
|
43
43
|
optional: z.optional
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
const factory = {
|
|
46
|
+
...primitiveField,
|
|
47
|
+
...structureField,
|
|
48
|
+
...formatField,
|
|
49
|
+
...specialField
|
|
50
|
+
};
|
|
51
|
+
function shapeFn(definition) {
|
|
52
|
+
if (definition instanceof z.ZodObject) {
|
|
53
|
+
return decorateShape(definition);
|
|
54
|
+
}
|
|
46
55
|
if (typeof definition === "function") {
|
|
47
|
-
return createShape(
|
|
48
|
-
definition({
|
|
49
|
-
...primitiveField,
|
|
50
|
-
...structureField,
|
|
51
|
-
...formatField,
|
|
52
|
-
...specialField
|
|
53
|
-
})
|
|
54
|
-
);
|
|
56
|
+
return createShape(definition(factory));
|
|
55
57
|
}
|
|
56
58
|
return createShape(definition);
|
|
57
59
|
}
|
|
60
|
+
function shapeExtend(base, extension) {
|
|
61
|
+
return decorateShape(base.extend(extension));
|
|
62
|
+
}
|
|
63
|
+
function shapePick(base, mask) {
|
|
64
|
+
return decorateShape(base.pick(mask));
|
|
65
|
+
}
|
|
66
|
+
function shapeOmit(base, mask) {
|
|
67
|
+
return decorateShape(base.omit(mask));
|
|
68
|
+
}
|
|
69
|
+
export const shape = Object.assign(shapeFn, {
|
|
70
|
+
extend: shapeExtend,
|
|
71
|
+
pick: shapePick,
|
|
72
|
+
omit: shapeOmit
|
|
73
|
+
});
|
|
@@ -52,9 +52,12 @@ export interface ActionApiCommit<MD extends ModelDefinitions, K extends keyof MD
|
|
|
52
52
|
value?: (data: unknown) => unknown;
|
|
53
53
|
options?: ModelOneCommitOptions | ModelManyCommitOptions;
|
|
54
54
|
}
|
|
55
|
-
export
|
|
55
|
+
export type ActionApiCommitReturn<MD extends ModelDefinitions, C extends readonly ActionApiCommit<MD>[]> = C extends readonly [] ? unknown : {
|
|
56
|
+
[E in C[number] as E["model"] & string]: E["model"] extends keyof MD ? ModelDefinitionInfer<MD, E["model"]> : never;
|
|
57
|
+
};
|
|
58
|
+
export interface ActionApiDefinition<MD extends ModelDefinitions, VD extends ViewDefinitions<MD>, C extends readonly ActionApiCommit<MD>[] = readonly ActionApiCommit<MD>[]> extends BaseDefinition {
|
|
56
59
|
request: ActionApiRequest<MD, VD>;
|
|
57
|
-
|
|
60
|
+
commits: C;
|
|
58
61
|
}
|
|
59
62
|
export interface ActionHandlerOptions<P = unknown> {
|
|
60
63
|
payload?: P;
|
|
@@ -69,23 +72,27 @@ export interface ActionHandlerDefinition<MD extends ModelDefinitions, VD extends
|
|
|
69
72
|
callback: ActionHandlerCallback<MD, VD, P, R>;
|
|
70
73
|
options?: ActionHandlerOptions<P>;
|
|
71
74
|
}
|
|
72
|
-
export type ActionDefinition<MD extends ModelDefinitions, VD extends ViewDefinitions<MD>> = ActionApiDefinition<MD, VD> | ActionHandlerDefinition<MD, VD, any, any>;
|
|
75
|
+
export type ActionDefinition<MD extends ModelDefinitions, VD extends ViewDefinitions<MD>> = ActionApiDefinition<MD, VD, any> | ActionHandlerDefinition<MD, VD, any, any>;
|
|
73
76
|
export type ActionDefinitions<MD extends ModelDefinitions, VD extends ViewDefinitions<MD>> = Record<string, ActionDefinition<MD, VD>>;
|
|
77
|
+
type ActionApiCommitTuple<MD extends ModelDefinitions> = readonly [
|
|
78
|
+
ActionApiCommit<MD, keyof MD>,
|
|
79
|
+
...ActionApiCommit<MD, keyof MD>[]
|
|
80
|
+
];
|
|
74
81
|
export interface ActionApiFactory<MD extends ModelDefinitions, VD extends ViewDefinitions<MD>> {
|
|
75
|
-
|
|
76
|
-
(request: ActionApiRequest<MD, VD
|
|
77
|
-
get
|
|
78
|
-
get(request: ActionApiRequestShortcut<MD, VD
|
|
79
|
-
head
|
|
80
|
-
head(request: ActionApiRequestShortcut<MD, VD
|
|
81
|
-
post
|
|
82
|
-
post(request: ActionApiRequestShortcut<MD, VD
|
|
83
|
-
put
|
|
84
|
-
put(request: ActionApiRequestShortcut<MD, VD
|
|
85
|
-
patch
|
|
86
|
-
patch(request: ActionApiRequestShortcut<MD, VD
|
|
87
|
-
delete
|
|
88
|
-
delete(request: ActionApiRequestShortcut<MD, VD
|
|
82
|
+
(request: ActionApiRequest<MD, VD>): ActionApiDefinition<MD, VD, []>;
|
|
83
|
+
<const C extends ActionApiCommitTuple<MD>>(request: ActionApiRequest<MD, VD>, ...commits: C): ActionApiDefinition<MD, VD, C>;
|
|
84
|
+
get(request: ActionApiRequestShortcut<MD, VD>): ActionApiDefinition<MD, VD, []>;
|
|
85
|
+
get<const C extends ActionApiCommitTuple<MD>>(request: ActionApiRequestShortcut<MD, VD>, ...commits: C): ActionApiDefinition<MD, VD, C>;
|
|
86
|
+
head(request: ActionApiRequestShortcut<MD, VD>): ActionApiDefinition<MD, VD, []>;
|
|
87
|
+
head<const C extends ActionApiCommitTuple<MD>>(request: ActionApiRequestShortcut<MD, VD>, ...commits: C): ActionApiDefinition<MD, VD, C>;
|
|
88
|
+
post(request: ActionApiRequestShortcut<MD, VD>): ActionApiDefinition<MD, VD, []>;
|
|
89
|
+
post<const C extends ActionApiCommitTuple<MD>>(request: ActionApiRequestShortcut<MD, VD>, ...commits: C): ActionApiDefinition<MD, VD, C>;
|
|
90
|
+
put(request: ActionApiRequestShortcut<MD, VD>): ActionApiDefinition<MD, VD, []>;
|
|
91
|
+
put<const C extends ActionApiCommitTuple<MD>>(request: ActionApiRequestShortcut<MD, VD>, ...commits: C): ActionApiDefinition<MD, VD, C>;
|
|
92
|
+
patch(request: ActionApiRequestShortcut<MD, VD>): ActionApiDefinition<MD, VD, []>;
|
|
93
|
+
patch<const C extends ActionApiCommitTuple<MD>>(request: ActionApiRequestShortcut<MD, VD>, ...commits: C): ActionApiDefinition<MD, VD, C>;
|
|
94
|
+
delete(request: ActionApiRequestShortcut<MD, VD>): ActionApiDefinition<MD, VD, []>;
|
|
95
|
+
delete<const C extends ActionApiCommitTuple<MD>>(request: ActionApiRequestShortcut<MD, VD>, ...commits: C): ActionApiDefinition<MD, VD, C>;
|
|
89
96
|
}
|
|
90
97
|
export interface ActionHandlerFactory<MD extends ModelDefinitions, VD extends ViewDefinitions<MD>> {
|
|
91
98
|
<P = unknown, R = void>(callback: ActionHandlerCallback<MD, VD, P, R>, options?: ActionHandlerOptions<P>): ActionHandlerDefinition<MD, VD, P, R>;
|
|
@@ -116,7 +123,7 @@ export interface ActionCallTransformerOptions {
|
|
|
116
123
|
response?: (data: unknown) => unknown;
|
|
117
124
|
}
|
|
118
125
|
export interface ActionCallCommitOptions {
|
|
119
|
-
mode?: ModelOneMode | ModelManyMode
|
|
126
|
+
mode?: ModelOneMode | ModelManyMode | Record<string, ModelOneMode | ModelManyMode>;
|
|
120
127
|
}
|
|
121
128
|
export interface ActionApiCallOptions extends ActionCallBaseOptions {
|
|
122
129
|
params?: Record<string, string>;
|
|
@@ -153,5 +160,6 @@ export interface ActionHandlerCall<P = unknown, T = void> extends ActionCallBase
|
|
|
153
160
|
}
|
|
154
161
|
export type ActionCall<T = void> = ActionApiCall<T> | ActionHandlerCall<any, T>;
|
|
155
162
|
export type StoreAction<MD extends ModelDefinitions, VD extends ViewDefinitions<MD>, AD extends ActionDefinitions<MD, VD>> = {
|
|
156
|
-
[K in keyof AD]: AD[K] extends ActionApiDefinition<MD, VD, infer
|
|
163
|
+
[K in keyof AD]: AD[K] extends ActionApiDefinition<MD, VD, infer C> ? C extends readonly ActionApiCommit<MD>[] ? ActionApiCall<ActionApiCommitReturn<MD, C>> : ActionApiCall : AD[K] extends ActionHandlerDefinition<MD, VD, infer P, infer R> ? ActionHandlerCall<P, R> : never;
|
|
157
164
|
};
|
|
165
|
+
export {};
|
|
@@ -55,7 +55,7 @@ function resolveApiBody(definition, view, target, options) {
|
|
|
55
55
|
if (!isPlainObject(body)) {
|
|
56
56
|
return body;
|
|
57
57
|
}
|
|
58
|
-
if (!isEmptyRecord(target
|
|
58
|
+
if (target && !isEmptyRecord(target.aliases())) {
|
|
59
59
|
return resolveAliasOutbound(body, target.aliases());
|
|
60
60
|
}
|
|
61
61
|
return body;
|
|
@@ -87,22 +87,17 @@ function resolveHandlerPayload(definition, options) {
|
|
|
87
87
|
}
|
|
88
88
|
return void 0;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
function resolveApiCommitMode(commit, options) {
|
|
97
|
-
if (commit) {
|
|
98
|
-
if (options?.commit?.mode) {
|
|
99
|
-
return options.commit.mode;
|
|
90
|
+
function resolveCommitMode(commit, options) {
|
|
91
|
+
const override = options?.commit?.mode;
|
|
92
|
+
if (override) {
|
|
93
|
+
if (typeof override === "object") {
|
|
94
|
+
return override[commit.model] ?? commit.mode;
|
|
100
95
|
}
|
|
101
|
-
return
|
|
96
|
+
return override;
|
|
102
97
|
}
|
|
103
|
-
return
|
|
98
|
+
return commit.mode;
|
|
104
99
|
}
|
|
105
|
-
function
|
|
100
|
+
function resolveCommitValue(commit, data) {
|
|
106
101
|
if (typeof commit.value === "function") {
|
|
107
102
|
return commit.value(data);
|
|
108
103
|
}
|
|
@@ -182,26 +177,27 @@ async function executeHandler(definition, handler) {
|
|
|
182
177
|
throw handlerError;
|
|
183
178
|
}
|
|
184
179
|
}
|
|
185
|
-
function executeCommit(definition,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (!target || !mode) {
|
|
190
|
-
throw new ActionCommitError({
|
|
191
|
-
message: `Model "${definition.commit.model}" is not defined`
|
|
192
|
-
});
|
|
180
|
+
function executeCommit(definition, model, data, options) {
|
|
181
|
+
const commits = definition.commits;
|
|
182
|
+
if (!commits || commits.length === 0) {
|
|
183
|
+
return data;
|
|
193
184
|
}
|
|
185
|
+
const plan = [];
|
|
194
186
|
try {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
target
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
187
|
+
for (const commit of commits) {
|
|
188
|
+
const target = model[commit.model];
|
|
189
|
+
if (!target) {
|
|
190
|
+
throw new ActionCommitError({
|
|
191
|
+
message: `Model "${commit.model}" is not defined`
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const mode = resolveCommitMode(commit, options);
|
|
195
|
+
let value = resolveCommitValue(commit, data);
|
|
196
|
+
if (!isEmptyRecord(target.aliases())) {
|
|
197
|
+
value = resolveAliasInbound(value, target.aliases());
|
|
198
|
+
}
|
|
199
|
+
plan.push({ commit, target, mode, value });
|
|
202
200
|
}
|
|
203
|
-
const value = resolveApiCommitValue(definition.commit, data);
|
|
204
|
-
target.commit(mode, value, definition.commit.options);
|
|
205
201
|
} catch (error) {
|
|
206
202
|
const commitError = toError(error, ActionCommitError);
|
|
207
203
|
definition.logger?.error("Action commit error", {
|
|
@@ -210,6 +206,26 @@ function executeCommit(definition, target, mode, data) {
|
|
|
210
206
|
});
|
|
211
207
|
throw commitError;
|
|
212
208
|
}
|
|
209
|
+
const result = {};
|
|
210
|
+
for (const entry of plan) {
|
|
211
|
+
definition.logger?.debug("Action commit phase", {
|
|
212
|
+
action: definition.key,
|
|
213
|
+
target: entry.target,
|
|
214
|
+
mode: entry.mode
|
|
215
|
+
});
|
|
216
|
+
try {
|
|
217
|
+
entry.target.commit(entry.mode, entry.value, entry.commit.options);
|
|
218
|
+
} catch (error) {
|
|
219
|
+
const commitError = toError(error, ActionCommitError);
|
|
220
|
+
definition.logger?.error("Action commit error", {
|
|
221
|
+
action: definition.key,
|
|
222
|
+
error: commitError.message
|
|
223
|
+
});
|
|
224
|
+
throw commitError;
|
|
225
|
+
}
|
|
226
|
+
result[entry.commit.model] = entry.value;
|
|
227
|
+
}
|
|
228
|
+
return result;
|
|
213
229
|
}
|
|
214
230
|
export function createAction(definition, model, view) {
|
|
215
231
|
const actionType = isApiDefinition(definition) ? ActionType.API : ActionType.HANDLER;
|
|
@@ -258,16 +274,16 @@ export function createAction(definition, model, view) {
|
|
|
258
274
|
try {
|
|
259
275
|
let data = void 0;
|
|
260
276
|
if (isApiDefinition(definition)) {
|
|
261
|
-
const
|
|
262
|
-
const
|
|
277
|
+
const firstCommit = definition.commits?.[0];
|
|
278
|
+
const bodyTarget = firstCommit ? model[firstCommit.model] : void 0;
|
|
263
279
|
const url = resolveApiUrl(definition, view, options);
|
|
264
280
|
const method = resolveApiMethod(definition, view);
|
|
265
281
|
const headers = resolveApiHeaders(definition, view, options);
|
|
266
282
|
const query = resolveApiQuery(definition, view, options);
|
|
267
|
-
const body = resolveApiBody(definition, view,
|
|
283
|
+
const body = resolveApiBody(definition, view, bodyTarget, options);
|
|
268
284
|
const timeout = resolveApiTimeout(definition, view, options);
|
|
269
285
|
const signal = resolveApiSignal(options, abortController);
|
|
270
|
-
|
|
286
|
+
const response = await executeApi(
|
|
271
287
|
definition,
|
|
272
288
|
{
|
|
273
289
|
url,
|
|
@@ -280,7 +296,7 @@ export function createAction(definition, model, view) {
|
|
|
280
296
|
},
|
|
281
297
|
options
|
|
282
298
|
);
|
|
283
|
-
executeCommit(definition,
|
|
299
|
+
data = executeCommit(definition, model, response, options);
|
|
284
300
|
} else if (isHandlerDefinition(definition)) {
|
|
285
301
|
const payload = resolveHandlerPayload(definition, options);
|
|
286
302
|
data = await executeHandler(definition, {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import type { ShapeCall, ShapeDefinition, ShapeInfer, ShapeRawDefinition, ShapeType } from "../types/shape.js";
|
|
2
3
|
export declare function resolveAliasInbound<T = unknown>(data: T, aliases?: Record<string, string>): T;
|
|
3
4
|
export declare function resolveAliasOutbound<T = unknown>(data: T, aliases?: Record<string, string>): T;
|
|
4
5
|
export declare function resolveShapeIdentifier(shape: ShapeType<unknown>, ...overrides: (string | undefined)[]): string;
|
|
5
6
|
export declare function resolveShapeAliases(shape: ShapeType<unknown>): Record<string, string>;
|
|
6
7
|
export declare function resolveZeroValues<T extends ShapeDefinition>(shape: T): ShapeInfer<T>;
|
|
8
|
+
export declare function decorateShape<T extends ShapeRawDefinition>(object: z.ZodObject<T>): ShapeCall<T>;
|
|
7
9
|
export declare function createShape<T extends ShapeRawDefinition>(definition: T): ShapeCall<T>;
|
|
@@ -178,8 +178,7 @@ export function resolveZeroValues(shape) {
|
|
|
178
178
|
}
|
|
179
179
|
return output;
|
|
180
180
|
}
|
|
181
|
-
export function
|
|
182
|
-
const object = z.object(definition);
|
|
181
|
+
export function decorateShape(object) {
|
|
183
182
|
const shape = Object.assign(object, {
|
|
184
183
|
defaults(overrides) {
|
|
185
184
|
const zero = resolveZeroValues(object);
|
|
@@ -191,3 +190,7 @@ export function createShape(definition) {
|
|
|
191
190
|
});
|
|
192
191
|
return shape;
|
|
193
192
|
}
|
|
193
|
+
export function createShape(definition) {
|
|
194
|
+
const object = z.object(definition);
|
|
195
|
+
return decorateShape(object);
|
|
196
|
+
}
|
package/package.json
CHANGED
|
@@ -1,72 +1,73 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
"homepage": "https://diphyx.github.io/harlemify/",
|
|
20
|
-
"bugs": {
|
|
21
|
-
"url": "https://github.com/diphyx/harlemify/issues"
|
|
22
|
-
},
|
|
23
|
-
"license": "MIT",
|
|
24
|
-
"author": "Amir Reza Dalir",
|
|
25
|
-
"type": "module",
|
|
26
|
-
"exports": {
|
|
27
|
-
".": {
|
|
28
|
-
"types": "./dist/types.d.ts",
|
|
29
|
-
"import": "./dist/module.mjs",
|
|
30
|
-
"require": "./dist/module.cjs"
|
|
2
|
+
"name": "@diphyx/harlemify",
|
|
3
|
+
"version": "6.1.0",
|
|
4
|
+
"description": "API state management for Nuxt powered by Harlem",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nuxt",
|
|
7
|
+
"nuxt-module",
|
|
8
|
+
"harlem",
|
|
9
|
+
"state-management",
|
|
10
|
+
"api",
|
|
11
|
+
"zod",
|
|
12
|
+
"vue",
|
|
13
|
+
"typescript"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/diphyx/harlemify.git"
|
|
31
18
|
},
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
"homepage": "https://diphyx.github.io/harlemify/",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/diphyx/harlemify/issues"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"author": "Amir Reza Dalir",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/types.d.ts",
|
|
29
|
+
"import": "./dist/module.mjs",
|
|
30
|
+
"require": "./dist/module.cjs"
|
|
31
|
+
},
|
|
32
|
+
"./runtime": {
|
|
33
|
+
"types": "./dist/runtime/index.d.ts",
|
|
34
|
+
"import": "./dist/runtime/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"main": "./dist/module.cjs",
|
|
38
|
+
"module": "./dist/module.mjs",
|
|
39
|
+
"types": "./dist/types.d.ts",
|
|
40
|
+
"files": [
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"scripts": {
|
|
44
|
+
"cleanup": "pnpm nuxt cleanup && pnpm nuxt cleanup playground",
|
|
45
|
+
"prepare": "pnpm nuxt prepare && pnpm nuxt prepare playground",
|
|
46
|
+
"dev": "pnpm nuxt dev playground",
|
|
47
|
+
"build": "nuxt-module-build build",
|
|
48
|
+
"lint": "eslint . --fix",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"test:e2e": "playwright test"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@harlem/core": "^3.1.8",
|
|
54
|
+
"@nuxt/kit": "^3.14.0 || ^4.0.0",
|
|
55
|
+
"consola": "^3.4.2",
|
|
56
|
+
"defu": "^6.1.4",
|
|
57
|
+
"zod": "^4.3.6"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@nuxt/eslint-config": "^0.6.2",
|
|
61
|
+
"@nuxt/module-builder": "^0.8.4",
|
|
62
|
+
"@nuxt/schema": "^4.3.1",
|
|
63
|
+
"@nuxt/test-utils": "^3.23.0",
|
|
64
|
+
"@playwright/test": "^1.58.2",
|
|
65
|
+
"@types/node": "^22.19.11",
|
|
66
|
+
"@vitest/coverage-v8": "^2.1.9",
|
|
67
|
+
"eslint": "^9.39.2",
|
|
68
|
+
"nuxt": "^4.3.1",
|
|
69
|
+
"typescript": "^5.9.3",
|
|
70
|
+
"vitest": "^2.1.9",
|
|
71
|
+
"vue": "^3.5.28"
|
|
35
72
|
}
|
|
36
|
-
|
|
37
|
-
"main": "./dist/module.cjs",
|
|
38
|
-
"module": "./dist/module.mjs",
|
|
39
|
-
"types": "./dist/types.d.ts",
|
|
40
|
-
"files": [
|
|
41
|
-
"dist"
|
|
42
|
-
],
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"@harlem/core": "^3.1.8",
|
|
45
|
-
"@nuxt/kit": "^3.14.0 || ^4.0.0",
|
|
46
|
-
"consola": "^3.4.2",
|
|
47
|
-
"defu": "^6.1.4",
|
|
48
|
-
"zod": "^4.3.6"
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@nuxt/eslint-config": "^0.6.2",
|
|
52
|
-
"@nuxt/module-builder": "^0.8.4",
|
|
53
|
-
"@nuxt/schema": "^4.3.1",
|
|
54
|
-
"@nuxt/test-utils": "^3.23.0",
|
|
55
|
-
"@playwright/test": "^1.58.2",
|
|
56
|
-
"@types/node": "^22.19.11",
|
|
57
|
-
"@vitest/coverage-v8": "^2.1.9",
|
|
58
|
-
"eslint": "^9.39.2",
|
|
59
|
-
"nuxt": "^4.3.1",
|
|
60
|
-
"typescript": "^5.9.3",
|
|
61
|
-
"vitest": "^2.1.9",
|
|
62
|
-
"vue": "^3.5.28"
|
|
63
|
-
},
|
|
64
|
-
"scripts": {
|
|
65
|
-
"cleanup": "pnpm nuxt cleanup && pnpm nuxt cleanup playground",
|
|
66
|
-
"dev": "pnpm nuxt dev playground",
|
|
67
|
-
"build": "nuxt-module-build build",
|
|
68
|
-
"lint": "eslint . --fix",
|
|
69
|
-
"test": "vitest run",
|
|
70
|
-
"test:e2e": "playwright test"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
+
}
|