@inverted-tech/fragments 0.3.1 → 0.3.2
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/esm/index.js +1 -1
- package/dist/esm/validation.js +46 -0
- package/dist/protos/validation.d.ts +3 -0
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ts-gen/validation.ts
|
|
2
|
+
import { createRegistry } from "@bufbuild/protobuf";
|
|
3
|
+
import { createValidator } from "@bufbuild/protovalidate";
|
|
4
|
+
// Import barrels that re-export your generated descriptors (GenFile)
|
|
5
|
+
import * as Auth from "./gen/Protos/IT/WebServices/Fragments/Authentication";
|
|
6
|
+
import * as Authorization from "./gen/Protos/IT/WebServices/Fragments/Authorization";
|
|
7
|
+
import * as Comment from "./gen/Protos/IT/WebServices/Fragments/Comment";
|
|
8
|
+
import * as Content from "./gen/Protos/IT/WebServices/Fragments/Content";
|
|
9
|
+
import * as CreatorDashboard from "./gen/Protos/IT/WebServices/Fragments/CreatorDashboard";
|
|
10
|
+
import * as Generic from "./gen/Protos/IT/WebServices/Fragments/Generic";
|
|
11
|
+
import * as Notification from "./gen/Protos/IT/WebServices/Fragments/Notification";
|
|
12
|
+
import * as Page from "./gen/Protos/IT/WebServices/Fragments/Page";
|
|
13
|
+
import * as Settings from "./gen/Protos/IT/WebServices/Fragments/Settings";
|
|
14
|
+
import * as FragmentsRoot from "./gen/Protos/IT/WebServices/Fragments";
|
|
15
|
+
// Runtime guard (don’t use a type predicate over a module union)
|
|
16
|
+
function looksLikeGenFile(x) {
|
|
17
|
+
const v = x;
|
|
18
|
+
return !!v && typeof v === "object" && v.kind === "file" && typeof v.name === "string";
|
|
19
|
+
}
|
|
20
|
+
function collectFiles() {
|
|
21
|
+
const files = [];
|
|
22
|
+
const mods = [
|
|
23
|
+
Auth,
|
|
24
|
+
Authorization,
|
|
25
|
+
Comment,
|
|
26
|
+
Content,
|
|
27
|
+
CreatorDashboard,
|
|
28
|
+
Generic,
|
|
29
|
+
Notification,
|
|
30
|
+
Page,
|
|
31
|
+
Settings,
|
|
32
|
+
FragmentsRoot,
|
|
33
|
+
];
|
|
34
|
+
for (const m of mods) {
|
|
35
|
+
for (const value of Object.values(m)) {
|
|
36
|
+
if (looksLikeGenFile(value))
|
|
37
|
+
files.push(value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return files;
|
|
41
|
+
}
|
|
42
|
+
const registry = createRegistry(...collectFiles());
|
|
43
|
+
/** Create a protovalidate Validator bound to this package’s descriptors. */
|
|
44
|
+
export async function getValidator() {
|
|
45
|
+
return createValidator({ registry });
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inverted-tech/fragments",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Types and JS runtime for Inverted protocol buffers (Fragments)",
|
|
5
5
|
"types": "dist/protos/index.d.ts",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"lint": "eslint . --ext .ts",
|
|
98
98
|
"lint:gen": "eslint ts-gen --ext .ts",
|
|
99
99
|
"lint:gen:fix": "eslint ts-gen --ext .ts --fix",
|
|
100
|
-
"clean": "node -e \"const fs=require('fs')
|
|
100
|
+
"clean": "node -e \"const fs=require('fs'),path=require('path'); const rm=(p)=>fs.rmSync(p,{recursive:true,force:true}); if(fs.existsSync('dist')) rm('dist'); const base='ts-gen'; if(fs.existsSync(base)){ for(const ent of fs.readdirSync(base,{withFileTypes:true})) { if(ent.name==='validation.ts') continue; rm(path.join(base, ent.name)); } }\"",
|
|
101
101
|
"clean:pack": "node -e \"const fs=require('fs'); const path=require('path'); fs.rmSync('__pack_extract__',{recursive:true,force:true}); fs.readdirSync('.').filter(f=>f.endsWith('.tgz')).forEach(f=>fs.rmSync(path.join('.',f),{force:true})); console.log('Removed __pack_extract__ and *.tgz');\"",
|
|
102
102
|
"rebuild": "npm run clean && npm run build",
|
|
103
103
|
"compile": "tsc",
|