apixa 0.0.0-stage → 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 (182) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +301 -2
  3. package/dist/chunks/chunk-23CRJXIO.js +707 -0
  4. package/dist/chunks/chunk-3RDQXC6Q.js +607 -0
  5. package/dist/chunks/chunk-3ZFOEESZ.js +10 -0
  6. package/dist/chunks/chunk-6WSJJKM6.js +10 -0
  7. package/dist/chunks/chunk-7U7EGEIJ.js +823 -0
  8. package/dist/chunks/chunk-BRBSHKI5.js +360 -0
  9. package/dist/chunks/chunk-D2GA433L.js +10 -0
  10. package/dist/chunks/chunk-I5JYOAUR.js +10 -0
  11. package/dist/chunks/chunk-JM47QQH6.js +117 -0
  12. package/dist/chunks/chunk-K4ELX7MW.js +10 -0
  13. package/dist/chunks/chunk-OO6JF76I.js +10 -0
  14. package/dist/chunks/chunk-QPINWJOY.js +707 -0
  15. package/dist/chunks/chunk-RYTQAJRH.js +2412 -0
  16. package/dist/chunks/chunk-SO3IYVYQ.js +907 -0
  17. package/dist/chunks/chunk-VACVV4XV.js +727 -0
  18. package/dist/chunks/chunk-YZ7TR6HL.js +247 -0
  19. package/dist/chunks/data-4B7QV4F5.js +6 -0
  20. package/dist/chunks/data-544O3O74.js +3506 -0
  21. package/dist/chunks/data-5JYPNNLK.js +2550 -0
  22. package/dist/chunks/data-7ISALG7G.js +6 -0
  23. package/dist/chunks/data-BLJLBYSL.js +2211 -0
  24. package/dist/chunks/data-CJY7V7VX.js +3350 -0
  25. package/dist/chunks/data-CPWQB3IU.js +4772 -0
  26. package/dist/chunks/data-DD3Q7CSO.js +2456 -0
  27. package/dist/chunks/data-HAGFVAZM.js +6 -0
  28. package/dist/chunks/data-HNAJ5IYV.js +6 -0
  29. package/dist/chunks/data-MFATSP4G.js +3544 -0
  30. package/dist/chunks/data-MG5JK7PM.js +2256 -0
  31. package/dist/chunks/data-WOMFLQWC.js +6 -0
  32. package/dist/chunks/data-YHFBWU6E.js +1308 -0
  33. package/dist/chunks/data-ZPXVMWRQ.js +6 -0
  34. package/dist/core.d.ts +1 -0
  35. package/dist/core.js +80 -0
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +66 -0
  38. package/dist/mocking/datasets/comments.d.ts +1 -0
  39. package/dist/mocking/datasets/comments.js +7 -0
  40. package/dist/mocking/datasets/companies.d.ts +1 -0
  41. package/dist/mocking/datasets/companies.js +7 -0
  42. package/dist/mocking/datasets/index.d.ts +1 -0
  43. package/dist/mocking/datasets/index.js +265 -0
  44. package/dist/mocking/datasets/orders.d.ts +1 -0
  45. package/dist/mocking/datasets/orders.js +7 -0
  46. package/dist/mocking/datasets/posts.d.ts +1 -0
  47. package/dist/mocking/datasets/posts.js +7 -0
  48. package/dist/mocking/datasets/products.d.ts +1 -0
  49. package/dist/mocking/datasets/products.js +7 -0
  50. package/dist/mocking/datasets/users.d.ts +1 -0
  51. package/dist/mocking/datasets/users.js +7 -0
  52. package/dist/mocking/index.d.ts +1 -0
  53. package/dist/mocking/index.js +19 -0
  54. package/dist/mocking/node.d.ts +1 -0
  55. package/dist/mocking/node.js +190 -0
  56. package/dist/mocking/register.d.ts +1 -0
  57. package/dist/mocking/register.js +9 -0
  58. package/dist/react/advanced.d.ts +1 -0
  59. package/dist/react/advanced.js +130 -0
  60. package/dist/react/index.d.ts +1 -0
  61. package/dist/react/index.js +325 -0
  62. package/dist/types/packages/core/src/api/client.d.ts +11 -0
  63. package/dist/types/packages/core/src/api/define-api.d.ts +9 -0
  64. package/dist/types/packages/core/src/api/define-apis.d.ts +9 -0
  65. package/dist/types/packages/core/src/api/index.d.ts +3 -0
  66. package/dist/types/packages/core/src/api/metadata.d.ts +32 -0
  67. package/dist/types/packages/core/src/api/reset.d.ts +7 -0
  68. package/dist/types/packages/core/src/api/resource-client.d.ts +20 -0
  69. package/dist/types/packages/core/src/api/validate.d.ts +20 -0
  70. package/dist/types/packages/core/src/errors/abort-error.d.ts +4 -0
  71. package/dist/types/packages/core/src/errors/api-error.d.ts +22 -0
  72. package/dist/types/packages/core/src/errors/config-error.d.ts +5 -0
  73. package/dist/types/packages/core/src/errors/guards.d.ts +8 -0
  74. package/dist/types/packages/core/src/errors/http-error.d.ts +8 -0
  75. package/dist/types/packages/core/src/errors/index.d.ts +13 -0
  76. package/dist/types/packages/core/src/errors/mock-error.d.ts +10 -0
  77. package/dist/types/packages/core/src/errors/network-error.d.ts +4 -0
  78. package/dist/types/packages/core/src/errors/parse-error.d.ts +4 -0
  79. package/dist/types/packages/core/src/errors/security-error.d.ts +5 -0
  80. package/dist/types/packages/core/src/errors/timeout-error.d.ts +4 -0
  81. package/dist/types/packages/core/src/errors/transform-error.d.ts +11 -0
  82. package/dist/types/packages/core/src/errors/validation-error.d.ts +4 -0
  83. package/dist/types/packages/core/src/http/body.d.ts +2 -0
  84. package/dist/types/packages/core/src/http/headers.d.ts +9 -0
  85. package/dist/types/packages/core/src/http/index.d.ts +5 -0
  86. package/dist/types/packages/core/src/http/path.d.ts +6 -0
  87. package/dist/types/packages/core/src/http/query.d.ts +3 -0
  88. package/dist/types/packages/core/src/http/url.d.ts +27 -0
  89. package/dist/types/packages/core/src/index.d.ts +16 -0
  90. package/dist/types/packages/core/src/mock/datasets.d.ts +31 -0
  91. package/dist/types/packages/core/src/mock/execute.d.ts +27 -0
  92. package/dist/types/packages/core/src/mock/handler.d.ts +46 -0
  93. package/dist/types/packages/core/src/mock/index.d.ts +5 -0
  94. package/dist/types/packages/core/src/mock/source.d.ts +21 -0
  95. package/dist/types/packages/core/src/mock/store.d.ts +73 -0
  96. package/dist/types/packages/core/src/operation/args.d.ts +7 -0
  97. package/dist/types/packages/core/src/operation/conventions.d.ts +122 -0
  98. package/dist/types/packages/core/src/operation/expand.d.ts +12 -0
  99. package/dist/types/packages/core/src/operation/index.d.ts +4 -0
  100. package/dist/types/packages/core/src/request/index.d.ts +2 -0
  101. package/dist/types/packages/core/src/request/pipeline.d.ts +95 -0
  102. package/dist/types/packages/core/src/request/retry.d.ts +17 -0
  103. package/dist/types/packages/core/src/transform/index.d.ts +1 -0
  104. package/dist/types/packages/core/src/transform/keys.d.ts +12 -0
  105. package/dist/types/packages/core/src/transport/fetch.d.ts +2 -0
  106. package/dist/types/packages/core/src/transport/index.d.ts +2 -0
  107. package/dist/types/packages/core/src/transport/read-body.d.ts +2 -0
  108. package/dist/types/packages/core/src/types/builtins.d.ts +48 -0
  109. package/dist/types/packages/core/src/types/definition.d.ts +154 -0
  110. package/dist/types/packages/core/src/types/errors.d.ts +20 -0
  111. package/dist/types/packages/core/src/types/http.d.ts +29 -0
  112. package/dist/types/packages/core/src/types/index.d.ts +11 -0
  113. package/dist/types/packages/core/src/types/inference.d.ts +600 -0
  114. package/dist/types/packages/core/src/types/middleware.d.ts +35 -0
  115. package/dist/types/packages/core/src/types/mock-datasets.d.ts +177 -0
  116. package/dist/types/packages/core/src/types/mock-handler.d.ts +54 -0
  117. package/dist/types/packages/core/src/types/retry.d.ts +47 -0
  118. package/dist/types/packages/core/src/types/transform.d.ts +27 -0
  119. package/dist/types/packages/core/src/types/transport.d.ts +79 -0
  120. package/dist/types/packages/core/src/utils/slice.d.ts +12 -0
  121. package/dist/types/packages/internal/shared/src/index.d.ts +4 -0
  122. package/dist/types/packages/internal/shared/src/keys.d.ts +25 -0
  123. package/dist/types/packages/internal/shared/src/operations.d.ts +20 -0
  124. package/dist/types/packages/mocking/src/catalog.d.ts +26 -0
  125. package/dist/types/packages/mocking/src/data/entities.d.ts +5 -0
  126. package/dist/types/packages/mocking/src/dataset-modules/comments.d.ts +4 -0
  127. package/dist/types/packages/mocking/src/dataset-modules/companies.d.ts +4 -0
  128. package/dist/types/packages/mocking/src/dataset-modules/orders.d.ts +4 -0
  129. package/dist/types/packages/mocking/src/dataset-modules/posts.d.ts +4 -0
  130. package/dist/types/packages/mocking/src/dataset-modules/products.d.ts +4 -0
  131. package/dist/types/packages/mocking/src/dataset-modules/users.d.ts +4 -0
  132. package/dist/types/packages/mocking/src/datasets.d.ts +17 -0
  133. package/dist/types/packages/mocking/src/discover.d.ts +3 -0
  134. package/dist/types/packages/mocking/src/errors.d.ts +17 -0
  135. package/dist/types/packages/mocking/src/index.d.ts +19 -0
  136. package/dist/types/packages/mocking/src/load.d.ts +15 -0
  137. package/dist/types/packages/mocking/src/loader.d.ts +16 -0
  138. package/dist/types/packages/mocking/src/mock-api.d.ts +25 -0
  139. package/dist/types/packages/mocking/src/mock-types.d.ts +279 -0
  140. package/dist/types/packages/mocking/src/node.d.ts +8 -0
  141. package/dist/types/packages/mocking/src/paths.d.ts +6 -0
  142. package/dist/types/packages/mocking/src/register.d.ts +1 -0
  143. package/dist/types/packages/mocking/src/registry.d.ts +11 -0
  144. package/dist/types/packages/mocking/src/resource.d.ts +13 -0
  145. package/dist/types/packages/mocking/src/slice.d.ts +16 -0
  146. package/dist/types/packages/mocking/src/types.d.ts +44 -0
  147. package/dist/types/packages/react/src/advanced.d.ts +28 -0
  148. package/dist/types/packages/react/src/cache.d.ts +15 -0
  149. package/dist/types/packages/react/src/compose.d.ts +10 -0
  150. package/dist/types/packages/react/src/controller.d.ts +11 -0
  151. package/dist/types/packages/react/src/hydration-boundary.d.ts +11 -0
  152. package/dist/types/packages/react/src/hydration.d.ts +5 -0
  153. package/dist/types/packages/react/src/index.d.ts +17 -0
  154. package/dist/types/packages/react/src/keys.d.ts +7 -0
  155. package/dist/types/packages/react/src/mutation-controller.d.ts +40 -0
  156. package/dist/types/packages/react/src/mutation-store.d.ts +57 -0
  157. package/dist/types/packages/react/src/mutation-types.d.ts +125 -0
  158. package/dist/types/packages/react/src/optimistic.d.ts +55 -0
  159. package/dist/types/packages/react/src/provider.d.ts +14 -0
  160. package/dist/types/packages/react/src/query-client.d.ts +31 -0
  161. package/dist/types/packages/react/src/query-controller.d.ts +49 -0
  162. package/dist/types/packages/react/src/query-helpers.d.ts +112 -0
  163. package/dist/types/packages/react/src/query-options.d.ts +152 -0
  164. package/dist/types/packages/react/src/types.d.ts +123 -0
  165. package/dist/types/packages/react/src/use-resource-mutation.d.ts +34 -0
  166. package/dist/types/packages/react/src/use-resource-query.d.ts +112 -0
  167. package/dist/types/packages/react/src/use-resource.d.ts +69 -0
  168. package/dist/types/src/core.d.ts +1 -0
  169. package/dist/types/src/index.d.ts +8 -0
  170. package/dist/types/src/mocking/datasets/comments.d.ts +1 -0
  171. package/dist/types/src/mocking/datasets/companies.d.ts +1 -0
  172. package/dist/types/src/mocking/datasets/index.d.ts +1 -0
  173. package/dist/types/src/mocking/datasets/orders.d.ts +1 -0
  174. package/dist/types/src/mocking/datasets/posts.d.ts +1 -0
  175. package/dist/types/src/mocking/datasets/products.d.ts +1 -0
  176. package/dist/types/src/mocking/datasets/users.d.ts +1 -0
  177. package/dist/types/src/mocking/index.d.ts +1 -0
  178. package/dist/types/src/mocking/node.d.ts +1 -0
  179. package/dist/types/src/mocking/register.d.ts +2 -0
  180. package/dist/types/src/react/advanced.d.ts +1 -0
  181. package/dist/types/src/react/index.d.ts +2 -0
  182. package/package.json +143 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abdalrahman bani younes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,302 @@
1
- # Temporary Holding Version
1
+ # Apixa
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Define your API once. Use it everywhere.**
4
+
5
+ Apixa is an open-source, TypeScript-first library for defining APIs and generating fully typed API clients from a single source of truth.
6
+
7
+ Instead of repeatedly writing request functions, types, URL construction, and response handling for every resource, Apixa aims to let you define your API once and handle the repetitive mechanics automatically.
8
+
9
+ ## Why Apixa?
10
+
11
+ Working with APIs often means repeating the same patterns across resources and projects:
12
+
13
+ - Writing request functions for every endpoint.
14
+ - Maintaining request and response types separately.
15
+ - Reimplementing headers, parsing, and error handling.
16
+ - Repeating common resource operations.
17
+ - Integrating API calls with different data-fetching libraries.
18
+
19
+ Apixa aims to reduce this duplication while preserving TypeScript's type safety and flexibility.
20
+
21
+ ## Installation
22
+
23
+ Apixa publishes one npm package: `apixa` (`1.0.0-rc.0`, ESM, Node.js 22+). The RC is prepared
24
+ locally and has not been published. After release, install it with:
25
+
26
+ ```sh
27
+ npm install apixa
28
+ # React applications also install the optional peers:
29
+ npm install apixa react @tanstack/react-query
30
+ ```
31
+
32
+ ```ts
33
+ import { defineApi, defineApis, defineMockApi } from "apixa";
34
+ import { MockStore } from "apixa/core";
35
+ import "apixa/mocking/register";
36
+ import { users } from "apixa/mocking/datasets/users";
37
+ import { listDatasets } from "apixa/mocking/node"; // Node-only
38
+ ```
39
+
40
+ ```tsx
41
+ import {
42
+ QueryClient,
43
+ ApixaProvider,
44
+ ApixaHydrationBoundary,
45
+ useResource,
46
+ useResourceQuery,
47
+ useResourceMutation,
48
+ } from "apixa/react";
49
+ // Server Components use the server-safe entry:
50
+ import { QueryClient as ServerQueryClient, dehydrate } from "apixa/react/advanced";
51
+ ```
52
+
53
+ Framework subpaths keep integrations isolated. Root, Core and Mocking imports require neither
54
+ React nor TanStack Query. React and TanStack Query are optional peers, left external to the
55
+ library build; install them only when using `apixa/react`. Missing peers produce the loader's
56
+ module-not-found error when a React entry is imported. Future `apixa/vue` and `apixa/angular`
57
+ subpaths are planned, not implemented.
58
+
59
+ Core, Mocking, React and shared integration helpers remain private workspace modules. Their
60
+ canonical code is compiled into one distribution with shared runtime chunks. No scoped package
61
+ installation is required. See the [installation guide](./docs/guides/humans/install-apixa.md)
62
+ and [public API contract](./docs/public-api.md).
63
+
64
+ ### Runtime support
65
+
66
+ | Runtime | Status |
67
+ | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
68
+ | Node.js 22, 24 | Supported (CI matrix) |
69
+ | Modern browsers | Supported (verified in Chromium) |
70
+ | Cloudflare Workers | `apixa`, `apixa/core`, `apixa/mocking*` (not `/node`) and `apixa/react/advanced`, run in `workerd` without `nodejs_compat` |
71
+ | Vercel Edge Runtime | Same entries, run in `edge-runtime` |
72
+ | React 18 / 19, Next.js 15 App Router, Vite 6 | Supported (packed consumers, production and development builds) |
73
+ | TypeScript 5.5+ | Declarations checked with 5.5.4 and the latest release, `Bundler` and `NodeNext` resolution |
74
+
75
+ `apixa/mocking/node` reads the file system and is Node-only. Thrown errors keep `error.request`
76
+ (including headers and body) readable but non-enumerable, so logging an error does not print
77
+ credentials.
78
+
79
+ ## Core Principles
80
+
81
+ - **Define once:** Keep API definitions in a single source of truth.
82
+ - **Type-safe by design:** Infer request arguments and response types from definitions.
83
+ - **Convention-driven:** Generate common resource operations where appropriate.
84
+ - **Fully customizable:** Support custom endpoints and override generated behavior.
85
+ - **Framework-agnostic:** Keep the core independent of UI frameworks and data-fetching libraries.
86
+ - **Composable:** Allow additional capabilities through isolated subpaths.
87
+
88
+ ## Usage (implemented)
89
+
90
+ Minimal resource — built-in CRUD is generated from `path`:
91
+
92
+ ```ts
93
+ import { defineApi } from "apixa";
94
+ const api = defineApi({
95
+ baseURL: "https://api.example.com",
96
+ headers: { Accept: "application/json" },
97
+ resources: { users: { path: "/users" } },
98
+ });
99
+
100
+ await api.users.getAll();
101
+ await api.users.getById("123");
102
+ await api.users.create({ name: "Ada", email: "ada@example.com" });
103
+ await api.users.update("123", { name: "Ada Lovelace" });
104
+ await api.users.delete("123");
105
+ ```
106
+
107
+ Typed payloads use a Zustand-style **resource-only** state generic (no `type()` helper).
108
+ `create` / `update` are derived from `entity` (`Omit<Entity,"id">` / `Partial<Entity>`).
109
+ Root config (`baseURL`, `headers`, …) is typed by Core — not listed on `AppApi`:
110
+
111
+ ```ts
112
+ import { defineApi } from "apixa";
113
+
114
+ type User = { id: string; name: string; email: string };
115
+
116
+ type AppApi = {
117
+ users: {
118
+ entity: User;
119
+ };
120
+ };
121
+
122
+ const api = defineApi<AppApi>()({
123
+ baseURL: "https://api.example.com",
124
+ headers: { Accept: "application/json", "X-Client": "dashboard" },
125
+ resources: {
126
+ users: {
127
+ path: "/users",
128
+ operations: {
129
+ getAll: { path: "/active" },
130
+ patch: { path: "/:id" },
131
+ archive: { kind: "write", method: "POST", path: "/:id/archive" },
132
+ },
133
+ },
134
+ },
135
+ });
136
+ ```
137
+
138
+ Operations return native `Promise<T>` (response data is unwrapped). A resource path generates 16
139
+ builtins by default. The runtime resource config chooses paths and enabled methods; the optional
140
+ generic supplies payload types. `operations` can disable a builtin with `false`, restore it with
141
+ `true`, override it with a partial config, or define a custom operation with an explicit
142
+ `kind: "read" | "write"`. Custom functions use `{ kind, run }`. HTTP methods must agree with
143
+ the operation kind. `createMany` and
144
+ `deleteMany` replace the former `bulkCreate` and `bulkDelete` names while retaining `/bulk` as
145
+ their default wire path.
146
+
147
+ ```ts
148
+ const api = defineApi<AppApi>()({
149
+ baseURL: "https://api.example.com",
150
+ resources: {
151
+ users: {
152
+ path: "/users",
153
+ readOnly: true,
154
+ operationGroups: { many: true },
155
+ operations: { create: true, getById: false },
156
+ },
157
+ },
158
+ });
159
+ // TypeScript exposes only the methods generated by these settings.
160
+ ```
161
+
162
+ Set `defaultOperations: false` to start with no builtins, then enable individual operations or
163
+ groups. `writeOnly: true` filters read defaults. Group precedence and all default wire conventions
164
+ are documented in [docs/conventions.md](docs/conventions.md#selection-order).
165
+
166
+ Pass `transport` to inject a custom HTTP implementation (used in tests). The default is Fetch, shipped inside Core.
167
+
168
+ ### Request reliability (implemented)
169
+
170
+ Per-call cancel and timeout via `RequestOptions` (call → operation → resource → api). Abort → `AbortError`; timeout → `TimeoutError`.
171
+
172
+ ```ts
173
+ const controller = new AbortController();
174
+ await api.users.getAll({ signal: controller.signal, timeout: 5_000 });
175
+ controller.abort();
176
+ ```
177
+
178
+ Opt-in retries (default methods `GET` / `HEAD`; network errors, `408` / `429` / `5xx`):
179
+
180
+ ```ts
181
+ const api = defineApi({
182
+ baseURL: "https://api.example.com",
183
+ timeout: 10_000,
184
+ retry: { retries: 2, baseDelayMs: 200 },
185
+ resources: { users: { path: "/users" } },
186
+ });
187
+ ```
188
+
189
+ Middleware hooks, request middleware, and response middleware run inside Core's request
190
+ pipeline. See [`packages/core/README.md`](./packages/core/README.md) for the current API.
191
+
192
+ See [`packages/core/README.md`](./packages/core/README.md) and CHANGELOG v0.7.0 migration notes.
193
+
194
+ ### Simple Mocking (implemented)
195
+
196
+ Standalone, in-memory mock API from local datasets — no `defineApi()`, no network, no backend:
197
+
198
+ ```ts
199
+ import { defineMockApi } from "apixa/mocking";
200
+
201
+ const mockApi = defineMockApi({
202
+ resources: {
203
+ users: { type: "users-mock" },
204
+ products: { type: "products-mock", slice: 50, pagination: true },
205
+ },
206
+ });
207
+
208
+ const { data, total } = await mockApi.products.getAll({ page: 1, pageSize: 10 });
209
+ ```
210
+
211
+ Typed data: `import { users, type User } from "apixa/mocking/datasets"`.
212
+
213
+ Or mock individual resources of a Core client (register the included lazy dataset loader):
214
+
215
+ ```ts
216
+ import { defineApi } from "apixa";
217
+ import "apixa/mocking/register";
218
+
219
+ const api = defineApi({
220
+ baseURL: "https://api.example.com",
221
+ resources: {
222
+ users: { path: "/users", mock: "users-mock", pagination: "page" },
223
+ payments: { path: "/payments" }, // real network
224
+ },
225
+ });
226
+ ```
227
+
228
+ See [`datasets/`](./datasets/) and [`packages/mocking`](./packages/mocking).
229
+
230
+ See [`examples/next`](./examples/next) for the primary real-app playground (Next.js). Other frontends and a Node CLI live under [`examples/`](./examples/). Platform run scripts: [`scripts/README.md`](./scripts/README.md).
231
+
232
+ ## Vision
233
+
234
+ Apixa is being designed around a small, extensible core that can grow into a broader API development ecosystem.
235
+
236
+ **Implemented:** `defineApi()` with default-first CRUD (v0.2.0), resource-only `defineApi<T>()(config)` (v0.4.0), `@apixa/mocking` + datasets (v0.5.0), request reliability (v0.6.0), thin Core + plugin seams — path-param concat, `full` / middleware re-call, extension interfaces, structured error codes (v0.7.0).
237
+
238
+ **Planned later:**
239
+
240
+ - `crud<>()` preset.
241
+ - Runtime schema validation hooks (no schema library in Core).
242
+ - Live pagination, filtering, sorting, and search conventions.
243
+ - Online dataset catalog (browse/download) — local datasets only today.
244
+ - Other data-fetching integrations beyond the implemented TanStack Query package.
245
+ - Browser and server packages.
246
+ - OpenAPI interoperability.
247
+ - Additional transports extracted from Core.
248
+
249
+ These planned items are not currently implemented.
250
+
251
+ ## Design Philosophy
252
+
253
+ Apixa Core will provide API definitions, type inference, and request execution without requiring React, TanStack Query, or a particular runtime framework.
254
+
255
+ Integrations will build on the core rather than become dependencies of it.
256
+
257
+ API methods are intended to return native promises, allowing them to work naturally with `async`/`await` and libraries such as TanStack Query.
258
+
259
+ ## Project Structure
260
+
261
+ ```text
262
+ packages/
263
+ core/ # API definitions and execution
264
+ mocking/ # Local datasets and standalone mock APIs
265
+ react/ # Private React integration
266
+ internal/shared/ # Private, never published: framework-neutral integration helpers
267
+ datasets/ # Version-controlled JSON fixtures
268
+ examples/
269
+ next/ # Primary frontend playground (Next.js)
270
+ react-vite/ vue/ vanilla/ angular/ react-native/ basic/
271
+ scripts/ # Frontend run scripts (macOS / Linux / Windows)
272
+ tests/ # Vitest suite for core, mocking, and query
273
+ docs/ # Living context, architecture, roadmap, ADRs
274
+ versions/
275
+ v1.0.0/ # Active Query workstream
276
+ ```
277
+
278
+ Planned later packages (not created yet): `transport-fetch`, `client`, `server`, `openapi`.
279
+
280
+ ## Documentation
281
+
282
+ | Doc | Purpose |
283
+ | ---------------------------------------------- | ---------------------------------------------------- |
284
+ | [docs/context.md](./docs/context.md) | Project identity, principles, constraints |
285
+ | [docs/architecture.md](./docs/architecture.md) | Core shape and request flow |
286
+ | [docs/roadmap.md](./docs/roadmap.md) | Milestones and future phases |
287
+ | [docs/conventions.md](./docs/conventions.md) | How we build and document |
288
+ | [versions/v1.0.0/](./versions/v1.0.0/) | **Active coding contract** (scope, plan, acceptance) |
289
+
290
+ ## Project Status
291
+
292
+ Apixa is in early development. Last shipped: **v0.11.0**. The v1.0.0 TanStack Query workstream is in progress. Core exposes `defineApi()` with default-first CRUD, reliability, re-callable middleware, and extension seams. Mocking augments Core for resource mocks.
293
+
294
+ See [versions/v1.0.0/acceptance-criteria.md](./versions/v1.0.0/acceptance-criteria.md) for the active milestone checklist.
295
+
296
+ ## Author
297
+
298
+ Created and maintained by **Abdalrahman bani younes** ([a2mby](https://github.com/a2mby)).
299
+
300
+ ## License
301
+
302
+ Apixa is licensed under the MIT License. See [LICENSE](./LICENSE) for details.