@classytic/arc-next 0.11.0 → 0.11.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/dist/hooks.d.ts CHANGED
@@ -9,6 +9,7 @@ import { SlugLookupMethods } from "./presets/slug.js";
9
9
  import { TreeMethods } from "./presets/tree.js";
10
10
  import { SearchPresetMethods } from "./presets/search.js";
11
11
  import { QueryKey, UseQueryResult } from "@tanstack/react-query";
12
+ import { PaginatedResult } from "@classytic/repo-core/pagination";
12
13
 
13
14
  //#region src/hooks.d.ts
14
15
  /**
@@ -224,7 +225,11 @@ interface CrudHooksReturn<T, TCreate, TUpdate> {
224
225
  useAction: <TResult = T, TBody extends Record<string, unknown> = Record<string, unknown>>(options?: {
225
226
  invalidateQueries?: QueryKey[]; /** Default action name. Can be overridden per-call via `mutate({ action })`. */
226
227
  action?: string;
227
- messages?: MutationMessages;
228
+ messages?: MutationMessages<TResult, {
229
+ id: string;
230
+ action?: string;
231
+ data?: TBody;
232
+ }>;
228
233
  onSuccess?: (data: TResult, variables: {
229
234
  id: string;
230
235
  action: string;
@@ -248,18 +253,25 @@ interface CrudHooksReturn<T, TCreate, TUpdate> {
248
253
  /** Mutation against the search-preset POST `/search` route. */
249
254
  useSearchEngine: <TResult = T, TBody extends Record<string, unknown> = Record<string, unknown>>(options?: {
250
255
  path?: string;
251
- messages?: MutationMessages;
256
+ messages?: MutationMessages<TResult[] | PaginatedResult<TResult>, {
257
+ query?: string;
258
+ body?: TBody;
259
+ }>;
252
260
  invalidateQueries?: QueryKey[];
253
- }) => TransitionMutationReturn<unknown, {
261
+ }) => TransitionMutationReturn<TResult[] | PaginatedResult<TResult>, {
254
262
  query?: string;
255
263
  body?: TBody;
256
264
  }>;
257
265
  /** Mutation against the search-preset POST `/search-similar` route. */
258
266
  useSearchSimilar: <TResult = T, TBody extends Record<string, unknown> = Record<string, unknown>>(options?: {
259
267
  path?: string;
260
- messages?: MutationMessages;
268
+ messages?: MutationMessages<TResult[] | PaginatedResult<TResult>, {
269
+ query?: string;
270
+ vector?: number[];
271
+ body?: TBody;
272
+ }>;
261
273
  invalidateQueries?: QueryKey[];
262
- }) => TransitionMutationReturn<unknown, {
274
+ }) => TransitionMutationReturn<TResult[] | PaginatedResult<TResult>, {
263
275
  query?: string;
264
276
  vector?: number[];
265
277
  body?: TBody;
@@ -309,7 +321,7 @@ interface CrudHooksReturn<T, TCreate, TUpdate> {
309
321
  useCustomMutation: <TData = unknown, TVariables = unknown>(config: {
310
322
  mutationFn: (variables: TVariables) => Promise<TData>;
311
323
  invalidateQueries?: QueryKey[];
312
- messages?: MutationMessages;
324
+ messages?: MutationMessages<TData, TVariables>;
313
325
  onSuccess?: (data: TData, variables: TVariables) => void;
314
326
  onError?: (error: Error, variables: TVariables) => void;
315
327
  onSettled?: (data: TData | undefined, error: Error | null, variables: TVariables) => void;
@@ -3,9 +3,16 @@ import * as _$_tanstack_react_query0 from "@tanstack/react-query";
3
3
  import { QueryClient, QueryKey, UseMutateAsyncFunction, UseMutateFunction } from "@tanstack/react-query";
4
4
 
5
5
  //#region src/mutation.d.ts
6
- interface MutationMessages {
7
- success?: string | ((data: unknown, variables: unknown) => string);
8
- error?: string | ((error: Error, variables: unknown) => string);
6
+ /**
7
+ * Toast copy for a mutation. Generic over the mutation's result/variables so
8
+ * `success: (result) => ...` sees the TYPED FLAT action result (arc 2.13+
9
+ * returns results with no `{ data }` envelope) — the stale-envelope
10
+ * `(data as { data: T }).data` cast class is a compile error now. Defaults
11
+ * keep pre-0.11.1 unparameterized usage compiling unchanged.
12
+ */
13
+ interface MutationMessages<TData = unknown, TVariables = unknown> {
14
+ success?: string | ((data: TData, variables: TVariables) => string);
15
+ error?: string | ((error: Error, variables: TVariables) => string);
9
16
  }
10
17
  interface MutationCallbacks<TData, TVariables, TContext = unknown> {
11
18
  onMutate?: (variables: TVariables) => TContext | Promise<TContext>;
@@ -56,7 +63,7 @@ interface TransitionMutationConfig<TData, TVariables> {
56
63
  onSuccess?: (data: TData, variables: TVariables) => void;
57
64
  onError?: (error: Error, variables: TVariables) => void;
58
65
  onSettled?: (data: TData | undefined, error: Error | null, variables: TVariables) => void;
59
- messages?: MutationMessages;
66
+ messages?: MutationMessages<TData, TVariables>;
60
67
  useTransition?: boolean;
61
68
  showToast?: boolean;
62
69
  /** Per-call toast guard — return false to suppress toast for this invocation */
@@ -80,7 +87,7 @@ interface OptimisticMutationConfig<TData, TVariables> {
80
87
  onSuccess?: (data: TData, variables: TVariables) => void;
81
88
  onError?: (error: Error, variables: TVariables) => void;
82
89
  onSettled?: (data: TData | undefined, error: Error | null, variables: TVariables) => void;
83
- messages?: MutationMessages;
90
+ messages?: MutationMessages<TData, TVariables>;
84
91
  showToast?: boolean;
85
92
  toastHandler?: ToastHandler;
86
93
  }
@@ -112,7 +119,7 @@ interface CreateOptimisticMutationConfig<TData, TVariables> {
112
119
  onSuccess?: (data: TData, variables: TVariables) => void;
113
120
  onError?: (error: Error, variables: TVariables) => void;
114
121
  onSettled?: (data: TData | undefined, error: Error | null, variables: TVariables) => void;
115
- messages?: MutationMessages;
122
+ messages?: MutationMessages<TData, TVariables>;
116
123
  /** Per-call toast guard — return false to suppress toast for this invocation */
117
124
  shouldToast?: () => boolean;
118
125
  toastHandler?: ToastHandler;
package/package.json CHANGED
@@ -1,178 +1,178 @@
1
- {
2
- "name": "@classytic/arc-next",
3
- "version": "0.11.0",
4
- "description": "React + TanStack Query SDK for Arc resources",
5
- "type": "module",
6
- "sideEffects": false,
7
- "license": "MIT",
8
- "author": "Classytic",
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/classytic/arc-next"
12
- },
13
- "keywords": [
14
- "react",
15
- "tanstack-query",
16
- "react-query",
17
- "crud",
18
- "api-client",
19
- "hooks",
20
- "optimistic-updates",
21
- "pagination",
22
- "multi-tenant",
23
- "arc",
24
- "mongokit",
25
- "sse",
26
- "real-time",
27
- "soft-delete",
28
- "bulk-operations"
29
- ],
30
- "main": "./dist/hooks.js",
31
- "types": "./dist/hooks.d.ts",
32
- "exports": {
33
- ".": {
34
- "types": "./dist/hooks.d.ts",
35
- "default": "./dist/hooks.js"
36
- },
37
- "./client": {
38
- "types": "./dist/client.d.ts",
39
- "default": "./dist/client.js"
40
- },
41
- "./encryption": {
42
- "types": "./dist/encryption.d.ts",
43
- "default": "./dist/encryption.js"
44
- },
45
- "./field-encryption": {
46
- "types": "./dist/field-encryption.d.ts",
47
- "default": "./dist/field-encryption.js"
48
- },
49
- "./api": {
50
- "types": "./dist/api.d.ts",
51
- "default": "./dist/api.js"
52
- },
53
- "./cache": {
54
- "types": "./dist/cache.d.ts",
55
- "default": "./dist/cache.js"
56
- },
57
- "./query": {
58
- "types": "./dist/query.d.ts",
59
- "default": "./dist/query.js"
60
- },
61
- "./mutation": {
62
- "types": "./dist/mutation.d.ts",
63
- "default": "./dist/mutation.js"
64
- },
65
- "./hooks": {
66
- "types": "./dist/hooks.d.ts",
67
- "default": "./dist/hooks.js"
68
- },
69
- "./query-client": {
70
- "types": "./dist/query-client.d.ts",
71
- "default": "./dist/query-client.js"
72
- },
73
- "./prefetch": {
74
- "types": "./dist/prefetch.d.ts",
75
- "default": "./dist/prefetch.js"
76
- },
77
- "./sse": {
78
- "types": "./dist/sse.d.ts",
79
- "default": "./dist/sse.js"
80
- },
81
- "./ws": {
82
- "types": "./dist/ws.d.ts",
83
- "default": "./dist/ws.js"
84
- },
85
- "./upload": {
86
- "types": "./dist/upload.d.ts",
87
- "default": "./dist/upload.js"
88
- },
89
- "./presets/soft-delete": {
90
- "types": "./dist/presets/soft-delete.d.ts",
91
- "default": "./dist/presets/soft-delete.js"
92
- },
93
- "./presets/history": {
94
- "types": "./dist/presets/history.d.ts",
95
- "default": "./dist/presets/history.js"
96
- },
97
- "./presets/bulk": {
98
- "types": "./dist/presets/bulk.d.ts",
99
- "default": "./dist/presets/bulk.js"
100
- },
101
- "./presets/slug": {
102
- "types": "./dist/presets/slug.d.ts",
103
- "default": "./dist/presets/slug.js"
104
- },
105
- "./presets/tree": {
106
- "types": "./dist/presets/tree.d.ts",
107
- "default": "./dist/presets/tree.js"
108
- },
109
- "./presets/search": {
110
- "types": "./dist/presets/search.d.ts",
111
- "default": "./dist/presets/search.js"
112
- },
113
- "./package.json": "./package.json",
114
- "./query-options": {
115
- "types": "./dist/query-options.d.ts",
116
- "default": "./dist/query-options.js"
117
- }
118
- },
119
- "files": [
120
- "dist",
121
- "llms.txt"
122
- ],
123
- "publishConfig": {
124
- "access": "public",
125
- "registry": "https://registry.npmjs.org/"
126
- },
127
- "engines": {
128
- "node": ">=20"
129
- },
130
- "scripts": {
131
- "build": "tsdown",
132
- "dev": "tsdown --watch",
133
- "test": "vitest run",
134
- "test:watch": "vitest",
135
- "typecheck": "tsc --noEmit",
136
- "push": "classytic-push",
137
- "release:tag": "node -e \"require('child_process').execSync('npm run push -- v'+require('./package.json').version,{stdio:'inherit'})\"",
138
- "release": "npm run push -- main && npm run release:tag && npm publish",
139
- "prepublishOnly": "npm run typecheck && npm test && npm run build",
140
- "typecheck:tests": "tsc --noEmit -p tsconfig.test.json"
141
- },
142
- "peerDependencies": {
143
- "@classytic/repo-core": ">=0.4.0",
144
- "@tanstack/react-query": ">=5.62.0",
145
- "jose": ">=5.0.0",
146
- "react": ">=19.0.0"
147
- },
148
- "peerDependenciesMeta": {
149
- "react": {
150
- "optional": false
151
- },
152
- "@tanstack/react-query": {
153
- "optional": false
154
- },
155
- "@classytic/repo-core": {
156
- "optional": false
157
- },
158
- "jose": {
159
- "optional": true
160
- }
161
- },
162
- "devDependencies": {
163
- "@classytic/dev-tools": "^0.2.0",
164
- "@classytic/repo-core": "^0.5.0",
165
- "@tanstack/react-query": "^5.97.0",
166
- "@testing-library/jest-dom": "^6.9.1",
167
- "@testing-library/react": "^16.3.2",
168
- "@types/react": "^19.2.14",
169
- "@types/react-dom": "^19.2.3",
170
- "jose": "^6.2.3",
171
- "jsdom": "^29.0.2",
172
- "react": "^19.2.5",
173
- "react-dom": "^19.2.5",
174
- "tsdown": "^0.21.7",
175
- "typescript": "^6.0.2",
176
- "vitest": "^4.1.4"
177
- }
178
- }
1
+ {
2
+ "name": "@classytic/arc-next",
3
+ "version": "0.11.1",
4
+ "description": "React + TanStack Query SDK for Arc resources",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "license": "MIT",
8
+ "author": "Classytic",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/classytic/arc-next"
12
+ },
13
+ "keywords": [
14
+ "react",
15
+ "tanstack-query",
16
+ "react-query",
17
+ "crud",
18
+ "api-client",
19
+ "hooks",
20
+ "optimistic-updates",
21
+ "pagination",
22
+ "multi-tenant",
23
+ "arc",
24
+ "mongokit",
25
+ "sse",
26
+ "real-time",
27
+ "soft-delete",
28
+ "bulk-operations"
29
+ ],
30
+ "main": "./dist/hooks.js",
31
+ "types": "./dist/hooks.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/hooks.d.ts",
35
+ "default": "./dist/hooks.js"
36
+ },
37
+ "./client": {
38
+ "types": "./dist/client.d.ts",
39
+ "default": "./dist/client.js"
40
+ },
41
+ "./encryption": {
42
+ "types": "./dist/encryption.d.ts",
43
+ "default": "./dist/encryption.js"
44
+ },
45
+ "./field-encryption": {
46
+ "types": "./dist/field-encryption.d.ts",
47
+ "default": "./dist/field-encryption.js"
48
+ },
49
+ "./api": {
50
+ "types": "./dist/api.d.ts",
51
+ "default": "./dist/api.js"
52
+ },
53
+ "./cache": {
54
+ "types": "./dist/cache.d.ts",
55
+ "default": "./dist/cache.js"
56
+ },
57
+ "./query": {
58
+ "types": "./dist/query.d.ts",
59
+ "default": "./dist/query.js"
60
+ },
61
+ "./mutation": {
62
+ "types": "./dist/mutation.d.ts",
63
+ "default": "./dist/mutation.js"
64
+ },
65
+ "./hooks": {
66
+ "types": "./dist/hooks.d.ts",
67
+ "default": "./dist/hooks.js"
68
+ },
69
+ "./query-client": {
70
+ "types": "./dist/query-client.d.ts",
71
+ "default": "./dist/query-client.js"
72
+ },
73
+ "./prefetch": {
74
+ "types": "./dist/prefetch.d.ts",
75
+ "default": "./dist/prefetch.js"
76
+ },
77
+ "./sse": {
78
+ "types": "./dist/sse.d.ts",
79
+ "default": "./dist/sse.js"
80
+ },
81
+ "./ws": {
82
+ "types": "./dist/ws.d.ts",
83
+ "default": "./dist/ws.js"
84
+ },
85
+ "./upload": {
86
+ "types": "./dist/upload.d.ts",
87
+ "default": "./dist/upload.js"
88
+ },
89
+ "./presets/soft-delete": {
90
+ "types": "./dist/presets/soft-delete.d.ts",
91
+ "default": "./dist/presets/soft-delete.js"
92
+ },
93
+ "./presets/history": {
94
+ "types": "./dist/presets/history.d.ts",
95
+ "default": "./dist/presets/history.js"
96
+ },
97
+ "./presets/bulk": {
98
+ "types": "./dist/presets/bulk.d.ts",
99
+ "default": "./dist/presets/bulk.js"
100
+ },
101
+ "./presets/slug": {
102
+ "types": "./dist/presets/slug.d.ts",
103
+ "default": "./dist/presets/slug.js"
104
+ },
105
+ "./presets/tree": {
106
+ "types": "./dist/presets/tree.d.ts",
107
+ "default": "./dist/presets/tree.js"
108
+ },
109
+ "./presets/search": {
110
+ "types": "./dist/presets/search.d.ts",
111
+ "default": "./dist/presets/search.js"
112
+ },
113
+ "./package.json": "./package.json",
114
+ "./query-options": {
115
+ "types": "./dist/query-options.d.ts",
116
+ "default": "./dist/query-options.js"
117
+ }
118
+ },
119
+ "files": [
120
+ "dist",
121
+ "llms.txt"
122
+ ],
123
+ "publishConfig": {
124
+ "access": "public",
125
+ "registry": "https://registry.npmjs.org/"
126
+ },
127
+ "engines": {
128
+ "node": ">=20"
129
+ },
130
+ "scripts": {
131
+ "build": "tsdown",
132
+ "dev": "tsdown --watch",
133
+ "test": "vitest run",
134
+ "test:watch": "vitest",
135
+ "typecheck": "tsc --noEmit",
136
+ "push": "classytic-push",
137
+ "release:tag": "node -e \"require('child_process').execSync('npm run push -- v'+require('./package.json').version,{stdio:'inherit'})\"",
138
+ "release": "npm run push -- main && npm run release:tag && npm publish",
139
+ "prepublishOnly": "npm run typecheck && npm test && npm run build",
140
+ "typecheck:tests": "tsc --noEmit -p tsconfig.test.json"
141
+ },
142
+ "peerDependencies": {
143
+ "@classytic/repo-core": ">=0.4.0",
144
+ "@tanstack/react-query": ">=5.62.0",
145
+ "jose": ">=5.0.0",
146
+ "react": ">=19.0.0"
147
+ },
148
+ "peerDependenciesMeta": {
149
+ "react": {
150
+ "optional": false
151
+ },
152
+ "@tanstack/react-query": {
153
+ "optional": false
154
+ },
155
+ "@classytic/repo-core": {
156
+ "optional": false
157
+ },
158
+ "jose": {
159
+ "optional": true
160
+ }
161
+ },
162
+ "devDependencies": {
163
+ "@classytic/dev-tools": "^0.2.0",
164
+ "@classytic/repo-core": "^0.5.0",
165
+ "@tanstack/react-query": "^5.97.0",
166
+ "@testing-library/jest-dom": "^6.9.1",
167
+ "@testing-library/react": "^16.3.2",
168
+ "@types/react": "^19.2.14",
169
+ "@types/react-dom": "^19.2.3",
170
+ "jose": "^6.2.3",
171
+ "jsdom": "^29.0.2",
172
+ "react": "^19.2.5",
173
+ "react-dom": "^19.2.5",
174
+ "tsdown": "^0.21.7",
175
+ "typescript": "^6.0.2",
176
+ "vitest": "^4.1.4"
177
+ }
178
+ }