@fern-api/csharp-dynamic-snippets 0.0.2 → 0.0.3

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.
Files changed (79) hide show
  1. package/cjs/Config.cjs +2 -11
  2. package/cjs/Config.cjs.map +1 -0
  3. package/cjs/DynamicSnippetsGenerator.cjs +31 -19
  4. package/cjs/DynamicSnippetsGenerator.cjs.map +1 -0
  5. package/cjs/DynamicSnippetsGenerator.d.cts +4 -1
  6. package/cjs/DynamicSnippetsGeneratorContext-DQDI25Nx.d.cts +395 -0
  7. package/cjs/EndpointSnippetGenerator.cjs +30 -19
  8. package/cjs/EndpointSnippetGenerator.cjs.map +1 -0
  9. package/cjs/EndpointSnippetGenerator.d.cts +7 -3
  10. package/cjs/context/DynamicSnippetsGeneratorContext.cjs +31 -32
  11. package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +1 -0
  12. package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +4 -2
  13. package/cjs/context/DynamicTypeLiteralMapper.cjs +2 -34
  14. package/cjs/context/DynamicTypeLiteralMapper.cjs.map +1 -0
  15. package/cjs/context/DynamicTypeLiteralMapper.d.cts +3 -1
  16. package/cjs/context/DynamicTypeMapper.cjs +2 -34
  17. package/cjs/context/DynamicTypeMapper.cjs.map +1 -0
  18. package/cjs/context/DynamicTypeMapper.d.cts +3 -1
  19. package/cjs/context/FilePropertyMapper.cjs +26 -32
  20. package/cjs/context/FilePropertyMapper.cjs.map +1 -0
  21. package/cjs/context/FilePropertyMapper.d.cts +3 -1
  22. package/cjs/index.cjs +34 -31
  23. package/cjs/index.cjs.map +1 -0
  24. package/cjs/index.d.cts +4 -2
  25. package/esm/Config.js +2 -1
  26. package/esm/Config.js.map +1 -0
  27. package/esm/DynamicSnippetsGenerator.d.ts +4 -1
  28. package/esm/DynamicSnippetsGenerator.js +2 -1
  29. package/esm/DynamicSnippetsGenerator.js.map +1 -0
  30. package/esm/DynamicSnippetsGeneratorContext-DQDI25Nx.d.ts +395 -0
  31. package/esm/EndpointSnippetGenerator.d.ts +7 -3
  32. package/esm/EndpointSnippetGenerator.js +2 -1
  33. package/esm/EndpointSnippetGenerator.js.map +1 -0
  34. package/esm/chunk-2ZIORSVG.js +2 -0
  35. package/esm/chunk-2ZIORSVG.js.map +1 -0
  36. package/esm/chunk-7V3DJGVI.js +2 -0
  37. package/esm/chunk-7V3DJGVI.js.map +1 -0
  38. package/esm/chunk-C6VL3KCZ.js +33 -0
  39. package/esm/chunk-C6VL3KCZ.js.map +1 -0
  40. package/esm/chunk-E3QSX5HZ.js +2 -0
  41. package/esm/chunk-E3QSX5HZ.js.map +1 -0
  42. package/esm/chunk-E4DWHIH4.js +2 -0
  43. package/esm/chunk-E4DWHIH4.js.map +1 -0
  44. package/esm/chunk-GYLRU3VR.js +2 -0
  45. package/esm/chunk-GYLRU3VR.js.map +1 -0
  46. package/esm/chunk-HWTWQNRE.js +15 -0
  47. package/esm/chunk-HWTWQNRE.js.map +1 -0
  48. package/esm/chunk-KHCIVF5J.js +1 -0
  49. package/esm/chunk-KHCIVF5J.js.map +1 -0
  50. package/esm/chunk-MPTA2ZER.js +2 -0
  51. package/esm/chunk-MPTA2ZER.js.map +1 -0
  52. package/esm/context/DynamicSnippetsGeneratorContext.d.ts +4 -2
  53. package/esm/context/DynamicSnippetsGeneratorContext.js +2 -1
  54. package/esm/context/DynamicSnippetsGeneratorContext.js.map +1 -0
  55. package/esm/context/DynamicTypeLiteralMapper.d.ts +3 -1
  56. package/esm/context/DynamicTypeLiteralMapper.js +2 -1
  57. package/esm/context/DynamicTypeLiteralMapper.js.map +1 -0
  58. package/esm/context/DynamicTypeMapper.d.ts +3 -1
  59. package/esm/context/DynamicTypeMapper.js +2 -1
  60. package/esm/context/DynamicTypeMapper.js.map +1 -0
  61. package/esm/context/FilePropertyMapper.d.ts +3 -1
  62. package/esm/context/FilePropertyMapper.js +2 -1
  63. package/esm/context/FilePropertyMapper.js.map +1 -0
  64. package/esm/index.d.ts +4 -2
  65. package/esm/index.js +5 -13
  66. package/esm/index.js.map +1 -0
  67. package/package.json +1 -1
  68. package/cjs/DynamicSnippetsGeneratorContext-DbMhuHoi.d.cts +0 -116
  69. package/esm/DynamicSnippetsGeneratorContext-DbMhuHoi.d.ts +0 -116
  70. package/esm/chunk-2AZXIWKY.js +0 -11
  71. package/esm/chunk-ARC6F6E6.js +0 -1
  72. package/esm/chunk-CIENX2JS.js +0 -1
  73. package/esm/chunk-DVOWBIEL.js +0 -1
  74. package/esm/chunk-HN67B7VQ.js +0 -1
  75. package/esm/chunk-IIP7VDG4.js +0 -1
  76. package/esm/chunk-ME2YBVEY.js +0 -1
  77. package/esm/chunk-PJC2VZIA.js +0 -26
  78. package/esm/chunk-QKK5PTVJ.js +0 -1
  79. package/esm/chunk-YL3JFOME.js +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/context/DynamicTypeMapper.ts","../../../../../../packages/commons/core-utils/src/assert.ts","../../../../codegen/src/with-generation.ts"],"sourcesContent":["import { assertNever } from \"@fern-api/core-utils\";\nimport { ast, WithGeneration } from \"@fern-api/csharp-codegen\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\n\nimport { DynamicSnippetsGeneratorContext } from \"./DynamicSnippetsGeneratorContext\";\n\nexport declare namespace DynamicTypeMapper {\n interface Args {\n typeReference: FernIr.dynamic.TypeReference;\n unboxOptionals?: boolean;\n }\n}\n\nexport class DynamicTypeMapper extends WithGeneration {\n private context: DynamicSnippetsGeneratorContext;\n\n constructor({ context }: { context: DynamicSnippetsGeneratorContext }) {\n super(context);\n this.context = context;\n }\n\n public convert(args: DynamicTypeMapper.Args): ast.Type {\n switch (args.typeReference.type) {\n case \"list\":\n return this.csharp.Type.list(this.convert({ typeReference: args.typeReference, unboxOptionals: true }));\n case \"literal\":\n return this.convertLiteral({ literal: args.typeReference.value });\n case \"map\": {\n return this.csharp.Type.map(\n this.convert({ typeReference: args.typeReference.key }),\n this.convert({ typeReference: args.typeReference.value })\n );\n }\n case \"named\": {\n const named = this.context.resolveNamedType({ typeId: args.typeReference.value });\n if (named == null) {\n return this.convertUnknown();\n }\n return this.convertNamed({ named });\n }\n case \"optional\":\n case \"nullable\": {\n const value = this.convert({ typeReference: args.typeReference.value });\n return args.unboxOptionals ? value.unwrapIfOptional() : this.csharp.Type.optional(value);\n }\n case \"primitive\":\n return this.convertPrimitive({ primitive: args.typeReference.value });\n case \"set\":\n return this.csharp.Type.set(this.convert({ typeReference: args.typeReference, unboxOptionals: true }));\n case \"unknown\":\n return this.convertUnknown();\n default:\n assertNever(args.typeReference);\n }\n }\n\n convertToClassReference(named: FernIr.dynamic.NamedType): ast.ClassReference {\n return this.csharp.classReference({\n origin: named.declaration,\n namespace: this.context.getNamespace(named.declaration.fernFilepath)\n });\n }\n\n private convertNamed({ named }: { named: FernIr.dynamic.NamedType }): ast.Type {\n switch (named.type) {\n case \"alias\":\n return this.convert({ typeReference: named.typeReference });\n case \"enum\":\n case \"object\":\n return this.csharp.Type.reference(\n this.csharp.classReference({\n origin: named.declaration,\n namespace: this.context.getNamespace(named.declaration.fernFilepath)\n })\n );\n case \"discriminatedUnion\":\n if (!this.settings.shouldGeneratedDiscriminatedUnions) {\n return this.csharp.Type.object;\n }\n return this.csharp.Type.reference(\n this.csharp.classReference({\n origin: named.declaration,\n namespace: this.context.getNamespace(named.declaration.fernFilepath)\n })\n );\n case \"undiscriminatedUnion\":\n return this.csharp.Type.oneOf(\n named.types.map((typeReference) => {\n return this.convert({ typeReference });\n })\n );\n default:\n assertNever(named);\n }\n }\n\n private convertLiteral({ literal }: { literal: FernIr.dynamic.LiteralType }): ast.Type {\n switch (literal.type) {\n case \"boolean\":\n return this.csharp.Type.boolean;\n case \"string\":\n return this.csharp.Type.string;\n }\n }\n\n private convertUnknown(): ast.Type {\n return this.csharp.Type.object;\n }\n\n private convertPrimitive({ primitive }: { primitive: FernIr.dynamic.PrimitiveTypeV1 }): ast.Type {\n switch (primitive) {\n case \"INTEGER\":\n return this.csharp.Type.integer;\n case \"UINT\":\n return this.csharp.Type.uint;\n case \"LONG\":\n return this.csharp.Type.long;\n case \"UINT_64\":\n return this.csharp.Type.ulong;\n case \"FLOAT\":\n return this.csharp.Type.float;\n case \"DOUBLE\":\n return this.csharp.Type.double;\n case \"BOOLEAN\":\n return this.csharp.Type.boolean;\n case \"STRING\":\n return this.csharp.Type.string;\n case \"DATE\":\n return this.csharp.Type.dateOnly;\n case \"DATE_TIME\":\n return this.csharp.Type.dateTime;\n case \"UUID\":\n return this.csharp.Type.string;\n case \"BASE_64\":\n return this.csharp.Type.string;\n case \"BIG_INTEGER\":\n return this.csharp.Type.string;\n default:\n assertNever(primitive);\n }\n }\n}\n","/**\n * Asserts that a condition is truthy, throwing an exception with the specified message if it is falsy.\n */\nexport function assert(condition: unknown, message?: string): asserts condition {\n if (!condition) {\n throw new Error(message ?? \"Expected condition to be truthy but got falsy.\");\n }\n}\n\nexport function assertDefined<T>(val: T, message?: string): asserts val is Exclude<T, undefined> {\n if (val === undefined) {\n throw new Error(message ?? \"Expected value to be defined but got undefined.\");\n }\n}\n\nexport function assertNonNull<T>(val: T, message?: string): asserts val is Exclude<T, null> {\n if (val === null) {\n throw new Error(message ?? \"Expected value to be non-null but got null.\");\n }\n}\n\nexport function assertNever(x: never): never {\n throw new Error(\"Unexpected value: \" + JSON.stringify(x));\n}\n\n// biome-ignore lint/suspicious/noEmptyBlockStatements: allow\nexport function assertNeverNoThrow(_: never): void {}\n\n// biome-ignore lint/suspicious/noEmptyBlockStatements: allow\nexport function assertVoidNoThrow(_x: void): void {}\n","import { type Generation } from \"./context/generation-info\";\n\n/**\n * The portable things that a context will provide to a generator.\n *\n * This interface defines the minimal contract that any context must fulfill\n * to be compatible with generator classes that extend `WithGeneration`.\n */\nexport interface IGeneration {\n /** The generation context containing all utilities and state needed for code generation */\n generation: Generation;\n}\n\n/**\n * A trivial class of convenience properties that a generator class can inherit from to gain access to the portable context features.\n *\n * This base class provides convenient access to common generation context properties through protected getters,\n * eliminating the need to repeatedly access `this.ctx.generation.*` throughout generator implementations.\n */\nexport class WithGeneration {\n public constructor(private readonly ctx: IGeneration) {}\n\n /** Provides access to the generation context */\n protected get generation() {\n return this.ctx.generation;\n }\n\n /** Provides access to C# code generation utilities */\n protected get csharp() {\n return this.generation.csharp;\n }\n\n /** Provides access to generation settings and configuration */\n protected get settings() {\n return this.generation.settings;\n }\n\n /** Provides access to generation constants */\n protected get constants() {\n return this.generation.constants;\n }\n\n /** Provides access to namespace management utilities */\n protected get namespaces() {\n return this.generation.namespaces;\n }\n\n /** Provides access to naming utilities for generating consistent identifiers */\n protected get names() {\n return this.generation.names;\n }\n\n /** Provides access to type information and utilities */\n protected get types() {\n return this.generation.types;\n }\n\n /** Provides access to external type references and dependencies */\n protected get extern() {\n return this.generation.extern;\n }\n\n /** Provides access to the model navigation and inspection utilities */\n protected get model() {\n return this.generation.model;\n }\n\n /** Provides access to the type registry for looking up generated types */\n protected get registry() {\n return this.generation.registry;\n }\n\n /** Provides access to .NET System namespace types and utilities */\n public get System() {\n return this.extern.System;\n }\n\n /** Provides access to NUnit testing framework types */\n public get NUnit() {\n return this.extern.NUnit;\n }\n\n /** Provides access to OneOf discriminated union library types */\n public get OneOf() {\n return this.extern.OneOf;\n }\n\n /** Provides access to Google protocol buffer types */\n public get Google() {\n return this.extern.Google;\n }\n}\n"],"mappings":"ijBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,IAAA,eAAAC,EAAAH,GCqBM,SAAUI,EAAYC,EAAQ,CAChC,MAAM,IAAI,MAAM,qBAAuB,KAAK,UAAUA,CAAC,CAAC,CAC5D,CCJM,IAAOC,EAAP,KAAqB,CACvB,YAAoCC,EAAgB,CAAhBC,EAAA,YAAA,KAAA,IAAAD,CAAmB,CAGvD,IAAc,YAAU,CACpB,OAAO,KAAK,IAAI,UACpB,CAGA,IAAc,QAAM,CAChB,OAAO,KAAK,WAAW,MAC3B,CAGA,IAA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AE,cAAAA,CAAc,CAAC,CACxC,CACL,EACJ,QACID,EAAYF,CAAK,CACzB,CACJ,CAEQ,eAAe,CAAE,QAAAI,CAAQ,EAAsD,CACnF,OAAQA,EAAQ,KAAM,CAClB,IAAK,UACD,OAAO,KAAK,OAAO,KAAK,QAC5B,IAAK,SACD,OAAO,KAAK,OAAO,KAAK,MAChC,CACJ,CAEQ,gBAA2B,CAC/B,OAAO,KAAK,OAAO,KAAK,MAC5B,CAEQ,iBAAiB,CAAE,UAAAC,CAAU,EAA4D,CAC7F,OAAQA,EAAW,CACf,IAAK,UACD,OAAO,KAAK,OAAO,KAAK,QAC5B,IAAK,OACD,OAAO,KAAK,OAAO,KAAK,KAC5B,IAAK,OACD,OAAO,KAAK,OAAO,KAAK,KAC5B,IAAK,UACD,OAAO,KAAK,OAAO,KAAK,MAC5B,IAAK,QACD,OAAO,KAAK,OAAO,KAAK,MAC5B,IAAK,SACD,OAAO,KAAK,OAAO,KAAK,OAC5B,IAAK,UACD,OAAO,KAAK,OAAO,KAAK,QAC5B,IAAK,SACD,OAAO,KAAK,OAAO,KAAK,OAC5B,IAAK,OACD,OAAO,KAAK,OAAO,KAAK,SAC5B,IAAK,YACD,OAAO,KAAK,OAAO,KAAK,SAC5B,IAAK,OACD,OAAO,KAAK,OAAO,KAAK,OAC5B,IAAK,UACD,OAAO,KAAK,OAAO,KAAK,OAC5B,IAAK,cACD,OAAO,KAAK,OAAO,KAAK,OAC5B,QACIH,EAAYG,CAAS,CAC7B,CACJ,CACJ","names":["DynamicTypeMapper_exports","__export","DynamicTypeMapper","__toCommonJS","assertNever","x","WithGeneration","ctx","__publicField","DynamicTypeMapper","WithGeneration","context","__publicField","args","named","value","assertNever","typeReference","literal","primitive"]}
@@ -1,4 +1,6 @@
1
1
  import '@fern-api/csharp-codegen';
2
2
  import '@fern-api/dynamic-ir-sdk';
3
- export { b as DynamicTypeMapper } from '../DynamicSnippetsGeneratorContext-DbMhuHoi.cjs';
3
+ export { b as DynamicTypeMapper } from '../DynamicSnippetsGeneratorContext-DQDI25Nx.cjs';
4
+ import '@fern-api/csharp-codegen/lib/context/model-navigator';
5
+ import '@fern-api/csharp-codegen/lib/context/extern';
4
6
  import '@fern-api/browser-compatible-base-generator';