@fern-api/java-dynamic-snippets 0.0.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/cjs/Config.cjs +11 -0
- package/cjs/Config.d.cts +6 -0
- package/cjs/DynamicSnippetsGenerator.cjs +36 -0
- package/cjs/DynamicSnippetsGenerator.d.cts +19 -0
- package/cjs/DynamicSnippetsGeneratorContext-CjKFdkU7.d.cts +131 -0
- package/cjs/EndpointSnippetGenerator.cjs +25 -0
- package/cjs/EndpointSnippetGenerator.d.cts +54 -0
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +36 -0
- package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +4 -0
- package/cjs/context/DynamicTypeLiteralMapper.cjs +25 -0
- package/cjs/context/DynamicTypeLiteralMapper.d.cts +4 -0
- package/cjs/context/DynamicTypeMapper.cjs +25 -0
- package/cjs/context/DynamicTypeMapper.d.cts +4 -0
- package/cjs/context/FilePropertyMapper.cjs +25 -0
- package/cjs/context/FilePropertyMapper.d.cts +4 -0
- package/cjs/index.cjs +48 -0
- package/cjs/index.d.cts +7 -0
- package/esm/Config.d.ts +6 -0
- package/esm/Config.js +1 -0
- package/esm/DynamicSnippetsGenerator.d.ts +19 -0
- package/esm/DynamicSnippetsGenerator.js +1 -0
- package/esm/DynamicSnippetsGeneratorContext-CjKFdkU7.d.ts +131 -0
- package/esm/EndpointSnippetGenerator.d.ts +54 -0
- package/esm/EndpointSnippetGenerator.js +1 -0
- package/esm/chunk-2AZXIWKY.js +11 -0
- package/esm/chunk-3DDUCXS2.js +1 -0
- package/esm/chunk-452HWDL4.js +1 -0
- package/esm/chunk-7CY27UU7.js +1 -0
- package/esm/chunk-AASPH6YC.js +15 -0
- package/esm/chunk-FOUIYX4V.js +1 -0
- package/esm/chunk-GHM3YOPV.js +14 -0
- package/esm/chunk-HN67B7VQ.js +1 -0
- package/esm/chunk-JSEUWNSK.js +1 -0
- package/esm/chunk-WFKWXM7L.js +1 -0
- package/esm/context/DynamicSnippetsGeneratorContext.d.ts +4 -0
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -0
- package/esm/context/DynamicTypeLiteralMapper.d.ts +4 -0
- package/esm/context/DynamicTypeLiteralMapper.js +1 -0
- package/esm/context/DynamicTypeMapper.d.ts +4 -0
- package/esm/context/DynamicTypeMapper.js +1 -0
- package/esm/context/FilePropertyMapper.d.ts +4 -0
- package/esm/context/FilePropertyMapper.js +1 -0
- package/esm/index.d.ts +7 -0
- package/esm/index.js +13 -0
- package/package.json +27 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec, Options } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
+
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
3
|
+
import { java, BaseJavaCustomConfigSchema } from '@fern-api/java-ast';
|
|
4
|
+
|
|
5
|
+
declare namespace DynamicTypeLiteralMapper {
|
|
6
|
+
interface Args {
|
|
7
|
+
typeReference: FernIr.dynamic.TypeReference;
|
|
8
|
+
value: unknown;
|
|
9
|
+
as?: ConvertedAs;
|
|
10
|
+
}
|
|
11
|
+
type ConvertedAs = "mapKey" | "mapValue";
|
|
12
|
+
}
|
|
13
|
+
declare class DynamicTypeLiteralMapper {
|
|
14
|
+
private context;
|
|
15
|
+
constructor({ context }: {
|
|
16
|
+
context: DynamicSnippetsGeneratorContext;
|
|
17
|
+
});
|
|
18
|
+
convert(args: DynamicTypeLiteralMapper.Args): java.TypeLiteral;
|
|
19
|
+
private convertList;
|
|
20
|
+
private convertLiteral;
|
|
21
|
+
private convertSet;
|
|
22
|
+
private convertMap;
|
|
23
|
+
private convertNamed;
|
|
24
|
+
private convertDiscriminatedUnion;
|
|
25
|
+
private convertObject;
|
|
26
|
+
private convertEnum;
|
|
27
|
+
private getEnumValueName;
|
|
28
|
+
private convertUndiscriminatedUnion;
|
|
29
|
+
private findMatchingUndiscriminatedUnionType;
|
|
30
|
+
private getUndiscriminatedUnionFieldName;
|
|
31
|
+
private getUndiscriminatedUnionFieldNameForList;
|
|
32
|
+
private getUndiscriminatedUnionFieldNameForMap;
|
|
33
|
+
private getUndiscriminatedUnionFieldNameForOptional;
|
|
34
|
+
private getUndiscriminatedUnionFieldNameForNullable;
|
|
35
|
+
private getUndiscriminatedUnionFieldNameForSet;
|
|
36
|
+
private getUndiscriminatedUnionFieldNameForLiteral;
|
|
37
|
+
private getUndiscriminatedUnionFieldNameForPrimitive;
|
|
38
|
+
private convertUnknown;
|
|
39
|
+
private convertPrimitive;
|
|
40
|
+
private getValueAsNumber;
|
|
41
|
+
private getValueAsBoolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare namespace DynamicTypeMapper {
|
|
45
|
+
interface Args {
|
|
46
|
+
typeReference: FernIr.dynamic.TypeReference;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
declare class DynamicTypeMapper {
|
|
50
|
+
private context;
|
|
51
|
+
constructor({ context }: {
|
|
52
|
+
context: DynamicSnippetsGeneratorContext;
|
|
53
|
+
});
|
|
54
|
+
convert(args: DynamicTypeMapper.Args): java.Type;
|
|
55
|
+
private convertNamed;
|
|
56
|
+
private convertLiteral;
|
|
57
|
+
private convertUnknown;
|
|
58
|
+
private convertPrimitive;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface FilePropertyInfo {
|
|
62
|
+
fileFields: java.BuilderParameter[];
|
|
63
|
+
bodyPropertyFields: java.BuilderParameter[];
|
|
64
|
+
}
|
|
65
|
+
declare class FilePropertyMapper {
|
|
66
|
+
private context;
|
|
67
|
+
constructor({ context }: {
|
|
68
|
+
context: DynamicSnippetsGeneratorContext;
|
|
69
|
+
});
|
|
70
|
+
getFilePropertyInfo({ body, value }: {
|
|
71
|
+
body: FernIr.dynamic.FileUploadRequestBody;
|
|
72
|
+
value: unknown;
|
|
73
|
+
}): FilePropertyInfo;
|
|
74
|
+
private getSingleFileProperty;
|
|
75
|
+
private getArrayFileProperty;
|
|
76
|
+
private getBodyProperty;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGeneratorContext {
|
|
80
|
+
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
81
|
+
customConfig: BaseJavaCustomConfigSchema | undefined;
|
|
82
|
+
dynamicTypeMapper: DynamicTypeMapper;
|
|
83
|
+
dynamicTypeLiteralMapper: DynamicTypeLiteralMapper;
|
|
84
|
+
filePropertyMapper: FilePropertyMapper;
|
|
85
|
+
constructor({ ir, config, options }: {
|
|
86
|
+
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
87
|
+
config: FernGeneratorExec.GeneratorConfig;
|
|
88
|
+
options?: Options;
|
|
89
|
+
});
|
|
90
|
+
clone(): DynamicSnippetsGeneratorContext;
|
|
91
|
+
getClassName(name: FernIr.Name): string;
|
|
92
|
+
getEnumName(name: FernIr.Name): string;
|
|
93
|
+
getPropertyName(name: FernIr.Name): string;
|
|
94
|
+
getMethodName(name: FernIr.Name): string;
|
|
95
|
+
getRootClientClassReference(): java.ClassReference;
|
|
96
|
+
getRootClientClassName(): string;
|
|
97
|
+
getEnvironmentClassName(): string;
|
|
98
|
+
getEnvironmentTypeReferenceFromID(environmentID: string): java.ClassReference | undefined;
|
|
99
|
+
getEnvironmentClassReference(): java.ClassReference;
|
|
100
|
+
private getEnvironmentClassReferenceForEnumName;
|
|
101
|
+
getJavaClassReferenceFromDeclaration({ declaration }: {
|
|
102
|
+
declaration: FernIr.dynamic.Declaration;
|
|
103
|
+
}): java.ClassReference;
|
|
104
|
+
getNullableClassReference(): java.ClassReference;
|
|
105
|
+
getNullableOfNull(): java.TypeLiteral;
|
|
106
|
+
getFileStreamFromString(content: string): java.TypeLiteral;
|
|
107
|
+
getFileStreamClassReference(): java.ClassReference;
|
|
108
|
+
getByteArrayInputStreamClassReference(): java.ClassReference;
|
|
109
|
+
getStandardCharsetsClassReference(): java.ClassReference;
|
|
110
|
+
isPrimitive(typeReference: FernIr.dynamic.TypeReference): boolean;
|
|
111
|
+
getRootPackageName(): string;
|
|
112
|
+
getCorePackageName(): string;
|
|
113
|
+
getTypesPackageName(fernFilepath: FernIr.FernFilepath): string;
|
|
114
|
+
getRequestsPackageName(fernFilepath: FernIr.FernFilepath): string;
|
|
115
|
+
protected getResourcesPackage(fernFilepath: FernIr.FernFilepath, suffix?: string): string;
|
|
116
|
+
getPackageName(fernFilepath: FernIr.FernFilepath, suffix?: string): string;
|
|
117
|
+
getPackageLayout(): string;
|
|
118
|
+
private getPackageNameSegments;
|
|
119
|
+
private getPackageNameSegment;
|
|
120
|
+
private getPackagePrefixTokens;
|
|
121
|
+
private getBaseNamePrefix;
|
|
122
|
+
private getApiName;
|
|
123
|
+
private startsWithNumber;
|
|
124
|
+
private splitOnNonAlphaNumericChar;
|
|
125
|
+
private convertKebabCaseToUpperCamelCase;
|
|
126
|
+
private joinPackageTokens;
|
|
127
|
+
private getName;
|
|
128
|
+
private isReservedName;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { DynamicSnippetsGeneratorContext as D, type FilePropertyInfo as F, DynamicTypeLiteralMapper as a, DynamicTypeMapper as b, FilePropertyMapper as c };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AbstractFormatter, Options } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
+
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
3
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-CjKFdkU7.js';
|
|
4
|
+
import '@fern-api/java-ast';
|
|
5
|
+
|
|
6
|
+
declare class EndpointSnippetGenerator {
|
|
7
|
+
private context;
|
|
8
|
+
private formatter;
|
|
9
|
+
constructor({ context, formatter }: {
|
|
10
|
+
context: DynamicSnippetsGeneratorContext;
|
|
11
|
+
formatter?: AbstractFormatter;
|
|
12
|
+
});
|
|
13
|
+
generateSnippet({ endpoint, request, options }: {
|
|
14
|
+
endpoint: FernIr.dynamic.Endpoint;
|
|
15
|
+
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
16
|
+
options: Options;
|
|
17
|
+
}): Promise<string>;
|
|
18
|
+
generateSnippetSync({ endpoint, request, options }: {
|
|
19
|
+
endpoint: FernIr.dynamic.Endpoint;
|
|
20
|
+
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
21
|
+
options: Options;
|
|
22
|
+
}): string;
|
|
23
|
+
private buildCodeBlock;
|
|
24
|
+
private constructClient;
|
|
25
|
+
private buildFullCodeBlock;
|
|
26
|
+
private getRootClientBuilderArgs;
|
|
27
|
+
private getRootClientBaseUrlArg;
|
|
28
|
+
private getRootClientAuthArgs;
|
|
29
|
+
private getRootClientBasicAuthArgs;
|
|
30
|
+
private getRootClientBearerAuthArgs;
|
|
31
|
+
private getRootClientHeaderAuthArgs;
|
|
32
|
+
private getRootClientOAuthArgs;
|
|
33
|
+
private getRootClientHeaderArgs;
|
|
34
|
+
private getRootClientHeaderArg;
|
|
35
|
+
private callMethod;
|
|
36
|
+
private getMethodArgs;
|
|
37
|
+
private getMethodArgsForBodyRequest;
|
|
38
|
+
private getBodyRequestArg;
|
|
39
|
+
private getBytesBodyRequestArg;
|
|
40
|
+
private getMethodArgsForInlinedRequest;
|
|
41
|
+
private getFilePropertyInfo;
|
|
42
|
+
private getInlinedRequestArg;
|
|
43
|
+
private getInlinedRequestBodyBuilderParameters;
|
|
44
|
+
private getFileUploadRequestBodyBuilderParameters;
|
|
45
|
+
private getReferencedRequestBodyPropertyBuilderParameter;
|
|
46
|
+
private getReferencedRequestBodyPropertyTypeLiteral;
|
|
47
|
+
private getInlinedRequestBodyPropertyBuilderParameters;
|
|
48
|
+
private getPathParameters;
|
|
49
|
+
private getMethod;
|
|
50
|
+
private getStyle;
|
|
51
|
+
private getConfig;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { EndpointSnippetGenerator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-FOUIYX4V.js";import"./chunk-WFKWXM7L.js";import"./chunk-AASPH6YC.js";import"./chunk-2AZXIWKY.js";export{a as EndpointSnippetGenerator};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var Tr=Object.create;var S=Object.defineProperty,Rr=Object.defineProperties,_r=Object.getOwnPropertyDescriptor,Ir=Object.getOwnPropertyDescriptors,vr=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols,Ur=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var W=(n,r,i)=>r in n?S(n,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[r]=i,Yi=(n,r)=>{for(var i in r||(r={}))H.call(r,i)&&W(n,i,r[i]);if(P)for(var i of P(r))q.call(r,i)&&W(n,i,r[i]);return n},Si=(n,r)=>Rr(n,Ir(r));var Pi=n=>typeof n=="symbol"?n:n+"",Mi=(n,r)=>{var i={};for(var e in n)H.call(n,e)&&r.indexOf(e)<0&&(i[e]=n[e]);if(n!=null&&P)for(var e of P(n))r.indexOf(e)<0&&q.call(n,e)&&(i[e]=n[e]);return i};var V=(n,r)=>()=>(n&&(r=n(n=0)),r);var Di=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),Ci=(n,r)=>{for(var i in r)S(n,i,{get:r[i],enumerable:!0})},Z=(n,r,i,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of vr(r))!H.call(n,t)&&t!==i&&S(n,t,{get:()=>r[t],enumerable:!(e=_r(r,t))||e.enumerable});return n};var ki=(n,r,i)=>(i=n!=null?Tr(Ur(n)):{},Z(r||!n||!n.__esModule?S(i,"default",{value:n,enumerable:!0}):i,n)),Ni=n=>Z(S({},"__esModule",{value:!0}),n);var Li=(n,r,i)=>W(n,typeof r!="symbol"?r+"":r,i);function $(){throw new Error("setTimeout has not been defined")}function b(){throw new Error("clearTimeout has not been defined")}function j(n){if(R===setTimeout)return setTimeout(n,0);if((R===$||!R)&&setTimeout)return R=setTimeout,setTimeout(n,0);try{return R(n,0)}catch(r){try{return R.call(null,n,0)}catch(i){return R.call(this,n,0)}}}function Br(n){if(_===clearTimeout)return clearTimeout(n);if((_===b||!_)&&clearTimeout)return _=clearTimeout,clearTimeout(n);try{return _(n)}catch(r){try{return _.call(null,n)}catch(i){return _.call(this,n)}}}function dr(){!Y||!I||(Y=!1,I.length?y=I.concat(y):M=-1,y.length&&rr())}function rr(){if(!Y){var n=j(dr);Y=!0;for(var r=y.length;r;){for(I=y,y=[];++M<r;)I&&I[M].run();M=-1,r=y.length}I=null,Y=!1,Br(n)}}function Yr(n){var r=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)r[i-1]=arguments[i];y.push(new ir(n,r)),y.length===1&&!Y&&j(rr)}function ir(n,r){this.fun=n,this.array=r}function v(){}function Qr(n){throw new Error("process.binding is not supported")}function Xr(){return"/"}function qr(n){throw new Error("process.chdir is not supported")}function Zr(){return 0}function $r(n){var r=Kr.call(d)*.001,i=Math.floor(r),e=Math.floor(r%1*1e9);return n&&(i=i-n[0],e=e-n[1],e<0&&(i--,e+=1e9)),[i,e]}function jr(){var n=new Date,r=n-br;return r/1e3}var R,_,y,Y,I,M,Sr,Pr,Mr,Dr,Cr,kr,Nr,Lr,Fr,Wr,Hr,Vr,zr,Gr,Jr,Or,d,Kr,br,nr,K,z=V(()=>{"use strict";R=$,_=b;typeof globalThis.setTimeout=="function"&&(R=setTimeout);typeof globalThis.clearTimeout=="function"&&(_=clearTimeout);y=[],Y=!1,M=-1;ir.prototype.run=function(){this.fun.apply(null,this.array)};Sr="browser",Pr="browser",Mr=!0,Dr={},Cr=[],kr="",Nr={},Lr={},Fr={};Wr=v,Hr=v,Vr=v,zr=v,Gr=v,Jr=v,Or=v;d=globalThis.performance||{},Kr=d.now||d.mozNow||d.msNow||d.oNow||d.webkitNow||function(){return new Date().getTime()};br=new Date;nr={nextTick:Yr,title:Sr,browser:Mr,env:Dr,argv:Cr,version:kr,versions:Nr,on:Wr,addListener:Hr,once:Vr,off:zr,removeListener:Gr,removeAllListeners:Jr,emit:Or,binding:Qr,cwd:Xr,chdir:qr,umask:Zr,hrtime:$r,platform:Pr,release:Lr,config:Fr,uptime:jr},K={};Object.keys(K).forEach(n=>{let r=n.split("."),i=nr;for(let e=0;e<r.length;e++){let t=r[e];e===r.length-1?i[t]=K[n]:i=i[t]||(i[t]={})}})});function ur(){O=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,i=n.length;r<i;++r)A[r]=n[r],E[n.charCodeAt(r)]=r;E[45]=62,E[95]=63}function ii(n){O||ur();var r,i,e,t,f,u,h=n.length;if(h%4>0)throw new Error("Invalid string. Length must be a multiple of 4");f=n[h-2]==="="?2:n[h-1]==="="?1:0,u=new ri(h*3/4-f),e=f>0?h-4:h;var a=0;for(r=0,i=0;r<e;r+=4,i+=3)t=E[n.charCodeAt(r)]<<18|E[n.charCodeAt(r+1)]<<12|E[n.charCodeAt(r+2)]<<6|E[n.charCodeAt(r+3)],u[a++]=t>>16&255,u[a++]=t>>8&255,u[a++]=t&255;return f===2?(t=E[n.charCodeAt(r)]<<2|E[n.charCodeAt(r+1)]>>4,u[a++]=t&255):f===1&&(t=E[n.charCodeAt(r)]<<10|E[n.charCodeAt(r+1)]<<4|E[n.charCodeAt(r+2)]>>2,u[a++]=t>>8&255,u[a++]=t&255),u}function ni(n){return A[n>>18&63]+A[n>>12&63]+A[n>>6&63]+A[n&63]}function ei(n,r,i){for(var e,t=[],f=r;f<i;f+=3)e=(n[f]<<16)+(n[f+1]<<8)+n[f+2],t.push(ni(e));return t.join("")}function er(n){O||ur();for(var r,i=n.length,e=i%3,t="",f=[],u=16383,h=0,a=i-e;h<a;h+=u)f.push(ei(n,h,h+u>a?a:h+u));return e===1?(r=n[i-1],t+=A[r>>2],t+=A[r<<4&63],t+="=="):e===2&&(r=(n[i-2]<<8)+n[i-1],t+=A[r>>10],t+=A[r>>4&63],t+=A[r<<2&63],t+="="),f.push(t),f.join("")}function D(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function T(n,r){if(D()<r)throw new RangeError("Invalid typed array length");return o.TYPED_ARRAY_SUPPORT?(n=new Uint8Array(r),n.__proto__=o.prototype):(n===null&&(n=new o(r)),n.length=r),n}function o(n,r,i){if(!o.TYPED_ARRAY_SUPPORT&&!(this instanceof o))return new o(n,r,i);if(typeof n=="number"){if(typeof r=="string")throw new Error("If encoding is specified then the first argument must be a string");return Q(this,n)}return or(this,n,r,i)}function or(n,r,i,e){if(typeof r=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&r instanceof ArrayBuffer?ui(n,r,i,e):typeof r=="string"?fi(n,r,i):oi(n,r)}function hr(n){if(typeof n!="number")throw new TypeError('"size" argument must be a number');if(n<0)throw new RangeError('"size" argument must not be negative')}function ti(n,r,i,e){return hr(r),r<=0?T(n,r):i!==void 0?typeof e=="string"?T(n,r).fill(i,e):T(n,r).fill(i):T(n,r)}function Q(n,r){if(hr(r),n=T(n,r<0?0:X(r)|0),!o.TYPED_ARRAY_SUPPORT)for(var i=0;i<r;++i)n[i]=0;return n}function fi(n,r,i){if((typeof i!="string"||i==="")&&(i="utf8"),!o.isEncoding(i))throw new TypeError('"encoding" must be a valid string encoding');var e=ar(r,i)|0;n=T(n,e);var t=n.write(r,i);return t!==e&&(n=n.slice(0,t)),n}function G(n,r){var i=r.length<0?0:X(r.length)|0;n=T(n,i);for(var e=0;e<i;e+=1)n[e]=r[e]&255;return n}function ui(n,r,i,e){if(r.byteLength,i<0||r.byteLength<i)throw new RangeError("'offset' is out of bounds");if(r.byteLength<i+(e||0))throw new RangeError("'length' is out of bounds");return i===void 0&&e===void 0?r=new Uint8Array(r):e===void 0?r=new Uint8Array(r,i):r=new Uint8Array(r,i,e),o.TYPED_ARRAY_SUPPORT?(n=r,n.__proto__=o.prototype):n=G(n,r),n}function oi(n,r){if(g(r)){var i=X(r.length)|0;return n=T(n,i),n.length===0||r.copy(n,0,0,i),n}if(r){if(typeof ArrayBuffer!="undefined"&&r.buffer instanceof ArrayBuffer||"length"in r)return typeof r.length!="number"||Ui(r.length)?T(n,0):G(n,r);if(r.type==="Buffer"&&Array.isArray(r.data))return G(n,r.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function X(n){if(n>=D())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+D().toString(16)+" bytes");return n|0}function g(n){return!!(n!=null&&n._isBuffer)}function ar(n,r){if(g(n))return n.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(n)||n instanceof ArrayBuffer))return n.byteLength;typeof n!="string"&&(n=""+n);var i=n.length;if(i===0)return 0;for(var e=!1;;)switch(r){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return C(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return Er(n).length;default:if(e)return C(n).length;r=(""+r).toLowerCase(),e=!0}}function hi(n,r,i){var e=!1;if((r===void 0||r<0)&&(r=0),r>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,r>>>=0,i<=r))return"";for(n||(n="utf8");;)switch(n){case"hex":return Ai(this,r,i);case"utf8":case"utf-8":return pr(this,r,i);case"ascii":return Ei(this,r,i);case"latin1":case"binary":return mi(this,r,i);case"base64":return wi(this,r,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return gi(this,r,i);default:if(e)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),e=!0}}function U(n,r,i){var e=n[r];n[r]=n[i],n[i]=e}function cr(n,r,i,e,t){if(n.length===0)return-1;if(typeof i=="string"?(e=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=t?0:n.length-1),i<0&&(i=n.length+i),i>=n.length){if(t)return-1;i=n.length-1}else if(i<0)if(t)i=0;else return-1;if(typeof r=="string"&&(r=o.from(r,e)),g(r))return r.length===0?-1:tr(n,r,i,e,t);if(typeof r=="number")return r=r&255,o.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?t?Uint8Array.prototype.indexOf.call(n,r,i):Uint8Array.prototype.lastIndexOf.call(n,r,i):tr(n,[r],i,e,t);throw new TypeError("val must be string, number or Buffer")}function tr(n,r,i,e,t){var f=1,u=n.length,h=r.length;if(e!==void 0&&(e=String(e).toLowerCase(),e==="ucs2"||e==="ucs-2"||e==="utf16le"||e==="utf-16le")){if(n.length<2||r.length<2)return-1;f=2,u/=2,h/=2,i/=2}function a(x,B){return f===1?x[B]:x.readUInt16BE(B*f)}var l;if(t){var p=-1;for(l=i;l<u;l++)if(a(n,l)===a(r,p===-1?0:l-p)){if(p===-1&&(p=l),l-p+1===h)return p*f}else p!==-1&&(l-=l-p),p=-1}else for(i+h>u&&(i=u-h),l=i;l>=0;l--){for(var c=!0,m=0;m<h;m++)if(a(n,l+m)!==a(r,m)){c=!1;break}if(c)return l}return-1}function ai(n,r,i,e){i=Number(i)||0;var t=n.length-i;e?(e=Number(e),e>t&&(e=t)):e=t;var f=r.length;if(f%2!==0)throw new TypeError("Invalid hex string");e>f/2&&(e=f/2);for(var u=0;u<e;++u){var h=parseInt(r.substr(u*2,2),16);if(isNaN(h))return u;n[i+u]=h}return u}function ci(n,r,i,e){return L(C(r,n.length-i),n,i,e)}function lr(n,r,i,e){return L(Ii(r),n,i,e)}function li(n,r,i,e){return lr(n,r,i,e)}function pi(n,r,i,e){return L(Er(r),n,i,e)}function si(n,r,i,e){return L(vi(r,n.length-i),n,i,e)}function wi(n,r,i){return r===0&&i===n.length?er(n):er(n.slice(r,i))}function pr(n,r,i){i=Math.min(n.length,i);for(var e=[],t=r;t<i;){var f=n[t],u=null,h=f>239?4:f>223?3:f>191?2:1;if(t+h<=i){var a,l,p,c;switch(h){case 1:f<128&&(u=f);break;case 2:a=n[t+1],(a&192)===128&&(c=(f&31)<<6|a&63,c>127&&(u=c));break;case 3:a=n[t+1],l=n[t+2],(a&192)===128&&(l&192)===128&&(c=(f&15)<<12|(a&63)<<6|l&63,c>2047&&(c<55296||c>57343)&&(u=c));break;case 4:a=n[t+1],l=n[t+2],p=n[t+3],(a&192)===128&&(l&192)===128&&(p&192)===128&&(c=(f&15)<<18|(a&63)<<12|(l&63)<<6|p&63,c>65535&&c<1114112&&(u=c))}}u===null?(u=65533,h=1):u>65535&&(u-=65536,e.push(u>>>10&1023|55296),u=56320|u&1023),e.push(u),t+=h}return xi(e)}function xi(n){var r=n.length;if(r<=fr)return String.fromCharCode.apply(String,n);for(var i="",e=0;e<r;)i+=String.fromCharCode.apply(String,n.slice(e,e+=fr));return i}function Ei(n,r,i){var e="";i=Math.min(n.length,i);for(var t=r;t<i;++t)e+=String.fromCharCode(n[t]&127);return e}function mi(n,r,i){var e="";i=Math.min(n.length,i);for(var t=r;t<i;++t)e+=String.fromCharCode(n[t]);return e}function Ai(n,r,i){var e=n.length;(!r||r<0)&&(r=0),(!i||i<0||i>e)&&(i=e);for(var t="",f=r;f<i;++f)t+=_i(n[f]);return t}function gi(n,r,i){for(var e=n.slice(r,i),t="",f=0;f<e.length;f+=2)t+=String.fromCharCode(e[f]+e[f+1]*256);return t}function s(n,r,i){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+r>i)throw new RangeError("Trying to access beyond buffer length")}function w(n,r,i,e,t,f){if(!g(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>t||r<f)throw new RangeError('"value" argument is out of bounds');if(i+e>n.length)throw new RangeError("Index out of range")}function k(n,r,i,e){r<0&&(r=65535+r+1);for(var t=0,f=Math.min(n.length-i,2);t<f;++t)n[i+t]=(r&255<<8*(e?t:1-t))>>>(e?t:1-t)*8}function N(n,r,i,e){r<0&&(r=4294967295+r+1);for(var t=0,f=Math.min(n.length-i,4);t<f;++t)n[i+t]=r>>>(e?t:3-t)*8&255}function sr(n,r,i,e,t,f){if(i+e>n.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function wr(n,r,i,e,t){return t||sr(n,r,i,4,34028234663852886e22,-34028234663852886e22),Ar(n,r,i,e,23,4),i+4}function xr(n,r,i,e,t){return t||sr(n,r,i,8,17976931348623157e292,-17976931348623157e292),Ar(n,r,i,e,52,8),i+8}function Ti(n){if(n=Ri(n).replace(yi,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function Ri(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function _i(n){return n<16?"0"+n.toString(16):n.toString(16)}function C(n,r){r=r||1/0;for(var i,e=n.length,t=null,f=[],u=0;u<e;++u){if(i=n.charCodeAt(u),i>55295&&i<57344){if(!t){if(i>56319){(r-=3)>-1&&f.push(239,191,189);continue}else if(u+1===e){(r-=3)>-1&&f.push(239,191,189);continue}t=i;continue}if(i<56320){(r-=3)>-1&&f.push(239,191,189),t=i;continue}i=(t-55296<<10|i-56320)+65536}else t&&(r-=3)>-1&&f.push(239,191,189);if(t=null,i<128){if((r-=1)<0)break;f.push(i)}else if(i<2048){if((r-=2)<0)break;f.push(i>>6|192,i&63|128)}else if(i<65536){if((r-=3)<0)break;f.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((r-=4)<0)break;f.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return f}function Ii(n){for(var r=[],i=0;i<n.length;++i)r.push(n.charCodeAt(i)&255);return r}function vi(n,r){for(var i,e,t,f=[],u=0;u<n.length&&!((r-=2)<0);++u)i=n.charCodeAt(u),e=i>>8,t=i%256,f.push(t),f.push(e);return f}function Er(n){return ii(Ti(n))}function L(n,r,i,e){for(var t=0;t<e&&!(t+i>=r.length||t>=n.length);++t)r[t+i]=n[t];return t}function Ui(n){return n!==n}function Bi(n){return n!=null&&(!!n._isBuffer||mr(n)||di(n))}function mr(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function di(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&mr(n.slice(0,0))}function F(n,r,i,e,t){var f,u,h=t*8-e-1,a=(1<<h)-1,l=a>>1,p=-7,c=i?t-1:0,m=i?-1:1,x=n[r+c];for(c+=m,f=x&(1<<-p)-1,x>>=-p,p+=h;p>0;f=f*256+n[r+c],c+=m,p-=8);for(u=f&(1<<-p)-1,f>>=-p,p+=e;p>0;u=u*256+n[r+c],c+=m,p-=8);if(f===0)f=1-l;else{if(f===a)return u?NaN:(x?-1:1)*(1/0);u=u+Math.pow(2,e),f=f-l}return(x?-1:1)*u*Math.pow(2,f-e)}function Ar(n,r,i,e,t,f){var u,h,a,l=f*8-t-1,p=(1<<l)-1,c=p>>1,m=t===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=e?0:f-1,B=e?1:-1,yr=r<0||r===0&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(h=isNaN(r)?1:0,u=p):(u=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-u))<1&&(u--,a*=2),u+c>=1?r+=m/a:r+=m*Math.pow(2,1-c),r*a>=2&&(u++,a/=2),u+c>=p?(h=0,u=p):u+c>=1?(h=(r*a-1)*Math.pow(2,t),u=u+c):(h=r*Math.pow(2,c-1)*Math.pow(2,t),u=0));t>=8;n[i+x]=h&255,x+=B,h/=256,t-=8);for(u=u<<t|h,l+=t;l>0;n[i+x]=u&255,x+=B,u/=256,l-=8);n[i+x-B]|=yr*128}var A,E,ri,O,fr,yi,gr=V(()=>{"use strict";z();J();A=[],E=[],ri=typeof Uint8Array!="undefined"?Uint8Array:Array,O=!1;o.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;o.poolSize=8192;o._augment=function(n){return n.__proto__=o.prototype,n};o.from=function(n,r,i){return or(null,n,r,i)};o.kMaxLength=D();o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&o[Symbol.species]);o.alloc=function(n,r,i){return ti(null,n,r,i)};o.allocUnsafe=function(n){return Q(null,n)};o.allocUnsafeSlow=function(n){return Q(null,n)};o.isBuffer=Bi;o.compare=function(r,i){if(!g(r)||!g(i))throw new TypeError("Arguments must be Buffers");if(r===i)return 0;for(var e=r.length,t=i.length,f=0,u=Math.min(e,t);f<u;++f)if(r[f]!==i[f]){e=r[f],t=i[f];break}return e<t?-1:t<e?1:0};o.isEncoding=function(r){switch(String(r).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};o.concat=function(r,i){if(!Array.isArray(r))throw new TypeError('"list" argument must be an Array of Buffers');if(r.length===0)return o.alloc(0);var e;if(i===void 0)for(i=0,e=0;e<r.length;++e)i+=r[e].length;var t=o.allocUnsafe(i),f=0;for(e=0;e<r.length;++e){var u=r[e];if(!g(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(t,f),f+=u.length}return t};o.byteLength=ar;o.prototype._isBuffer=!0;o.prototype.swap16=function(){var r=this.length;if(r%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var i=0;i<r;i+=2)U(this,i,i+1);return this};o.prototype.swap32=function(){var r=this.length;if(r%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var i=0;i<r;i+=4)U(this,i,i+3),U(this,i+1,i+2);return this};o.prototype.swap64=function(){var r=this.length;if(r%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var i=0;i<r;i+=8)U(this,i,i+7),U(this,i+1,i+6),U(this,i+2,i+5),U(this,i+3,i+4);return this};o.prototype.toString=function(){var r=this.length|0;return r===0?"":arguments.length===0?pr(this,0,r):hi.apply(this,arguments)};o.prototype.equals=function(r){if(!g(r))throw new TypeError("Argument must be a Buffer");return this===r?!0:o.compare(this,r)===0};o.prototype.compare=function(r,i,e,t,f){if(!g(r))throw new TypeError("Argument must be a Buffer");if(i===void 0&&(i=0),e===void 0&&(e=r?r.length:0),t===void 0&&(t=0),f===void 0&&(f=this.length),i<0||e>r.length||t<0||f>this.length)throw new RangeError("out of range index");if(t>=f&&i>=e)return 0;if(t>=f)return-1;if(i>=e)return 1;if(i>>>=0,e>>>=0,t>>>=0,f>>>=0,this===r)return 0;for(var u=f-t,h=e-i,a=Math.min(u,h),l=this.slice(t,f),p=r.slice(i,e),c=0;c<a;++c)if(l[c]!==p[c]){u=l[c],h=p[c];break}return u<h?-1:h<u?1:0};o.prototype.includes=function(r,i,e){return this.indexOf(r,i,e)!==-1};o.prototype.indexOf=function(r,i,e){return cr(this,r,i,e,!0)};o.prototype.lastIndexOf=function(r,i,e){return cr(this,r,i,e,!1)};o.prototype.write=function(r,i,e,t){if(i===void 0)t="utf8",e=this.length,i=0;else if(e===void 0&&typeof i=="string")t=i,e=this.length,i=0;else if(isFinite(i))i=i|0,isFinite(e)?(e=e|0,t===void 0&&(t="utf8")):(t=e,e=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var f=this.length-i;if((e===void 0||e>f)&&(e=f),r.length>0&&(e<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");t||(t="utf8");for(var u=!1;;)switch(t){case"hex":return ai(this,r,i,e);case"utf8":case"utf-8":return ci(this,r,i,e);case"ascii":return lr(this,r,i,e);case"latin1":case"binary":return li(this,r,i,e);case"base64":return pi(this,r,i,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return si(this,r,i,e);default:if(u)throw new TypeError("Unknown encoding: "+t);t=(""+t).toLowerCase(),u=!0}};o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};fr=4096;o.prototype.slice=function(r,i){var e=this.length;r=~~r,i=i===void 0?e:~~i,r<0?(r+=e,r<0&&(r=0)):r>e&&(r=e),i<0?(i+=e,i<0&&(i=0)):i>e&&(i=e),i<r&&(i=r);var t;if(o.TYPED_ARRAY_SUPPORT)t=this.subarray(r,i),t.__proto__=o.prototype;else{var f=i-r;t=new o(f,void 0);for(var u=0;u<f;++u)t[u]=this[u+r]}return t};o.prototype.readUIntLE=function(r,i,e){r=r|0,i=i|0,e||s(r,i,this.length);for(var t=this[r],f=1,u=0;++u<i&&(f*=256);)t+=this[r+u]*f;return t};o.prototype.readUIntBE=function(r,i,e){r=r|0,i=i|0,e||s(r,i,this.length);for(var t=this[r+--i],f=1;i>0&&(f*=256);)t+=this[r+--i]*f;return t};o.prototype.readUInt8=function(r,i){return i||s(r,1,this.length),this[r]};o.prototype.readUInt16LE=function(r,i){return i||s(r,2,this.length),this[r]|this[r+1]<<8};o.prototype.readUInt16BE=function(r,i){return i||s(r,2,this.length),this[r]<<8|this[r+1]};o.prototype.readUInt32LE=function(r,i){return i||s(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+this[r+3]*16777216};o.prototype.readUInt32BE=function(r,i){return i||s(r,4,this.length),this[r]*16777216+(this[r+1]<<16|this[r+2]<<8|this[r+3])};o.prototype.readIntLE=function(r,i,e){r=r|0,i=i|0,e||s(r,i,this.length);for(var t=this[r],f=1,u=0;++u<i&&(f*=256);)t+=this[r+u]*f;return f*=128,t>=f&&(t-=Math.pow(2,8*i)),t};o.prototype.readIntBE=function(r,i,e){r=r|0,i=i|0,e||s(r,i,this.length);for(var t=i,f=1,u=this[r+--t];t>0&&(f*=256);)u+=this[r+--t]*f;return f*=128,u>=f&&(u-=Math.pow(2,8*i)),u};o.prototype.readInt8=function(r,i){return i||s(r,1,this.length),this[r]&128?(255-this[r]+1)*-1:this[r]};o.prototype.readInt16LE=function(r,i){i||s(r,2,this.length);var e=this[r]|this[r+1]<<8;return e&32768?e|4294901760:e};o.prototype.readInt16BE=function(r,i){i||s(r,2,this.length);var e=this[r+1]|this[r]<<8;return e&32768?e|4294901760:e};o.prototype.readInt32LE=function(r,i){return i||s(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24};o.prototype.readInt32BE=function(r,i){return i||s(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]};o.prototype.readFloatLE=function(r,i){return i||s(r,4,this.length),F(this,r,!0,23,4)};o.prototype.readFloatBE=function(r,i){return i||s(r,4,this.length),F(this,r,!1,23,4)};o.prototype.readDoubleLE=function(r,i){return i||s(r,8,this.length),F(this,r,!0,52,8)};o.prototype.readDoubleBE=function(r,i){return i||s(r,8,this.length),F(this,r,!1,52,8)};o.prototype.writeUIntLE=function(r,i,e,t){if(r=+r,i=i|0,e=e|0,!t){var f=Math.pow(2,8*e)-1;w(this,r,i,e,f,0)}var u=1,h=0;for(this[i]=r&255;++h<e&&(u*=256);)this[i+h]=r/u&255;return i+e};o.prototype.writeUIntBE=function(r,i,e,t){if(r=+r,i=i|0,e=e|0,!t){var f=Math.pow(2,8*e)-1;w(this,r,i,e,f,0)}var u=e-1,h=1;for(this[i+u]=r&255;--u>=0&&(h*=256);)this[i+u]=r/h&255;return i+e};o.prototype.writeUInt8=function(r,i,e){return r=+r,i=i|0,e||w(this,r,i,1,255,0),o.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),this[i]=r&255,i+1};o.prototype.writeUInt16LE=function(r,i,e){return r=+r,i=i|0,e||w(this,r,i,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[i]=r&255,this[i+1]=r>>>8):k(this,r,i,!0),i+2};o.prototype.writeUInt16BE=function(r,i,e){return r=+r,i=i|0,e||w(this,r,i,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[i]=r>>>8,this[i+1]=r&255):k(this,r,i,!1),i+2};o.prototype.writeUInt32LE=function(r,i,e){return r=+r,i=i|0,e||w(this,r,i,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[i+3]=r>>>24,this[i+2]=r>>>16,this[i+1]=r>>>8,this[i]=r&255):N(this,r,i,!0),i+4};o.prototype.writeUInt32BE=function(r,i,e){return r=+r,i=i|0,e||w(this,r,i,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255):N(this,r,i,!1),i+4};o.prototype.writeIntLE=function(r,i,e,t){if(r=+r,i=i|0,!t){var f=Math.pow(2,8*e-1);w(this,r,i,e,f-1,-f)}var u=0,h=1,a=0;for(this[i]=r&255;++u<e&&(h*=256);)r<0&&a===0&&this[i+u-1]!==0&&(a=1),this[i+u]=(r/h>>0)-a&255;return i+e};o.prototype.writeIntBE=function(r,i,e,t){if(r=+r,i=i|0,!t){var f=Math.pow(2,8*e-1);w(this,r,i,e,f-1,-f)}var u=e-1,h=1,a=0;for(this[i+u]=r&255;--u>=0&&(h*=256);)r<0&&a===0&&this[i+u+1]!==0&&(a=1),this[i+u]=(r/h>>0)-a&255;return i+e};o.prototype.writeInt8=function(r,i,e){return r=+r,i=i|0,e||w(this,r,i,1,127,-128),o.TYPED_ARRAY_SUPPORT||(r=Math.floor(r)),r<0&&(r=255+r+1),this[i]=r&255,i+1};o.prototype.writeInt16LE=function(r,i,e){return r=+r,i=i|0,e||w(this,r,i,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[i]=r&255,this[i+1]=r>>>8):k(this,r,i,!0),i+2};o.prototype.writeInt16BE=function(r,i,e){return r=+r,i=i|0,e||w(this,r,i,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[i]=r>>>8,this[i+1]=r&255):k(this,r,i,!1),i+2};o.prototype.writeInt32LE=function(r,i,e){return r=+r,i=i|0,e||w(this,r,i,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[i]=r&255,this[i+1]=r>>>8,this[i+2]=r>>>16,this[i+3]=r>>>24):N(this,r,i,!0),i+4};o.prototype.writeInt32BE=function(r,i,e){return r=+r,i=i|0,e||w(this,r,i,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),o.TYPED_ARRAY_SUPPORT?(this[i]=r>>>24,this[i+1]=r>>>16,this[i+2]=r>>>8,this[i+3]=r&255):N(this,r,i,!1),i+4};o.prototype.writeFloatLE=function(r,i,e){return wr(this,r,i,!0,e)};o.prototype.writeFloatBE=function(r,i,e){return wr(this,r,i,!1,e)};o.prototype.writeDoubleLE=function(r,i,e){return xr(this,r,i,!0,e)};o.prototype.writeDoubleBE=function(r,i,e){return xr(this,r,i,!1,e)};o.prototype.copy=function(r,i,e,t){if(e||(e=0),!t&&t!==0&&(t=this.length),i>=r.length&&(i=r.length),i||(i=0),t>0&&t<e&&(t=e),t===e||r.length===0||this.length===0)return 0;if(i<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=this.length)throw new RangeError("sourceStart out of bounds");if(t<0)throw new RangeError("sourceEnd out of bounds");t>this.length&&(t=this.length),r.length-i<t-e&&(t=r.length-i+e);var f=t-e,u;if(this===r&&e<i&&i<t)for(u=f-1;u>=0;--u)r[u+i]=this[u+e];else if(f<1e3||!o.TYPED_ARRAY_SUPPORT)for(u=0;u<f;++u)r[u+i]=this[u+e];else Uint8Array.prototype.set.call(r,this.subarray(e,e+f),i);return f};o.prototype.fill=function(r,i,e,t){if(typeof r=="string"){if(typeof i=="string"?(t=i,i=0,e=this.length):typeof e=="string"&&(t=e,e=this.length),r.length===1){var f=r.charCodeAt(0);f<256&&(r=f)}if(t!==void 0&&typeof t!="string")throw new TypeError("encoding must be a string");if(typeof t=="string"&&!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t)}else typeof r=="number"&&(r=r&255);if(i<0||this.length<i||this.length<e)throw new RangeError("Out of range index");if(e<=i)return this;i=i>>>0,e=e===void 0?this.length:e>>>0,r||(r=0);var u;if(typeof r=="number")for(u=i;u<e;++u)this[u]=r;else{var h=g(r)?r:C(new o(r,t).toString()),a=h.length;for(u=0;u<e-i;++u)this[u+i]=h[u%a]}return this};yi=/[^+\/0-9A-Za-z-_]/g});var J=V(()=>{"use strict";gr()});export{Yi as a,Si as b,Pi as c,Mi as d,V as e,Di as f,Ci as g,ki as h,Ni as i,Li as j,z as k,o as l,J as m};
|
|
2
|
+
/*! Bundled license information:
|
|
3
|
+
|
|
4
|
+
@esbuild-plugins/node-globals-polyfill/Buffer.js:
|
|
5
|
+
(*!
|
|
6
|
+
* The buffer module from node.js, for the browser.
|
|
7
|
+
*
|
|
8
|
+
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
9
|
+
* @license MIT
|
|
10
|
+
*)
|
|
11
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-FOUIYX4V.js";import{a}from"./chunk-GHM3YOPV.js";import{a as o}from"./chunk-WFKWXM7L.js";import{j as t,k as r,m as p}from"./chunk-2AZXIWKY.js";r();p();var s=class extends o{constructor({ir:e,config:n,options:c={}}){super(new a({ir:e,config:n,options:c}));t(this,"formatter")}async generate(e,n={}){return super.generate(e,n)}generateSync(e,n={}){return super.generateSync(e,n)}createSnippetGenerator(e){return new i({context:e})}};export{s as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s,c as n}from"./chunk-AASPH6YC.js";import{j as l,k as p,m as y}from"./chunk-2AZXIWKY.js";p();y();var c=class{constructor({context:r}){l(this,"context");this.context=r}getFilePropertyInfo({body:r,value:o}){var a;let e={fileFields:[],bodyPropertyFields:[]},i=(a=this.context.getRecord(o))!=null?a:{};for(let t of r.properties)switch(t.type){case"file":e.fileFields.push({name:this.context.getMethodName(t.name),value:this.getSingleFileProperty({property:t,record:i})});break;case"fileArray":e.fileFields.push({name:this.context.getMethodName(t.name),value:this.getArrayFileProperty({property:t,record:i})});break;case"bodyProperty":e.bodyPropertyFields.push({name:this.context.getMethodName(t.name.name),value:this.getBodyProperty({property:t,record:i})});break;default:s(t)}return e}getSingleFileProperty({property:r,record:o}){let e=this.context.getSingleFileValue({property:r,record:o});return e==null?n.TypeLiteral.nop():n.TypeLiteral.reference(this.context.getFileStreamFromString(e))}getArrayFileProperty({property:r,record:o}){let e=this.context.getFileArrayValues({property:r,record:o});if(e==null)return n.TypeLiteral.nop();for(let i of e)return n.TypeLiteral.reference(this.context.getFileStreamFromString(i));return n.TypeLiteral.nop()}getBodyProperty({property:r,record:o}){let e=o[r.name.wireValue];return e==null?n.TypeLiteral.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:r.typeReference,value:e})}};export{c as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r,c as t}from"./chunk-AASPH6YC.js";import{j as a,k as c,m as i}from"./chunk-2AZXIWKY.js";c();i();var p=class{constructor({context:e}){a(this,"context");this.context=e}convert(e){switch(e.typeReference.type){case"list":return t.Type.list(this.convert({typeReference:e.typeReference}));case"literal":return this.convertLiteral({literal:e.typeReference.value});case"map":return t.Type.map(this.convert({typeReference:e.typeReference.key}),this.convert({typeReference:e.typeReference.value}));case"named":{let n=this.context.resolveNamedType({typeId:e.typeReference.value});return n==null?this.convertUnknown():this.convertNamed({named:n})}case"optional":case"nullable":return t.Type.optional(this.convert({typeReference:e.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:e.typeReference.value});case"set":return t.Type.set(this.convert({typeReference:e.typeReference}));case"unknown":return this.convertUnknown();default:r(e.typeReference)}}convertNamed({named:e}){switch(e.type){case"alias":return this.convert({typeReference:e.typeReference});case"enum":case"discriminatedUnion":case"object":case"undiscriminatedUnion":return t.Type.reference(t.classReference({name:this.context.getClassName(e.declaration.name),packageName:this.context.getTypesPackageName(e.declaration.fernFilepath)}));default:r(e)}}convertLiteral({literal:e}){switch(e.type){case"boolean":return t.Type.boolean();case"string":return t.Type.string()}}convertUnknown(){return t.Type.object()}convertPrimitive({primitive:e}){switch(e){case"INTEGER":return t.Type.integer();case"UINT":return t.Type.integer();case"LONG":return t.Type.long();case"UINT_64":return t.Type.long();case"FLOAT":return t.Type.float();case"DOUBLE":return t.Type.double();case"BOOLEAN":return t.Type.boolean();case"STRING":return t.Type.string();case"DATE":return t.Type.date();case"DATE_TIME":return t.Type.dateTime();case"UUID":return t.Type.uuid();case"BASE_64":return t.Type.bytes();case"BIG_INTEGER":return t.Type.bigInteger();default:r(e)}}};export{p as a};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{g as P,j as o,k as r,m as a}from"./chunk-2AZXIWKY.js";r();a();function T(i){throw new Error("Unexpected value: "+JSON.stringify(i))}r();a();r();a();function D(i){return Object.keys(i)}var f={};P(f,{Access:()=>B,AstNode:()=>h,Class:()=>N,ClassInstantiation:()=>x,ClassReference:()=>l,CodeBlock:()=>k,Method:()=>b,MethodInvocation:()=>v,Parameter:()=>L,Type:()=>C,TypeLiteral:()=>m,Writer:()=>g,classReference:()=>oe,class_:()=>ae,codeblock:()=>re,instantiateClass:()=>le,invokeMethod:()=>ce,method:()=>pe,parameter:()=>ue});r();a();r();a();r();a();var B={Public:"public",Protected:"protected",Private:"private"};r();a();r();a();r();a();var y=class{};r();a();r();a();var w=class extends y{constructor(e){super();o(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):this.value(e)}};var F=4,I=class{constructor(){o(this,"buffer","");o(this,"indentLevel",0);o(this,"hasWrittenAnything",!1);o(this,"lastCharacterIsSemicolon",!1);o(this,"lastCharacterIsNewline",!1)}write(n){let e=n.length>0&&n.endsWith(`
|
|
2
|
+
`),t=e?n.substring(0,n.length-1):n,s=this.getIndentString(),c=t.replaceAll(`
|
|
3
|
+
`,`
|
|
4
|
+
${s}`);this.isAtStartOfLine()&&(c=s+c),e&&(c+=`
|
|
5
|
+
`),this.writeInternal(c)}writeNoIndent(n){let e=this.indentLevel;this.indentLevel=0,this.write(n),this.indentLevel=e}writeNode(n){n.write(this)}writeNodeOrString(n){if(typeof n=="string"){this.write(n);return}this.writeNode(n)}writeNodeStatement(n){n.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(n){new w(n).write(this),this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(n,e){new w(n).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}endControlFlow(){this.dedent(),this.writeLine("}")}contiguousControlFlow(n,e){this.dedent(),this.write("} "),new w(n).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}alternativeControlFlow(n){this.dedent(),this.write("} "),new w(n).write(this),this.write(" {"),this.writeNewLineIfLastLineNot(),this.indent()}openBlock(n,e="{",t,s="}"){let c=n.filter(d=>d!==void 0).join(" ");c?this.write(`${c} ${e!=null?e:""}`):this.write(e!=null?e:"");try{this.indent(),t(),this.dedent()}finally{this.write(s!=null?s:"")}}writeLine(n=""){this.write(n),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
6
|
+
`)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
7
|
+
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:n,delimiter:e,writeFunction:t}){if(n.length>0){let s=n[0];s!=null&&t(s);for(let c=1;c<n.length;c++){this.write(e);let d=n[c];d!=null&&t(d)}}}toString(){return this.buffer}writeInternal(n){return n.length>0&&(this.hasWrittenAnything=!0,this.lastCharacterIsNewline=n.endsWith(`
|
|
8
|
+
`),this.lastCharacterIsSemicolon=n.endsWith(";")),this.buffer+=n}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*F)}};r();a();var O=class{},A=class extends O{async format(n){return n}formatSync(n){return n}};r();a();function M(i){return(i==null?void 0:i.name)!=null}r();a();r();a();var g=class extends I{constructor({packageName:e,customConfig:t,formatter:s}){super();o(this,"packageName");o(this,"customConfig");o(this,"formatter");o(this,"imports",new Set);this.packageName=e,this.customConfig=t,this.formatter=s!=null?s:new A}addImport(e){this.imports.add(e)}};var S=class extends g{constructor({packageName:n,customConfig:e,formatter:t}){super({packageName:n,customConfig:e,formatter:t})}async toStringAsync(){let n=this.getContent();if(this.formatter!=null)try{return this.formatter.format(n)}catch(e){throw new Error(`Failed to format Java file: ${e}
|
|
9
|
+
${n}`)}return n}toString(){let n=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(n)}catch(e){throw new Error(`Failed to format Java file: ${e}
|
|
10
|
+
${n}`)}return n}getContent(){let n=`package ${this.packageName};
|
|
11
|
+
|
|
12
|
+
`,e=this.stringifyImports();return e.length>0?`${n}${e}
|
|
13
|
+
|
|
14
|
+
${this.buffer}`:n+this.buffer}stringifyImports(){return Array.from(this.imports).filter(n=>n!==this.packageName).map(n=>`import ${n};`).sort().join(`
|
|
15
|
+
`)}};var h=class extends y{async toStringAsync({packageName:n,customConfig:e,formatter:t}){let s=new S({packageName:n,customConfig:e,formatter:t});return this.write(s),s.toStringAsync()}toString({packageName:n,customConfig:e,formatter:t}){let s=new S({packageName:n,customConfig:e,formatter:t});return this.write(s),s.toString()}};r();a();var N=class extends h{constructor({name:e,access:t}){super();o(this,"name");o(this,"access");o(this,"methods",[]);this.name=e,this.access=t}write(e){if(e.write(`${this.access} class ${this.name}`),this.isEmpty()){e.writeLine(" {}");return}e.writeLine(" {"),e.indent();for(let t of this.methods)e.writeNode(t),e.newLine();e.dedent(),e.write("}")}addMethod(e){this.methods.push(e)}isEmpty(){return this.methods.length===0}};r();a();var l=class extends h{constructor({name:e,packageName:t,fullyQualified:s}){super();o(this,"name");o(this,"packageName");o(this,"fullyQualified");this.name=e,this.packageName=t,this.fullyQualified=s!=null?s:!1}write(e){if(e.addImport(`${this.packageName}.${this.name}`),this.fullyQualified){e.write(`${this.packageName}.${this.name}`);return}e.write(this.name)}};r();a();r();a();r();a();r();a();r();a();var C=class extends h{constructor(e){super();o(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"bigInteger":e.writeNode(J);break;case"boolean":e.write("Boolean");break;case"bytes":e.write("byte[]");break;case"float":e.write("Float");break;case"date":e.write("String");break;case"dateTime":e.writeNode(Y);break;case"double":e.write("Double");break;case"integer":e.write("Integer");break;case"list":{this.writeList({writer:e,list:this.internalType});break}case"long":{e.write("Long");break}case"map":{this.writeMap({writer:e,map:this.internalType});break}case"object":{e.write("Object");break}case"optional":{this.writeOptional({writer:e,optional:this.internalType});break}case"reference":e.writeNode(this.internalType.value);break;case"set":{this.writeSet({writer:e,set:this.internalType});break}case"string":e.write("String");break;case"uuid":e.writeNode(q);break;default:T(this.internalType)}}isOptional(){return this.internalType.type==="optional"}static bigInteger(){return new this({type:"bigInteger"})}static boolean(){return new this({type:"boolean"})}static bytes(){return new this({type:"bytes"})}static date(){return new this({type:"date"})}static dateTime(){return new this({type:"dateTime"})}static double(){return new this({type:"double"})}static float(){return new this({type:"float"})}static integer(){return new this({type:"integer"})}static list(e){return new this({type:"list",value:e})}static long(){return new this({type:"long"})}static map(e,t){return new this({type:"map",keyType:e,valueType:t})}static object(){return new this({type:"object"})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static reference(e){return new this({type:"reference",value:e})}static set(e){return new this({type:"set",value:e})}static string(){return new this({type:"string"})}static uuid(){return new this({type:"uuid"})}writeList({writer:e,list:t}){e.writeNode(H),e.write("<"),t.value.write(e),e.write(">")}writeMap({writer:e,map:t}){e.writeNode(V),e.write("<"),t.keyType.write(e),e.write(", "),t.valueType.write(e),e.write(">")}writeOptional({writer:e,optional:t}){e.writeNode(E),e.write("<"),t.value.write(e),e.write(">")}writeSet({writer:e,set:t}){e.writeNode(Z),e.write("<"),t.value.write(e),e.write(">")}static isAlreadyOptional(e){return e.internalType.type==="optional"}},$=new l({name:"Arrays",packageName:"java.util"}),J=new l({name:"BigInteger",packageName:"java.math"}),jt=new l({name:"HashMap",packageName:"java.util"}),H=new l({name:"List",packageName:"java.util"}),V=new l({name:"Map",packageName:"java.util"}),Y=new l({name:"OffsetDateTime",packageName:"java.time"}),E=new l({name:"Optional",packageName:"java.util"}),Z=new l({name:"Set",packageName:"java.util"}),q=new l({name:"UUID",packageName:"java.util"});var m=class i extends h{constructor(e){super();o(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"bigInteger":this.writeBigInteger({writer:e,bigInteger:this.internalType});break;case"boolean":e.write(this.internalType.value.toString());break;case"builder":this.writeBuilder({writer:e,builder:this.internalType});break;case"bytes":e.write(`"${this.internalType.value}".getBytes()`);break;case"class":{this.writeClass({writer:e,class_:this.internalType});break}case"date":e.write(`"${this.internalType.value}"`);break;case"dateTime":this.writeDateTime({writer:e,dateTime:this.internalType});break;case"double":e.write(this.internalType.value.toString());break;case"enum":this.writeEnum({writer:e,enum_:this.internalType});break;case"float":e.write(`${this.internalType.value}f`);break;case"integer":e.write(this.internalType.value.toString());break;case"list":{this.writeList({writer:e,list:this.internalType});break}case"long":{e.write(`${this.internalType.value}L`);break}case"map":{this.writeMap({writer:e,map:this.internalType});break}case"optional":{this.writeOptional({writer:e,optional:this.internalType});break}case"raw":{e.write(this.internalType.value);break}case"reference":e.writeNode(this.internalType.value);break;case"set":{this.writeSet({writer:e,set:this.internalType});break}case"string":e.write(`"${this.escapeString(this.internalType.value)}"`);break;case"unknown":this.writeUnknown({writer:e,value:this.internalType.value});break;case"uuid":this.writeUUID({writer:e,uuid:this.internalType});break;case"nop":break;default:T(this.internalType)}}isOptional(){return this.internalType.type==="optional"}static bigInteger(e){return new this({type:"bigInteger",value:e})}static boolean(e){return new this({type:"boolean",value:e})}static builder({classReference:e,parameters:t}){return new this({type:"builder",classReference:e,parameters:t})}static bytes(e){return new this({type:"bytes",value:e})}static class_({reference:e,parameters:t}){return new this({type:"class",reference:e,parameters:t})}static date(e){return new this({type:"date",value:e})}static dateTime(e){return new this({type:"dateTime",value:e})}static double(e){return new this({type:"double",value:e})}static enum_({classReference:e,value:t}){return new this({type:"enum",classReference:e,value:t})}static float(e){return new this({type:"float",value:e})}static integer(e){return new this({type:"integer",value:e})}static list({valueType:e,values:t}){return new this({type:"list",valueType:e,values:t})}static long(e){return new this({type:"long",value:e})}static map({keyType:e,valueType:t,entries:s}){return new this({type:"map",keyType:e,valueType:t,entries:s})}static optional({value:e,useOf:t}){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e,useOf:t})}static raw(e){return new this({type:"raw",value:e})}static reference(e){return new this({type:"reference",value:e})}static set({valueType:e,values:t}){return new this({type:"set",valueType:e,values:t})}static string(e){return new this({type:"string",value:e})}static unknown(e){return new this({type:"unknown",value:e})}static uuid(e){return new this({type:"uuid",value:e})}static nop(){return new this({type:"nop"})}static isNop(e){return e.internalType.type==="nop"}shouldWriteInLine(){switch(this.internalType.type){case"bigInteger":case"boolean":case"bytes":case"date":case"dateTime":case"double":case"enum":case"float":case"integer":case"long":case"nop":case"raw":case"string":case"unknown":case"uuid":return!0;case"optional":return this.internalType.value.shouldWriteInLine();case"builder":case"class":case"list":case"map":case"reference":case"set":return!1;default:T(this.internalType)}}writeBigInteger({writer:e,bigInteger:t}){e.write("new "),e.writeNode(f.instantiateClass({classReference:z,arguments_:[i.string(t.value)]}))}writeBuilder({writer:e,builder:t}){e.writeNode(t.classReference),e.writeNewLineIfLastLineNot(),e.indent(),this.writeBuilderParameters({writer:e,parameters:this.orderBuilderParameters(ee({parameters:t.parameters}))}),e.dedent()}writeBuilderParameters({writer:e,parameters:t}){e.writeLine(".builder()");for(let s of t)e.write(`.${s.name}(`),s.value.shouldWriteInLine()||e.newLine(),e.indent(),e.writeNode(s.value),e.dedent(),s.value.shouldWriteInLine()||e.newLine(),e.writeLine(")");e.writeNewLineIfLastLineNot(),e.write(".build()")}orderBuilderParameters(e){return e.sort((t,s)=>t.value.isOptional()&&!s.value.isOptional()?1:!t.value.isOptional()&&s.value.isOptional()?-1:0)}writeClass({writer:e,class_:t}){let s=Q({parameters:t.parameters});e.writeNode(f.instantiateClass({classReference:t.reference,arguments_:s.map(c=>c.value)}))}writeDateTime({writer:e,dateTime:t}){e.writeNode(f.invokeMethod({on:K,method:"parse",arguments_:[i.string(t.value)]}))}writeEnum({writer:e,enum_:t}){e.writeNode(t.classReference),e.write("."+t.value)}writeList({writer:e,list:t}){this.writeIterable({writer:e,iterable:t})}writeMap({writer:e,map:t}){let s=te({entries:t.entries});if(s.length===0){e.write("new "),e.writeNode(j),e.write("<"),e.writeNode(t.keyType),e.write(", "),e.writeNode(t.valueType),e.write(">()");return}e.write("new "),e.writeNode(j),e.write("<"),e.writeNode(t.keyType),e.write(", "),e.writeNode(t.valueType),e.writeLine(">() {{"),e.indent();for(let c of s)e.write("put("),e.writeNode(c.key),e.write(", "),e.writeNode(c.value),e.writeLine(");");e.dedent(),e.write("}}")}writeOptional({writer:e,optional:t}){if(!t.useOf){e.writeNode(t.value);return}e.writeNode(f.invokeMethod({on:E,method:"of",arguments_:[t.value]}))}writeSet({writer:e,set:t}){this.writeIterable({writer:e,iterable:t})}writeIterable({writer:e,iterable:t}){let s=t.type==="list"?U:G,c=ne({values:t.values});if(c.length===0){e.write(`new ${s.name}<`),e.writeNode(t.valueType),e.write(">()");return}e.write("new "),e.writeNode(s),e.write("<"),e.writeNode(t.valueType),e.writeLine(">("),e.indent(),e.writeNode(f.invokeMethod({on:$,method:"asList",arguments_:c})),e.writeNewLineIfLastLineNot(),e.dedent(),e.write(")")}writeUnknown({writer:e,value:t}){switch(typeof t){case"boolean":e.write(t.toString());return;case"string":e.write(`"${this.escapeString(t)}"`);return;case"number":e.write(t.toString());return;case"object":if(t==null){e.write("null");return}if(Array.isArray(t)){this.writeUnknownArray({writer:e,value:t});return}this.writeUnknownMap({writer:e,value:t});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof t}`)}}writeUnknownArray({writer:e,value:t}){if(t.length===0){e.write("new"),e.writeNode(U),e.write("<Object>()");return}e.writeLine("new"),e.writeNode(U),e.write("<Object>() {"),e.indent(),e.writeNode(f.invokeMethod({on:$,method:"asList",arguments_:t.map(s=>i.unknown(s))})),e.writeNewLineIfLastLineNot(),e.dedent(),e.write("}")}writeUnknownMap({writer:e,value:t}){let s=Object.entries(t);if(s.length===0){e.write("new "),e.writeNode(j),e.write("<String, Object>()");return}e.writeLine("new "),e.writeNode(j),e.write("<String, Object>() {{"),e.indent();for(let[c,d]of s)e.write(`put("${c}", `),e.writeNode(i.unknown(d)),e.writeLine(");");e.dedent(),e.write("}}")}writeUUID({writer:e,uuid:t}){e.writeNode(f.invokeMethod({on:X,method:"fromString",arguments_:[i.string(t.value)]}))}escapeString(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}static isAlreadyOptional(e){return e.internalType.type==="optional"}},U=new l({name:"ArrayList",packageName:"java.util"}),z=new l({name:"BigInteger",packageName:"java.math"}),j=new l({name:"HashMap",packageName:"java.util"}),G=new l({name:"HashSet",packageName:"java.util"}),Dt=new l({name:"List",packageName:"java.util"}),Ft=new l({name:"Map",packageName:"java.util"}),K=new l({name:"OffsetDateTime",packageName:"java.time"}),Jt=new l({name:"Set",packageName:"java.util"}),X=new l({name:"UUID",packageName:"java.util"});function Q({parameters:i}){return i.filter(n=>!m.isNop(n.value))}function ee({parameters:i}){return i.filter(n=>!m.isNop(n.value))}function te({entries:i}){return i.filter(n=>!m.isNop(n.key)&&!m.isNop(n.value))}function ne({values:i}){return i.filter(n=>!m.isNop(n))}function R({writer:i,arguments_:n}){let e=se(n);if(e.length===0){i.write("()");return}if(e.some(s=>s instanceof m&&!s.shouldWriteInLine())){ie({writer:i,arguments_:e});return}i.write("("),e.forEach((s,c)=>{c>0&&i.write(", "),_({writer:i,argument:s})}),i.write(")")}function ie({writer:i,arguments_:n}){i.writeLine("("),i.indent(),n.forEach((e,t)=>{t>0&&i.writeLine(","),_({writer:i,argument:e})}),i.dedent(),n.length>0&&i.newLine(),i.write(")")}function _({writer:i,argument:n}){M(n)?i.writeNodeOrString(n.assignment):n.write(i)}function se(i){return i.filter(n=>!(n instanceof m&&m.isNop(n)))}var x=class extends h{constructor({classReference:e,arguments_:t}){super();o(this,"classReference");o(this,"arguments_");this.classReference=e,this.arguments_=t}write(e){e.writeNode(this.classReference),R({writer:e,arguments_:this.arguments_})}};r();a();var k=class extends h{constructor(e){super();o(this,"arg");this.arg=e}write(e){return new w(this.arg).write(e)}};r();a();var b=class extends h{constructor({name:e,access:t,parameters:s,body:c,static_:d,return_:W}){super();o(this,"name");o(this,"access");o(this,"parameters");o(this,"body");o(this,"return_");o(this,"static_");this.name=e,this.access=t,this.parameters=s,this.body=c,this.return_=W,this.static_=d!=null?d:!1}write(e){if(e.write(`${this.access} `),this.static_&&e.write("static "),this.return_!=null?e.writeNode(this.return_):e.write("void"),e.write(` ${this.name}`),this.parameters.length===0?e.write("()"):(e.writeLine("("),e.indent(),this.parameters.forEach((t,s)=>{s>0&&e.writeLine(", "),e.writeNode(t)}),e.dedent(),e.write(")")),this.body==null){e.write(";");return}e.writeLine(" {"),e.indent(),e.writeNode(this.body),e.writeNewLineIfLastLineNot(),e.dedent(),e.write("}")}};r();a();var v=class extends h{constructor({method:e,arguments_:t,on:s}){super();o(this,"on");o(this,"method");o(this,"arguments_");this.on=s,this.method=e,this.arguments_=t}write(e){this.on.write(e),e.write("."),e.write(this.method),R({writer:e,arguments_:this.arguments_})}};r();a();var L=class extends h{constructor({name:e,type:t}){super();o(this,"name");o(this,"type");this.name=e,this.type=t}write(e){e.writeNode(this.type),e.write(` ${this.name}`)}};function re(i){return new k(i)}function ae(i){return new N(i)}function oe(i){return new l(i)}function le(i){return new x(i)}function ce(i){return new v(i)}function pe(i){return new b(i)}function ue(i){return new L(i)}export{T as a,D as b,f as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as c,d as h,e as d}from"./chunk-WFKWXM7L.js";import{a as l,c as i}from"./chunk-AASPH6YC.js";import{j as y,k as R,m as x}from"./chunk-2AZXIWKY.js";R();x();var B="com.example.usage",A="Example",C="run",F="client",q={type:"primitive",value:"STRING"},I=class{constructor({context:e,formatter:t}){y(this,"context");y(this,"formatter");this.context=e,this.formatter=t}async generateSnippet({endpoint:e,request:t,options:r}){var s,o;let a=this.getConfig(r);return await this.buildCodeBlock({endpoint:e,snippet:t,options:r}).toStringAsync({packageName:(s=a.fullStylePackageName)!=null?s:B,customConfig:(o=this.context.customConfig)!=null?o:{},formatter:this.formatter})}generateSnippetSync({endpoint:e,request:t,options:r}){var s,o;let a=this.getConfig(r);return this.buildCodeBlock({endpoint:e,snippet:t,options:r}).toString({packageName:(s=a.fullStylePackageName)!=null?s:B,customConfig:(o=this.context.customConfig)!=null?o:{},formatter:this.formatter})}buildCodeBlock({endpoint:e,snippet:t,options:r}){let a=i.codeblock(s=>{s.writeNodeStatement(this.constructClient({endpoint:e,snippet:t})),s.newLine(),s.writeNodeStatement(this.callMethod({endpoint:e,snippet:t}))}),n=this.getStyle(r);switch(n){case h.Concise:return a;case h.Full:return this.buildFullCodeBlock({body:a,options:r});default:l(n)}}constructClient({endpoint:e,snippet:t}){return i.codeblock(r=>{r.writeNode(this.context.getRootClientClassReference()),r.write(` ${F} = `),r.writeNode(i.TypeLiteral.builder({classReference:this.context.getRootClientClassReference(),parameters:this.getRootClientBuilderArgs({endpoint:e,snippet:t})}))})}buildFullCodeBlock({body:e,options:t}){var n;let r=this.getConfig(t),a=i.class_({name:(n=r.fullStyleClassName)!=null?n:A,access:i.Access.Public});return a.addMethod(i.method({name:C,access:i.Access.Public,static_:!0,parameters:[],body:e})),a}getRootClientBuilderArgs({endpoint:e,snippet:t}){let r=[];e.auth!=null&&(t.auth!=null?r.push(...this.getRootClientAuthArgs({auth:e.auth,values:t.auth})):this.context.errors.add({severity:c.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`}));let a=this.getRootClientBaseUrlArg({baseUrl:t.baseURL,environment:t.environment});return a!=null&&r.push(a),this.context.errors.scope(d.Headers),this.context.ir.headers!=null&&t.headers!=null&&r.push(...this.getRootClientHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope(),r}getRootClientBaseUrlArg({baseUrl:e,environment:t}){var r;if(e!=null&&t!=null){this.context.errors.add({severity:c.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(e!=null){if(((r=this.context.ir.environments)==null?void 0:r.environments.type)==="multipleBaseUrls"){this.context.errors.add({severity:c.Critical,message:"The Java SDK doesn't support a baseUrl when multiple URL environments are configured"});return}return{name:"url",value:i.TypeLiteral.string(e)}}if(t!=null){if(this.context.isSingleEnvironmentID(t)){let a=this.context.getEnvironmentTypeReferenceFromID(t);if(a==null){this.context.errors.add({severity:c.Warning,message:`Environment ${JSON.stringify(t)} was not found`});return}return{name:"environment",value:i.TypeLiteral.reference(a)}}if(this.context.isMultiEnvironmentValues(t))return this.context.validateMultiEnvironmentUrlValues(t)?{name:"environment",value:i.TypeLiteral.reference(i.instantiateClass({classReference:this.context.getEnvironmentClassReference(),arguments_:Object.values(t).map(a=>this.context.dynamicTypeLiteralMapper.convert({typeReference:q,value:a}))}))}:void 0}}getRootClientAuthArgs({auth:e,values:t}){switch(e.type){case"basic":return t.type!=="basic"?(this.context.errors.add({severity:c.Critical,message:this.context.newAuthMismatchError({auth:e,values:t}).message}),[]):this.getRootClientBasicAuthArgs({auth:e,values:t});case"bearer":return t.type!=="bearer"?(this.context.errors.add({severity:c.Critical,message:this.context.newAuthMismatchError({auth:e,values:t}).message}),[]):this.getRootClientBearerAuthArgs({auth:e,values:t});case"header":return t.type!=="header"?(this.context.errors.add({severity:c.Critical,message:this.context.newAuthMismatchError({auth:e,values:t}).message}),[]):this.getRootClientHeaderAuthArgs({auth:e,values:t});case"oauth":return t.type!=="oauth"?(this.context.errors.add({severity:c.Critical,message:this.context.newAuthMismatchError({auth:e,values:t}).message}),[]):this.getRootClientOAuthArgs({auth:e,values:t});default:l(e)}}getRootClientBasicAuthArgs({auth:e,values:t}){return[{name:"credentials",value:i.TypeLiteral.raw(`"${t.username}", "${t.password}"`)}]}getRootClientBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.token),value:i.TypeLiteral.string(t.token)}]}getRootClientHeaderAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.header.typeReference,value:t.value})}]}getRootClientOAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.clientId),value:i.TypeLiteral.string(t.clientId)},{name:this.context.getMethodName(e.clientSecret),value:i.TypeLiteral.string(t.clientSecret)}]}getRootClientHeaderArgs({headers:e,values:t}){let r=[];for(let a of e){let n=this.getRootClientHeaderArg({header:a,value:t.value});n!=null&&r.push({name:this.context.getMethodName(a.name.name),value:n})}return r}getRootClientHeaderArg({header:e,value:t}){let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:t});if(!i.TypeLiteral.isNop(r))return r}callMethod({endpoint:e,snippet:t}){return i.invokeMethod({on:i.codeblock(F),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t})})}getMethodArgs({endpoint:e,snippet:t}){switch(e.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:e.request,snippet:t});case"body":return this.getMethodArgsForBodyRequest({request:e.request,snippet:t});default:l(e.request)}}getMethodArgsForBodyRequest({request:e,snippet:t}){var n,s;let r=[];this.context.errors.scope(d.PathParameters);let a=[...(n=this.context.ir.pathParameters)!=null?n:[],...(s=e.pathParameters)!=null?s:[]];return a.length>0&&r.push(...this.getPathParameters({namedParameters:a,snippet:t}).map(o=>o.value)),this.context.errors.unscope(),this.context.errors.scope(d.RequestBody),e.body!=null&&r.push(this.getBodyRequestArg({body:e.body,value:t.requestBody})),this.context.errors.unscope(),r}getBodyRequestArg({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return e.value.type==="optional"?i.TypeLiteral.optional({value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value.value,value:t}),useOf:!0}):this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t});default:l(e)}}getBytesBodyRequestArg({value:e}){return typeof e!="string"?(this.context.errors.add({severity:c.Critical,message:`Expected bytes value to be a string, got ${typeof e}`}),i.TypeLiteral.nop()):i.TypeLiteral.bytes(e)}getMethodArgsForInlinedRequest({request:e,snippet:t}){var o,m;let r=[],a=(m=(o=this.context.customConfig)==null?void 0:o["inline-path-parameters"])!=null?m:!1;this.context.errors.scope(d.PathParameters);let n=[];e.pathParameters!=null&&n.push(...this.getPathParameters({namedParameters:e.pathParameters,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(d.RequestBody);let s=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:a})||r.push(...n.map(u=>u.value)),r.push(...s.fileFields.map(u=>u.value)),r.push(this.getInlinedRequestArg({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:a})?n:[],filePropertyInfo:s})),r}getFilePropertyInfo({request:e,snippet:t}){return e.body==null||!this.context.isFileUploadRequestBody(e.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:e.body,value:t.requestBody})}getInlinedRequestArg({request:e,snippet:t,pathParameterFields:r,filePropertyInfo:a}){var g,f,v,P;this.context.errors.scope(d.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(g=e.queryParameters)!=null?g:[],values:(f=t.queryParameters)!=null?f:{}}).map(p=>({name:this.context.getMethodName(p.name.name),value:this.context.dynamicTypeLiteralMapper.convert(p)}));this.context.errors.unscope(),this.context.errors.scope(d.Headers);let m=this.context.associateByWireValue({parameters:(v=e.headers)!=null?v:[],values:(P=t.headers)!=null?P:{}}).map(p=>({name:this.context.getMethodName(p.name.name),value:this.context.dynamicTypeLiteralMapper.convert(p)}));this.context.errors.unscope(),this.context.errors.scope(d.RequestBody);let u=e.body!=null?this.getInlinedRequestBodyBuilderParameters({body:e.body,value:t.requestBody,filePropertyInfo:a}):[];return this.context.errors.unscope(),i.TypeLiteral.builder({classReference:i.classReference({name:this.context.getClassName(e.declaration.name),packageName:this.context.getRequestsPackageName(e.declaration.fernFilepath)}),parameters:[...r,...m,...s,...u]})}getInlinedRequestBodyBuilderParameters({body:e,value:t,filePropertyInfo:r}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyBuilderParameters({parameters:e.value,value:t});case"referenced":return[this.getReferencedRequestBodyPropertyBuilderParameter({body:e,value:t})];case"fileUpload":return this.getFileUploadRequestBodyBuilderParameters({filePropertyInfo:r});default:l(e)}}getFileUploadRequestBodyBuilderParameters({filePropertyInfo:e}){return e.bodyPropertyFields}getReferencedRequestBodyPropertyBuilderParameter({body:e,value:t}){return{name:this.context.getMethodName(e.bodyKey),value:this.getReferencedRequestBodyPropertyTypeLiteral({body:e.bodyType,value:t})}}getReferencedRequestBodyPropertyTypeLiteral({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t});default:l(e)}}getInlinedRequestBodyPropertyBuilderParameters({parameters:e,value:t}){var n;let r=[],a=this.context.associateByWireValue({parameters:e,values:(n=this.context.getRecord(t))!=null?n:{}});for(let s of a)r.push({name:this.context.getMethodName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return r}getPathParameters({namedParameters:e,snippet:t}){var n;let r=[],a=this.context.associateByWireValue({parameters:e,values:(n=t.pathParameters)!=null?n:{}});for(let s of a)r.push({name:this.context.getMethodName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return r}getMethod({endpoint:e}){return e.declaration.fernFilepath.allParts.length>0?`${e.declaration.fernFilepath.allParts.map(t=>`${this.context.getMethodName(t)}()`).join(".")}.${this.context.getMethodName(e.declaration.name)}`:this.context.getMethodName(e.declaration.name)}getStyle(e){var t,r;return(r=(t=e.style)!=null?t:this.context.options.style)!=null?r:h.Full}getConfig(e){var t,r;return(r=(t=e.config)!=null?t:this.context.options.config)!=null?r:{}}};export{I as a};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{a as R}from"./chunk-JSEUWNSK.js";import{c as v}from"./chunk-WFKWXM7L.js";import{a as N}from"./chunk-7CY27UU7.js";import{a as k}from"./chunk-452HWDL4.js";import{a as h,c as l}from"./chunk-AASPH6YC.js";import{j as d,k as t,m as a}from"./chunk-2AZXIWKY.js";t();a();t();a();t();a();t();a();t();a();t();a();t();a();var Pe=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,S=Pe;var Ae=typeof self=="object"&&self&&self.Object===Object&&self,Ie=S||Ae||Function("return this")(),T=Ie;var je=T.Symbol,i=je;t();a();var P=Object.prototype,Oe=P.hasOwnProperty,we=P.toString,c=i?i.toStringTag:void 0;function Fe(r){var f=Oe.call(r,c),e=r[c];try{r[c]=void 0;var o=!0}catch(n){}var s=we.call(r);return o&&(f?r[c]=e:delete r[c]),s}var A=Fe;t();a();var Ee=Object.prototype,Le=Ee.toString;function Me(r){return Le.call(r)}var I=Me;var We="[object Null]",Ue="[object Undefined]",j=i?i.toStringTag:void 0;function Be(r){return r==null?r===void 0?Ue:We:j&&j in Object(r)?A(r):I(r)}var O=Be;t();a();function ze(r){return r!=null&&typeof r=="object"}var w=ze;var De="[object Symbol]";function Ze(r){return typeof r=="symbol"||w(r)&&O(r)==De}var F=Ze;t();a();t();a();function qe(r,f){for(var e=-1,o=r==null?0:r.length,s=Array(o);++e<o;)s[e]=f(r[e],e,r);return s}var E=qe;t();a();var Ge=Array.isArray,L=Ge;var Je=1/0,M=i?i.prototype:void 0,W=M?M.toString:void 0;function U(r){if(typeof r=="string")return r;if(L(r))return E(r,U)+"";if(F(r))return W?W.call(r):"";var f=r+"";return f=="0"&&1/r==-Je?"-0":f}var B=U;t();a();function He(r){return r==null?"":B(r)}var m=He;t();a();t();a();t();a();t();a();t();a();t();a();function Ve(r,f,e){var o=-1,s=r.length;f<0&&(f=-f>s?0:s+f),e=e>s?s:e,e<0&&(e+=s),s=f>e?0:e-f>>>0,f>>>=0;for(var n=Array(s);++o<s;)n[o]=r[o+f];return n}var z=Ve;function Ke(r,f,e){var o=r.length;return e=e===void 0?o:e,!f&&e>=o?r:z(r,f,e)}var D=Ke;t();a();var _e="\\ud800-\\udfff",$e="\\u0300-\\u036f",Ye="\\ufe20-\\ufe2f",Qe="\\u20d0-\\u20ff",Xe=$e+Ye+Qe,er="\\ufe0e\\ufe0f",rr="\\u200d",tr=RegExp("["+rr+_e+Xe+er+"]");function ar(r){return tr.test(r)}var g=ar;t();a();t();a();function or(r){return r.split("")}var Z=or;t();a();var q="\\ud800-\\udfff",fr="\\u0300-\\u036f",sr="\\ufe20-\\ufe2f",ur="\\u20d0-\\u20ff",pr=fr+sr+ur,lr="\\ufe0e\\ufe0f",nr="["+q+"]",b="["+pr+"]",y="\\ud83c[\\udffb-\\udfff]",ir="(?:"+b+"|"+y+")",G="[^"+q+"]",J="(?:\\ud83c[\\udde6-\\uddff]){2}",H="[\\ud800-\\udbff][\\udc00-\\udfff]",mr="\\u200d",V=ir+"?",K="["+lr+"]?",dr="(?:"+mr+"(?:"+[G,J,H].join("|")+")"+K+V+")*",xr=K+V+dr,cr="(?:"+[G+b+"?",b,J,H,nr].join("|")+")",gr=RegExp(y+"(?="+y+")|"+cr+xr,"g");function hr(r){return r.match(gr)||[]}var _=hr;function br(r){return g(r)?_(r):Z(r)}var $=br;function yr(r){return function(f){f=m(f);var e=g(f)?$(f):void 0,o=e?e[0]:f.charAt(0),s=e?D(e,1).join(""):f.slice(1);return o[r]()+s}}var Y=yr;var Cr=Y("toUpperCase"),Q=Cr;function vr(r){return Q(m(r).toLowerCase())}var X=vr;t();a();t();a();function Rr(r,f,e,o){var s=-1,n=r==null?0:r.length;for(o&&n&&(e=r[++s]);++s<n;)e=f(e,r[s],s,r);return e}var ee=Rr;t();a();t();a();t();a();function Nr(r){return function(f){return r==null?void 0:r[f]}}var re=Nr;var kr={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Sr=re(kr),te=Sr;var Tr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Pr="\\u0300-\\u036f",Ar="\\ufe20-\\ufe2f",Ir="\\u20d0-\\u20ff",jr=Pr+Ar+Ir,Or="["+jr+"]",wr=RegExp(Or,"g");function Fr(r){return r=m(r),r&&r.replace(Tr,te).replace(wr,"")}var ae=Fr;t();a();t();a();var Er=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Lr(r){return r.match(Er)||[]}var oe=Lr;t();a();var Mr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Wr(r){return Mr.test(r)}var fe=Wr;t();a();var ne="\\ud800-\\udfff",Ur="\\u0300-\\u036f",Br="\\ufe20-\\ufe2f",zr="\\u20d0-\\u20ff",Dr=Ur+Br+zr,ie="\\u2700-\\u27bf",me="a-z\\xdf-\\xf6\\xf8-\\xff",Zr="\\xac\\xb1\\xd7\\xf7",qr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Gr="\\u2000-\\u206f",Jr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",de="A-Z\\xc0-\\xd6\\xd8-\\xde",Hr="\\ufe0e\\ufe0f",xe=Zr+qr+Gr+Jr,ce="['\u2019]",se="["+xe+"]",Vr="["+Dr+"]",ge="\\d+",Kr="["+ie+"]",he="["+me+"]",be="[^"+ne+xe+ge+ie+me+de+"]",_r="\\ud83c[\\udffb-\\udfff]",$r="(?:"+Vr+"|"+_r+")",Yr="[^"+ne+"]",ye="(?:\\ud83c[\\udde6-\\uddff]){2}",Ce="[\\ud800-\\udbff][\\udc00-\\udfff]",x="["+de+"]",Qr="\\u200d",ue="(?:"+he+"|"+be+")",Xr="(?:"+x+"|"+be+")",pe="(?:"+ce+"(?:d|ll|m|re|s|t|ve))?",le="(?:"+ce+"(?:D|LL|M|RE|S|T|VE))?",ve=$r+"?",Re="["+Hr+"]?",et="(?:"+Qr+"(?:"+[Yr,ye,Ce].join("|")+")"+Re+ve+")*",rt="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",tt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",at=Re+ve+et,ot="(?:"+[Kr,ye,Ce].join("|")+")"+at,ft=RegExp([x+"?"+he+"+"+pe+"(?="+[se,x,"$"].join("|")+")",Xr+"+"+le+"(?="+[se,x+ue,"$"].join("|")+")",x+"?"+ue+"+"+pe,x+"+"+le,tt,rt,ge,ot].join("|"),"g");function st(r){return r.match(ft)||[]}var Ne=st;function ut(r,f,e){return r=m(r),f=e?void 0:f,f===void 0?fe(r)?Ne(r):oe(r):r.match(f)||[]}var ke=ut;var pt="['\u2019]",lt=RegExp(pt,"g");function nt(r){return function(f){return ee(ke(ae(f).replace(lt,"")),r,"")}}var Se=nt;var it=Se(function(r,f,e){return f=f.toLowerCase(),r+(e?X(f):f)}),C=it;var mt=new Set(["enum","extends","package","void","short","class","abstract","return","import","for","assert","switch","getClass"]),Te=class r extends v{constructor({ir:e,config:o,options:s}){super({ir:e,config:o,options:s});d(this,"ir");d(this,"customConfig");d(this,"dynamicTypeMapper");d(this,"dynamicTypeLiteralMapper");d(this,"filePropertyMapper");this.ir=e,this.customConfig=o.customConfig!=null?o.customConfig:void 0,this.dynamicTypeMapper=new N({context:this}),this.dynamicTypeLiteralMapper=new R({context:this}),this.filePropertyMapper=new k({context:this})}clone(){return new r({ir:this.ir,config:this.config,options:this.options})}getClassName(e){return this.getName(e.pascalCase.safeName)}getEnumName(e){return this.getName(e.screamingSnakeCase.safeName)}getPropertyName(e){return this.getName(e.camelCase.safeName)}getMethodName(e){return this.getName(e.camelCase.safeName)}getRootClientClassReference(){return l.classReference({name:this.getRootClientClassName(),packageName:this.getRootPackageName()})}getRootClientClassName(){var e,o;return(o=(e=this.customConfig)==null?void 0:e["client-class-name"])!=null?o:`${this.getBaseNamePrefix()}Client`}getEnvironmentClassName(){return"Environment"}getEnvironmentTypeReferenceFromID(e){let o=this.resolveEnvironmentName(e);if(o!=null)return this.getEnvironmentClassReferenceForEnumName(o)}getEnvironmentClassReference(){return l.classReference({name:this.getEnvironmentClassName(),packageName:this.getCorePackageName()})}getEnvironmentClassReferenceForEnumName(e){return l.classReference({name:`${this.getEnvironmentClassName()}.${this.getEnumName(e)}`,packageName:this.getCorePackageName()})}getJavaClassReferenceFromDeclaration({declaration:e}){return l.classReference({name:e.name.pascalCase.unsafeName,packageName:this.getTypesPackageName(e.fernFilepath)})}getNullableClassReference(){return l.classReference({name:"Nullable",packageName:this.getCorePackageName()})}getNullableOfNull(){return l.TypeLiteral.reference(l.invokeMethod({on:this.getNullableClassReference(),method:"ofNull",arguments_:[]}))}getFileStreamFromString(e){return l.TypeLiteral.reference(l.codeblock(o=>{o.write("new "),o.writeNode(this.getFileStreamClassReference()),o.write("("),o.writeNode(this.getByteArrayInputStreamClassReference()),o.write("("),o.writeNode(l.TypeLiteral.string(e)),o.write(".getBytes("),o.writeNode(this.getStandardCharsetsClassReference()),o.write(".UTF_8)))")}))}getFileStreamClassReference(){return l.classReference({name:"FileStream",packageName:this.getCorePackageName()})}getByteArrayInputStreamClassReference(){return l.classReference({name:"ByteArrayInputStream",packageName:"java.io"})}getStandardCharsetsClassReference(){return l.classReference({name:"StandardCharsets",packageName:"java.nio.charset"})}isPrimitive(e){switch(e.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(e.value);case"named":{let o=this.resolveNamedType({typeId:e.value});if(o==null)return!1;switch(o.type){case"alias":return this.isPrimitive(o.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:h(o)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:h(e)}}getRootPackageName(){let e=this.getPackagePrefixTokens();return this.joinPackageTokens(e)}getCorePackageName(){let e=this.getPackagePrefixTokens();return e.push("core"),this.joinPackageTokens(e)}getTypesPackageName(e){return this.getResourcesPackage(e,"types")}getRequestsPackageName(e){return this.getPackageLayout()==="flat"?this.getTypesPackageName(e):this.getResourcesPackage(e,"requests")}getResourcesPackage(e,o){let s=this.getPackagePrefixTokens();switch(this.getPackageLayout()){case"flat":e!=null&&s.push(...e.packagePath.map(n=>this.getPackageNameSegment(n)));break;case"nested":default:e!=null&&e.allParts.length>0&&s.push("resources"),e!=null&&s.push(...e.allParts.map(n=>this.getPackageNameSegment(n)))}return o!=null&&s.push(o),this.joinPackageTokens(s)}getPackageName(e,o){let s=this.getPackageNameSegments(e);return s=o!=null?[...s,o]:s,[...this.getPackagePrefixTokens(),...s].join(".")}getPackageLayout(){var e,o;return(o=(e=this.customConfig)==null?void 0:e["package-layout"])!=null?o:"nested"}getPackageNameSegments(e){return e.packagePath.map(o=>this.getPackageNameSegment(o))}getPackageNameSegment(e){return e.camelCase.safeName.toLowerCase()}getPackagePrefixTokens(){var o;if(((o=this.customConfig)==null?void 0:o["package-prefix"])!=null)return this.customConfig["package-prefix"].split(".");let e=[];return e.push("com"),e.push(...this.splitOnNonAlphaNumericChar(this.config.organization)),e.push(...this.splitOnNonAlphaNumericChar(this.getApiName())),e}getBaseNamePrefix(){return this.convertKebabCaseToUpperCamelCase(this.config.organization)+this.convertKebabCaseToUpperCamelCase(this.getApiName())}getApiName(){return C(this.config.workspaceName)}startsWithNumber(e){return/^\d/.test(e)}splitOnNonAlphaNumericChar(e){return e.split(/[^a-zA-Z0-9]/)}convertKebabCaseToUpperCamelCase(e){return e.replace(/-([a-z])/g,(o,s)=>s.toUpperCase()).replace(/^[a-z]/,o=>o.toUpperCase())}joinPackageTokens(e){return e.map(s=>this.startsWithNumber(s)?"_"+s:s).join(".")}getName(e){return this.isReservedName(e)?"_"+e:e}isReservedName(e){return mt.has(e)}};export{Te as a};
|
|
2
|
+
/*! Bundled license information:
|
|
3
|
+
|
|
4
|
+
lodash-es/lodash.js:
|
|
5
|
+
(**
|
|
6
|
+
* @license
|
|
7
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
8
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
9
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
10
|
+
* Released under MIT license <https://lodash.com/license>
|
|
11
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
12
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
13
|
+
*)
|
|
14
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as e,m as l}from"./chunk-2AZXIWKY.js";e();l();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as c}from"./chunk-WFKWXM7L.js";import{a as s,c as n}from"./chunk-AASPH6YC.js";import{j as l,k as u,m as p}from"./chunk-2AZXIWKY.js";u();p();var d=class{constructor({context:e}){l(this,"context");this.context=e}convert(e){if(e.value===null)return this.context.isNullable(e.typeReference)?this.context.getNullableOfNull():(this.context.errors.add({severity:c.Critical,message:"Expected non-null value, but got null"}),n.TypeLiteral.nop());if(e.value===void 0)return n.TypeLiteral.nop();switch(e.typeReference.type){case"list":return this.convertList({list:e.typeReference.value,value:e.value});case"literal":return this.convertLiteral({literal:e.typeReference.value,value:e.value});case"map":return this.convertMap({map:e.typeReference,value:e.value});case"named":{let t=this.context.resolveNamedType({typeId:e.typeReference.value});return t==null?n.TypeLiteral.nop():this.convertNamed({named:t,value:e.value,as:e.as})}case"nullable":case"optional":return n.TypeLiteral.optional({value:this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as}),useOf:e.as==="mapValue"});case"primitive":return this.convertPrimitive({primitive:e.typeReference.value,value:e.value,as:e.as});case"set":return this.convertSet({set:e.typeReference.value,value:e.value});case"unknown":return this.convertUnknown({value:e.value});default:s(e.typeReference)}}convertList({list:e,value:t}){return Array.isArray(t)?n.TypeLiteral.list({valueType:this.context.dynamicTypeMapper.convert({typeReference:e}),values:t.map((i,r)=>{this.context.errors.scope({index:r});try{return this.convert({typeReference:e,value:i})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:c.Critical,message:`Expected array but got: ${typeof t}`}),n.TypeLiteral.nop())}convertLiteral({literal:e,value:t}){switch(e.type){case"boolean":{let i=this.context.getValueAsBoolean({value:t});return i==null?n.TypeLiteral.nop():n.TypeLiteral.boolean(i)}case"string":{let i=this.context.getValueAsString({value:t});return i==null?n.TypeLiteral.nop():n.TypeLiteral.string(i)}default:s(e)}}convertSet({set:e,value:t}){return Array.isArray(t)?n.TypeLiteral.set({valueType:this.context.dynamicTypeMapper.convert({typeReference:e}),values:t.map((i,r)=>{this.context.errors.scope({index:r});try{return this.convert({typeReference:e,value:i})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:c.Critical,message:`Expected array but got: ${typeof t}`}),n.TypeLiteral.nop())}convertMap({map:e,value:t}){return typeof t!="object"||t==null?(this.context.errors.add({severity:c.Critical,message:`Expected object but got: ${t==null?"null":typeof t}`}),n.TypeLiteral.nop()):n.TypeLiteral.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:e.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:e.value}),entries:Object.entries(t).map(([i,r])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:e.key,value:i,as:"mapKey"}),value:this.convert({typeReference:e.value,value:r,as:"mapValue"})}}finally{this.context.errors.unscope()}})})}convertNamed({named:e,value:t,as:i}){switch(e.type){case"alias":return this.convert({typeReference:e.typeReference,value:t,as:i});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:e,value:t});case"enum":return this.convertEnum({enum_:e,value:t});case"object":return this.convertObject({object_:e,value:t,as:i});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t});default:s(e)}}convertDiscriminatedUnion({discriminatedUnion:e,value:t}){let i=this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),r=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t});if(r==null)return n.TypeLiteral.nop();let a=r.singleDiscriminatedUnionType;switch(a.type){case"samePropertiesAsObject":{let o=this.context.resolveNamedType({typeId:a.typeId});return o==null?n.TypeLiteral.nop():n.TypeLiteral.reference(n.invokeMethod({on:i,method:this.context.getPropertyName(a.discriminantValue.name),arguments_:[this.convertNamed({named:o,value:r.value})]}))}case"singleProperty":{let o=this.context.getRecord(r.value);if(o==null)return n.TypeLiteral.nop();try{return this.context.errors.scope(a.discriminantValue.wireValue),n.TypeLiteral.reference(n.invokeMethod({on:i,method:this.context.getPropertyName(a.discriminantValue.name),arguments_:[this.convert({typeReference:a.typeReference,value:o[a.discriminantValue.wireValue]})]}))}finally{this.context.errors.unscope()}}case"noProperties":return n.TypeLiteral.reference(n.invokeMethod({on:i,method:this.context.getPropertyName(a.discriminantValue.name),arguments_:[]}));default:s(a)}}convertObject({object_:e,value:t,as:i}){var a;let r=this.context.associateByWireValue({parameters:e.properties,values:(a=this.context.getRecord(t))!=null?a:{}});return n.TypeLiteral.builder({classReference:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),parameters:r.map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getMethodName(o.name.name),value:this.convert({typeReference:o.typeReference,value:o.value,as:i})}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:e,value:t}){let i=this.getEnumValueName({enum_:e,value:t});return i==null?n.TypeLiteral.nop():n.TypeLiteral.enum_({classReference:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),value:i})}getEnumValueName({enum_:e,value:t}){if(typeof t!="string"){this.context.errors.add({severity:c.Critical,message:`Expected enum value string, got: ${typeof t}`});return}let i=e.values.find(r=>r.wireValue===t);if(i==null){this.context.errors.add({severity:c.Critical,message:`An enum value named "${t}" does not exist in this context`});return}return this.context.getEnumName(i.name)}convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t}){let i=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t});if(i==null)return n.TypeLiteral.nop();if(this.context.isPrimitive(i.valueTypeReference))return n.TypeLiteral.reference(n.invokeMethod({on:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),method:"of",arguments_:[i.typeInstantiation]}));let r=this.getUndiscriminatedUnionFieldName({typeReference:i.valueTypeReference});return r==null?n.TypeLiteral.nop():n.TypeLiteral.reference(n.invokeMethod({on:this.context.getJavaClassReferenceFromDeclaration({declaration:e.declaration}),method:`of${r}`,arguments_:[i.typeInstantiation]}))}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t}){for(let i of e.types)try{let r=this.convert({typeReference:i,value:t});return{valueTypeReference:i,typeInstantiation:r}}catch(r){continue}this.context.errors.add({severity:c.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof t}" value`})}getUndiscriminatedUnionFieldName({typeReference:e}){switch(e.type){case"list":return this.getUndiscriminatedUnionFieldNameForList({list:e});case"literal":return this.getUndiscriminatedUnionFieldNameForLiteral({literal:e.value});case"map":return this.getUndiscriminatedUnionFieldNameForMap({map:e});case"named":{let t=this.context.resolveNamedType({typeId:e.value});return t==null?void 0:this.context.getClassName(t.declaration.name)}case"optional":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:e});case"nullable":return this.getUndiscriminatedUnionFieldNameForNullable({typeReference:e});case"primitive":return this.getUndiscriminatedUnionFieldNameForPrimitive({primitive:e.value});case"set":return this.getUndiscriminatedUnionFieldNameForSet({set:e});case"unknown":return"Unknown";default:s(e)}}getUndiscriminatedUnionFieldNameForList({list:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`ListOf${t}`}getUndiscriminatedUnionFieldNameForMap({map:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e.key});if(t==null)return;let i=this.getUndiscriminatedUnionFieldName({typeReference:e.value});if(i!=null)return`MapOf${t}To${i}`}getUndiscriminatedUnionFieldNameForOptional({typeReference:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`Optional${t}`}getUndiscriminatedUnionFieldNameForNullable({typeReference:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`Nullable${t}`}getUndiscriminatedUnionFieldNameForSet({set:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`SetOf${t}`}getUndiscriminatedUnionFieldNameForLiteral({literal:e}){}getUndiscriminatedUnionFieldNameForPrimitive({primitive:e}){switch(e){case"INTEGER":case"UINT":return"Integer";case"LONG":case"UINT_64":return"Long";case"FLOAT":return"Float";case"DOUBLE":return"Double";case"BOOLEAN":return"Boolean";case"BIG_INTEGER":return"BigInteger";case"STRING":return"String";case"UUID":return"Uuid";case"DATE":return"Date";case"DATE_TIME":return"DateTime";case"BASE_64":return"Base64";default:s(e)}}convertUnknown({value:e}){return n.TypeLiteral.unknown(e)}convertPrimitive({primitive:e,value:t,as:i}){switch(e){case"INTEGER":case"UINT":{let r=this.getValueAsNumber({value:t,as:i});return r==null?n.TypeLiteral.nop():n.TypeLiteral.integer(r)}case"LONG":case"UINT_64":{let r=this.getValueAsNumber({value:t,as:i});return r==null?n.TypeLiteral.nop():n.TypeLiteral.long(r)}case"FLOAT":{let r=this.getValueAsNumber({value:t,as:i});return r==null?n.TypeLiteral.nop():n.TypeLiteral.float(r)}case"DOUBLE":{let r=this.getValueAsNumber({value:t,as:i});return r==null?n.TypeLiteral.nop():n.TypeLiteral.double(r)}case"BOOLEAN":{let r=this.getValueAsBoolean({value:t,as:i});return r==null?n.TypeLiteral.nop():n.TypeLiteral.boolean(r)}case"STRING":{let r=this.context.getValueAsString({value:t});return r==null?n.TypeLiteral.nop():n.TypeLiteral.string(r)}case"DATE":{let r=this.context.getValueAsString({value:t});return r==null?n.TypeLiteral.nop():n.TypeLiteral.string(r)}case"DATE_TIME":{let r=this.context.getValueAsString({value:t});return r==null?n.TypeLiteral.nop():n.TypeLiteral.dateTime(r)}case"UUID":{let r=this.context.getValueAsString({value:t});return r==null?n.TypeLiteral.nop():n.TypeLiteral.uuid(r)}case"BASE_64":{let r=this.context.getValueAsString({value:t});return r==null?n.TypeLiteral.nop():n.TypeLiteral.bytes(r)}case"BIG_INTEGER":{let r=this.context.getValueAsString({value:t});return r==null?n.TypeLiteral.nop():n.TypeLiteral.bigInteger(r)}default:s(e)}}getValueAsNumber({value:e,as:t}){let i=t==="mapKey"&&typeof e=="string"?Number(e):e;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:e,as:t}){let i=t==="mapKey"?typeof e=="string"?e==="true":e==="false"?!1:e:e;return this.context.getValueAsBoolean({value:i})}};export{d as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as m,b as E}from"./chunk-AASPH6YC.js";import{a as T,b as S,c as b,d as A,j as l,k as o,m as a}from"./chunk-2AZXIWKY.js";o();a();o();a();var y=class{constructor(){l(this,"reporter");l(this,"snippet");l(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:e,snippet:r}){this.shouldUpdate({snippet:r,reporter:e.errors})&&(this.reporter=e.errors.clone(),this.snippet=r)}getResponseOrThrow({endpoint:e}){var r;if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw(r=this.err)!=null?r:new Error(`Failed to generate snippet for endpoint "${e.method} ${e.path}"`)}shouldUpdate({snippet:e,reporter:r}){var t,n;return this.reporter==null||this.reporter.size()>0&&r.size()===0?!0:e.length>((n=(t=this.snippet)==null?void 0:t.length)!=null?n:0)}};var R=class{constructor(e){l(this,"context");this.context=e}async generate(e,r={}){let t=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(t.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let n=new y;for(let i of t){let s=this.context.clone(),d=this.createSnippetGenerator(s);try{let u=await d.generateSnippet({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:u,errors:void 0};n.update({context:s,snippet:u})}catch(u){n.err==null&&(n.err=u)}}return n.getResponseOrThrow({endpoint:e.endpoint})}generateSync(e,r={}){let t=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(t.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let n=new y;for(let i of t){let s=this.context.clone(),d=this.createSnippetGenerator(s);try{let u=d.generateSnippetSync({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:u,errors:void 0};n.update({context:s,snippet:u})}catch(u){n.err==null&&(n.err=u)}}return n.getResponseOrThrow({endpoint:e.endpoint})}};o();a();var p={Critical:"CRITICAL",Warning:"WARNING"},g=class c{constructor(){l(this,"errors");l(this,"path");this.errors=[],this.path=[]}add(e){this.errors.push(S(T({},e),{path:[...this.path]}))}scope(e){this.path.push(e)}unscope(){this.path.pop()}getBySeverity(e){return this.errors.filter(r=>r.severity===e)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let e=new c;return e.errors=[...this.errors],e.path=[...this.path],e}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(e=>({severity:e.severity,path:e.path!=null?this.pathToStringArray(e.path):void 0,message:e.message}))}pathToStringArray(e){let r=[];for(let t of e){if(typeof t=="string"){r.push(t);continue}r[r.length-1]+=`[${t.index}]`}return r}};o();a();o();a();o();a();var v=class{constructor(){l(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH)\s(\/[a-zA-Z0-9\/{}_-]*)$/)}validate(e){return this.REFERENCE_REGEX.test(e)?{type:"valid"}:{type:"invalid"}}tryParse(e){if(this.validate(e).type==="invalid")return;let t=e.match(this.REFERENCE_REGEX);if(!(t==null||t[1]==null||t[2]==null))return{method:t[1],path:t[2]}}};var w=class{constructor({ir:e,config:r,options:t={}}){l(this,"config");l(this,"options");l(this,"errors");l(this,"_ir");l(this,"httpEndpointReferenceParser");this._ir=e,this.config=r,this.options=t,this.errors=new g,this.httpEndpointReferenceParser=new v}associateQueryParametersByWireValue({parameters:e,values:r}){let t=[];for(let[n,i]of Object.entries(r)){this.errors.scope(n);try{let s=e.find(u=>u.name.wireValue===n);if(s==null)throw this.newParameterNotRecognizedError(n);let d=this.isListTypeReference(s.typeReference)&&!Array.isArray(i)?[i]:i;t.push({name:s.name,typeReference:s.typeReference,value:d})}finally{this.errors.unscope()}}return t}associateByWireValue({parameters:e,values:r,ignoreMissingParameters:t}){let n=[];for(let[i,s]of Object.entries(r)){this.errors.scope(i);try{let d=e.find(u=>u.name.wireValue===i);if(d==null){if(t)continue;this.errors.add({severity:p.Critical,message:this.newParameterNotRecognizedError(i).message});continue}n.push({name:d.name,typeReference:d.typeReference,value:s})}finally{this.errors.unscope()}}return n}getSingleFileValue({property:e,record:r}){let t=r[e.wireValue];if(t!=null){if(typeof t!="string"){this.errors.add({severity:p.Critical,message:`Expected file value to be a string, got ${typeof t}`});return}return t}}getFileArrayValues({property:e,record:r}){let t=r[e.wireValue];if(t==null)return;if(!Array.isArray(t)){this.errors.add({severity:p.Critical,message:`Expected file array value to be an array of strings, got ${typeof t}`});return}let n=[];for(let i of t){if(typeof i!="string"){this.errors.add({severity:p.Critical,message:`Expected file array value to be an array of strings, got ${typeof i}`});return}n.push(i)}return n}getRecord(e){if(typeof e!="object"||Array.isArray(e)){this.errors.add({severity:p.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(e)?"array":typeof e}`});return}return e==null?{}:e}resolveNamedType({typeId:e}){let r=this._ir.types[e];if(r==null){this.errors.add({severity:p.Critical,message:`Type identified by "${e}" could not be found`});return}return r}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:r}){let t=this.getRecord(r);if(t==null)return;let n=e.discriminant.wireValue,i=t[n];if(i==null){this.errors.add({severity:p.Critical,message:this.newParameterNotRecognizedError(n).message});return}if(typeof i!="string"){this.errors.add({severity:p.Critical,message:`Expected discriminant value to be a string but got: ${typeof i}`});return}let s=e.types[i];if(s==null){this.errors.add({severity:p.Critical,message:`No type found for discriminant value "${i}"`});return}let P=t,{[n]:d}=P,u=A(P,[b(n)]);return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:u}}resolveEndpointOrThrow(e){let r=this.httpEndpointReferenceParser.tryParse(e);if(r==null)throw new Error(`Failed to parse endpoint reference "${e}"`);return this.resolveEndpointLocationOrThrow(r)}resolveEndpointLocationOrThrow(e){let r=[];for(let t of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:t,parsedEndpoint:e})&&r.push(t);if(r.length===0)throw new Error(`Failed to find endpoint identified by "${e.method} ${e.path}"`);return r}needsRequestParameter({request:e,inlinePathParameters:r,inlineFileProperties:t}){var n;return this.includePathParametersInWrappedRequest({request:e,inlinePathParameters:r})||e.queryParameters!=null&&e.queryParameters.length>0||e.headers!=null&&e.headers.length>0?!0:e.body!=null?this.includeRequestBodyInWrappedRequest({body:e.body,inlineFileProperties:t}):!((n=e.metadata)!=null&&n.onlyPathParameters)}includePathParametersInWrappedRequest({request:e,inlinePathParameters:r}){var t,n;return r&&((n=(t=e.metadata)==null?void 0:t.includePathParameters)!=null?n:!1)}isFileUploadRequestBody(e){switch(e.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:m(e)}}resolveEnvironmentName(e){if(this._ir.environments==null)return;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}case"multipleBaseUrls":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}default:m(r)}}isSingleEnvironmentID(e){return typeof e=="string"}isMultiEnvironmentValues(e){return typeof e=="object"}validateMultiEnvironmentUrlValues(e){if(this._ir.environments==null)return this.errors.add({severity:p.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":return this.errors.add({severity:p.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let t=r.environments[0];if(t==null)return this.errors.add({severity:p.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let n=new Set(E(t.urls));for(let i of E(e))n.has(i)&&n.delete(i);return n.size>0?(this.errors.add({severity:p.Critical,message:`The provided environments are invalid; got: [${Object.keys(e).join(", ")}], expected: [${E(t.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:e}){if(typeof e!="number"){this.errors.add({severity:p.Critical,message:this.newTypeMismatchError({expected:"number",value:e}).message});return}return e}getValueAsBoolean({value:e}){if(typeof e!="boolean"){this.errors.add({severity:p.Critical,message:this.newTypeMismatchError({expected:"boolean",value:e}).message});return}return e}getValueAsString({value:e}){if(typeof e!="string"){this.errors.add({severity:p.Critical,message:this.newTypeMismatchError({expected:"string",value:e}).message});return}return e}isOptional(e){switch(e.type){case"nullable":return this.isOptional(e.value);case"optional":return!0;case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}isNullable(e){switch(e.type){case"nullable":return!0;case"optional":return this.isNullable(e.value);case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}newAuthMismatchError({auth:e,values:r}){return new Error(`Expected auth type ${e.type}, got ${r.type}`)}newParameterNotRecognizedError(e){return new Error(`"${e}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:e,value:r}){return new Error(`Expected ${e}, got ${typeof r}`)}includeRequestBodyInWrappedRequest({body:e,inlineFileProperties:r}){switch(e.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r});default:m(e)}}includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r}){return this.fileUploadHasBodyProperties({fileUpload:e})||r&&this.fileUploadHasFileProperties({fileUpload:e})}fileUploadHasBodyProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:m(r)}})}fileUploadHasFileProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:m(r)}})}isListTypeReference(e){return e.type==="optional"?this.isListTypeReference(e.value):e.type==="list"||e.type==="set"}parsedEndpointMatches({endpoint:e,parsedEndpoint:r}){return e.location.method===r.method&&e.location.path===r.path}};o();a();var x;(function(c){c.Concise="concise",c.Full="full"})(x||(x={}));o();a();var C={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};o();a();export{R as a,p as b,w as c,x as d,C as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-GHM3YOPV.js";import"../chunk-JSEUWNSK.js";import"../chunk-WFKWXM7L.js";import"../chunk-7CY27UU7.js";import"../chunk-452HWDL4.js";import"../chunk-AASPH6YC.js";import"../chunk-2AZXIWKY.js";export{a as DynamicSnippetsGeneratorContext};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-JSEUWNSK.js";import"../chunk-WFKWXM7L.js";import"../chunk-AASPH6YC.js";import"../chunk-2AZXIWKY.js";export{a as DynamicTypeLiteralMapper};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-7CY27UU7.js";import"../chunk-AASPH6YC.js";import"../chunk-2AZXIWKY.js";export{a as DynamicTypeMapper};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-452HWDL4.js";import"../chunk-AASPH6YC.js";import"../chunk-2AZXIWKY.js";export{a as FilePropertyMapper};
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Config } from './Config.js';
|
|
2
|
+
export { DynamicSnippetsGenerator } from './DynamicSnippetsGenerator.js';
|
|
3
|
+
import '@fern-api/browser-compatible-base-generator';
|
|
4
|
+
import '@fern-api/dynamic-ir-sdk';
|
|
5
|
+
import './EndpointSnippetGenerator.js';
|
|
6
|
+
import './DynamicSnippetsGeneratorContext-CjKFdkU7.js';
|
|
7
|
+
import '@fern-api/java-ast';
|