@cisri/json-schema-core 1.0.0

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/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(e){switch(e.type){case"string":return"string";case"number":case"integer":return 0;case"boolean":return!0;case"object":{const r={};if(e.properties)for(const[n,a]of Object.entries(e.properties))r[n]=t(a);return r}case"array":return e.items?[t(e.items)]:[];default:return null}}exports.generateSampleData=t;
@@ -0,0 +1,3 @@
1
+ export type { JsonSchemaType, JsonSchema } from './utils';
2
+ export { generateSampleData } from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ function t(e) {
2
+ switch (e.type) {
3
+ case "string":
4
+ return "string";
5
+ case "number":
6
+ case "integer":
7
+ return 0;
8
+ case "boolean":
9
+ return !0;
10
+ case "object": {
11
+ const r = {};
12
+ if (e.properties)
13
+ for (const [n, i] of Object.entries(e.properties))
14
+ r[n] = t(i);
15
+ return r;
16
+ }
17
+ case "array":
18
+ return e.items ? [t(e.items)] : [];
19
+ default:
20
+ return null;
21
+ }
22
+ }
23
+ export {
24
+ t as generateSampleData
25
+ };
@@ -0,0 +1,12 @@
1
+ export type JsonSchemaType = 'object' | 'array' | 'string' | 'number' | 'boolean' | 'integer';
2
+ export interface JsonSchema {
3
+ type?: JsonSchemaType;
4
+ title?: string;
5
+ description?: string;
6
+ properties?: Record<string, JsonSchema>;
7
+ required?: string[];
8
+ items?: JsonSchema;
9
+ enum?: unknown[];
10
+ }
11
+ export declare function generateSampleData(schema: JsonSchema): unknown;
12
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,CAAC;AAEd,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;CAClB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CA2B9D"}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@cisri/json-schema-core",
3
+ "version": "1.0.0",
4
+ "description": "Shared JSON Schema types and utilities for @cisri business components",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "sideEffects": false,
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "devDependencies": {
24
+ "typescript": "^5.4.5",
25
+ "vite": "^5.2.11",
26
+ "vitest": "^1.6.0"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc && vite build",
30
+ "test": "vitest run",
31
+ "test:watch": "vitest"
32
+ }
33
+ }