apixa 0.1.0 → 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/README.md +57 -13
  2. package/dist/{chunk-QZIU7J3G.js → chunks/chunk-3ZFOEESZ.js} +1 -1
  3. package/dist/{chunk-QVKMZELC.js → chunks/chunk-6WSJJKM6.js} +1 -1
  4. package/dist/{chunk-SIFGLE22.js → chunks/chunk-7U7EGEIJ.js} +43 -14
  5. package/dist/chunks/chunk-BRBSHKI5.js +360 -0
  6. package/dist/{chunk-IAQ5YOVE.js → chunks/chunk-D2GA433L.js} +1 -1
  7. package/dist/{chunk-6ZX7GAWG.js → chunks/chunk-I5JYOAUR.js} +1 -1
  8. package/dist/{chunk-LARJYKRJ.js → chunks/chunk-JM47QQH6.js} +15 -15
  9. package/dist/{chunk-MLPW6EET.js → chunks/chunk-K4ELX7MW.js} +1 -1
  10. package/dist/{chunk-R4FXTZWU.js → chunks/chunk-OO6JF76I.js} +1 -1
  11. package/dist/{chunk-GWZTJ7LM.js → chunks/chunk-RYTQAJRH.js} +177 -175
  12. package/dist/{data-GNCSLYM4.js → chunks/data-4B7QV4F5.js} +1 -1
  13. package/dist/{data-B47EIZXW.js → chunks/data-7ISALG7G.js} +1 -1
  14. package/dist/{data-GTTIEVFI.js → chunks/data-HAGFVAZM.js} +1 -1
  15. package/dist/{data-DL4IKJCX.js → chunks/data-HNAJ5IYV.js} +1 -1
  16. package/dist/chunks/data-WOMFLQWC.js +6 -0
  17. package/dist/chunks/data-ZPXVMWRQ.js +6 -0
  18. package/dist/core.d.ts +1 -0
  19. package/dist/core.js +80 -0
  20. package/dist/index.d.ts +1 -305
  21. package/dist/index.js +11 -25
  22. package/dist/mocking/datasets/comments.d.ts +1 -6
  23. package/dist/mocking/datasets/comments.js +2 -2
  24. package/dist/mocking/datasets/companies.d.ts +1 -6
  25. package/dist/mocking/datasets/companies.js +2 -2
  26. package/dist/mocking/datasets/index.d.ts +1 -18
  27. package/dist/mocking/datasets/index.js +15 -15
  28. package/dist/mocking/datasets/orders.d.ts +1 -6
  29. package/dist/mocking/datasets/orders.js +2 -2
  30. package/dist/mocking/datasets/posts.d.ts +1 -6
  31. package/dist/mocking/datasets/posts.js +2 -2
  32. package/dist/mocking/datasets/products.d.ts +1 -6
  33. package/dist/mocking/datasets/products.js +2 -2
  34. package/dist/mocking/datasets/users.d.ts +1 -6
  35. package/dist/mocking/datasets/users.js +2 -2
  36. package/dist/mocking/index.d.ts +1 -317
  37. package/dist/mocking/index.js +4 -351
  38. package/dist/mocking/node.d.ts +1 -33
  39. package/dist/mocking/node.js +5 -4
  40. package/dist/mocking/register.d.ts +1 -2
  41. package/dist/mocking/register.js +2 -2
  42. package/dist/react/advanced.d.ts +1 -111
  43. package/dist/react/advanced.js +17 -6
  44. package/dist/react/index.d.ts +1 -283
  45. package/dist/react/index.js +29 -7
  46. package/dist/types/packages/core/src/api/client.d.ts +11 -0
  47. package/dist/types/packages/core/src/api/define-api.d.ts +9 -0
  48. package/dist/types/packages/core/src/api/define-apis.d.ts +9 -0
  49. package/dist/types/packages/core/src/api/index.d.ts +3 -0
  50. package/dist/types/packages/core/src/api/metadata.d.ts +32 -0
  51. package/dist/types/packages/core/src/api/reset.d.ts +7 -0
  52. package/dist/types/packages/core/src/api/resource-client.d.ts +20 -0
  53. package/dist/types/packages/core/src/api/validate.d.ts +20 -0
  54. package/dist/types/packages/core/src/errors/abort-error.d.ts +4 -0
  55. package/dist/types/packages/core/src/errors/api-error.d.ts +22 -0
  56. package/dist/types/packages/core/src/errors/config-error.d.ts +5 -0
  57. package/dist/types/packages/core/src/errors/guards.d.ts +8 -0
  58. package/dist/types/packages/core/src/errors/http-error.d.ts +8 -0
  59. package/dist/types/packages/core/src/errors/index.d.ts +13 -0
  60. package/dist/types/packages/core/src/errors/mock-error.d.ts +10 -0
  61. package/dist/types/packages/core/src/errors/network-error.d.ts +4 -0
  62. package/dist/types/packages/core/src/errors/parse-error.d.ts +4 -0
  63. package/dist/types/packages/core/src/errors/security-error.d.ts +5 -0
  64. package/dist/types/packages/core/src/errors/timeout-error.d.ts +4 -0
  65. package/dist/types/packages/core/src/errors/transform-error.d.ts +11 -0
  66. package/dist/types/packages/core/src/errors/validation-error.d.ts +4 -0
  67. package/dist/types/packages/core/src/http/body.d.ts +2 -0
  68. package/dist/types/packages/core/src/http/headers.d.ts +9 -0
  69. package/dist/types/packages/core/src/http/index.d.ts +5 -0
  70. package/dist/types/packages/core/src/http/path.d.ts +6 -0
  71. package/dist/types/packages/core/src/http/query.d.ts +3 -0
  72. package/dist/types/packages/core/src/http/url.d.ts +27 -0
  73. package/dist/types/packages/core/src/index.d.ts +16 -0
  74. package/dist/types/packages/core/src/mock/datasets.d.ts +31 -0
  75. package/dist/types/packages/core/src/mock/execute.d.ts +27 -0
  76. package/dist/types/packages/core/src/mock/handler.d.ts +46 -0
  77. package/dist/types/packages/core/src/mock/index.d.ts +5 -0
  78. package/dist/types/packages/core/src/mock/source.d.ts +21 -0
  79. package/dist/types/packages/core/src/mock/store.d.ts +73 -0
  80. package/dist/types/packages/core/src/operation/args.d.ts +7 -0
  81. package/dist/types/packages/core/src/operation/conventions.d.ts +122 -0
  82. package/dist/types/packages/core/src/operation/expand.d.ts +12 -0
  83. package/dist/types/packages/core/src/operation/index.d.ts +4 -0
  84. package/dist/types/packages/core/src/request/index.d.ts +2 -0
  85. package/dist/types/packages/core/src/request/pipeline.d.ts +95 -0
  86. package/dist/types/packages/core/src/request/retry.d.ts +17 -0
  87. package/dist/types/packages/core/src/transform/index.d.ts +1 -0
  88. package/dist/types/packages/core/src/transform/keys.d.ts +12 -0
  89. package/dist/types/packages/core/src/transport/fetch.d.ts +2 -0
  90. package/dist/types/packages/core/src/transport/index.d.ts +2 -0
  91. package/dist/types/packages/core/src/transport/read-body.d.ts +2 -0
  92. package/dist/types/packages/core/src/types/builtins.d.ts +48 -0
  93. package/dist/types/packages/core/src/types/definition.d.ts +154 -0
  94. package/dist/types/packages/core/src/types/errors.d.ts +20 -0
  95. package/dist/types/packages/core/src/types/http.d.ts +29 -0
  96. package/dist/types/packages/core/src/types/index.d.ts +11 -0
  97. package/dist/types/packages/core/src/types/inference.d.ts +600 -0
  98. package/dist/types/packages/core/src/types/middleware.d.ts +35 -0
  99. package/dist/{mock-datasets-Xa9NXK9n.d.ts → types/packages/core/src/types/mock-datasets.d.ts} +19 -20
  100. package/dist/types/packages/core/src/types/mock-handler.d.ts +54 -0
  101. package/dist/types/packages/core/src/types/retry.d.ts +47 -0
  102. package/dist/types/packages/core/src/types/transform.d.ts +27 -0
  103. package/dist/types/packages/core/src/types/transport.d.ts +79 -0
  104. package/dist/types/packages/core/src/utils/slice.d.ts +12 -0
  105. package/dist/types/packages/internal/shared/src/index.d.ts +4 -0
  106. package/dist/types/packages/internal/shared/src/keys.d.ts +25 -0
  107. package/dist/types/packages/internal/shared/src/operations.d.ts +20 -0
  108. package/dist/types/packages/mocking/src/catalog.d.ts +26 -0
  109. package/dist/types/packages/mocking/src/data/entities.d.ts +5 -0
  110. package/dist/types/packages/mocking/src/dataset-modules/comments.d.ts +4 -0
  111. package/dist/types/packages/mocking/src/dataset-modules/companies.d.ts +4 -0
  112. package/dist/types/packages/mocking/src/dataset-modules/orders.d.ts +4 -0
  113. package/dist/types/packages/mocking/src/dataset-modules/posts.d.ts +4 -0
  114. package/dist/types/packages/mocking/src/dataset-modules/products.d.ts +4 -0
  115. package/dist/types/packages/mocking/src/dataset-modules/users.d.ts +4 -0
  116. package/dist/types/packages/mocking/src/datasets.d.ts +17 -0
  117. package/dist/types/packages/mocking/src/discover.d.ts +3 -0
  118. package/dist/types/packages/mocking/src/errors.d.ts +17 -0
  119. package/dist/types/packages/mocking/src/index.d.ts +19 -0
  120. package/dist/types/packages/mocking/src/load.d.ts +15 -0
  121. package/dist/types/packages/mocking/src/loader.d.ts +16 -0
  122. package/dist/types/packages/mocking/src/mock-api.d.ts +25 -0
  123. package/dist/types/packages/mocking/src/mock-types.d.ts +279 -0
  124. package/dist/types/packages/mocking/src/node.d.ts +8 -0
  125. package/dist/types/packages/mocking/src/paths.d.ts +6 -0
  126. package/dist/types/packages/mocking/src/register.d.ts +1 -0
  127. package/dist/types/packages/mocking/src/registry.d.ts +11 -0
  128. package/dist/types/packages/mocking/src/resource.d.ts +13 -0
  129. package/dist/types/packages/mocking/src/slice.d.ts +16 -0
  130. package/dist/{types-mSoi1qGP.d.ts → types/packages/mocking/src/types.d.ts} +6 -8
  131. package/dist/types/packages/react/src/advanced.d.ts +28 -0
  132. package/dist/types/packages/react/src/cache.d.ts +15 -0
  133. package/dist/types/packages/react/src/compose.d.ts +10 -0
  134. package/dist/types/packages/react/src/controller.d.ts +11 -0
  135. package/dist/types/packages/react/src/hydration-boundary.d.ts +11 -0
  136. package/dist/types/packages/react/src/hydration.d.ts +5 -0
  137. package/dist/types/packages/react/src/index.d.ts +17 -0
  138. package/dist/types/packages/react/src/keys.d.ts +7 -0
  139. package/dist/types/packages/react/src/mutation-controller.d.ts +40 -0
  140. package/dist/types/packages/react/src/mutation-store.d.ts +57 -0
  141. package/dist/types/packages/react/src/mutation-types.d.ts +125 -0
  142. package/dist/types/packages/react/src/optimistic.d.ts +55 -0
  143. package/dist/types/packages/react/src/provider.d.ts +14 -0
  144. package/dist/types/packages/react/src/query-client.d.ts +31 -0
  145. package/dist/types/packages/react/src/query-controller.d.ts +49 -0
  146. package/dist/types/packages/react/src/query-helpers.d.ts +112 -0
  147. package/dist/types/packages/react/src/query-options.d.ts +152 -0
  148. package/dist/types/packages/react/src/types.d.ts +123 -0
  149. package/dist/types/packages/react/src/use-resource-mutation.d.ts +34 -0
  150. package/dist/types/packages/react/src/use-resource-query.d.ts +112 -0
  151. package/dist/types/packages/react/src/use-resource.d.ts +69 -0
  152. package/dist/types/src/core.d.ts +1 -0
  153. package/dist/types/src/index.d.ts +8 -0
  154. package/dist/types/src/mocking/datasets/comments.d.ts +1 -0
  155. package/dist/types/src/mocking/datasets/companies.d.ts +1 -0
  156. package/dist/types/src/mocking/datasets/index.d.ts +1 -0
  157. package/dist/types/src/mocking/datasets/orders.d.ts +1 -0
  158. package/dist/types/src/mocking/datasets/posts.d.ts +1 -0
  159. package/dist/types/src/mocking/datasets/products.d.ts +1 -0
  160. package/dist/types/src/mocking/datasets/users.d.ts +1 -0
  161. package/dist/types/src/mocking/index.d.ts +1 -0
  162. package/dist/types/src/mocking/node.d.ts +1 -0
  163. package/dist/types/src/mocking/register.d.ts +2 -0
  164. package/dist/types/src/react/advanced.d.ts +1 -0
  165. package/dist/types/src/react/index.d.ts +2 -0
  166. package/package.json +36 -21
  167. package/dist/data-JR6F6HSR.js +0 -6
  168. package/dist/data-WRWVXGYD.js +0 -6
  169. package/dist/inference-BGj3DlzE.d.ts +0 -1220
  170. package/dist/loader-hhMdppVZ.d.ts +0 -32
  171. package/dist/mutation-controller-BjCOn42y.d.ts +0 -476
  172. /package/dist/{chunk-WNJUPR6P.js → chunks/chunk-23CRJXIO.js} +0 -0
  173. /package/dist/{chunk-QY5YMHHN.js → chunks/chunk-3RDQXC6Q.js} +0 -0
  174. /package/dist/{chunk-KE7UM4VW.js → chunks/chunk-QPINWJOY.js} +0 -0
  175. /package/dist/{chunk-A3QU5MFP.js → chunks/chunk-SO3IYVYQ.js} +0 -0
  176. /package/dist/{chunk-ZSLMMDUX.js → chunks/chunk-VACVV4XV.js} +0 -0
  177. /package/dist/{chunk-DGSIZXRI.js → chunks/chunk-YZ7TR6HL.js} +0 -0
  178. /package/dist/{data-QF32LRM4.js → chunks/data-544O3O74.js} +0 -0
  179. /package/dist/{data-3HVQ54F3.js → chunks/data-5JYPNNLK.js} +0 -0
  180. /package/dist/{data-ADLKYCN6.js → chunks/data-BLJLBYSL.js} +0 -0
  181. /package/dist/{data-Y6374BIT.js → chunks/data-CJY7V7VX.js} +0 -0
  182. /package/dist/{data-HWX62BTJ.js → chunks/data-CPWQB3IU.js} +0 -0
  183. /package/dist/{data-UIVRJ77R.js → chunks/data-DD3Q7CSO.js} +0 -0
  184. /package/dist/{data-OKVHGTXW.js → chunks/data-MFATSP4G.js} +0 -0
  185. /package/dist/{data-UZVNJUNM.js → chunks/data-MG5JK7PM.js} +0 -0
  186. /package/dist/{data-PQPSE56A.js → chunks/data-YHFBWU6E.js} +0 -0
@@ -2,63 +2,63 @@
2
2
  var catalog = {
3
3
  "users-mock": {
4
4
  idKey: "id",
5
- load: () => import("./data-GNCSLYM4.js")
5
+ load: () => import("./data-WOMFLQWC.js")
6
6
  },
7
7
  "products-mock": {
8
8
  idKey: "id",
9
- load: () => import("./data-B47EIZXW.js")
9
+ load: () => import("./data-ZPXVMWRQ.js")
10
10
  },
11
11
  "companies-mock": {
12
12
  idKey: "id",
13
- load: () => import("./data-GTTIEVFI.js")
13
+ load: () => import("./data-4B7QV4F5.js")
14
14
  },
15
15
  "orders-mock": {
16
16
  idKey: "id",
17
- load: () => import("./data-DL4IKJCX.js")
17
+ load: () => import("./data-7ISALG7G.js")
18
18
  },
19
19
  "posts-mock": {
20
20
  idKey: "id",
21
- load: () => import("./data-JR6F6HSR.js")
21
+ load: () => import("./data-HAGFVAZM.js")
22
22
  },
23
23
  "comments-mock": {
24
24
  idKey: "id",
25
- load: () => import("./data-WRWVXGYD.js")
25
+ load: () => import("./data-HNAJ5IYV.js")
26
26
  },
27
27
  "countries-csc": {
28
28
  idKey: "id",
29
- load: () => import("./data-QF32LRM4.js")
29
+ load: () => import("./data-544O3O74.js")
30
30
  },
31
31
  "countries-mledoze": {
32
32
  idKey: "id",
33
- load: () => import("./data-OKVHGTXW.js")
33
+ load: () => import("./data-MFATSP4G.js")
34
34
  },
35
35
  "countries-parseapi": {
36
36
  idKey: "country",
37
- load: () => import("./data-HWX62BTJ.js")
37
+ load: () => import("./data-CPWQB3IU.js")
38
38
  },
39
39
  "country-codes-iso": {
40
40
  idKey: "id",
41
- load: () => import("./data-UZVNJUNM.js")
41
+ load: () => import("./data-MG5JK7PM.js")
42
42
  },
43
43
  "cities-capitals": {
44
44
  idKey: "id",
45
- load: () => import("./data-UIVRJ77R.js")
45
+ load: () => import("./data-DD3Q7CSO.js")
46
46
  },
47
47
  "currencies-parseapi": {
48
48
  idKey: "currency",
49
- load: () => import("./data-PQPSE56A.js")
49
+ load: () => import("./data-YHFBWU6E.js")
50
50
  },
51
51
  "languages-parseapi": {
52
52
  idKey: "language",
53
- load: () => import("./data-ADLKYCN6.js")
53
+ load: () => import("./data-BLJLBYSL.js")
54
54
  },
55
55
  "timezones-parseapi": {
56
56
  idKey: "timezone",
57
- load: () => import("./data-Y6374BIT.js")
57
+ load: () => import("./data-CJY7V7VX.js")
58
58
  },
59
59
  "area-codes-parseapi": {
60
60
  idKey: "area_code",
61
- load: () => import("./data-3HVQ54F3.js")
61
+ load: () => import("./data-5JYPNNLK.js")
62
62
  }
63
63
  };
64
64
  function isDatasetId(value) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  data_default
3
- } from "./chunk-KE7UM4VW.js";
3
+ } from "./chunk-QPINWJOY.js";
4
4
 
5
5
  // packages/mocking/src/dataset-modules/posts.ts
6
6
  var posts = data_default;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  data_default
3
- } from "./chunk-WNJUPR6P.js";
3
+ } from "./chunk-23CRJXIO.js";
4
4
 
5
5
  // packages/mocking/src/dataset-modules/users.ts
6
6
  var users = data_default;
@@ -14,8 +14,10 @@ var ApiError = class extends Error {
14
14
  this.status = options?.status;
15
15
  this.code = options?.code ?? "NETWORK";
16
16
  this.data = options?.data;
17
- this.request = options?.request;
18
- this.response = options?.response;
17
+ Object.defineProperties(this, {
18
+ request: { value: options?.request, enumerable: false, writable: true, configurable: true },
19
+ response: { value: options?.response, enumerable: false, writable: true, configurable: true }
20
+ });
19
21
  this.retryable = options?.retryable ?? false;
20
22
  this.attempt = options?.attempt;
21
23
  this.cause = options?.cause;
@@ -128,67 +130,6 @@ function isMockError(error) {
128
130
  return error instanceof MockError;
129
131
  }
130
132
 
131
- // packages/core/src/http/url.ts
132
- var ABSOLUTE = /^https?:\/\//i;
133
- function isAbsoluteUrl(value) {
134
- return ABSOLUTE.test(value);
135
- }
136
- function parseBaseURL(value) {
137
- if (typeof value !== "string" || value.trim() === "") {
138
- throw new ConfigError(
139
- `baseURL must be a non-empty string (got ${value === "" ? '""' : typeof value}).`
140
- );
141
- }
142
- if (isAbsoluteUrl(value)) {
143
- let url;
144
- try {
145
- url = new URL(value);
146
- } catch (cause) {
147
- throw new ConfigError(`baseURL "${value}" is not a valid URL.`, { cause });
148
- }
149
- if (url.search || url.hash) {
150
- throw new ConfigError(`baseURL "${value}" must not contain a query string or fragment.`);
151
- }
152
- return { raw: value, origin: url.origin, path: url.pathname.replace(/\/+$/, "") };
153
- }
154
- if (value.startsWith("/") && !value.startsWith("//")) {
155
- if (/[?#]/.test(value)) {
156
- throw new ConfigError(`baseURL "${value}" must not contain a query string or fragment.`);
157
- }
158
- return { raw: value, origin: null, path: value.replace(/\/+$/, "") };
159
- }
160
- throw new ConfigError(
161
- `baseURL "${value}" must be an absolute http(s) URL (e.g. "https://api.example.com") or a browser-relative path starting with "/" (e.g. "/api").`
162
- );
163
- }
164
- function requestOrigin(base) {
165
- if (base.origin) return base.origin;
166
- const origin = globalThis.location?.origin;
167
- if (typeof origin === "string" && origin !== "null" && origin !== "") return origin;
168
- throw new ConfigError(
169
- `baseURL "${base.raw}" is relative, but this environment has no browser origin to resolve it against. Use an absolute URL (e.g. "http://localhost:3000${base.raw}") outside the browser.`
170
- );
171
- }
172
- function buildUrl(base, path, queryString, origin) {
173
- if (isAbsoluteUrl(path)) return `${path}${queryString}`;
174
- const normalized = path === "" || path === "/" ? "" : path.startsWith("/") ? path : `/${path}`;
175
- return `${origin ?? ""}${base.path}${normalized}${queryString}`;
176
- }
177
- function assertSameOrigin(url, origin) {
178
- let parsed;
179
- try {
180
- parsed = new URL(url, origin);
181
- } catch (cause) {
182
- throw new SecurityError(`Request URL "${url}" is not a valid URL.`, { cause });
183
- }
184
- if (parsed.origin !== origin || parsed.protocol !== "http:" && parsed.protocol !== "https:") {
185
- throw new SecurityError(
186
- `Request URL ${parsed.href} resolves outside the API origin ${origin}; it was not sent so credentials cannot leak. Use a separate client (or defineApis) for another origin.`
187
- );
188
- }
189
- return parsed;
190
- }
191
-
192
133
  // packages/core/src/http/body.ts
193
134
  function isJsonContentType(headers) {
194
135
  const contentType = headers.get("content-type") ?? "";
@@ -292,42 +233,6 @@ function createFetchTransport(fetchImpl = fetch) {
292
233
  };
293
234
  }
294
235
 
295
- // packages/core/src/http/path.ts
296
- var PARAM = /:([A-Za-z0-9_]+)/g;
297
- function interpolatePath(path, params) {
298
- const absolute = /^(https?:\/\/[^/]+)(.*)$/i.exec(path);
299
- const head = absolute ? absolute[1] : "";
300
- const tail = absolute ? absolute[2] : path;
301
- return head + tail.replace(PARAM, (_, key) => {
302
- const value = params?.[key];
303
- if (value === void 0 || value === null || value === "") {
304
- throw new ValidationError(`Missing path parameter "${key}" for ${path}`);
305
- }
306
- return encodeURIComponent(String(value));
307
- });
308
- }
309
- function joinPath(base, relative) {
310
- if (!relative || relative === "/") {
311
- return base.replace(/\/+$/, "") || "/";
312
- }
313
- if (/^https?:\/\//i.test(relative)) {
314
- return relative;
315
- }
316
- const normalizedBase = base.replace(/\/+$/, "");
317
- const normalizedRelative = relative.startsWith("/") ? relative : `/${relative}`;
318
- return `${normalizedBase}${normalizedRelative}`;
319
- }
320
- function extractPathParamNames(path) {
321
- if (/^https?:\/\//i.test(path)) path = new URL(path).pathname;
322
- const names = [];
323
- const re = /:([A-Za-z0-9_]+)/g;
324
- let match;
325
- while ((match = re.exec(path)) !== null) {
326
- names.push(match[1]);
327
- }
328
- return names;
329
- }
330
-
331
236
  // packages/core/src/mock/datasets.ts
332
237
  var MOCK_DATASETS = {
333
238
  "users-mock": "id",
@@ -361,7 +266,7 @@ async function loadNamedDataset(id) {
361
266
  if (!datasetLoader) {
362
267
  throw new MockError(
363
268
  "MOCK_LOAD",
364
- `mock: "${id}" needs the optional "@apixa/mocking" integration. Install it and import "@apixa/mocking/register" once (before the first call), or pass inline records / a provider instead.`
269
+ `mock: "${id}" needs the optional Mocking integration. Import "apixa/mocking/register" once before the first call or pass inline records / a provider instead.`
365
270
  );
366
271
  }
367
272
  return datasetLoader(id);
@@ -1057,67 +962,6 @@ function parseOperationArgs(pathParamNames, hasBody, args) {
1057
962
  return { params, body, options };
1058
963
  }
1059
964
 
1060
- // packages/core/src/http/headers.ts
1061
- function apply(target, source) {
1062
- if (!source) return;
1063
- if (source instanceof Headers) {
1064
- source.forEach((value, key) => target.set(key, value));
1065
- return;
1066
- }
1067
- if (Array.isArray(source)) {
1068
- for (const [key, value] of source) target.set(key, value);
1069
- return;
1070
- }
1071
- for (const [key, value] of Object.entries(source)) {
1072
- if (value === void 0 || value === null) target.delete(key);
1073
- else target.set(key, String(value));
1074
- }
1075
- }
1076
- async function resolveHeaders(sources, request) {
1077
- const headers = new Headers();
1078
- for (const source of sources) {
1079
- if (typeof source === "function") {
1080
- let value;
1081
- try {
1082
- value = await source();
1083
- } catch (cause) {
1084
- const detail = cause instanceof Error ? cause.message : String(cause);
1085
- throw new ApiError(`Header provider failed: ${detail}`, { code: "HEADERS", cause });
1086
- }
1087
- apply(headers, value);
1088
- } else {
1089
- apply(headers, source);
1090
- }
1091
- }
1092
- apply(headers, request);
1093
- return headers;
1094
- }
1095
-
1096
- // packages/core/src/http/query.ts
1097
- function buildQueryString(query, format = "repeat") {
1098
- if (!query) return "";
1099
- const parts = [];
1100
- for (const [key, value] of Object.entries(query)) {
1101
- if (value === void 0 || value === null) continue;
1102
- if (Array.isArray(value)) {
1103
- if (format === "comma") {
1104
- parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value.map(String).join(","))}`);
1105
- } else if (format === "brackets") {
1106
- for (const item of value) {
1107
- parts.push(`${encodeURIComponent(key)}[]=${encodeURIComponent(String(item))}`);
1108
- }
1109
- } else {
1110
- for (const item of value) {
1111
- parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(item))}`);
1112
- }
1113
- }
1114
- } else {
1115
- parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
1116
- }
1117
- }
1118
- return parts.length ? `?${parts.join("&")}` : "";
1119
- }
1120
-
1121
965
  // packages/core/src/transform/keys.ts
1122
966
  var KEY_CASES = [
1123
967
  "camelCase",
@@ -1315,6 +1159,164 @@ function delay(ms, signal) {
1315
1159
  });
1316
1160
  }
1317
1161
 
1162
+ // packages/core/src/http/headers.ts
1163
+ function apply(target, source) {
1164
+ if (!source) return;
1165
+ if (source instanceof Headers) {
1166
+ source.forEach((value, key) => target.set(key, value));
1167
+ return;
1168
+ }
1169
+ if (Array.isArray(source)) {
1170
+ for (const [key, value] of source) target.set(key, value);
1171
+ return;
1172
+ }
1173
+ for (const [key, value] of Object.entries(source)) {
1174
+ if (value === void 0 || value === null) target.delete(key);
1175
+ else target.set(key, String(value));
1176
+ }
1177
+ }
1178
+ async function resolveHeaders(sources, request) {
1179
+ const headers = new Headers();
1180
+ for (const source of sources) {
1181
+ if (typeof source === "function") {
1182
+ let value;
1183
+ try {
1184
+ value = await source();
1185
+ } catch (cause) {
1186
+ const detail = cause instanceof Error ? cause.message : String(cause);
1187
+ throw new ApiError(`Header provider failed: ${detail}`, { code: "HEADERS", cause });
1188
+ }
1189
+ apply(headers, value);
1190
+ } else {
1191
+ apply(headers, source);
1192
+ }
1193
+ }
1194
+ apply(headers, request);
1195
+ return headers;
1196
+ }
1197
+
1198
+ // packages/core/src/http/path.ts
1199
+ var PARAM = /:([A-Za-z0-9_]+)/g;
1200
+ function interpolatePath(path, params) {
1201
+ const absolute = /^(https?:\/\/[^/]+)(.*)$/i.exec(path);
1202
+ const head = absolute ? absolute[1] : "";
1203
+ const tail = absolute ? absolute[2] : path;
1204
+ return head + tail.replace(PARAM, (_, key) => {
1205
+ const value = params?.[key];
1206
+ if (value === void 0 || value === null || value === "") {
1207
+ throw new ValidationError(`Missing path parameter "${key}" for ${path}`);
1208
+ }
1209
+ return encodeURIComponent(String(value));
1210
+ });
1211
+ }
1212
+ function joinPath(base, relative) {
1213
+ if (!relative || relative === "/") {
1214
+ return base.replace(/\/+$/, "") || "/";
1215
+ }
1216
+ if (/^https?:\/\//i.test(relative)) {
1217
+ return relative;
1218
+ }
1219
+ const normalizedBase = base.replace(/\/+$/, "");
1220
+ const normalizedRelative = relative.startsWith("/") ? relative : `/${relative}`;
1221
+ return `${normalizedBase}${normalizedRelative}`;
1222
+ }
1223
+ function extractPathParamNames(path) {
1224
+ if (/^https?:\/\//i.test(path)) path = new URL(path).pathname;
1225
+ const names = [];
1226
+ const re = /:([A-Za-z0-9_]+)/g;
1227
+ let match;
1228
+ while ((match = re.exec(path)) !== null) {
1229
+ names.push(match[1]);
1230
+ }
1231
+ return names;
1232
+ }
1233
+
1234
+ // packages/core/src/http/query.ts
1235
+ function buildQueryString(query, format = "repeat") {
1236
+ if (!query) return "";
1237
+ const parts = [];
1238
+ for (const [key, value] of Object.entries(query)) {
1239
+ if (value === void 0 || value === null) continue;
1240
+ if (Array.isArray(value)) {
1241
+ if (format === "comma") {
1242
+ parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value.map(String).join(","))}`);
1243
+ } else if (format === "brackets") {
1244
+ for (const item of value) {
1245
+ parts.push(`${encodeURIComponent(key)}[]=${encodeURIComponent(String(item))}`);
1246
+ }
1247
+ } else {
1248
+ for (const item of value) {
1249
+ parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(item))}`);
1250
+ }
1251
+ }
1252
+ } else {
1253
+ parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
1254
+ }
1255
+ }
1256
+ return parts.length ? `?${parts.join("&")}` : "";
1257
+ }
1258
+
1259
+ // packages/core/src/http/url.ts
1260
+ var ABSOLUTE = /^https?:\/\//i;
1261
+ function isAbsoluteUrl(value) {
1262
+ return ABSOLUTE.test(value);
1263
+ }
1264
+ function parseBaseURL(value) {
1265
+ if (typeof value !== "string" || value.trim() === "") {
1266
+ throw new ConfigError(
1267
+ `baseURL must be a non-empty string (got ${value === "" ? '""' : typeof value}).`
1268
+ );
1269
+ }
1270
+ if (isAbsoluteUrl(value)) {
1271
+ let url;
1272
+ try {
1273
+ url = new URL(value);
1274
+ } catch (cause) {
1275
+ throw new ConfigError(`baseURL "${value}" is not a valid URL.`, { cause });
1276
+ }
1277
+ if (url.search || url.hash) {
1278
+ throw new ConfigError(`baseURL "${value}" must not contain a query string or fragment.`);
1279
+ }
1280
+ return { raw: value, origin: url.origin, path: url.pathname.replace(/\/+$/, "") };
1281
+ }
1282
+ if (value.startsWith("/") && !value.startsWith("//")) {
1283
+ if (/[?#]/.test(value)) {
1284
+ throw new ConfigError(`baseURL "${value}" must not contain a query string or fragment.`);
1285
+ }
1286
+ return { raw: value, origin: null, path: value.replace(/\/+$/, "") };
1287
+ }
1288
+ throw new ConfigError(
1289
+ `baseURL "${value}" must be an absolute http(s) URL (e.g. "https://api.example.com") or a browser-relative path starting with "/" (e.g. "/api").`
1290
+ );
1291
+ }
1292
+ function requestOrigin(base) {
1293
+ if (base.origin) return base.origin;
1294
+ const origin = globalThis.location?.origin;
1295
+ if (typeof origin === "string" && origin !== "null" && origin !== "") return origin;
1296
+ throw new ConfigError(
1297
+ `baseURL "${base.raw}" is relative, but this environment has no browser origin to resolve it against. Use an absolute URL (e.g. "http://localhost:3000${base.raw}") outside the browser.`
1298
+ );
1299
+ }
1300
+ function buildUrl(base, path, queryString, origin) {
1301
+ if (isAbsoluteUrl(path)) return `${path}${queryString}`;
1302
+ const normalized = path === "" || path === "/" ? "" : path.startsWith("/") ? path : `/${path}`;
1303
+ return `${origin ?? ""}${base.path}${normalized}${queryString}`;
1304
+ }
1305
+ function assertSameOrigin(url, origin) {
1306
+ let parsed;
1307
+ try {
1308
+ parsed = new URL(url, origin);
1309
+ } catch (cause) {
1310
+ throw new SecurityError(`Request URL "${url}" is not a valid URL.`, { cause });
1311
+ }
1312
+ if (parsed.origin !== origin || parsed.protocol !== "http:" && parsed.protocol !== "https:") {
1313
+ throw new SecurityError(
1314
+ `Request URL ${parsed.href} resolves outside the API origin ${origin}; it was not sent so credentials cannot leak. Use a separate client (or defineApis) for another origin.`
1315
+ );
1316
+ }
1317
+ return parsed;
1318
+ }
1319
+
1318
1320
  // packages/core/src/request/pipeline.ts
1319
1321
  var REQUEST_KEYS = ["method", "url", "headers", "signal", "meta"];
1320
1322
  function transformQuery(query, to) {
@@ -1645,6 +1647,20 @@ function applyResourceSliceToListResult(data, slice) {
1645
1647
  return applyResourceSlice(data, slice);
1646
1648
  }
1647
1649
 
1650
+ // packages/core/src/api/metadata.ts
1651
+ var OPERATION_METADATA = /* @__PURE__ */ Symbol.for("apixa.operations");
1652
+ function getOperationMetadata(resource) {
1653
+ const value = resource[OPERATION_METADATA];
1654
+ return value && typeof value === "object" ? value : void 0;
1655
+ }
1656
+ var IDEMPOTENCY_GENERATORS = /* @__PURE__ */ new WeakMap();
1657
+ function registerIdempotencyGenerators(resource, generators) {
1658
+ IDEMPOTENCY_GENERATORS.set(resource, generators);
1659
+ }
1660
+ function createIdempotencyKey(resource, operation) {
1661
+ return IDEMPOTENCY_GENERATORS.get(resource)?.[operation]?.();
1662
+ }
1663
+
1648
1664
  // packages/core/src/api/validate.ts
1649
1665
  var ROOT_KEYS = /* @__PURE__ */ new Set([
1650
1666
  "baseURL",
@@ -1974,20 +1990,6 @@ function validateIdempotency(where, value, kind) {
1974
1990
  }
1975
1991
  }
1976
1992
 
1977
- // packages/core/src/api/metadata.ts
1978
- var OPERATION_METADATA = /* @__PURE__ */ Symbol.for("apixa.operations");
1979
- function getOperationMetadata(resource) {
1980
- const value = resource[OPERATION_METADATA];
1981
- return value && typeof value === "object" ? value : void 0;
1982
- }
1983
- var IDEMPOTENCY_GENERATORS = /* @__PURE__ */ new WeakMap();
1984
- function registerIdempotencyGenerators(resource, generators) {
1985
- IDEMPOTENCY_GENERATORS.set(resource, generators);
1986
- }
1987
- function createIdempotencyKey(resource, operation) {
1988
- return IDEMPOTENCY_GENERATORS.get(resource)?.[operation]?.();
1989
- }
1990
-
1991
1993
  // packages/core/src/api/resource-client.ts
1992
1994
  var BODY_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH"]);
1993
1995
  function pick(...values) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  data_default
3
- } from "./chunk-WNJUPR6P.js";
3
+ } from "./chunk-YZ7TR6HL.js";
4
4
  export {
5
5
  data_default as default
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  data_default
3
- } from "./chunk-A3QU5MFP.js";
3
+ } from "./chunk-VACVV4XV.js";
4
4
  export {
5
5
  data_default as default
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  data_default
3
- } from "./chunk-DGSIZXRI.js";
3
+ } from "./chunk-QPINWJOY.js";
4
4
  export {
5
5
  data_default as default
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  data_default
3
- } from "./chunk-ZSLMMDUX.js";
3
+ } from "./chunk-3RDQXC6Q.js";
4
4
  export {
5
5
  data_default as default
6
6
  };
@@ -0,0 +1,6 @@
1
+ import {
2
+ data_default
3
+ } from "./chunk-23CRJXIO.js";
4
+ export {
5
+ data_default as default
6
+ };
@@ -0,0 +1,6 @@
1
+ import {
2
+ data_default
3
+ } from "./chunk-SO3IYVYQ.js";
4
+ export {
5
+ data_default as default
6
+ };
package/dist/core.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./types/src/core.js";
package/dist/core.js ADDED
@@ -0,0 +1,80 @@
1
+ import {
2
+ AbortError,
3
+ ApiError,
4
+ BUILTIN_CONVENTIONS,
5
+ ConfigError,
6
+ HttpError,
7
+ KEY_CASES,
8
+ MOCK_DATASETS,
9
+ MockError,
10
+ MockStore,
11
+ NetworkError,
12
+ OPERATION_METADATA,
13
+ ParseError,
14
+ SecurityError,
15
+ TimeoutError,
16
+ TransformError,
17
+ ValidationError,
18
+ applyResourceSliceToListResult,
19
+ computeBackoffMs,
20
+ convertKey,
21
+ createFetchTransport,
22
+ createIdempotencyKey,
23
+ defineApi,
24
+ defineApis,
25
+ expandOperations,
26
+ getOperationMetadata,
27
+ isApiError,
28
+ isHttpError,
29
+ isMockDatasetId,
30
+ isMockError,
31
+ isRetryableStatus,
32
+ isTimeoutError,
33
+ listMockDatasetIds,
34
+ normalizeMockSource,
35
+ parseRetryAfter,
36
+ registerMockDatasetLoader,
37
+ resetMock,
38
+ runBuiltin,
39
+ transformKeys
40
+ } from "./chunks/chunk-RYTQAJRH.js";
41
+ export {
42
+ AbortError,
43
+ ApiError,
44
+ BUILTIN_CONVENTIONS,
45
+ ConfigError,
46
+ HttpError,
47
+ KEY_CASES,
48
+ MOCK_DATASETS,
49
+ MockError,
50
+ MockStore,
51
+ NetworkError,
52
+ OPERATION_METADATA,
53
+ ParseError,
54
+ SecurityError,
55
+ TimeoutError,
56
+ TransformError,
57
+ ValidationError,
58
+ applyResourceSliceToListResult,
59
+ computeBackoffMs,
60
+ convertKey,
61
+ createFetchTransport,
62
+ createIdempotencyKey,
63
+ defineApi,
64
+ defineApis,
65
+ expandOperations,
66
+ getOperationMetadata,
67
+ isApiError,
68
+ isHttpError,
69
+ isMockDatasetId,
70
+ isMockError,
71
+ isRetryableStatus,
72
+ isTimeoutError,
73
+ listMockDatasetIds,
74
+ normalizeMockSource,
75
+ parseRetryAfter,
76
+ registerMockDatasetLoader,
77
+ resetMock,
78
+ runBuiltin,
79
+ transformKeys
80
+ };