@safe-ugc-ui/schema 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Safe UGC UI Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,15 @@
1
+ // src/generate.ts
2
+ import { writeFileSync } from "fs";
3
+ import { dirname, resolve } from "path";
4
+ import { fileURLToPath } from "url";
5
+ import { ugcCardSchema } from "@safe-ugc-ui/types";
6
+ import { zodToJsonSchema } from "zod-to-json-schema";
7
+ var jsonSchema = zodToJsonSchema(ugcCardSchema, {
8
+ name: "UGCCard",
9
+ nameStrategy: "title"
10
+ });
11
+ var __dirname = dirname(fileURLToPath(import.meta.url));
12
+ var outputPath = resolve(__dirname, "ugc-card.schema.json");
13
+ writeFileSync(outputPath, JSON.stringify(jsonSchema, null, 2), "utf-8");
14
+ console.log(`Generated ${outputPath}`);
15
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generate.ts"],"sourcesContent":["/**\n * @safe-ugc-ui/schema — JSON Schema Generator (build-time script)\n *\n * Converts the Zod-based UGCCard schema from @safe-ugc-ui/types into a\n * standard JSON Schema document and writes it to dist/ugc-card.schema.json.\n *\n * Run via: `node dist/generate.js` (called automatically by the build script).\n *\n * NOTE: This produces a *structural* schema only. Context-dependent rules\n * (position constraints, security checks, resource limits, etc.) cannot be\n * expressed in JSON Schema and require the validator package.\n */\n\nimport { writeFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { ugcCardSchema } from '@safe-ugc-ui/types';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\n\nconst jsonSchema = zodToJsonSchema(ugcCardSchema, {\n name: 'UGCCard',\n nameStrategy: 'title',\n});\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst outputPath = resolve(__dirname, 'ugc-card.schema.json');\n\nwriteFileSync(outputPath, JSON.stringify(jsonSchema, null, 2), 'utf-8');\n\nconsole.log(`Generated ${outputPath}`);\n"],"mappings":";AAaA,SAAS,qBAAqB;AAC9B,SAAS,SAAS,eAAe;AACjC,SAAS,qBAAqB;AAE9B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAEhC,IAAM,aAAa,gBAAgB,eAAe;AAAA,EAChD,MAAM;AAAA,EACN,cAAc;AAChB,CAAC;AAED,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AACxD,IAAM,aAAa,QAAQ,WAAW,sBAAsB;AAE5D,cAAc,YAAY,KAAK,UAAU,YAAY,MAAM,CAAC,GAAG,OAAO;AAEtE,QAAQ,IAAI,aAAa,UAAU,EAAE;","names":[]}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @safe-ugc-ui/schema — Public API
3
+ *
4
+ * Provides programmatic access to the UGC Card JSON Schema.
5
+ *
6
+ * For the static JSON file (editor / ajv integration), import from:
7
+ * `@safe-ugc-ui/schema/ugc-card.schema.json`
8
+ *
9
+ * For runtime generation:
10
+ * `import { generateCardSchema } from '@safe-ugc-ui/schema';`
11
+ *
12
+ * IMPORTANT: JSON Schema covers structural validation only.
13
+ * Security rules, resource limits, and context-dependent checks require
14
+ * the @safe-ugc-ui/validator package.
15
+ */
16
+ /**
17
+ * Generate the UGC Card JSON Schema at runtime.
18
+ *
19
+ * Returns a plain object conforming to JSON Schema Draft 7.
20
+ * Equivalent to the static `ugc-card.schema.json` file produced at build time.
21
+ */
22
+ declare function generateCardSchema(): Record<string, unknown>;
23
+
24
+ export { generateCardSchema };
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ // src/index.ts
2
+ import { ugcCardSchema } from "@safe-ugc-ui/types";
3
+ import { zodToJsonSchema } from "zod-to-json-schema";
4
+ function generateCardSchema() {
5
+ return zodToJsonSchema(ugcCardSchema, {
6
+ name: "UGCCard",
7
+ nameStrategy: "title"
8
+ });
9
+ }
10
+ export {
11
+ generateCardSchema
12
+ };
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @safe-ugc-ui/schema — Public API\n *\n * Provides programmatic access to the UGC Card JSON Schema.\n *\n * For the static JSON file (editor / ajv integration), import from:\n * `@safe-ugc-ui/schema/ugc-card.schema.json`\n *\n * For runtime generation:\n * `import { generateCardSchema } from '@safe-ugc-ui/schema';`\n *\n * IMPORTANT: JSON Schema covers structural validation only.\n * Security rules, resource limits, and context-dependent checks require\n * the @safe-ugc-ui/validator package.\n */\n\nimport { ugcCardSchema } from '@safe-ugc-ui/types';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\n\n/**\n * Generate the UGC Card JSON Schema at runtime.\n *\n * Returns a plain object conforming to JSON Schema Draft 7.\n * Equivalent to the static `ugc-card.schema.json` file produced at build time.\n */\nexport function generateCardSchema(): Record<string, unknown> {\n return zodToJsonSchema(ugcCardSchema, {\n name: 'UGCCard',\n nameStrategy: 'title',\n }) as Record<string, unknown>;\n}\n"],"mappings":";AAgBA,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAQzB,SAAS,qBAA8C;AAC5D,SAAO,gBAAgB,eAAe;AAAA,IACpC,MAAM;AAAA,IACN,cAAc;AAAA,EAChB,CAAC;AACH;","names":[]}