@devvit/shared-types 0.11.0-next-2024-07-11-c0e47b869.0 → 0.11.0-next-2024-07-12-f7e815447.0
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@devvit/shared-types",
|
3
|
-
"version": "0.11.0-next-2024-07-
|
3
|
+
"version": "0.11.0-next-2024-07-12-f7e815447.0",
|
4
4
|
"license": "BSD-3-Clause",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -24,12 +24,13 @@
|
|
24
24
|
},
|
25
25
|
"types": "./index.d.ts",
|
26
26
|
"dependencies": {
|
27
|
-
"@devvit/protos": "0.11.0-next-2024-07-
|
27
|
+
"@devvit/protos": "0.11.0-next-2024-07-12-f7e815447.0",
|
28
|
+
"jsonschema": "1.4.1"
|
28
29
|
},
|
29
30
|
"devDependencies": {
|
30
|
-
"@devvit/eslint-config": "0.11.0-next-2024-07-
|
31
|
-
"@devvit/repo-tools": "0.11.0-next-2024-07-
|
32
|
-
"@devvit/tsconfig": "0.11.0-next-2024-07-
|
31
|
+
"@devvit/eslint-config": "0.11.0-next-2024-07-12-f7e815447.0",
|
32
|
+
"@devvit/repo-tools": "0.11.0-next-2024-07-12-f7e815447.0",
|
33
|
+
"@devvit/tsconfig": "0.11.0-next-2024-07-12-f7e815447.0",
|
33
34
|
"@types/redis-mock": "0.17.1",
|
34
35
|
"eslint": "8.9.0",
|
35
36
|
"lit": "2.2.8",
|
@@ -42,5 +43,5 @@
|
|
42
43
|
"directory": "dist"
|
43
44
|
},
|
44
45
|
"source": "./src/index.ts",
|
45
|
-
"gitHead": "
|
46
|
+
"gitHead": "0ed144ccca7964528ac7e6a241ba97b64f5df936"
|
46
47
|
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { Product } from './Product.js';
|
2
|
+
/**
|
3
|
+
* This function validates the `products.json` file of a devvit project and returns the parsed
|
4
|
+
* objects
|
5
|
+
*/
|
6
|
+
export declare function validateProductsJson(json: unknown): Product[];
|
7
|
+
//# sourceMappingURL=productSchemaJSONValidator.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"productSchemaJSONValidator.d.ts","sourceRoot":"","sources":["../../src/payments/productSchemaJSONValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,EAAE,CAO7D"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import jsonschema from 'jsonschema/lib/index.js';
|
2
|
+
import productSchema from './products.schema.json' assert { type: 'json' };
|
3
|
+
/**
|
4
|
+
* This function validates the `products.json` file of a devvit project and returns the parsed
|
5
|
+
* objects
|
6
|
+
*/
|
7
|
+
export function validateProductsJson(json) {
|
8
|
+
const validationResult = jsonschema.validate(json, productSchema);
|
9
|
+
if (!validationResult.valid) {
|
10
|
+
throw new Error(validationResult.errors.map((e) => e.toString()).join('\n'));
|
11
|
+
}
|
12
|
+
return validationResult.instance.products ?? [];
|
13
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"productSchemaJSONValidator.test.d.ts","sourceRoot":"","sources":["../../src/payments/productSchemaJSONValidator.test.ts"],"names":[],"mappings":""}
|