@bg-dev/nuxt-zenstack 0.0.5 → 0.0.6
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/module.d.mts +2 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +8 -57
- package/dist/runtime/composables/common.d.ts +2 -4
- package/dist/runtime/composables/useZenstackCreate/index.d.ts +1 -1
- package/dist/runtime/composables/useZenstackDelete/index.d.ts +1 -1
- package/dist/runtime/composables/useZenstackRead/index.d.ts +1 -1
- package/dist/runtime/composables/useZenstackReadMany/index.d.ts +1 -1
- package/dist/runtime/composables/useZenstackReadMany/index.js +1 -1
- package/dist/runtime/composables/useZenstackUpdate/index.d.ts +1 -1
- package/dist/runtime/server/api/models/[model]/[id].delete.js +7 -2
- package/dist/runtime/server/api/models/[model]/[id].get.js +7 -2
- package/dist/runtime/server/api/models/[model]/[id].patch.js +7 -2
- package/dist/runtime/server/api/models/[model]/index.get.js +7 -2
- package/dist/runtime/server/api/models/[model]/index.post.js +7 -2
- package/dist/runtime/server/routes/realtime.js +5 -0
- package/dist/runtime/server/utils/helpers.d.ts +2 -0
- package/dist/runtime/server/utils/helpers.js +5 -0
- package/dist/runtime/types/index.d.ts +12 -0
- package/dist/runtime/types/index.js +0 -0
- package/dist/runtime/types/template.d.ts +52 -0
- package/package.json +3 -3
package/dist/module.d.mts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import {
|
|
2
|
+
import { PublicModuleOptions, PrivateModuleOptions } from '../dist/runtime/types/index.js';
|
|
3
3
|
|
|
4
|
-
interface ModuleOptions {
|
|
5
|
-
apiPath: string;
|
|
6
|
-
fetchPolicy: FetchPolicy;
|
|
7
|
-
realtime: boolean;
|
|
8
|
-
baseUrl: string;
|
|
4
|
+
interface ModuleOptions extends PublicModuleOptions, PrivateModuleOptions {
|
|
9
5
|
}
|
|
10
6
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
11
7
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { joinURL } from 'ufo';
|
|
|
3
3
|
import { defu } from 'defu';
|
|
4
4
|
|
|
5
5
|
const name = "@bg-dev/nuxt-zenstack";
|
|
6
|
-
const version = "0.0.
|
|
6
|
+
const version = "0.0.6";
|
|
7
7
|
|
|
8
8
|
const module$1 = defineNuxtModule({
|
|
9
9
|
meta: {
|
|
@@ -16,7 +16,8 @@ const module$1 = defineNuxtModule({
|
|
|
16
16
|
apiPath: "/api/_zenstack",
|
|
17
17
|
fetchPolicy: "cache-first",
|
|
18
18
|
realtime: false,
|
|
19
|
-
baseUrl: "http://localhost:3000"
|
|
19
|
+
baseUrl: "http://localhost:3000",
|
|
20
|
+
expose: {}
|
|
20
21
|
},
|
|
21
22
|
setup(_options, _nuxt) {
|
|
22
23
|
_nuxt.options.runtimeConfig.public = defu(_nuxt.options.runtimeConfig.public, {
|
|
@@ -27,6 +28,10 @@ const module$1 = defineNuxtModule({
|
|
|
27
28
|
baseUrl: _options.baseUrl
|
|
28
29
|
}
|
|
29
30
|
});
|
|
31
|
+
_nuxt.options.runtimeConfig.zenstack = {
|
|
32
|
+
expose: _options.expose,
|
|
33
|
+
..._nuxt.options.runtimeConfig.zenstack ?? {}
|
|
34
|
+
};
|
|
30
35
|
const resolver = createResolver(import.meta.url);
|
|
31
36
|
addTemplate({
|
|
32
37
|
write: true,
|
|
@@ -43,61 +48,7 @@ export { schema as zenstackSchema } from '~~/zenstack/schema'
|
|
|
43
48
|
});
|
|
44
49
|
addTypeTemplate({
|
|
45
50
|
filename: "types/nuxt-zenstack.d.ts",
|
|
46
|
-
|
|
47
|
-
import type { ClientContract, ModelOperations, ModelResult, IncludeInput, WhereInput, FindManyArgs, SimplifiedPlainResult, SelectIncludeOmit, QueryOptions, CreateArgs, UpdateArgs } from '@zenstackhq/orm'
|
|
48
|
-
import type { SchemaType } from '~~/zenstack/schema'
|
|
49
|
-
import type { ModelDef } from '@zenstackhq/orm/schema'
|
|
50
|
-
import type { H3Error } from 'h3'
|
|
51
|
-
import { ORMError, RejectedByPolicyReason, ORMErrorReason } from '@zenstackhq/orm'
|
|
52
|
-
|
|
53
|
-
type ItemGetPayload<Zmodel extends $Zmodel, Args extends SelectIncludeOmit<SchemaType, Zmodel, true>, Options extends QueryOptions<SchemaType> = QueryOptions<SchemaType>> = SimplifiedPlainResult<SchemaType, Zmodel, Args, Options>
|
|
54
|
-
|
|
55
|
-
export type $Zschema = SchemaType
|
|
56
|
-
export type $Zclient = ClientContract<SchemaType>
|
|
57
|
-
export type $Zmodel = keyof SchemaType['models']
|
|
58
|
-
export type $Zdef = ModelDef
|
|
59
|
-
export type $Zoperations<Zmodel extends $Zmodel> = ModelOperations<SchemaType, Zmodel>
|
|
60
|
-
export type $Zid<Zmodel extends $Zmodel> = ModelResult<SchemaType, Zmodel> extends { id: infer Id } ? Id : never
|
|
61
|
-
export type $Zinclude<Zmodel extends $Zmodel> = IncludeInput<SchemaType, Zmodel> | undefined
|
|
62
|
-
export type $Zitem<Zmodel extends $Zmodel, Zinclude extends $Zinclude = undefined> = ItemGetPayload<Zmodel, { include: Zinclude }>
|
|
63
|
-
export type $Zwhere<Zmodel extends $Zmodel> = WhereInput<SchemaType, Zmodel> | undefined
|
|
64
|
-
export type $ZorderBy<Zmodel extends $Zmodel> = FindManyArgs<SchemaType, Zmodel>['orderBy'] | undefined
|
|
65
|
-
|
|
66
|
-
type NonRelationalFields<Zmodel extends $Zmodel> = keyof $Zitem<Zmodel>
|
|
67
|
-
type CreateData<Zmodel extends $Zmodel> = CreateArgs<SchemaType, Zmodel>['data']
|
|
68
|
-
type UpdateData<Zmodel extends $Zmodel> = UpdateArgs<SchemaType, Zmodel>['data']
|
|
69
|
-
|
|
70
|
-
export type $ZcreateData<Zmodel extends $Zmodel> = Pick<CreateData<Zmodel>, NonRelationalFields<Zmodel>>
|
|
71
|
-
export type $ZupdateData<Zmodel extends $Zmodel> = Pick<UpdateData<Zmodel>, NonRelationalFields<Zmodel>>
|
|
72
|
-
export type $ZormError = ORMError
|
|
73
|
-
export type $Zerror = H3Error<{
|
|
74
|
-
ormErrorReason: ORMErrorReason
|
|
75
|
-
dbErrorCode?: unknown
|
|
76
|
-
dbErrorMessage?: string
|
|
77
|
-
model?: string
|
|
78
|
-
rejectedByPolicyReason?: RejectedByPolicyReason
|
|
79
|
-
}>
|
|
80
|
-
|
|
81
|
-
declare module 'h3' {
|
|
82
|
-
interface H3EventContext {
|
|
83
|
-
zenstack: {
|
|
84
|
-
client: ClientContract<SchemaType>
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
type RealtimeData = {
|
|
90
|
-
action: 'create' | 'update' | 'delete'
|
|
91
|
-
model: $Zmodel
|
|
92
|
-
ids: Array<number | string>
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
declare module 'nitropack' {
|
|
96
|
-
interface NitroRuntimeHooks {
|
|
97
|
-
'zenstack:after_mutation': (action: 'create' | 'update' | 'delete', model: $Zmodel, items: Record<string, unknown>[]) => Promise<void> | void
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
`
|
|
51
|
+
src: resolver.resolve("./runtime/types/template.d.ts")
|
|
101
52
|
});
|
|
102
53
|
addServerHandler({
|
|
103
54
|
route: joinURL(_options.apiPath, "models/:model"),
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
3
|
-
export type FetchPolicy = 'cache-first' | 'fetch-only' | 'cache-only' | 'cache-and-fetch';
|
|
4
|
-
export declare function getConfig(): ModuleOptions;
|
|
1
|
+
import type { PublicModuleOptions } from '../types/index.js';
|
|
2
|
+
export declare function getConfig(): PublicModuleOptions;
|
|
5
3
|
/**
|
|
6
4
|
* @param instance a custom fetch method created by `$fetch.create`
|
|
7
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { $Zmodel, $Zitem, $ZcreateData, $Zerror } from '#build/types/nuxt-zenstack';
|
|
2
|
-
import type { Status } from '
|
|
2
|
+
import type { Status } from '../../types/index.js';
|
|
3
3
|
import { type Ref } from '#imports';
|
|
4
4
|
export declare function useZenstackCreate<Zmodel extends $Zmodel, Zitem extends $Zitem<Zmodel>>(model: Zmodel): {
|
|
5
5
|
data: Ref<Zitem | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { $Zmodel, $Zitem, $Zid, $Zerror } from '#build/types/nuxt-zenstack';
|
|
2
|
-
import type { Status } from '
|
|
2
|
+
import type { Status } from '../../types/index.js';
|
|
3
3
|
import { type Ref } from '#imports';
|
|
4
4
|
export declare function useZenstackDelete<Zmodel extends $Zmodel, Zitem extends $Zitem<Zmodel>>(model: Zmodel): {
|
|
5
5
|
data: Ref<Zitem | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { $Zmodel, $Zitem, $Zid, $Zinclude, $Zerror } from '#build/types/nuxt-zenstack';
|
|
2
|
-
import type { Status, FetchPolicy } from '
|
|
2
|
+
import type { Status, FetchPolicy } from '../../types/index.js';
|
|
3
3
|
import type { Ref } from '#imports';
|
|
4
4
|
type Options<Zinclude> = {
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { $Zmodel, $Zitem, $Zinclude, $Zwhere, $ZorderBy, $Zerror } from '#build/types/nuxt-zenstack';
|
|
2
|
-
import type { Status, FetchPolicy } from '
|
|
2
|
+
import type { Status, FetchPolicy } from '../../types/index.js';
|
|
3
3
|
import type { MaybeRefOrGetter, Ref } from '#imports';
|
|
4
4
|
type Options<Zinclude, Zwhere, ZorderBy> = {
|
|
5
5
|
/**
|
|
@@ -81,7 +81,7 @@ export async function useZenstackReadMany(model, opts = {}) {
|
|
|
81
81
|
} catch (err) {
|
|
82
82
|
error.value = err.data;
|
|
83
83
|
status.value = "error";
|
|
84
|
-
canFetchMore.value =
|
|
84
|
+
canFetchMore.value = false;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
return { data, error, status, canFetchMore, refetch };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { $Zmodel, $Zitem, $ZupdateData, $Zid, $Zerror } from '#build/types/nuxt-zenstack';
|
|
2
|
-
import type { Status } from '
|
|
2
|
+
import type { Status } from '../../types/index.js';
|
|
3
3
|
import type { Ref } from '#imports';
|
|
4
4
|
export declare function useZenstackUpdate<Zmodel extends $Zmodel, Zitem extends $Zitem<Zmodel>>(model: Zmodel): {
|
|
5
5
|
data: Ref<Zitem | null>;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
1
|
+
import { defineEventHandler, createError } from "h3";
|
|
2
2
|
import { parseModel, parseId, parseClient } from "../../../utils/parsers.js";
|
|
3
3
|
import { useZenstack } from "../../../utils/index.js";
|
|
4
|
+
import { getConfig } from "../../../utils/helpers.js";
|
|
4
5
|
export default defineEventHandler(async (event) => {
|
|
5
|
-
const client = parseClient(event);
|
|
6
6
|
const model = parseModel(event);
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
if (!config.expose[model]?.find((permission) => permission === "delete")) {
|
|
9
|
+
throw createError({ statusCode: 403, statusMessage: "Forbidden" });
|
|
10
|
+
}
|
|
11
|
+
const client = parseClient(event);
|
|
7
12
|
const id = parseId(event, model);
|
|
8
13
|
const zenstack = useZenstack();
|
|
9
14
|
return zenstack.delete({ client, model, id });
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { parseModel, parseId, parseReadArgs, parseClient } from "../../../utils/parsers.js";
|
|
2
|
-
import { defineEventHandler } from "h3";
|
|
2
|
+
import { defineEventHandler, createError } from "h3";
|
|
3
3
|
import { useZenstack } from "../../../utils/index.js";
|
|
4
|
+
import { getConfig } from "../../../utils/helpers.js";
|
|
4
5
|
export default defineEventHandler(async (event) => {
|
|
5
|
-
const client = parseClient(event);
|
|
6
6
|
const model = parseModel(event);
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
if (!config.expose[model]?.find((permission) => permission === "read")) {
|
|
9
|
+
throw createError({ statusCode: 403, statusMessage: "Forbidden" });
|
|
10
|
+
}
|
|
11
|
+
const client = parseClient(event);
|
|
7
12
|
const id = parseId(event, model);
|
|
8
13
|
const readArgs = parseReadArgs(event, model);
|
|
9
14
|
const zenstack = useZenstack();
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { parseModel, parseId, parseUpdateArgs, parseClient } from "../../../utils/parsers.js";
|
|
2
|
-
import { defineEventHandler } from "h3";
|
|
2
|
+
import { defineEventHandler, createError } from "h3";
|
|
3
3
|
import { useZenstack } from "../../../utils/index.js";
|
|
4
|
+
import { getConfig } from "../../../utils/helpers.js";
|
|
4
5
|
export default defineEventHandler(async (event) => {
|
|
5
|
-
const client = parseClient(event);
|
|
6
6
|
const model = parseModel(event);
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
if (!config.expose[model]?.find((permission) => permission === "update")) {
|
|
9
|
+
throw createError({ statusCode: 403, statusMessage: "Forbidden" });
|
|
10
|
+
}
|
|
11
|
+
const client = parseClient(event);
|
|
7
12
|
const id = parseId(event, model);
|
|
8
13
|
const updateArgs = await parseUpdateArgs(event, model);
|
|
9
14
|
const zenstack = useZenstack();
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { parseClient, parseModel, parseReadArgs } from "../../../utils/parsers.js";
|
|
2
|
-
import { defineEventHandler } from "h3";
|
|
2
|
+
import { defineEventHandler, createError } from "h3";
|
|
3
3
|
import { useZenstack } from "../../../utils/index.js";
|
|
4
|
+
import { getConfig } from "../../../utils/helpers.js";
|
|
4
5
|
export default defineEventHandler(async (event) => {
|
|
5
|
-
const client = parseClient(event);
|
|
6
6
|
const model = parseModel(event);
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
if (!config.expose[model]?.find((permission) => permission === "read")) {
|
|
9
|
+
throw createError({ statusCode: 403, statusMessage: "Forbidden" });
|
|
10
|
+
}
|
|
11
|
+
const client = parseClient(event);
|
|
7
12
|
const readArgs = parseReadArgs(event, model);
|
|
8
13
|
const zenstack = useZenstack();
|
|
9
14
|
return zenstack.findMany({
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { parseModel, parseCreateArgs, parseClient } from "../../../utils/parsers.js";
|
|
2
|
-
import { defineEventHandler } from "h3";
|
|
2
|
+
import { defineEventHandler, createError } from "h3";
|
|
3
3
|
import { useZenstack } from "../../../utils/index.js";
|
|
4
|
+
import { getConfig } from "../../../utils/helpers.js";
|
|
4
5
|
export default defineEventHandler(async (event) => {
|
|
5
|
-
const client = parseClient(event);
|
|
6
6
|
const model = parseModel(event);
|
|
7
|
+
const config = getConfig();
|
|
8
|
+
if (!config.expose[model]?.find((permission) => permission === "create")) {
|
|
9
|
+
throw createError({ statusCode: 403, statusMessage: "Forbidden" });
|
|
10
|
+
}
|
|
11
|
+
const client = parseClient(event);
|
|
7
12
|
const createArgs = await parseCreateArgs(event, model);
|
|
8
13
|
const zenstack = useZenstack();
|
|
9
14
|
return zenstack.create({ client, model, data: createArgs.data });
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { defineEventHandler, createEventStream } from "h3";
|
|
2
2
|
import { useNitroApp } from "nitropack/runtime";
|
|
3
|
+
import { getConfig } from "../utils/helpers.js";
|
|
3
4
|
export default defineEventHandler(async (event) => {
|
|
4
5
|
const eventStream = createEventStream(event);
|
|
5
6
|
const nitroApp = useNitroApp();
|
|
7
|
+
const config = getConfig();
|
|
6
8
|
nitroApp.hooks.hook("zenstack:after_mutation", (action, model, items) => {
|
|
9
|
+
if (!config.expose[model]?.find((permission) => permission === "read")) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
7
12
|
const message = {
|
|
8
13
|
model,
|
|
9
14
|
action,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { $Zmodel, $Zdef, $ZcreateData, $ZupdateData } from '#build/types/nuxt-zenstack';
|
|
2
|
+
import type { PrivateModuleOptions } from '../../types/index.js';
|
|
2
3
|
export declare function getModelDef(model: $Zmodel): $Zdef;
|
|
3
4
|
export declare function isIdString(model: $Zmodel): boolean;
|
|
4
5
|
export declare function getModels(): $Zmodel[];
|
|
5
6
|
export declare function isValidModel(model: $Zmodel): boolean;
|
|
6
7
|
export declare function sanitizeCreateData<Zmodel extends $Zmodel>(model: Zmodel, data: $ZcreateData<Zmodel>): $ZcreateData<Zmodel>;
|
|
7
8
|
export declare function sanitizeUpdateData<Zmodel extends $Zmodel>(model: Zmodel, data: $ZupdateData<Zmodel>): $ZupdateData<Zmodel>;
|
|
9
|
+
export declare function getConfig(): PrivateModuleOptions;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { zenstackSchema } from "nuxt-zenstack-server.mjs";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
3
|
export function getModelDef(model) {
|
|
3
4
|
return zenstackSchema.models[model];
|
|
4
5
|
}
|
|
@@ -32,3 +33,7 @@ export function sanitizeUpdateData(model, data) {
|
|
|
32
33
|
});
|
|
33
34
|
return data;
|
|
34
35
|
}
|
|
36
|
+
export function getConfig() {
|
|
37
|
+
const config = useRuntimeConfig();
|
|
38
|
+
return config.zenstack;
|
|
39
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { $Zmodel } from '#build/types/nuxt-zenstack';
|
|
2
|
+
export type Status = 'idle' | 'pending' | 'success' | 'error';
|
|
3
|
+
export type FetchPolicy = 'cache-first' | 'fetch-only' | 'cache-only' | 'cache-and-fetch';
|
|
4
|
+
export interface PublicModuleOptions {
|
|
5
|
+
apiPath: string;
|
|
6
|
+
fetchPolicy: FetchPolicy;
|
|
7
|
+
realtime: boolean;
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PrivateModuleOptions {
|
|
11
|
+
expose: Partial<Record<$Zmodel, Array<'create' | 'read' | 'update' | 'delete'>>>;
|
|
12
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ClientContract, ModelOperations, ModelResult, IncludeInput, WhereInput, FindManyArgs, SimplifiedPlainResult, SelectIncludeOmit, QueryOptions, CreateArgs, UpdateArgs, ORMError, RejectedByPolicyReason, ORMErrorReason } from '@zenstackhq/orm'
|
|
2
|
+
import type { SchemaType } from '~~/zenstack/schema'
|
|
3
|
+
import type { ModelDef } from '@zenstackhq/orm/schema'
|
|
4
|
+
import type { H3Error } from 'h3'
|
|
5
|
+
|
|
6
|
+
type ItemGetPayload<Zmodel extends $Zmodel, Args extends SelectIncludeOmit<SchemaType, Zmodel, true>, Options extends QueryOptions<SchemaType> = QueryOptions<SchemaType>> = SimplifiedPlainResult<SchemaType, Zmodel, Args, Options>
|
|
7
|
+
|
|
8
|
+
export type $Zschema = SchemaType
|
|
9
|
+
export type $Zclient = ClientContract<SchemaType>
|
|
10
|
+
export type $Zmodel = keyof SchemaType['models']
|
|
11
|
+
export type $Zdef = ModelDef
|
|
12
|
+
export type $Zoperations<Zmodel extends $Zmodel> = ModelOperations<SchemaType, Zmodel>
|
|
13
|
+
export type $Zid<Zmodel extends $Zmodel> = ModelResult<SchemaType, Zmodel> extends { id: infer Id } ? Id : never
|
|
14
|
+
export type $Zinclude<Zmodel extends $Zmodel> = IncludeInput<SchemaType, Zmodel> | undefined
|
|
15
|
+
export type $Zitem<Zmodel extends $Zmodel, Zinclude extends $Zinclude = undefined> = ItemGetPayload<Zmodel, { include: Zinclude }>
|
|
16
|
+
export type $Zwhere<Zmodel extends $Zmodel> = WhereInput<SchemaType, Zmodel> | undefined
|
|
17
|
+
export type $ZorderBy<Zmodel extends $Zmodel> = FindManyArgs<SchemaType, Zmodel>['orderBy'] | undefined
|
|
18
|
+
|
|
19
|
+
type NonRelationalFields<Zmodel extends $Zmodel> = keyof $Zitem<Zmodel>
|
|
20
|
+
type CreateData<Zmodel extends $Zmodel> = CreateArgs<SchemaType, Zmodel>['data']
|
|
21
|
+
type UpdateData<Zmodel extends $Zmodel> = UpdateArgs<SchemaType, Zmodel>['data']
|
|
22
|
+
|
|
23
|
+
export type $ZcreateData<Zmodel extends $Zmodel> = Pick<CreateData<Zmodel>, NonRelationalFields<Zmodel>>
|
|
24
|
+
export type $ZupdateData<Zmodel extends $Zmodel> = Pick<UpdateData<Zmodel>, NonRelationalFields<Zmodel>>
|
|
25
|
+
export type $ZormError = ORMError
|
|
26
|
+
export type $Zerror = H3Error<{
|
|
27
|
+
ormErrorReason: ORMErrorReason
|
|
28
|
+
dbErrorCode?: unknown
|
|
29
|
+
dbErrorMessage?: string
|
|
30
|
+
model?: string
|
|
31
|
+
rejectedByPolicyReason?: RejectedByPolicyReason
|
|
32
|
+
}>
|
|
33
|
+
|
|
34
|
+
declare module 'h3' {
|
|
35
|
+
interface H3EventContext {
|
|
36
|
+
zenstack: {
|
|
37
|
+
client: ClientContract<SchemaType>
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type RealtimeData = {
|
|
43
|
+
action: 'create' | 'update' | 'delete'
|
|
44
|
+
model: $Zmodel
|
|
45
|
+
ids: Array<number | string>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare module 'nitropack' {
|
|
49
|
+
interface NitroRuntimeHooks {
|
|
50
|
+
'zenstack:after_mutation': (action: 'create' | 'update' | 'delete', model: $Zmodel, items: Record<string, unknown>[]) => Promise<void> | void
|
|
51
|
+
}
|
|
52
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bg-dev/nuxt-zenstack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "ZenStack integration for Nuxt",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/becem-gharbi/nuxt-zenstack"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dev:db:push": "cd playground && zen db push",
|
|
43
43
|
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
44
44
|
"lint": "eslint .",
|
|
45
|
-
"test": "vitest run",
|
|
45
|
+
"test": "vitest run --no-file-parallelism",
|
|
46
46
|
"test:watch": "vitest watch",
|
|
47
47
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
48
48
|
"test:db:push": "cd test/fixtures/basic && zen db push",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"eslint": "^9.39.2",
|
|
74
74
|
"libsql": "^0.5.22",
|
|
75
75
|
"nuxt": "^4.2.2",
|
|
76
|
-
"playwright-core": "^1.
|
|
76
|
+
"playwright-core": "^1.58.0",
|
|
77
77
|
"typescript": "~5.9.3",
|
|
78
78
|
"vitest": "^4.0.17",
|
|
79
79
|
"vue-tsc": "^3.2.2"
|