rlz-engine 1.0.40 → 1.0.42
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.
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { httpErrors } from '@fastify/sensible';
|
|
2
2
|
import fastifyPlugin from 'fastify-plugin';
|
|
3
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
4
3
|
import { API_AUTH_RESPONSE_SCHEMA_V0, API_SIGNIN_REQUEST_SCHEMA_V0, API_SIGNUP_REQUEST_SCHEMA_V0 } from '../../shared/api/auth.js';
|
|
5
4
|
import { logout, signin, signup } from './utils.js';
|
|
6
5
|
export const AUTH_API = fastifyPlugin(async function authApi(app, { storage }) {
|
|
7
6
|
app.post('/api/v0/signup', {
|
|
8
7
|
schema: {
|
|
9
|
-
body:
|
|
10
|
-
response: { 200:
|
|
8
|
+
body: API_SIGNUP_REQUEST_SCHEMA_V0.toJSONSchema({ target: 'draft-07' }),
|
|
9
|
+
response: { 200: API_AUTH_RESPONSE_SCHEMA_V0.toJSONSchema({ target: 'draft-07' }) }
|
|
11
10
|
}
|
|
12
11
|
}, async (req, _resp) => {
|
|
13
12
|
const body = API_SIGNUP_REQUEST_SCHEMA_V0.parse(req.body);
|
|
@@ -15,8 +14,8 @@ export const AUTH_API = fastifyPlugin(async function authApi(app, { storage }) {
|
|
|
15
14
|
});
|
|
16
15
|
app.post('/api/v0/signin', {
|
|
17
16
|
schema: {
|
|
18
|
-
body:
|
|
19
|
-
response: { 200:
|
|
17
|
+
body: API_SIGNIN_REQUEST_SCHEMA_V0.toJSONSchema({ target: 'draft-07' }),
|
|
18
|
+
response: { 200: API_AUTH_RESPONSE_SCHEMA_V0.toJSONSchema({ target: 'draft-07' }) }
|
|
20
19
|
}
|
|
21
20
|
}, async (req, _resp) => {
|
|
22
21
|
const body = API_SIGNIN_REQUEST_SCHEMA_V0.parse(req.body);
|
package/dist/back/rpc/gen.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts, { NewLineKind, ScriptKind, ScriptTarget } from 'typescript';
|
|
2
|
-
import { zodToTs } from 'zod-to-ts';
|
|
2
|
+
import { createAuxiliaryTypeStore, zodToTs } from 'zod-to-ts';
|
|
3
3
|
const F = ts.factory;
|
|
4
4
|
export function generateClient(fileName, ...rpcBuilders) {
|
|
5
5
|
const sourceFile = ts.createSourceFile(fileName, '', ScriptTarget.Latest, false, ScriptKind.TS);
|
|
@@ -41,13 +41,14 @@ export function generateClient(fileName, ...rpcBuilders) {
|
|
|
41
41
|
return fileContent.join('\n');
|
|
42
42
|
}
|
|
43
43
|
function generateTypes(rpcName, e, p) {
|
|
44
|
+
const typeStore = createAuxiliaryTypeStore();
|
|
44
45
|
const resp = [];
|
|
45
46
|
const bodyTypeName = createBodyTypeName(rpcName, e);
|
|
46
|
-
const bodyType = zodToTs(e.bodySchema,
|
|
47
|
+
const bodyType = zodToTs(e.bodySchema, { auxiliaryTypeStore: typeStore });
|
|
47
48
|
const bodyTypeAlias = F.createTypeAliasDeclaration([F.createToken(ts.SyntaxKind.ExportKeyword)], F.createIdentifier(bodyTypeName), undefined, bodyType.node);
|
|
48
49
|
resp.push(p(bodyTypeAlias));
|
|
49
50
|
const respTypeName = createRespTypeName(rpcName, e);
|
|
50
|
-
const respType = zodToTs(e.respSchema,
|
|
51
|
+
const respType = zodToTs(e.respSchema, { auxiliaryTypeStore: typeStore });
|
|
51
52
|
const respTypeAlias = F.createTypeAliasDeclaration([F.createToken(ts.SyntaxKind.ExportKeyword)], F.createIdentifier(respTypeName), undefined, respType.node);
|
|
52
53
|
resp.push(p(respTypeAlias));
|
|
53
54
|
return resp;
|
package/dist/back/rpc/rpc.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { httpErrors } from '@fastify/sensible';
|
|
2
2
|
import fastifyPlugin from 'fastify-plugin';
|
|
3
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
4
3
|
function makeReg(pluginName, endpoint) {
|
|
5
4
|
return {
|
|
6
5
|
v: endpoint.v,
|
|
@@ -11,9 +10,9 @@ function makeReg(pluginName, endpoint) {
|
|
|
11
10
|
reg(app, opts) {
|
|
12
11
|
app.post(`/rpc/${pluginName}_${this.name}_v${this.v}`, {
|
|
13
12
|
schema: {
|
|
14
|
-
body:
|
|
13
|
+
body: this.bodySchema.toJSONSchema({ target: 'draft-07' }),
|
|
15
14
|
response: {
|
|
16
|
-
200:
|
|
15
|
+
200: this.respSchema.toJSONSchema({ target: 'draft-07' })
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
}, endpoint.anonimous === true
|
|
@@ -9,22 +9,8 @@ export declare const SYNC_OBJECT_SCHEMA: z.ZodObject<{
|
|
|
9
9
|
_id: z.ZodString;
|
|
10
10
|
data: z.ZodObject<{
|
|
11
11
|
lastModified: z.ZodString;
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
}, {
|
|
15
|
-
lastModified: string;
|
|
16
|
-
}>;
|
|
17
|
-
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
_id: string;
|
|
19
|
-
data: {
|
|
20
|
-
lastModified: string;
|
|
21
|
-
};
|
|
22
|
-
}, {
|
|
23
|
-
_id: string;
|
|
24
|
-
data: {
|
|
25
|
-
lastModified: string;
|
|
26
|
-
};
|
|
27
|
-
}>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
}, z.core.$strip>;
|
|
28
14
|
export interface SyncObject<T> {
|
|
29
15
|
_id: string;
|
|
30
16
|
ownerId: string;
|
|
@@ -4,40 +4,16 @@ export declare const API_AUTH_RESPONSE_SCHEMA_V0: z.ZodObject<{
|
|
|
4
4
|
name: z.ZodString;
|
|
5
5
|
email: z.ZodString;
|
|
6
6
|
tempPassword: z.ZodString;
|
|
7
|
-
},
|
|
8
|
-
name: string;
|
|
9
|
-
id: string;
|
|
10
|
-
email: string;
|
|
11
|
-
tempPassword: string;
|
|
12
|
-
}, {
|
|
13
|
-
name: string;
|
|
14
|
-
id: string;
|
|
15
|
-
email: string;
|
|
16
|
-
tempPassword: string;
|
|
17
|
-
}>;
|
|
7
|
+
}, z.core.$strip>;
|
|
18
8
|
export type ApiAuthResponseV0 = z.infer<typeof API_AUTH_RESPONSE_SCHEMA_V0>;
|
|
19
9
|
export declare const API_SIGNUP_REQUEST_SCHEMA_V0: z.ZodObject<{
|
|
20
10
|
name: z.ZodString;
|
|
21
11
|
email: z.ZodString;
|
|
22
12
|
password: z.ZodString;
|
|
23
|
-
},
|
|
24
|
-
name: string;
|
|
25
|
-
email: string;
|
|
26
|
-
password: string;
|
|
27
|
-
}, {
|
|
28
|
-
name: string;
|
|
29
|
-
email: string;
|
|
30
|
-
password: string;
|
|
31
|
-
}>;
|
|
13
|
+
}, z.core.$strip>;
|
|
32
14
|
export type ApiSignupRequestV0 = z.infer<typeof API_SIGNUP_REQUEST_SCHEMA_V0>;
|
|
33
15
|
export declare const API_SIGNIN_REQUEST_SCHEMA_V0: z.ZodObject<{
|
|
34
16
|
name: z.ZodString;
|
|
35
17
|
password: z.ZodString;
|
|
36
|
-
},
|
|
37
|
-
name: string;
|
|
38
|
-
password: string;
|
|
39
|
-
}, {
|
|
40
|
-
name: string;
|
|
41
|
-
password: string;
|
|
42
|
-
}>;
|
|
18
|
+
}, z.core.$strip>;
|
|
43
19
|
export type ApiSigninRequestV0 = z.infer<typeof API_SIGNIN_REQUEST_SCHEMA_V0>;
|
|
@@ -1,43 +1,21 @@
|
|
|
1
1
|
import z, { ZodType } from 'zod';
|
|
2
2
|
export declare const API_GET_OBJECTS_QUERY_STRING_SCHEMA_V0: z.ZodObject<{
|
|
3
3
|
syncAfter: z.ZodOptional<z.ZodString>;
|
|
4
|
-
},
|
|
5
|
-
syncAfter?: string | undefined;
|
|
6
|
-
}, {
|
|
7
|
-
syncAfter?: string | undefined;
|
|
8
|
-
}>;
|
|
4
|
+
}, z.z.core.$strip>;
|
|
9
5
|
export declare function API_ITEMS_RESPONSE_SCHEMA_V0<T extends ZodType>(itemsSchema: T): z.ZodReadonly<z.ZodObject<{
|
|
10
|
-
items: z.ZodReadonly<z.ZodArray<T
|
|
11
|
-
},
|
|
12
|
-
items: readonly T["_output"][];
|
|
13
|
-
}, {
|
|
14
|
-
items: readonly T["_input"][];
|
|
15
|
-
}>>;
|
|
6
|
+
items: z.ZodReadonly<z.ZodArray<T>>;
|
|
7
|
+
}, z.z.core.$strip>>;
|
|
16
8
|
export type ApiItemsResponseV0<T extends ZodType> = z.infer<ReturnType<typeof API_ITEMS_RESPONSE_SCHEMA_V0<T>>>;
|
|
17
9
|
export declare const API_GET_OBJECTS_REQUEST_SCHEMA_V0: z.ZodReadonly<z.ZodObject<{
|
|
18
|
-
ids: z.ZodReadonly<z.ZodArray<z.ZodString
|
|
19
|
-
},
|
|
20
|
-
ids: readonly string[];
|
|
21
|
-
}, {
|
|
22
|
-
ids: readonly string[];
|
|
23
|
-
}>>;
|
|
10
|
+
ids: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
11
|
+
}, z.z.core.$strip>>;
|
|
24
12
|
export type ApiGetObjectsRequestV0 = z.infer<typeof API_GET_OBJECTS_REQUEST_SCHEMA_V0>;
|
|
25
13
|
export declare const API_COMPARISON_OBJECT_SCHEMA_V0: z.ZodObject<{
|
|
26
14
|
id: z.ZodString;
|
|
27
15
|
lastModified: z.ZodString;
|
|
28
|
-
},
|
|
29
|
-
lastModified: string;
|
|
30
|
-
id: string;
|
|
31
|
-
}, {
|
|
32
|
-
lastModified: string;
|
|
33
|
-
id: string;
|
|
34
|
-
}>;
|
|
16
|
+
}, z.z.core.$strip>;
|
|
35
17
|
export type ApiComparisonObjectV0 = z.infer<typeof API_COMPARISON_OBJECT_SCHEMA_V0>;
|
|
36
18
|
export declare function API_ITEMS_REQUEST_SCHEMA_V0<T extends ZodType>(itemsSchema: T): z.ZodReadonly<z.ZodObject<{
|
|
37
|
-
items: z.ZodReadonly<z.ZodArray<T
|
|
38
|
-
},
|
|
39
|
-
items: readonly T["_output"][];
|
|
40
|
-
}, {
|
|
41
|
-
items: readonly T["_input"][];
|
|
42
|
-
}>>;
|
|
19
|
+
items: z.ZodReadonly<z.ZodArray<T>>;
|
|
20
|
+
}, z.z.core.$strip>>;
|
|
43
21
|
export type ApiItemsRequestV0<T extends ZodType> = z.infer<ReturnType<typeof API_ITEMS_REQUEST_SCHEMA_V0<T>>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rlz-engine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.42",
|
|
4
4
|
"description": "Deps and tools for my style of development",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc",
|
|
@@ -69,9 +69,8 @@
|
|
|
69
69
|
"react-resize-detector": "^12.0.2",
|
|
70
70
|
"react-router-dom": "^7.1.1",
|
|
71
71
|
"uuidv7": "^1.0.2",
|
|
72
|
-
"zod": "^3.
|
|
73
|
-
"zod-to-
|
|
74
|
-
"zod-to-ts": "^1.2.0",
|
|
72
|
+
"zod": "^4.3.4",
|
|
73
|
+
"zod-to-ts": "^2.0.0",
|
|
75
74
|
"zustand": "^5.0.3"
|
|
76
75
|
}
|
|
77
76
|
}
|