@kosmojs/dev 0.0.6 → 0.0.7

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/stub-generator/index.ts", "load-as-text:/volumes/studio/OpenSource/KosmoJS/Monorepo/packages/core/dev/src/stub-generator/templates/env.d.ts", "../../src/stub-generator/templates/gitignore.hbs", "../../src/stub-generator/templates/schemas.hbs"],
3
+ "sources": ["../../src/stub-generator/index.ts", "load-as-text:/volumes/studio/OpenSource/KosmoJS/Kosmo/packages/core/dev/src/stub-generator/templates/env.d.ts", "../../src/stub-generator/templates/gitignore.hbs", "../../src/stub-generator/templates/schemas.hbs"],
4
4
  "sourcesContent": ["import {\n type GeneratorConstructor,\n pathResolver,\n renderToFile,\n} from \"@kosmojs/devlib\";\n\nimport envTpl from \"./templates/env.d.ts?as=text\";\nimport gitignoreTpl from \"./templates/gitignore.hbs\";\nimport schemasTpl from \"./templates/schemas.hbs\";\n\n/**\n * Generates stub files required by various generators.\n * Ensures cross-generator dependencies remain resolvable\n * even if specialized generators supposed to generate these files are not installed.\n * */\nexport default (): GeneratorConstructor => {\n return {\n name: \"Stub\",\n moduleImport: import.meta.filename,\n moduleConfig: undefined,\n async factory({ appRoot, sourceFolder }) {\n return {\n async watchHandler(entries) {\n const { resolve } = pathResolver({ appRoot, sourceFolder });\n\n /**\n * expose TRefine as a global type.\n * not supposed to be overriden by generators.\n * */\n await renderToFile(resolve(\"libDir\", \"env.d.ts\"), envTpl, {});\n\n /**\n * deploy a default gitignore file that ignore everything,\n * except cache.json files; if file exists, do not override.\n * */\n await renderToFile(\n resolve(\"libDir\", \".gitignore\"),\n gitignoreTpl,\n {},\n { overwrite: false },\n );\n\n for (const { kind, route } of entries) {\n if (kind === \"api\") {\n // Generating stub schemas file.\n // It is required by various generators, e.g. api-generator, fetch-generator.\n // Specialized generators (e.g. typebox-generator) may override this later.\n await renderToFile(\n resolve(\"apiLibDir\", route.importPath, \"schemas.ts\"),\n schemasTpl,\n { route },\n { overwrite: false },\n );\n }\n }\n },\n };\n },\n };\n};\n", "/**\n * Enhances base TypeScript types with JSON Schema validation constraints.\n * Allows declaring refined types that carry validation metadata for runtime\n * schema validation while maintaining full TypeScript type safety.\n *\n * Useful for generating validation schemas and ensuring\n * data conforms to specific business rules beyond basic type checking.\n * */\nexport declare global {\n type TRefine<\n T extends unknown[] | number | string | object,\n _ extends T extends unknown[]\n ? TArrayOptions\n : T extends number\n ? TNumberOptions\n : T extends string\n ? TStringOptions\n : TObjectOptions,\n > = T;\n}\n\n/**\n * Type definitions inspired by and gently adapted from TypeBox.\n * Original TypeBox created by sinclairzx81: https://github.com/sinclairzx81/typebox\n * TypeBox is licensed under MIT: https://github.com/sinclairzx81/typebox/blob/main/license\n *\n * These types provide JSON Schema compatible type refinements for TypeScript.\n * */\ninterface TSchema {}\n\n// ------------------------------------------------------------------\n// ObjectOptions\n// ------------------------------------------------------------------\ninterface TObjectOptions {\n /**\n * Defines whether additional properties are allowed beyond those explicitly defined in `properties`.\n */\n additionalProperties?: TSchema | boolean;\n /**\n * The minimum number of properties required in the object.\n */\n minProperties?: number;\n /**\n * The maximum number of properties allowed in the object.\n */\n maxProperties?: number;\n /**\n * Defines conditional requirements for properties.\n */\n dependencies?: Record<string, boolean | TSchema | string[]>;\n /**\n * Specifies properties that *must* be present if a given property is present.\n */\n dependentRequired?: Record<string, string[]>;\n /**\n * Defines schemas that apply if a specific property is present.\n */\n dependentSchemas?: Record<string, TSchema>;\n /**\n * Maps regular expressions to schemas properties matching a pattern must validate against the schema.\n */\n patternProperties?: Record<string, TSchema>;\n /**\n * A schema that all property names within the object must validate against.\n */\n propertyNames?: TSchema;\n}\n\n// ------------------------------------------------------------------\n// ArrayOptions\n// ------------------------------------------------------------------\ninterface TArrayOptions {\n /**\n * The minimum number of items allowed in the array.\n */\n minItems?: number;\n /**\n * The maximum number of items allowed in the array.\n */\n maxItems?: number;\n /**\n * A schema that at least one item in the array must validate against.\n */\n contains?: TSchema;\n /**\n * The minimum number of array items that must validate against the `contains` schema.\n */\n minContains?: number;\n /**\n * The maximum number of array items that may validate against the `contains` schema.\n */\n maxContains?: number;\n /**\n * An array of schemas, where each schema in `prefixItems` validates against items at corresponding positions from the beginning of the array.\n */\n prefixItems?: TSchema[];\n /**\n * If `true`, all items in the array must be unique.\n */\n uniqueItems?: boolean;\n}\n\n// ------------------------------------------------------------------\n// NumberOptions\n// ------------------------------------------------------------------\ninterface TNumberOptions {\n /**\n * Specifies an exclusive upper limit for the number (number must be less than this value).\n */\n exclusiveMaximum?: number | bigint;\n /**\n * Specifies an exclusive lower limit for the number (number must be greater than this value).\n */\n exclusiveMinimum?: number | bigint;\n /**\n * Specifies an inclusive upper limit for the number (number must be less than or equal to this value).\n */\n maximum?: number | bigint;\n /**\n * Specifies an inclusive lower limit for the number (number must be greater than or equal to this value).\n */\n minimum?: number | bigint;\n /**\n * Specifies that the number must be a multiple of this value.\n */\n multipleOf?: number | bigint;\n}\n\n// ------------------------------------------------------------------\n// StringOptions\n// ------------------------------------------------------------------\ntype TFormat =\n | \"date-time\"\n | \"date\"\n | \"duration\"\n | \"email\"\n | \"hostname\"\n | \"idn-email\"\n | \"idn-hostname\"\n | \"ipv4\"\n | \"ipv6\"\n | \"iri-reference\"\n | \"iri\"\n | \"json-pointer-uri-fragment\"\n | \"json-pointer\"\n | \"json-string\"\n | \"regex\"\n | \"relative-json-pointer\"\n | \"time\"\n | \"uri-reference\"\n | \"uri-template\"\n | \"url\"\n | \"uuid\";\n\ninterface TStringOptions {\n /**\n * Specifies the expected string format.\n *\n * Common values include:\n * - `base64` \u2013 Base64-encoded string.\n * - `date-time` \u2013 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time format.\n * - `date` \u2013 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date (YYYY-MM-DD).\n * - `duration` \u2013 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) duration format.\n * - `email` \u2013 RFC 5321/5322 compliant email address.\n * - `hostname` \u2013 RFC 1034/1035 compliant host name.\n * - `idn-email` \u2013 Internationalized email address.\n * - `idn-hostname` \u2013 Internationalized host name.\n * - `ipv4` \u2013 IPv4 address.\n * - `ipv6` \u2013 IPv6 address.\n * - `iri` / `iri-reference` \u2013 Internationalized Resource Identifier.\n * - `json-pointer` / `json-pointer-uri-fragment` \u2013 JSON Pointer format.\n * - `json-string` \u2013 String containing valid JSON.\n * - `regex` \u2013 Regular expression syntax.\n * - `relative-json-pointer` \u2013 Relative JSON Pointer format.\n * - `time` \u2013 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time (HH:MM:SS).\n * - `uri-reference` / `uri-template` \u2013 URI reference or template.\n * - `url` \u2013 Web URL format.\n * - `uuid` \u2013 RFC 4122 UUID string.\n *\n * May also be a custom format string.\n */\n format?: TFormat;\n /**\n * Specifies the minimum number of characters allowed in the string.\n * Must be a non-negative integer.\n */\n minLength?: number;\n /**\n * Specifies the maximum number of characters allowed in the string.\n * Must be a non-negative integer.\n */\n maxLength?: number;\n /**\n * Specifies a regular expression pattern that the string value must match.\n * Can be provided as a string (ECMA-262 regex syntax) or a `RegExp` object.\n */\n pattern?: string | RegExp;\n}\n", "# Ignore all files\n*\n\n# But don't ignore directories (so Git can traverse them)\n!*/\n\n# And don't ignore these files at any depth\n!cache.json\n!types.ts\n", "// stub schemas, specialized generators supposed to overwrite this file\nimport type { ValidationSchemas } from \"@kosmojs/api\";\nexport type { ValidationSchemas };\nexport const validationSchemas: ValidationSchemas = {};\n"],
5
5
  "mappings": ";AAAA;AAAA,EAEE;AAAA,EACA;AAAA,OACK;;;ACJP;;;ACAA;;;ACAA;;;AHeA,IAAO,yBAAQ,MAA4B;AACzC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,cAAc,YAAY;AAAA,IAC1B,cAAc;AAAA,IACd,MAAM,QAAQ,EAAE,SAAS,aAAa,GAAG;AACvC,aAAO;AAAA,QACL,MAAM,aAAa,SAAS;AAC1B,gBAAM,EAAE,QAAQ,IAAI,aAAa,EAAE,SAAS,aAAa,CAAC;AAM1D,gBAAM,aAAa,QAAQ,UAAU,UAAU,GAAG,eAAQ,CAAC,CAAC;AAM5D,gBAAM;AAAA,YACJ,QAAQ,UAAU,YAAY;AAAA,YAC9B;AAAA,YACA,CAAC;AAAA,YACD,EAAE,WAAW,MAAM;AAAA,UACrB;AAEA,qBAAW,EAAE,MAAM,MAAM,KAAK,SAAS;AACrC,gBAAI,SAAS,OAAO;AAIlB,oBAAM;AAAA,gBACJ,QAAQ,aAAa,MAAM,YAAY,YAAY;AAAA,gBACnD;AAAA,gBACA,EAAE,MAAM;AAAA,gBACR,EAAE,WAAW,MAAM;AAAA,cACrB;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []