@flexkit/schema 0.0.0-stage → 0.1.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.
package/dist/index.js ADDED
@@ -0,0 +1,281 @@
1
+ // src/normalize-entity.ts
2
+ function assertAssetScope(attribute, entityName) {
3
+ if (attribute.dataType !== "asset") {
4
+ return;
5
+ }
6
+ if (attribute.scope !== void 0 && attribute.scope !== "global") {
7
+ throw new Error(
8
+ `Attribute "${attribute.name}" in entity "${entityName}" uses dataType "asset" but scope "${String(attribute.scope)}". Asset attributes must use scope "global" or omit scope.`
9
+ );
10
+ }
11
+ }
12
+ function normalizeAttributeScope(attribute) {
13
+ if (attribute.dataType !== "asset") {
14
+ return attribute;
15
+ }
16
+ return {
17
+ ...attribute,
18
+ scope: "global"
19
+ };
20
+ }
21
+ function assertDisplayAttribute(entity) {
22
+ const displayAttribute = entity.display ? entity.attributes.find((attribute) => attribute.name === entity.display) : entity.attributes[0];
23
+ if (entity.display && !displayAttribute) {
24
+ throw new Error(`Entity "${entity.name}" sets display to "${entity.display}", but no attribute has that name.`);
25
+ }
26
+ if (!displayAttribute || (displayAttribute.spaces ?? []).length === 0) {
27
+ return;
28
+ }
29
+ throw new Error(
30
+ `Entity "${entity.name}" cannot use space-bound attribute "${displayAttribute.name}" as its display field.`
31
+ );
32
+ }
33
+ function normalizeEntity(entity) {
34
+ entity.attributes.forEach((attribute) => {
35
+ assertAssetScope(attribute, entity.name);
36
+ });
37
+ assertDisplayAttribute(entity);
38
+ return {
39
+ ...entity,
40
+ attributes: entity.attributes.map(normalizeAttributeScope)
41
+ };
42
+ }
43
+
44
+ // src/define.ts
45
+ function defineConfig(config) {
46
+ return config;
47
+ }
48
+ function defineEntity(entity) {
49
+ return normalizeEntity(entity);
50
+ }
51
+
52
+ // src/json-schema.ts
53
+ function stripJsonSchemaMeta(value) {
54
+ if (Array.isArray(value)) {
55
+ return value.map((entry) => stripJsonSchemaMeta(entry));
56
+ }
57
+ if (!value || typeof value !== "object") {
58
+ return value;
59
+ }
60
+ const result = {};
61
+ for (const [key, nested] of Object.entries(value)) {
62
+ if (key === "$schema") {
63
+ continue;
64
+ }
65
+ result[key] = stripJsonSchemaMeta(nested);
66
+ }
67
+ return result;
68
+ }
69
+
70
+ // src/serialize.ts
71
+ import { z } from "zod";
72
+ var SUPPORTED_VALIDATION_KEYWORDS = /* @__PURE__ */ new Set([
73
+ "type",
74
+ "minLength",
75
+ "maxLength",
76
+ "pattern",
77
+ "format",
78
+ "minimum",
79
+ "maximum",
80
+ "exclusiveMinimum",
81
+ "exclusiveMaximum",
82
+ "multipleOf",
83
+ "enum",
84
+ "const",
85
+ "properties",
86
+ "required",
87
+ "additionalProperties",
88
+ "items",
89
+ "minItems",
90
+ "maxItems",
91
+ "anyOf",
92
+ "oneOf",
93
+ "not",
94
+ "description",
95
+ "title"
96
+ ]);
97
+ var SUPPORTED_VALIDATION_FORMATS = /* @__PURE__ */ new Set([
98
+ "email",
99
+ "uri",
100
+ "uuid",
101
+ "date-time",
102
+ "date",
103
+ "time"
104
+ ]);
105
+ var SchemaSerializationError = class extends Error {
106
+ entity;
107
+ attribute;
108
+ constructor(reason, location = {}, options) {
109
+ const where = location.entity ? location.attribute ? `Attribute "${location.attribute}" of entity "${location.entity}": ` : `Entity "${location.entity}": ` : "";
110
+ super(`${where}${reason}`, options);
111
+ this.name = "SchemaSerializationError";
112
+ this.entity = location.entity;
113
+ this.attribute = location.attribute;
114
+ }
115
+ };
116
+ function getDef(schema) {
117
+ return schema._zod.def;
118
+ }
119
+ function findCustomCheck(schema, seen = /* @__PURE__ */ new Set()) {
120
+ if (seen.has(schema)) {
121
+ return false;
122
+ }
123
+ seen.add(schema);
124
+ const def = getDef(schema);
125
+ if (def.checks?.some((check) => check._zod.def.check === "custom")) {
126
+ return true;
127
+ }
128
+ const children = [
129
+ def.innerType,
130
+ def.in,
131
+ def.out,
132
+ def.element,
133
+ def.left,
134
+ def.right,
135
+ def.keyType,
136
+ def.valueType,
137
+ ...def.options ?? [],
138
+ ...Object.values(def.shape ?? {}),
139
+ ...def.type === "lazy" && def.getter ? [def.getter()] : []
140
+ ];
141
+ return children.some((child) => child !== void 0 && findCustomCheck(child, seen));
142
+ }
143
+ function assertSupportedJsonSchema(fragment, location, path = []) {
144
+ if (Array.isArray(fragment)) {
145
+ fragment.forEach((entry, index) => {
146
+ assertSupportedJsonSchema(entry, location, [...path, String(index)]);
147
+ });
148
+ return;
149
+ }
150
+ if (!fragment || typeof fragment !== "object") {
151
+ return;
152
+ }
153
+ for (const [key, value] of Object.entries(fragment)) {
154
+ const insideMap = path.length > 0 && path[path.length - 1] === "properties";
155
+ if (!insideMap && !SUPPORTED_VALIDATION_KEYWORDS.has(key)) {
156
+ throw new SchemaSerializationError(
157
+ `validation uses the JSON Schema keyword "${[...path, key].join(".")}", which the Studio form cannot enforce. Supported keywords: ${[...SUPPORTED_VALIDATION_KEYWORDS].join(", ")}.`,
158
+ location
159
+ );
160
+ }
161
+ if (!insideMap && key === "format" && typeof value === "string" && !SUPPORTED_VALIDATION_FORMATS.has(value)) {
162
+ throw new SchemaSerializationError(
163
+ `validation uses the format "${value}", which the Studio form cannot enforce. Supported formats: ${[...SUPPORTED_VALIDATION_FORMATS].join(", ")}.`,
164
+ location
165
+ );
166
+ }
167
+ if (key === "properties" || key === "items" || key === "anyOf" || key === "oneOf" || key === "not") {
168
+ assertSupportedJsonSchema(value, location, [...path, key]);
169
+ } else if (insideMap) {
170
+ assertSupportedJsonSchema(value, location, [...path, key]);
171
+ }
172
+ }
173
+ }
174
+ function serializeValidation(validation, location = {}) {
175
+ let schema;
176
+ try {
177
+ schema = validation(z);
178
+ } catch (error) {
179
+ throw new SchemaSerializationError("validation() threw while building the Zod schema.", location, { cause: error });
180
+ }
181
+ if (findCustomCheck(schema)) {
182
+ throw new SchemaSerializationError(
183
+ "validation uses refine(), superRefine() or check(), which cannot be expressed as JSON Schema. Use built-in Zod checks such as min(), max(), length(), regex() or email().",
184
+ location
185
+ );
186
+ }
187
+ let fragment;
188
+ try {
189
+ fragment = z.toJSONSchema(schema, { target: "draft-07", unrepresentable: "throw" });
190
+ } catch (error) {
191
+ const reason = error instanceof Error ? error.message : String(error);
192
+ throw new SchemaSerializationError(`validation cannot be expressed as JSON Schema: ${reason}`, location, {
193
+ cause: error
194
+ });
195
+ }
196
+ const stripped = stripJsonSchemaMeta(fragment);
197
+ assertSupportedJsonSchema(stripped, location);
198
+ return stripped;
199
+ }
200
+ function assertBooleanFlag(value, name, location) {
201
+ if (value !== void 0 && typeof value !== "boolean") {
202
+ throw new SchemaSerializationError(
203
+ `"${name}" must be a boolean. Conditional callbacks are no longer supported; move the rule into the schema or drop it.`,
204
+ location
205
+ );
206
+ }
207
+ }
208
+ function assertIconName(value, where, location) {
209
+ if (value !== void 0 && typeof value !== "string") {
210
+ throw new SchemaSerializationError(
211
+ `${where} must be a lucide icon name such as 'Tag'. React elements are no longer supported in flexkit.config.ts.`,
212
+ location
213
+ );
214
+ }
215
+ }
216
+ function serializeAttribute(attribute, entityName) {
217
+ const location = { entity: entityName, attribute: attribute.name };
218
+ assertBooleanFlag(attribute.hidden, "hidden", location);
219
+ assertBooleanFlag(attribute.readOnly, "readOnly", location);
220
+ const { validation, ...rest } = attribute;
221
+ if (validation === void 0) {
222
+ return rest;
223
+ }
224
+ if (typeof validation !== "function") {
225
+ throw new SchemaSerializationError("validation must be a function receiving the Zod namespace.", location);
226
+ }
227
+ return { ...rest, validation: serializeValidation(validation, location) };
228
+ }
229
+ function serializeEntity(entity) {
230
+ const location = { entity: entity.name };
231
+ assertIconName(entity.menu?.icon, "menu.icon", location);
232
+ entity.groups?.forEach((group) => {
233
+ assertIconName(group.icon, `groups["${group.name}"].icon`, location);
234
+ assertBooleanFlag(group.hidden, `groups["${group.name}"].hidden`, location);
235
+ });
236
+ const serialized = {
237
+ name: entity.name,
238
+ plural: entity.plural,
239
+ attributes: entity.attributes.map((attribute) => serializeAttribute(attribute, entity.name))
240
+ };
241
+ if (entity.display !== void 0) serialized.display = entity.display;
242
+ if (entity.menu !== void 0) serialized.menu = entity.menu;
243
+ if (entity.spaces !== void 0) serialized.spaces = entity.spaces;
244
+ if (entity.groups !== void 0) serialized.groups = entity.groups;
245
+ return serialized;
246
+ }
247
+ function serializeProjectConfig(project) {
248
+ if (!project || typeof project !== "object" || typeof project.projectId !== "string") {
249
+ throw new SchemaSerializationError('each project needs a string "projectId".');
250
+ }
251
+ if (!Array.isArray(project.schema)) {
252
+ throw new SchemaSerializationError('"schema" must be an array of entities.', {});
253
+ }
254
+ const serialized = {
255
+ projectId: project.projectId,
256
+ schema: project.schema.map(serializeEntity)
257
+ };
258
+ if (project.title !== void 0) serialized.title = project.title;
259
+ if (project.menuGroups !== void 0) serialized.menuGroups = project.menuGroups;
260
+ if (project.scopes !== void 0) serialized.scopes = project.scopes;
261
+ if (project.spaces !== void 0) serialized.spaces = project.spaces;
262
+ return serialized;
263
+ }
264
+ function serializeConfig(config) {
265
+ return (Array.isArray(config) ? config : [config]).map(serializeProjectConfig);
266
+ }
267
+ export {
268
+ SUPPORTED_VALIDATION_FORMATS,
269
+ SUPPORTED_VALIDATION_KEYWORDS,
270
+ SchemaSerializationError,
271
+ defineConfig,
272
+ defineEntity,
273
+ normalizeEntity,
274
+ serializeAttribute,
275
+ serializeConfig,
276
+ serializeEntity,
277
+ serializeProjectConfig,
278
+ serializeValidation,
279
+ stripJsonSchemaMeta
280
+ };
281
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/normalize-entity.ts","../src/define.ts","../src/json-schema.ts","../src/serialize.ts"],"sourcesContent":["import type { Attribute, Entity } from './types';\n\nfunction assertAssetScope(attribute: Attribute, entityName: string): void {\n if (attribute.dataType !== 'asset') {\n return;\n }\n\n if (attribute.scope !== undefined && attribute.scope !== 'global') {\n throw new Error(\n `Attribute \"${attribute.name}\" in entity \"${entityName}\" uses dataType \"asset\" but scope \"${String(attribute.scope)}\". Asset attributes must use scope \"global\" or omit scope.`\n );\n }\n}\n\nfunction normalizeAttributeScope(attribute: Attribute): Attribute {\n if (attribute.dataType !== 'asset') {\n return attribute;\n }\n\n return {\n ...attribute,\n scope: 'global',\n };\n}\n\nfunction assertDisplayAttribute(entity: Entity): void {\n const displayAttribute = entity.display\n ? entity.attributes.find((attribute) => attribute.name === entity.display)\n : entity.attributes[0];\n\n if (entity.display && !displayAttribute) {\n throw new Error(`Entity \"${entity.name}\" sets display to \"${entity.display}\", but no attribute has that name.`);\n }\n\n if (!displayAttribute || (displayAttribute.spaces ?? []).length === 0) {\n return;\n }\n\n throw new Error(\n `Entity \"${entity.name}\" cannot use space-bound attribute \"${displayAttribute.name}\" as its display field.`\n );\n}\n\nexport function normalizeEntity(entity: Entity): Entity {\n entity.attributes.forEach((attribute) => {\n assertAssetScope(attribute, entity.name);\n });\n\n assertDisplayAttribute(entity);\n\n return {\n ...entity,\n attributes: entity.attributes.map(normalizeAttributeScope),\n };\n}\n","import { normalizeEntity } from './normalize-entity';\nimport type { Config, Entity } from './types';\n\n/** Types and returns a `flexkit.config.ts` export unchanged. */\nexport function defineConfig<T extends Config>(config: T): T {\n return config;\n}\n\n/**\n * Types an entity and normalizes it: asset attributes get `scope: 'global'`,\n * and invalid asset scopes or display attributes throw at config load time.\n */\nexport function defineEntity<T extends Entity>(entity: T): Entity {\n return normalizeEntity(entity);\n}\n","/** Removes `$schema` at every level of a JSON Schema document. */\nexport function stripJsonSchemaMeta(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map((entry) => stripJsonSchemaMeta(entry));\n }\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n\n const result: { [key: string]: unknown } = {};\n\n for (const [key, nested] of Object.entries(value as { [key: string]: unknown })) {\n if (key === '$schema') {\n continue;\n }\n\n result[key] = stripJsonSchemaMeta(nested);\n }\n\n return result;\n}\n","import { z } from 'zod';\nimport { stripJsonSchemaMeta } from './json-schema';\nimport type {\n Attribute,\n Config,\n Entity,\n JsonSchemaObject,\n ProjectConfig,\n UiAttribute,\n UiEntity,\n UiProjectSchema,\n ZodValidation,\n} from './types';\n\n/**\n * JSON Schema keywords the Studio form knows how to validate. Anything else\n * fails the deploy so a rule never silently disappears between the config and\n * the form.\n */\nexport const SUPPORTED_VALIDATION_KEYWORDS: ReadonlySet<string> = new Set([\n 'type',\n 'minLength',\n 'maxLength',\n 'pattern',\n 'format',\n 'minimum',\n 'maximum',\n 'exclusiveMinimum',\n 'exclusiveMaximum',\n 'multipleOf',\n 'enum',\n 'const',\n 'properties',\n 'required',\n 'additionalProperties',\n 'items',\n 'minItems',\n 'maxItems',\n 'anyOf',\n 'oneOf',\n 'not',\n 'description',\n 'title',\n]);\n\nexport const SUPPORTED_VALIDATION_FORMATS: ReadonlySet<string> = new Set([\n 'email',\n 'uri',\n 'uuid',\n 'date-time',\n 'date',\n 'time',\n]);\n\ntype SerializationLocation = { entity?: string; attribute?: string };\n\n/** Raised when a config cannot be turned into a deployable JSON schema. */\nexport class SchemaSerializationError extends Error {\n readonly entity: string | undefined;\n readonly attribute: string | undefined;\n\n constructor(reason: string, location: SerializationLocation = {}, options?: { cause?: unknown }) {\n const where = location.entity\n ? location.attribute\n ? `Attribute \"${location.attribute}\" of entity \"${location.entity}\": `\n : `Entity \"${location.entity}\": `\n : '';\n\n super(`${where}${reason}`, options);\n this.name = 'SchemaSerializationError';\n this.entity = location.entity;\n this.attribute = location.attribute;\n }\n}\n\ntype ZodDef = {\n type?: string;\n checks?: { _zod: { def: { check?: string } } }[];\n innerType?: z.ZodType;\n in?: z.ZodType;\n out?: z.ZodType;\n element?: z.ZodType;\n options?: z.ZodType[];\n left?: z.ZodType;\n right?: z.ZodType;\n keyType?: z.ZodType;\n valueType?: z.ZodType;\n shape?: { [key: string]: z.ZodType };\n getter?: () => z.ZodType;\n};\n\nfunction getDef(schema: z.ZodType): ZodDef {\n return (schema as unknown as { _zod: { def: ZodDef } })._zod.def;\n}\n\n/**\n * `z.toJSONSchema` drops `.refine()` / `.superRefine()` / `.check()` without\n * complaint. Walk the schema and reject them explicitly: a rule that only ran\n * in the config author's head is worse than a deploy error.\n */\nfunction findCustomCheck(schema: z.ZodType, seen = new Set<z.ZodType>()): boolean {\n if (seen.has(schema)) {\n return false;\n }\n\n seen.add(schema);\n const def = getDef(schema);\n\n if (def.checks?.some((check) => check._zod.def.check === 'custom')) {\n return true;\n }\n\n const children: (z.ZodType | undefined)[] = [\n def.innerType,\n def.in,\n def.out,\n def.element,\n def.left,\n def.right,\n def.keyType,\n def.valueType,\n ...(def.options ?? []),\n ...Object.values(def.shape ?? {}),\n ...(def.type === 'lazy' && def.getter ? [def.getter()] : []),\n ];\n\n return children.some((child) => child !== undefined && findCustomCheck(child, seen));\n}\n\nfunction assertSupportedJsonSchema(fragment: unknown, location: SerializationLocation, path: string[] = []): void {\n if (Array.isArray(fragment)) {\n fragment.forEach((entry, index) => {\n assertSupportedJsonSchema(entry, location, [...path, String(index)]);\n });\n\n return;\n }\n\n if (!fragment || typeof fragment !== 'object') {\n return;\n }\n\n for (const [key, value] of Object.entries(fragment as { [key: string]: unknown })) {\n const insideMap = path.length > 0 && path[path.length - 1] === 'properties';\n\n if (!insideMap && !SUPPORTED_VALIDATION_KEYWORDS.has(key)) {\n throw new SchemaSerializationError(\n `validation uses the JSON Schema keyword \"${[...path, key].join('.')}\", which the Studio form cannot enforce. Supported keywords: ${[...SUPPORTED_VALIDATION_KEYWORDS].join(', ')}.`,\n location\n );\n }\n\n if (!insideMap && key === 'format' && typeof value === 'string' && !SUPPORTED_VALIDATION_FORMATS.has(value)) {\n throw new SchemaSerializationError(\n `validation uses the format \"${value}\", which the Studio form cannot enforce. Supported formats: ${[...SUPPORTED_VALIDATION_FORMATS].join(', ')}.`,\n location\n );\n }\n\n if (key === 'properties' || key === 'items' || key === 'anyOf' || key === 'oneOf' || key === 'not') {\n assertSupportedJsonSchema(value, location, [...path, key]);\n } else if (insideMap) {\n assertSupportedJsonSchema(value, location, [...path, key]);\n }\n }\n}\n\n/**\n * Compiles an attribute's Zod validation to a JSON Schema (draft-07) fragment.\n * Throws `SchemaSerializationError` for anything the Studio cannot enforce.\n */\nexport function serializeValidation(validation: ZodValidation, location: SerializationLocation = {}): JsonSchemaObject {\n let schema: z.ZodType;\n\n try {\n schema = validation(z);\n } catch (error) {\n throw new SchemaSerializationError('validation() threw while building the Zod schema.', location, { cause: error });\n }\n\n if (findCustomCheck(schema)) {\n throw new SchemaSerializationError(\n 'validation uses refine(), superRefine() or check(), which cannot be expressed as JSON Schema. Use built-in Zod checks such as min(), max(), length(), regex() or email().',\n location\n );\n }\n\n let fragment: unknown;\n\n try {\n fragment = z.toJSONSchema(schema, { target: 'draft-07', unrepresentable: 'throw' });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n\n throw new SchemaSerializationError(`validation cannot be expressed as JSON Schema: ${reason}`, location, {\n cause: error,\n });\n }\n\n const stripped = stripJsonSchemaMeta(fragment) as JsonSchemaObject;\n assertSupportedJsonSchema(stripped, location);\n\n return stripped;\n}\n\nfunction assertBooleanFlag(value: unknown, name: string, location: SerializationLocation): void {\n if (value !== undefined && typeof value !== 'boolean') {\n throw new SchemaSerializationError(\n `\"${name}\" must be a boolean. Conditional callbacks are no longer supported; move the rule into the schema or drop it.`,\n location\n );\n }\n}\n\nfunction assertIconName(value: unknown, where: string, location: SerializationLocation): void {\n if (value !== undefined && typeof value !== 'string') {\n throw new SchemaSerializationError(\n `${where} must be a lucide icon name such as 'Tag'. React elements are no longer supported in flexkit.config.ts.`,\n location\n );\n }\n}\n\nexport function serializeAttribute(attribute: Attribute, entityName: string): UiAttribute {\n const location = { entity: entityName, attribute: attribute.name };\n\n assertBooleanFlag(attribute.hidden, 'hidden', location);\n assertBooleanFlag(attribute.readOnly, 'readOnly', location);\n\n const { validation, ...rest } = attribute;\n\n if (validation === undefined) {\n return rest as UiAttribute;\n }\n\n if (typeof validation !== 'function') {\n throw new SchemaSerializationError('validation must be a function receiving the Zod namespace.', location);\n }\n\n return { ...rest, validation: serializeValidation(validation, location) } as UiAttribute;\n}\n\nexport function serializeEntity(entity: Entity): UiEntity {\n const location = { entity: entity.name };\n\n assertIconName(entity.menu?.icon, 'menu.icon', location);\n entity.groups?.forEach((group) => {\n assertIconName(group.icon, `groups[\"${group.name}\"].icon`, location);\n assertBooleanFlag(group.hidden, `groups[\"${group.name}\"].hidden`, location);\n });\n\n const serialized: UiEntity = {\n name: entity.name,\n plural: entity.plural,\n attributes: entity.attributes.map((attribute) => serializeAttribute(attribute, entity.name)),\n };\n\n if (entity.display !== undefined) serialized.display = entity.display;\n if (entity.menu !== undefined) serialized.menu = entity.menu;\n if (entity.spaces !== undefined) serialized.spaces = entity.spaces;\n if (entity.groups !== undefined) serialized.groups = entity.groups;\n\n return serialized;\n}\n\n/**\n * Turns one project of a `flexkit.config.ts` into the payload `flexkit deploy`\n * sends. Only data survives: title, projectId, menuGroups, scopes, spaces and\n * the schema with validation compiled to JSON Schema.\n */\nexport function serializeProjectConfig(project: ProjectConfig): UiProjectSchema {\n if (!project || typeof project !== 'object' || typeof project.projectId !== 'string') {\n throw new SchemaSerializationError('each project needs a string \"projectId\".');\n }\n\n if (!Array.isArray(project.schema)) {\n throw new SchemaSerializationError('\"schema\" must be an array of entities.', {});\n }\n\n const serialized: UiProjectSchema = {\n projectId: project.projectId,\n schema: project.schema.map(serializeEntity),\n };\n\n if (project.title !== undefined) serialized.title = project.title;\n if (project.menuGroups !== undefined) serialized.menuGroups = project.menuGroups;\n if (project.scopes !== undefined) serialized.scopes = project.scopes;\n if (project.spaces !== undefined) serialized.spaces = project.spaces;\n\n return serialized;\n}\n\n/** Serializes a whole `flexkit.config.ts` export (one project or a list). */\nexport function serializeConfig(config: Config): UiProjectSchema[] {\n return (Array.isArray(config) ? config : [config]).map(serializeProjectConfig);\n}\n"],"mappings":";AAEA,SAAS,iBAAiB,WAAsB,YAA0B;AACxE,MAAI,UAAU,aAAa,SAAS;AAClC;AAAA,EACF;AAEA,MAAI,U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OAAO;AAE5D,SAAO;AACT;AAOO,SAAS,uBAAuB,SAAyC;AAC9E,MAAI,CAAC,WAAW,OAAO,YAAY,YAAY,OAAO,QAAQ,cAAc,UAAU;AACpF,UAAM,IAAI,yBAAyB,0CAA0C;AAAA,EAC/E;AAEA,MAAI,CAAC,MAAM,QAAQ,QAAQ,MAAM,GAAG;AAClC,UAAM,IAAI,yBAAyB,0CAA0C,CAAC,CAAC;AAAA,EACjF;AAEA,QAAM,aAA8B;AAAA,IAClC,WAAW,QAAQ;AAAA,IACnB,QAAQ,QAAQ,OAAO,IAAI,eAAe;AAAA,EAC5C;AAEA,MAAI,QAAQ,UAAU,OAAW,YAAW,QAAQ,QAAQ;AAC5D,MAAI,QAAQ,eAAe,OAAW,YAAW,aAAa,QAAQ;AACtE,MAAI,QAAQ,WAAW,OAAW,YAAW,SAAS,QAAQ;AAC9D,MAAI,QAAQ,WAAW,OAAW,YAAW,SAAS,QAAQ;AAE9D,SAAO;AACT;AAGO,SAAS,gBAAgB,QAAmC;AACjE,UAAQ,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM,GAAG,IAAI,sBAAsB;AAC/E;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@flexkit/schema",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Flexkit project configuration: schema types, defineConfig/defineEntity, and the serializer that turns a flexkit.config.ts into the deployable JSON schema.",
5
+ "keywords": [
6
+ "flexkit",
7
+ "schema",
8
+ "config"
9
+ ],
10
+ "type": "module",
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/flexkit-io/flexkit",
18
+ "directory": "packages/schema"
19
+ },
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs"
25
+ }
26
+ },
27
+ "sideEffects": false,
28
+ "files": [
29
+ "dist/**"
30
+ ],
31
+ "dependencies": {
32
+ "zod": "4.4.3"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^20.5.2",
36
+ "eslint": "^9.0.0",
37
+ "tsup": "8.5.1",
38
+ "typescript": "^5.3.3",
39
+ "eslint-config-custom": "0.0.0",
40
+ "tsconfig": "0.0.0"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup src/index.ts --format esm,cjs --dts --sourcemap",
47
+ "dev": "tsup src/index.ts --format esm,cjs --dts --watch src",
48
+ "lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
49
+ "test": "tsup --config tests/tsup.config.ts && node --test build/tests/*.test.js && tsc --noEmit -p tests/tsconfig.json",
50
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist && rm -rf build"
51
+ }
6
52
  }