@arrirpc/codegen-ts 0.76.0 → 0.76.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -928,6 +928,7 @@ function httpRpcFromDefinition(def, context) {
928
928
  {
929
929
  url: \`\${this._baseUrl}${def.path}\`,
930
930
  method: "${def.method.toLowerCase()}",
931
+ ofetch: this._fetch,
931
932
  headers: this._headers,
932
933
  onError: this._onError,
933
934
  ${params ? "params: params," : ""}
@@ -947,6 +948,7 @@ function httpRpcFromDefinition(def, context) {
947
948
  return arriRequest<${response ?? "undefined"}, ${params ?? "undefined"}>({
948
949
  url: \`\${this._baseUrl}${def.path}\`,
949
950
  method: "${def.method.toLowerCase()}",
951
+ ofetch: this._fetch,
950
952
  headers: this._headers,
951
953
  onError: this._onError,
952
954
  ${params ? "params: params," : ""}
@@ -1044,17 +1046,22 @@ function tsServiceFromDefinition(def, context) {
1044
1046
  name: serviceName,
1045
1047
  content: `export class ${serviceName} {
1046
1048
  private readonly _baseUrl: string;
1049
+ private readonly _fetch?: $Fetch;
1047
1050
  private readonly _headers: HeaderMap | (() => HeaderMap | Promise<HeaderMap>);
1048
1051
  private readonly _onError?: (err: unknown) => void;
1049
1052
  ${subServices.map((service) => ` ${service.key}: ${service.name};`).join("\n")}
1050
1053
  constructor(
1051
1054
  options: {
1052
1055
  baseUrl?: string;
1056
+ fetch?: Fetch;
1053
1057
  headers?: HeaderMap | (() => HeaderMap | Promise<HeaderMap>);
1054
1058
  onError?: (err: unknown) => void;
1055
1059
  } = {},
1056
1060
  ) {
1057
1061
  this._baseUrl = options.baseUrl ?? "";
1062
+ if (options.fetch) {
1063
+ this._fetch = createFetch({ fetch: options.fetch });
1064
+ }
1058
1065
  this._headers = options.headers ?? {};
1059
1066
  this._onError = options.onError;
1060
1067
  ${subServices.map((service) => ` this.${service.key} = new ${service.name}(options);`).join("\n")}
@@ -1162,6 +1169,9 @@ import {
1162
1169
  UINT16_MAX,
1163
1170
  UINT32_MAX,
1164
1171
  UINT64_MAX,
1172
+ type Fetch,
1173
+ type $Fetch,
1174
+ createFetch,
1165
1175
  ${context.usedFeatures.ws ? "type WsController," : ""}
1166
1176
  ${context.usedFeatures.ws ? "type WsOptions," : ""}
1167
1177
  } from "@arrirpc/client";
package/dist/index.mjs CHANGED
@@ -922,6 +922,7 @@ function httpRpcFromDefinition(def, context) {
922
922
  {
923
923
  url: \`\${this._baseUrl}${def.path}\`,
924
924
  method: "${def.method.toLowerCase()}",
925
+ ofetch: this._fetch,
925
926
  headers: this._headers,
926
927
  onError: this._onError,
927
928
  ${params ? "params: params," : ""}
@@ -941,6 +942,7 @@ function httpRpcFromDefinition(def, context) {
941
942
  return arriRequest<${response ?? "undefined"}, ${params ?? "undefined"}>({
942
943
  url: \`\${this._baseUrl}${def.path}\`,
943
944
  method: "${def.method.toLowerCase()}",
945
+ ofetch: this._fetch,
944
946
  headers: this._headers,
945
947
  onError: this._onError,
946
948
  ${params ? "params: params," : ""}
@@ -1038,17 +1040,22 @@ function tsServiceFromDefinition(def, context) {
1038
1040
  name: serviceName,
1039
1041
  content: `export class ${serviceName} {
1040
1042
  private readonly _baseUrl: string;
1043
+ private readonly _fetch?: $Fetch;
1041
1044
  private readonly _headers: HeaderMap | (() => HeaderMap | Promise<HeaderMap>);
1042
1045
  private readonly _onError?: (err: unknown) => void;
1043
1046
  ${subServices.map((service) => ` ${service.key}: ${service.name};`).join("\n")}
1044
1047
  constructor(
1045
1048
  options: {
1046
1049
  baseUrl?: string;
1050
+ fetch?: Fetch;
1047
1051
  headers?: HeaderMap | (() => HeaderMap | Promise<HeaderMap>);
1048
1052
  onError?: (err: unknown) => void;
1049
1053
  } = {},
1050
1054
  ) {
1051
1055
  this._baseUrl = options.baseUrl ?? "";
1056
+ if (options.fetch) {
1057
+ this._fetch = createFetch({ fetch: options.fetch });
1058
+ }
1052
1059
  this._headers = options.headers ?? {};
1053
1060
  this._onError = options.onError;
1054
1061
  ${subServices.map((service) => ` this.${service.key} = new ${service.name}(options);`).join("\n")}
@@ -1156,6 +1163,9 @@ import {
1156
1163
  UINT16_MAX,
1157
1164
  UINT32_MAX,
1158
1165
  UINT64_MAX,
1166
+ type Fetch,
1167
+ type $Fetch,
1168
+ createFetch,
1159
1169
  ${context.usedFeatures.ws ? "type WsController," : ""}
1160
1170
  ${context.usedFeatures.ws ? "type WsOptions," : ""}
1161
1171
  } from "@arrirpc/client";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arrirpc/codegen-ts",
3
- "version": "0.76.0",
3
+ "version": "0.76.3-beta.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -23,6 +23,6 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "prettier": "^3.5.1",
26
- "@arrirpc/codegen-utils": "0.76.0"
26
+ "@arrirpc/codegen-utils": "0.76.3-beta.0"
27
27
  }
28
28
  }