@nsp-labs/agnostic-sdk 1.1.0 → 1.5.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/CHANGELOG.md CHANGED
@@ -9,6 +9,64 @@ and pass the runtime OpenAPI schema check.
9
9
 
10
10
  ## Unreleased
11
11
 
12
+ ## 1.5.0 - 2026-09-06
13
+
14
+ ### Added
15
+
16
+ - `data.table(name).records.query` for projected JSON pages and nested filters
17
+ without URL array encoding; `data.batchQuery` for bounded independent pages.
18
+ - Updated runtime OpenAPI schema and exact public manifest. New methods require
19
+ the additive query/batch-query Runtime API; existing methods are unchanged.
20
+
21
+ ## 1.4.0 - 2026-09-02
22
+
23
+ ### Added
24
+
25
+ - Added `data.table(name).records.aggregate(...)` for bounded server-side
26
+ `count`, `sum`, `avg`, `min`, and `max` queries with filters, search, up to
27
+ two grouping dimensions, ordering, and a capped result size.
28
+
29
+ ### Changed
30
+
31
+ - Regenerated the Runtime OpenAPI client with the backwards-compatible Data
32
+ aggregate endpoint. The runtime identity remains the only source of project
33
+ and environment scope.
34
+
35
+ ## 1.3.0 - 2026-08-12
36
+
37
+ ### Added
38
+
39
+ - Added `storage.bucket(name).createUpload`, `completeUpload`, `get`,
40
+ `createDownloadUrl`, and `delete` with project/environment/runtime-owner
41
+ binding and stable Files errors.
42
+ - Added the canonical `files.read`, `files.write`, `files.delete`, and
43
+ `files.links.create` Runtime API capability mapping.
44
+
45
+ ### Changed
46
+
47
+ - Regenerated the Runtime OpenAPI client for the complete Files facade while
48
+ keeping provider bucket names, object keys, and credentials outside public
49
+ types.
50
+ - Bumped the compatible server-only SDK contract to `1.3.0`; existing runtime
51
+ paths remain backwards compatible.
52
+
53
+ ## 1.2.0 - 2026-08-10
54
+
55
+ ### Added
56
+
57
+ - Added the server-only
58
+ `storage.bucket(name).anonymousUploads.claim(...)` helper and its Runtime API
59
+ schema for idempotent anonymous session claim with ready/processing handles.
60
+
61
+ ### Changed
62
+
63
+ - Clarified in the exported Runtime SDK manifest that App Auth self-service
64
+ profile mutations use the public App Auth API through the project backend/BFF;
65
+ they are not runtime-token mutations and do not expand the callable SDK
66
+ surface.
67
+ - Generated the runtime OpenAPI layer with the backwards-compatible Files claim
68
+ endpoint; existing Runtime API paths are unchanged.
69
+
12
70
  ## 1.1.0 - 2026-07-26
13
71
 
14
72
  ### Added
package/README.md CHANGED
@@ -8,6 +8,19 @@ environment + runtime token` and does not expose control-plane resources.
8
8
  npm install @nsp-labs/agnostic-sdk
9
9
  ```
10
10
 
11
+ ## Projected and Batch Reads (1.5.0)
12
+
13
+ `data.table(name).records.query({ fields: ['title'], filter, limit, cursor })`
14
+ reads only requested technical fields plus id. JSON filters support the existing
15
+ 50-value `in` budget without URL-array encoding. Omit `fields` for full records.
16
+ Changing fields or conditions requires a new cursor chain.
17
+
18
+ `data.batchQuery([{ tableName: 'orders', query: { fields: ['status'], limit: 50 } }])`
19
+ returns `{ results: [...] }` in request order, with independent page cursors.
20
+ Limits: 20 queries, 1000 requested rows total, default 50 rows/query. One failed
21
+ query fails the batch; reads are not a transactional snapshot. Requires the
22
+ additive query/batch-query Runtime API and `data.read`. Old methods are unchanged.
23
+
11
24
  ## Context
12
25
 
13
26
  Inside managed runtime, context is resolved automatically:
@@ -36,7 +49,8 @@ Runtime tokens are server-side credentials. Do not put
36
49
  `AGNOSTIC_RUNTIME_TOKEN` in browser, mobile, Vite, or static frontend bundles.
37
50
 
38
51
  The current public runtime surface includes `auth`, `context`, `data`,
39
- `workflows`, and `workflowRuns`.
52
+ `storage`, `workflows`, and `workflowRuns`. `storage.bucket(name)` supports the
53
+ server-side Files lifecycle and anonymous upload claim.
40
54
 
41
55
  ## App Auth
42
56
 
@@ -80,6 +94,15 @@ It returns sanitized user/session claims and an `app_user` actor for audit
80
94
  metadata. `agnostic.auth.getUser(userId)` reads sanitized App Auth user claims
81
95
  for the same runtime project.
82
96
 
97
+ For a browser frontend and backend deployed on different hosts, login must use
98
+ the application backend/BFF. The BFF requests bearer mode from App Auth and
99
+ places the tokens in host-only HttpOnly cookies on its own host before calling
100
+ `requireSession(request)`. A host-only cookie set by `api.agn0.ru` is not sent
101
+ to an application backend host. Do not solve this with `Domain=.agn0.ru` or
102
+ browser token storage. For cross-origin frontend/backend pairs, return a
103
+ separate non-secret CSRF token from the BFF and validate it on state-changing
104
+ cookie-authenticated requests.
105
+
83
106
  ## Data
84
107
 
85
108
  ```ts
@@ -88,6 +111,17 @@ const orders = await agnostic.data.table('orders').records.list({
88
111
  limit: 50,
89
112
  });
90
113
 
114
+ const revenueByStatus = await agnostic.data.table('orders').records.aggregate({
115
+ filter: { currency: 'RUB' },
116
+ groupBy: ['status'],
117
+ metrics: [
118
+ { operation: 'count', as: 'orders' },
119
+ { operation: 'sum', field: 'amount', as: 'revenue' },
120
+ ],
121
+ orderBy: [{ by: 'revenue', direction: 'desc' }],
122
+ limit: 20,
123
+ });
124
+
91
125
  const created = await agnostic.data.table('orders').records.create({
92
126
  values: {
93
127
  customerId: 'cust_123',
@@ -102,6 +136,10 @@ await agnostic.data.table('orders').records.update(created.id, {
102
136
  await agnostic.data.table('orders').records.delete(created.id);
103
137
  ```
104
138
 
139
+ Aggregate queries support `count`, `sum`, `avg`, `min`, and `max`. They are
140
+ executed by the data provider, allow at most two grouping fields, return at
141
+ most 100 groups, and require the existing `data.read` capability.
142
+
105
143
  ## Workflows
106
144
 
107
145
  ```ts
@@ -114,6 +152,55 @@ const finished = await agnostic.workflowRuns.wait(run.id, {
114
152
  });
115
153
  ```
116
154
 
155
+ ## Anonymous File Claim
156
+
157
+ After creating the business object, claim the anonymous upload session from the
158
+ application backend. Reuse the same `externalRef` and `idempotencyKey` for saga
159
+ retries:
160
+
161
+ ```ts
162
+ const attachments = await agnostic.storage
163
+ .bucket('order-files')
164
+ .anonymousUploads.claim({
165
+ token: attachmentSessionToken,
166
+ externalRef: `order:${order.id}`,
167
+ idempotencyKey: `order:${order.id}`,
168
+ });
169
+ ```
170
+
171
+ The runtime token and anonymous claim token must remain server-side. The result
172
+ contains server-selected `ready` or `processing` file handles; callers do not
173
+ submit file IDs.
174
+
175
+ ## Files
176
+
177
+ ```ts
178
+ const bucket = agnostic.storage.bucket('uploads');
179
+ const upload = await bucket.createUpload({
180
+ fileName: 'invoice.pdf',
181
+ contentType: 'application/pdf',
182
+ size: contents.byteLength,
183
+ checksumSha256,
184
+ access: 'private',
185
+ idempotencyKey: `invoice:${invoice.id}:v1`,
186
+ });
187
+
188
+ await fetch(upload.uploadUrl, {
189
+ method: 'PUT',
190
+ headers: upload.requiredHeaders,
191
+ body: contents,
192
+ });
193
+
194
+ const completed = await bucket.completeUpload(upload.id);
195
+ const file = await bucket.get(completed.file.id);
196
+ const download = await bucket.createDownloadUrl(file.id);
197
+ await bucket.delete(file.id);
198
+ ```
199
+
200
+ Reuse the same idempotency key and IDs when retrying. Keep the SDK and runtime
201
+ token server-side; only a short scoped upload/download URL may cross into a
202
+ browser after the application has authorized the request.
203
+
117
204
  ## Actor Metadata
118
205
 
119
206
  After an application backend has verified its App Auth session and business
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsp-labs/agnostic-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.5.0",
4
4
  "description": "Server-side Runtime SDK for Agnostic project services, workers, automations, and trusted local scripts.",
5
5
  "license": "ISC",
6
6
  "type": "commonjs",