@degenerate/generic 0.7.0 → 0.7.1

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,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  import { ILibraryEntity, ILibraryVersion } from './library-models';
2
3
  import { LibraryListFilter, LibrarySearchQuery } from './library-store';
3
4
  /**
@@ -28,6 +29,86 @@ export type RemoteLibraryRequest = {
28
29
  op: 'delete';
29
30
  id: string;
30
31
  };
32
+ /**
33
+ * Runtime validator for a {@link RemoteLibraryRequest} — used by an HTTP/RPC
34
+ * server (e.g. the example endpoints route) to reject a malformed wire body
35
+ * before dispatching to the library server.
36
+ */
37
+ export declare const RemoteLibraryRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
38
+ op: z.ZodLiteral<"get">;
39
+ id: z.ZodString;
40
+ }, z.core.$strip>, z.ZodObject<{
41
+ op: z.ZodLiteral<"getVersion">;
42
+ id: z.ZodString;
43
+ currentHash: z.ZodString;
44
+ }, z.core.$strip>, z.ZodObject<{
45
+ op: z.ZodLiteral<"has">;
46
+ id: z.ZodString;
47
+ }, z.core.$strip>, z.ZodObject<{
48
+ op: z.ZodLiteral<"list">;
49
+ filter: z.ZodOptional<z.ZodObject<{
50
+ kind: z.ZodOptional<z.ZodEnum<{
51
+ function: "function";
52
+ rule: "rule";
53
+ }>>;
54
+ }, z.core.$strip>>;
55
+ }, z.core.$strip>, z.ZodObject<{
56
+ op: z.ZodLiteral<"search">;
57
+ query: z.ZodObject<{
58
+ kind: z.ZodOptional<z.ZodEnum<{
59
+ function: "function";
60
+ rule: "rule";
61
+ }>>;
62
+ text: z.ZodOptional<z.ZodString>;
63
+ ownerPublicKey: z.ZodOptional<z.ZodString>;
64
+ }, z.core.$strip>;
65
+ }, z.core.$strip>, z.ZodObject<{
66
+ op: z.ZodLiteral<"save">;
67
+ entity: z.ZodObject<{
68
+ kind: z.ZodEnum<{
69
+ function: "function";
70
+ rule: "rule";
71
+ }>;
72
+ id: z.ZodString;
73
+ name: z.ZodString;
74
+ description: z.ZodString;
75
+ gasLimit: z.ZodNumber;
76
+ owner: z.ZodObject<{
77
+ publicKey: z.ZodString;
78
+ }, z.core.$strip>;
79
+ delegations: z.ZodArray<z.ZodObject<{
80
+ signerPublicKey: z.ZodString;
81
+ createdAt: z.ZodNumber;
82
+ proof: z.ZodObject<{
83
+ publicKey: z.ZodString;
84
+ signature: z.ZodString;
85
+ }, z.core.$strip>;
86
+ }, z.core.$strip>>;
87
+ versions: z.ZodArray<z.ZodObject<{
88
+ createdAt: z.ZodNumber;
89
+ previousHash: z.ZodString;
90
+ source: z.ZodString;
91
+ currentHash: z.ZodString;
92
+ proof: z.ZodObject<{
93
+ publicKey: z.ZodString;
94
+ signature: z.ZodString;
95
+ }, z.core.$strip>;
96
+ proofType: z.ZodEnum<{
97
+ CRYPTOGRAPHIC_SIGNATURE: "CRYPTOGRAPHIC_SIGNATURE";
98
+ }>;
99
+ }, z.core.$strip>>;
100
+ head: z.ZodObject<{
101
+ currentHash: z.ZodString;
102
+ proof: z.ZodObject<{
103
+ publicKey: z.ZodString;
104
+ signature: z.ZodString;
105
+ }, z.core.$strip>;
106
+ }, z.core.$strip>;
107
+ }, z.core.$strip>;
108
+ }, z.core.$strip>, z.ZodObject<{
109
+ op: z.ZodLiteral<"delete">;
110
+ id: z.ZodString;
111
+ }, z.core.$strip>], "op">;
31
112
  /**
32
113
  * A portable-JSON response from a remote library. Only the field relevant to the
33
114
  * request's `op` is populated; `error` carries a server-side failure message.
@@ -1 +1 @@
1
- {"version":3,"file":"remote-library-models.d.ts","sourceRoot":"","sources":["../../src/library/remote-library-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAExE;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAC1B;I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AM,oBAAoB,GAC1B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,EAAE,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAC1C;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,GAC3C;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,GACtC;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAerC,CAAC;AAEH;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IAClC,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC7B,IAAI,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACvE"}
@@ -1,2 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RemoteLibraryRequestSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const library_models_1 = require("./library-models");
6
+ /**
7
+ * Runtime validator for a {@link RemoteLibraryRequest} — used by an HTTP/RPC
8
+ * server (e.g. the example endpoints route) to reject a malformed wire body
9
+ * before dispatching to the library server.
10
+ */
11
+ exports.RemoteLibraryRequestSchema = zod_1.z.discriminatedUnion('op', [
12
+ zod_1.z.object({ op: zod_1.z.literal('get'), id: zod_1.z.string() }),
13
+ zod_1.z.object({ op: zod_1.z.literal('getVersion'), id: zod_1.z.string(), currentHash: zod_1.z.string() }),
14
+ zod_1.z.object({ op: zod_1.z.literal('has'), id: zod_1.z.string() }),
15
+ zod_1.z.object({ op: zod_1.z.literal('list'), filter: zod_1.z.object({ kind: library_models_1.LibraryEntityKindSchema.optional() }).optional() }),
16
+ zod_1.z.object({
17
+ op: zod_1.z.literal('search'),
18
+ query: zod_1.z.object({
19
+ kind: library_models_1.LibraryEntityKindSchema.optional(),
20
+ text: zod_1.z.string().optional(),
21
+ ownerPublicKey: zod_1.z.string().optional(),
22
+ }),
23
+ }),
24
+ zod_1.z.object({ op: zod_1.z.literal('save'), entity: library_models_1.ILibraryEntitySchema }),
25
+ zod_1.z.object({ op: zod_1.z.literal('delete'), id: zod_1.z.string() }),
26
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@degenerate/generic",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "This contains the generic information needed for the ShareData Adaptive Framework Ecosystem (SAFE) network",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -44,7 +44,7 @@
44
44
  "jsonwebtoken": "^9.0.3",
45
45
  "zod": "^4.4.3"
46
46
  },
47
- "gitHead": "1f747e160c9022863c7b2d7b8a6a157f204be95b",
47
+ "gitHead": "5e9a8b3f1d17f6913ccac216ca1a64ad30c30ee5",
48
48
  "devDependencies": {
49
49
  "@eslint/js": "^10.0.1",
50
50
  "@types/eslint__js": "^8.42.3",