@fern-api/swift-dynamic-snippets 0.1.1 → 0.26.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.
Files changed (95) hide show
  1. package/dist/index.cjs +39 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +145 -0
  4. package/dist/index.d.ts +145 -0
  5. package/dist/index.js +39 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +11 -12
  8. package/cjs/Config.cjs +0 -12
  9. package/cjs/Config.cjs.map +0 -1
  10. package/cjs/Config.d.cts +0 -4
  11. package/cjs/DynamicSnippetsGenerator.cjs +0 -41
  12. package/cjs/DynamicSnippetsGenerator.cjs.map +0 -1
  13. package/cjs/DynamicSnippetsGenerator.d.cts +0 -18
  14. package/cjs/EndpointSnippetGenerator.cjs +0 -41
  15. package/cjs/EndpointSnippetGenerator.cjs.map +0 -1
  16. package/cjs/EndpointSnippetGenerator.d.cts +0 -54
  17. package/cjs/context/DynamicSnippetsGeneratorContext.cjs +0 -41
  18. package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +0 -1
  19. package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +0 -4
  20. package/cjs/context/DynamicTypeLiteralMapper.cjs +0 -41
  21. package/cjs/context/DynamicTypeLiteralMapper.cjs.map +0 -1
  22. package/cjs/context/DynamicTypeLiteralMapper.d.cts +0 -4
  23. package/cjs/context/DynamicTypeMapper.cjs +0 -41
  24. package/cjs/context/DynamicTypeMapper.cjs.map +0 -1
  25. package/cjs/context/DynamicTypeMapper.d.cts +0 -4
  26. package/cjs/context/FilePropertyMapper.cjs +0 -41
  27. package/cjs/context/FilePropertyMapper.cjs.map +0 -1
  28. package/cjs/context/FilePropertyMapper.d.cts +0 -4
  29. package/cjs/context/index.cjs +0 -41
  30. package/cjs/context/index.cjs.map +0 -1
  31. package/cjs/context/index.d.cts +0 -4
  32. package/cjs/index-DS-GXEiz.d.cts +0 -89
  33. package/cjs/index.cjs +0 -53
  34. package/cjs/index.cjs.map +0 -1
  35. package/cjs/index.d.cts +0 -7
  36. package/cjs/util/pascal-case.cjs +0 -23
  37. package/cjs/util/pascal-case.cjs.map +0 -1
  38. package/cjs/util/pascal-case.d.cts +0 -3
  39. package/esm/Config.d.ts +0 -4
  40. package/esm/Config.js +0 -2
  41. package/esm/Config.js.map +0 -1
  42. package/esm/DynamicSnippetsGenerator.d.ts +0 -18
  43. package/esm/DynamicSnippetsGenerator.js +0 -2
  44. package/esm/DynamicSnippetsGenerator.js.map +0 -1
  45. package/esm/EndpointSnippetGenerator.d.ts +0 -54
  46. package/esm/EndpointSnippetGenerator.js +0 -2
  47. package/esm/EndpointSnippetGenerator.js.map +0 -1
  48. package/esm/chunk-2M2RBZK2.js +0 -2
  49. package/esm/chunk-2M2RBZK2.js.map +0 -1
  50. package/esm/chunk-6DFEQNIA.js +0 -2
  51. package/esm/chunk-6DFEQNIA.js.map +0 -1
  52. package/esm/chunk-7RC2HH3P.js +0 -2
  53. package/esm/chunk-7RC2HH3P.js.map +0 -1
  54. package/esm/chunk-FX6IFKZ7.js +0 -2
  55. package/esm/chunk-FX6IFKZ7.js.map +0 -1
  56. package/esm/chunk-HTU5V5TT.js +0 -2
  57. package/esm/chunk-HTU5V5TT.js.map +0 -1
  58. package/esm/chunk-IHG2VZKL.js +0 -2
  59. package/esm/chunk-IHG2VZKL.js.map +0 -1
  60. package/esm/chunk-JFTYS7SI.js +0 -20
  61. package/esm/chunk-JFTYS7SI.js.map +0 -1
  62. package/esm/chunk-KIHSBETU.js +0 -2
  63. package/esm/chunk-KIHSBETU.js.map +0 -1
  64. package/esm/chunk-PJTPV2D6.js +0 -15
  65. package/esm/chunk-PJTPV2D6.js.map +0 -1
  66. package/esm/chunk-PYMG6Y4R.js +0 -12
  67. package/esm/chunk-PYMG6Y4R.js.map +0 -1
  68. package/esm/chunk-WG3NZOM6.js +0 -2
  69. package/esm/chunk-WG3NZOM6.js.map +0 -1
  70. package/esm/chunk-WXHVUJ6D.js +0 -2
  71. package/esm/chunk-WXHVUJ6D.js.map +0 -1
  72. package/esm/chunk-ZIQ5ITTV.js +0 -2
  73. package/esm/chunk-ZIQ5ITTV.js.map +0 -1
  74. package/esm/context/DynamicSnippetsGeneratorContext.d.ts +0 -4
  75. package/esm/context/DynamicSnippetsGeneratorContext.js +0 -2
  76. package/esm/context/DynamicSnippetsGeneratorContext.js.map +0 -1
  77. package/esm/context/DynamicTypeLiteralMapper.d.ts +0 -4
  78. package/esm/context/DynamicTypeLiteralMapper.js +0 -2
  79. package/esm/context/DynamicTypeLiteralMapper.js.map +0 -1
  80. package/esm/context/DynamicTypeMapper.d.ts +0 -4
  81. package/esm/context/DynamicTypeMapper.js +0 -2
  82. package/esm/context/DynamicTypeMapper.js.map +0 -1
  83. package/esm/context/FilePropertyMapper.d.ts +0 -4
  84. package/esm/context/FilePropertyMapper.js +0 -2
  85. package/esm/context/FilePropertyMapper.js.map +0 -1
  86. package/esm/context/index.d.ts +0 -4
  87. package/esm/context/index.js +0 -2
  88. package/esm/context/index.js.map +0 -1
  89. package/esm/index-DS-GXEiz.d.ts +0 -89
  90. package/esm/index.d.ts +0 -7
  91. package/esm/index.js +0 -14
  92. package/esm/index.js.map +0 -1
  93. package/esm/util/pascal-case.d.ts +0 -3
  94. package/esm/util/pascal-case.js +0 -2
  95. package/esm/util/pascal-case.js.map +0 -1
@@ -0,0 +1,145 @@
1
+ import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec, Options, AbstractAstNode, AbstractDynamicSnippetsGenerator } from '@fern-api/browser-compatible-base-generator';
2
+ import { FernIr } from '@fern-api/dynamic-ir-sdk';
3
+ import { swift, BaseSwiftCustomConfigSchema, NameRegistry, Referencer } from '@fern-api/swift-codegen';
4
+
5
+ interface Config {
6
+ }
7
+
8
+ declare namespace DynamicTypeLiteralMapper {
9
+ interface Args {
10
+ fromSymbol: swift.Symbol;
11
+ typeReference: FernIr.dynamic.TypeReference;
12
+ value: unknown;
13
+ as?: ConvertedAs;
14
+ }
15
+ type ConvertedAs = "mapKey" | "mapValue";
16
+ }
17
+ declare class DynamicTypeLiteralMapper {
18
+ private context;
19
+ constructor({ context }: {
20
+ context: DynamicSnippetsGeneratorContext;
21
+ });
22
+ convert(args: DynamicTypeLiteralMapper.Args): swift.Expression;
23
+ private convertList;
24
+ private convertMap;
25
+ private convertNamed;
26
+ private convertNullable;
27
+ private convertDiscriminatedUnion;
28
+ private convertDiscriminatedUnionProperties;
29
+ private getBaseFields;
30
+ private convertEnum;
31
+ private getEnumValue;
32
+ private convertObject;
33
+ private convertUndiscriminatedUnion;
34
+ private findMatchingUndiscriminatedUnionType;
35
+ private convertUnknown;
36
+ private convertPrimitive;
37
+ private getValueAsNumber;
38
+ private getValueAsBoolean;
39
+ }
40
+
41
+ interface FilePropertyInfo {
42
+ fileFields: swift.FunctionArgument[];
43
+ bodyPropertyFields: swift.FunctionArgument[];
44
+ }
45
+ declare class FilePropertyMapper {
46
+ private context;
47
+ constructor({ context }: {
48
+ context: DynamicSnippetsGeneratorContext;
49
+ });
50
+ getFilePropertyInfo({ fromSymbol, body, value }: {
51
+ fromSymbol: swift.Symbol;
52
+ body: FernIr.dynamic.FileUploadRequestBody;
53
+ value: unknown;
54
+ }): FilePropertyInfo;
55
+ private getSingleFileProperty;
56
+ private getArrayFileProperty;
57
+ private getBodyProperty;
58
+ }
59
+
60
+ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGeneratorContext {
61
+ ir: FernIr.dynamic.DynamicIntermediateRepresentation;
62
+ customConfig: BaseSwiftCustomConfigSchema | undefined;
63
+ dynamicTypeLiteralMapper: DynamicTypeLiteralMapper;
64
+ filePropertyMapper: FilePropertyMapper;
65
+ nameRegistry: NameRegistry;
66
+ constructor({ ir, config, options }: {
67
+ ir: FernIr.dynamic.DynamicIntermediateRepresentation;
68
+ config: FernGeneratorExec.GeneratorConfig;
69
+ options?: Options;
70
+ });
71
+ private registerSourceSymbols;
72
+ getNamedTypeOrThrow(typeId: string): FernIr.dynamic.NamedType;
73
+ getPropertiesOfDiscriminatedUnionVariant(typeId: string): FernIr.dynamic.NamedParameter[];
74
+ getSwiftTypeReferenceFromScope(typeReference: FernIr.dynamic.TypeReference, fromSymbol: swift.Symbol): swift.TypeReference;
75
+ createReferencer(fromSymbol: swift.Symbol): Referencer;
76
+ clone(): DynamicSnippetsGeneratorContext;
77
+ }
78
+
79
+ declare class EndpointSnippetGenerator {
80
+ private context;
81
+ constructor({ context }: {
82
+ context: DynamicSnippetsGeneratorContext;
83
+ });
84
+ generateSnippet({ endpoint, request, options }: {
85
+ endpoint: FernIr.dynamic.Endpoint;
86
+ request: FernIr.dynamic.EndpointSnippetRequest;
87
+ options?: Options;
88
+ }): Promise<string>;
89
+ generateSnippetSync({ endpoint, request, options }: {
90
+ endpoint: FernIr.dynamic.Endpoint;
91
+ request: FernIr.dynamic.EndpointSnippetRequest;
92
+ options?: Options;
93
+ }): string;
94
+ generateSnippetAst({ endpoint, request, options }: {
95
+ endpoint: FernIr.dynamic.Endpoint;
96
+ request: FernIr.dynamic.EndpointSnippetRequest;
97
+ options?: Options;
98
+ }): Promise<AbstractAstNode>;
99
+ private buildCodeBlock;
100
+ private generateImportFoundationStatement;
101
+ private generateImportModuleStatement;
102
+ private generateMainFunctionDeclarationWithEndpointSnippet;
103
+ generateRootClientInitializationStatement({ auth, snippet, additionalArgs }: {
104
+ auth: FernIr.dynamic.Auth | undefined;
105
+ snippet: FernIr.dynamic.EndpointSnippetRequest;
106
+ additionalArgs?: swift.FunctionArgument[];
107
+ }): swift.Statement;
108
+ private getRootClientBaseURLArg;
109
+ private getRootClientAuthArgs;
110
+ private generateEndpointMethodCallStatement;
111
+ generateEndpointMethodCallExpression({ endpoint, snippet, additionalArguments }: {
112
+ endpoint: FernIr.dynamic.Endpoint;
113
+ snippet: FernIr.dynamic.EndpointSnippetRequest;
114
+ additionalArguments?: swift.FunctionArgument[];
115
+ }): swift.Expression;
116
+ private generateMainFunctionInvocationStatement;
117
+ private getEndpointMethodName;
118
+ private getEndpointMethodArguments;
119
+ private getEndpointMethodArgsForInlinedRequest;
120
+ private getEndpointMethodPathParameters;
121
+ private getEndpointMethodQueryParameters;
122
+ private getFilePropertyInfo;
123
+ private getInlinedRequestArg;
124
+ private getInlinedRequestBodyObjectFields;
125
+ private getInlinedRequestBodyPropertyObjectFields;
126
+ private getReferencedRequestBodyPropertyObjectField;
127
+ private getReferencedRequestBodyPropertyTypeLiteral;
128
+ private getBytesBodyRequestArg;
129
+ private getEndpointMethodArgsForBodyRequest;
130
+ private getEndpointMethodBodyRequestArg;
131
+ }
132
+
133
+ declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext, EndpointSnippetGenerator> {
134
+ constructor({ ir, config, options }: {
135
+ ir: FernIr.dynamic.DynamicIntermediateRepresentation;
136
+ config: FernGeneratorExec.GeneratorConfig;
137
+ options?: Options;
138
+ });
139
+ generate(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): Promise<FernIr.dynamic.EndpointSnippetResponse>;
140
+ generateSync(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): FernIr.dynamic.EndpointSnippetResponse;
141
+ generateSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): Promise<AbstractAstNode>;
142
+ protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
143
+ }
144
+
145
+ export { type Config, DynamicSnippetsGenerator, EndpointSnippetGenerator };
@@ -0,0 +1,145 @@
1
+ import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec, Options, AbstractAstNode, AbstractDynamicSnippetsGenerator } from '@fern-api/browser-compatible-base-generator';
2
+ import { FernIr } from '@fern-api/dynamic-ir-sdk';
3
+ import { swift, BaseSwiftCustomConfigSchema, NameRegistry, Referencer } from '@fern-api/swift-codegen';
4
+
5
+ interface Config {
6
+ }
7
+
8
+ declare namespace DynamicTypeLiteralMapper {
9
+ interface Args {
10
+ fromSymbol: swift.Symbol;
11
+ typeReference: FernIr.dynamic.TypeReference;
12
+ value: unknown;
13
+ as?: ConvertedAs;
14
+ }
15
+ type ConvertedAs = "mapKey" | "mapValue";
16
+ }
17
+ declare class DynamicTypeLiteralMapper {
18
+ private context;
19
+ constructor({ context }: {
20
+ context: DynamicSnippetsGeneratorContext;
21
+ });
22
+ convert(args: DynamicTypeLiteralMapper.Args): swift.Expression;
23
+ private convertList;
24
+ private convertMap;
25
+ private convertNamed;
26
+ private convertNullable;
27
+ private convertDiscriminatedUnion;
28
+ private convertDiscriminatedUnionProperties;
29
+ private getBaseFields;
30
+ private convertEnum;
31
+ private getEnumValue;
32
+ private convertObject;
33
+ private convertUndiscriminatedUnion;
34
+ private findMatchingUndiscriminatedUnionType;
35
+ private convertUnknown;
36
+ private convertPrimitive;
37
+ private getValueAsNumber;
38
+ private getValueAsBoolean;
39
+ }
40
+
41
+ interface FilePropertyInfo {
42
+ fileFields: swift.FunctionArgument[];
43
+ bodyPropertyFields: swift.FunctionArgument[];
44
+ }
45
+ declare class FilePropertyMapper {
46
+ private context;
47
+ constructor({ context }: {
48
+ context: DynamicSnippetsGeneratorContext;
49
+ });
50
+ getFilePropertyInfo({ fromSymbol, body, value }: {
51
+ fromSymbol: swift.Symbol;
52
+ body: FernIr.dynamic.FileUploadRequestBody;
53
+ value: unknown;
54
+ }): FilePropertyInfo;
55
+ private getSingleFileProperty;
56
+ private getArrayFileProperty;
57
+ private getBodyProperty;
58
+ }
59
+
60
+ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGeneratorContext {
61
+ ir: FernIr.dynamic.DynamicIntermediateRepresentation;
62
+ customConfig: BaseSwiftCustomConfigSchema | undefined;
63
+ dynamicTypeLiteralMapper: DynamicTypeLiteralMapper;
64
+ filePropertyMapper: FilePropertyMapper;
65
+ nameRegistry: NameRegistry;
66
+ constructor({ ir, config, options }: {
67
+ ir: FernIr.dynamic.DynamicIntermediateRepresentation;
68
+ config: FernGeneratorExec.GeneratorConfig;
69
+ options?: Options;
70
+ });
71
+ private registerSourceSymbols;
72
+ getNamedTypeOrThrow(typeId: string): FernIr.dynamic.NamedType;
73
+ getPropertiesOfDiscriminatedUnionVariant(typeId: string): FernIr.dynamic.NamedParameter[];
74
+ getSwiftTypeReferenceFromScope(typeReference: FernIr.dynamic.TypeReference, fromSymbol: swift.Symbol): swift.TypeReference;
75
+ createReferencer(fromSymbol: swift.Symbol): Referencer;
76
+ clone(): DynamicSnippetsGeneratorContext;
77
+ }
78
+
79
+ declare class EndpointSnippetGenerator {
80
+ private context;
81
+ constructor({ context }: {
82
+ context: DynamicSnippetsGeneratorContext;
83
+ });
84
+ generateSnippet({ endpoint, request, options }: {
85
+ endpoint: FernIr.dynamic.Endpoint;
86
+ request: FernIr.dynamic.EndpointSnippetRequest;
87
+ options?: Options;
88
+ }): Promise<string>;
89
+ generateSnippetSync({ endpoint, request, options }: {
90
+ endpoint: FernIr.dynamic.Endpoint;
91
+ request: FernIr.dynamic.EndpointSnippetRequest;
92
+ options?: Options;
93
+ }): string;
94
+ generateSnippetAst({ endpoint, request, options }: {
95
+ endpoint: FernIr.dynamic.Endpoint;
96
+ request: FernIr.dynamic.EndpointSnippetRequest;
97
+ options?: Options;
98
+ }): Promise<AbstractAstNode>;
99
+ private buildCodeBlock;
100
+ private generateImportFoundationStatement;
101
+ private generateImportModuleStatement;
102
+ private generateMainFunctionDeclarationWithEndpointSnippet;
103
+ generateRootClientInitializationStatement({ auth, snippet, additionalArgs }: {
104
+ auth: FernIr.dynamic.Auth | undefined;
105
+ snippet: FernIr.dynamic.EndpointSnippetRequest;
106
+ additionalArgs?: swift.FunctionArgument[];
107
+ }): swift.Statement;
108
+ private getRootClientBaseURLArg;
109
+ private getRootClientAuthArgs;
110
+ private generateEndpointMethodCallStatement;
111
+ generateEndpointMethodCallExpression({ endpoint, snippet, additionalArguments }: {
112
+ endpoint: FernIr.dynamic.Endpoint;
113
+ snippet: FernIr.dynamic.EndpointSnippetRequest;
114
+ additionalArguments?: swift.FunctionArgument[];
115
+ }): swift.Expression;
116
+ private generateMainFunctionInvocationStatement;
117
+ private getEndpointMethodName;
118
+ private getEndpointMethodArguments;
119
+ private getEndpointMethodArgsForInlinedRequest;
120
+ private getEndpointMethodPathParameters;
121
+ private getEndpointMethodQueryParameters;
122
+ private getFilePropertyInfo;
123
+ private getInlinedRequestArg;
124
+ private getInlinedRequestBodyObjectFields;
125
+ private getInlinedRequestBodyPropertyObjectFields;
126
+ private getReferencedRequestBodyPropertyObjectField;
127
+ private getReferencedRequestBodyPropertyTypeLiteral;
128
+ private getBytesBodyRequestArg;
129
+ private getEndpointMethodArgsForBodyRequest;
130
+ private getEndpointMethodBodyRequestArg;
131
+ }
132
+
133
+ declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext, EndpointSnippetGenerator> {
134
+ constructor({ ir, config, options }: {
135
+ ir: FernIr.dynamic.DynamicIntermediateRepresentation;
136
+ config: FernGeneratorExec.GeneratorConfig;
137
+ options?: Options;
138
+ });
139
+ generate(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): Promise<FernIr.dynamic.EndpointSnippetResponse>;
140
+ generateSync(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): FernIr.dynamic.EndpointSnippetResponse;
141
+ generateSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): Promise<AbstractAstNode>;
142
+ protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
143
+ }
144
+
145
+ export { type Config, DynamicSnippetsGenerator, EndpointSnippetGenerator };