@jskit-ai/crud-core 0.1.194 → 0.1.196

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/crud-core",
3
- "version": "0.1.194",
3
+ "version": "0.1.196",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -23,9 +23,9 @@
23
23
  "./server/routeContracts": "./src/server/routeContracts.js"
24
24
  },
25
25
  "dependencies": {
26
- "@jskit-ai/database-runtime": "0.1.183",
27
- "@jskit-ai/json-rest-api-core": "0.1.127",
28
- "@jskit-ai/resource-crud-core": "0.1.125",
26
+ "@jskit-ai/database-runtime": "0.1.185",
27
+ "@jskit-ai/json-rest-api-core": "0.1.129",
28
+ "@jskit-ai/resource-crud-core": "0.1.127",
29
29
  "json-rest-schema": "^1.0.17"
30
30
  },
31
31
  "description": "Shared server-side CRUD service, repository, route, and query helpers.",
@@ -45,7 +45,7 @@
45
45
  }
46
46
  },
47
47
  "peerDependencies": {
48
- "@jskit-ai/http-runtime": "0.1.181",
49
- "@jskit-ai/kernel": "0.1.183"
48
+ "@jskit-ai/http-runtime": "0.1.183",
49
+ "@jskit-ai/kernel": "0.1.185"
50
50
  }
51
51
  }
@@ -8,8 +8,8 @@
8
8
  "./shared": "./src/shared/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "@jskit-ai/crud-core": "0.1.194",
12
- "@jskit-ai/resource-crud-core": "0.1.125"
11
+ "@jskit-ai/crud-core": "0.1.196",
12
+ "@jskit-ai/resource-crud-core": "0.1.127"
13
13
  },
14
14
  "jskit": {
15
15
  "kind": "runtime",
@@ -6,6 +6,7 @@ import { createActionCatalogue } from "@jskit-ai/kernel/server/actions";
6
6
  import {
7
7
  addResourceIfMissing,
8
8
  createJsonRestApiHost,
9
+ createJsonRestContext,
9
10
  createJsonRestResourceScopeOptions
10
11
  } from "@jskit-ai/json-rest-api-core/server/jsonRestApiHost";
11
12
  import { defineCrudResource } from "@jskit-ai/resource-crud-core/shared/crudResource";
@@ -137,4 +138,31 @@ test("assistant list traverses real SQL pages with sparse fields and capped limi
137
138
  assert.equal(new Set(ids).size, 205);
138
139
  });
139
140
  }
141
+
142
+ await t.test("plain writes and JSON:API repository writes preserve full records", async () => {
143
+ const created = await api.resources.books.post({
144
+ inputRecord: { id: "501", workspaceId: "1", name: "Plain record", createdAt: "2026-09-09T00:00:00.000Z" },
145
+ format: "plain"
146
+ }, createJsonRestContext(context));
147
+ assert.equal(created.id, "501");
148
+ assert.equal(created.name, "Plain record");
149
+ const patched = await repository.patchDocumentById("501", { name: "JSON:API update" }, { context });
150
+ assert.equal(patched.data.id, "501");
151
+ assert.equal(patched.data.attributes.name, "JSON:API update");
152
+ const document = await repository.createDocument({
153
+ id: "502", workspaceId: "1", name: "JSON:API record", createdAt: "2026-09-09T00:00:00.000Z"
154
+ }, { context });
155
+ assert.equal(document.data.id, "502");
156
+ assert.equal(document.data.attributes.name, "JSON:API record");
157
+ assert.equal((await api.resources.books.get({ id: "502", format: "plain" }, createJsonRestContext(context))).name, "JSON:API record");
158
+ await assert.rejects(knex.transaction(async (trx) => {
159
+ await repository.patchDocumentById("502", { name: "Rolled back" }, { trx, context });
160
+ throw new Error("Rollback proof");
161
+ }), /Rollback proof/);
162
+ assert.equal((await repository.getDocumentById("502", {}, { context })).data.attributes.name, "JSON:API record");
163
+ await repository.deleteDocumentById("501", { context });
164
+ await repository.deleteDocumentById("502", { context });
165
+ assert.equal(await repository.getDocumentById("501", {}, { context }), null);
166
+ assert.equal(await knex("books").whereIn("id", [501, 502]).first(), undefined);
167
+ });
140
168
  });