@jskit-ai/users-core 0.1.159 → 0.1.161

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.
@@ -1,7 +1,7 @@
1
1
  export default Object.freeze({
2
2
  packageVersion: 1,
3
3
  packageId: "@jskit-ai/users-core",
4
- version: "0.1.159",
4
+ version: "0.1.161",
5
5
  kind: "runtime",
6
6
  description: "Users/account runtime plus HTTP routes for account features.",
7
7
  dependsOn: [
@@ -146,16 +146,16 @@ export default Object.freeze({
146
146
  mutations: {
147
147
  dependencies: {
148
148
  runtime: {
149
- "@jskit-ai/auth-core": "0.1.144",
150
- "@jskit-ai/crud-core": "0.1.156",
151
- "@jskit-ai/database-runtime": "0.1.145",
152
- "@jskit-ai/http-runtime": "0.1.144",
153
- "@jskit-ai/json-rest-api-core": "0.1.90",
154
- "@jskit-ai/kernel": "0.1.146",
155
- "@jskit-ai/resource-core": "0.1.89",
156
- "@jskit-ai/resource-crud-core": "0.1.89",
149
+ "@jskit-ai/auth-core": "0.1.146",
150
+ "@jskit-ai/crud-core": "0.1.158",
151
+ "@jskit-ai/database-runtime": "0.1.147",
152
+ "@jskit-ai/http-runtime": "0.1.146",
153
+ "@jskit-ai/json-rest-api-core": "0.1.92",
154
+ "@jskit-ai/kernel": "0.1.147",
155
+ "@jskit-ai/resource-core": "0.1.90",
156
+ "@jskit-ai/resource-crud-core": "0.1.90",
157
157
  "@local/users": "file:packages/users",
158
- "@jskit-ai/uploads-runtime": "0.1.122"
158
+ "@jskit-ai/uploads-runtime": "0.1.123"
159
159
  },
160
160
  dev: {}
161
161
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/users-core",
3
- "version": "0.1.159",
3
+ "version": "0.1.161",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -11,14 +11,14 @@
11
11
  "./shared/resources/userSettingsResource": "./src/shared/resources/userSettingsResource.js"
12
12
  },
13
13
  "dependencies": {
14
- "@jskit-ai/auth-core": "0.1.144",
15
- "@jskit-ai/database-runtime": "0.1.145",
16
- "@jskit-ai/http-runtime": "0.1.144",
17
- "@jskit-ai/json-rest-api-core": "0.1.90",
18
- "@jskit-ai/kernel": "0.1.146",
19
- "@jskit-ai/resource-crud-core": "0.1.89",
20
- "@jskit-ai/resource-core": "0.1.89",
21
- "@jskit-ai/uploads-runtime": "0.1.122",
22
- "json-rest-schema": "1.x.x"
14
+ "@jskit-ai/auth-core": "0.1.146",
15
+ "@jskit-ai/database-runtime": "0.1.147",
16
+ "@jskit-ai/http-runtime": "0.1.146",
17
+ "@jskit-ai/json-rest-api-core": "0.1.92",
18
+ "@jskit-ai/kernel": "0.1.147",
19
+ "@jskit-ai/resource-crud-core": "0.1.90",
20
+ "@jskit-ai/resource-core": "0.1.90",
21
+ "@jskit-ai/uploads-runtime": "0.1.123",
22
+ "json-rest-schema": "^1.0.17"
23
23
  }
24
24
  }
@@ -1,24 +1,11 @@
1
1
  import {
2
2
  normalizeDbRecordId,
3
- toInsertDateTime,
4
- toNullableDateTime,
5
3
  toIsoString,
6
4
  createWithTransaction
7
5
  } from "@jskit-ai/database-runtime/shared";
8
6
  import { isDuplicateEntryError } from "@jskit-ai/database-runtime/shared/duplicateEntry";
9
7
  import { normalizeLowerText, normalizeRecordId, normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
10
8
 
11
- function nowDb() {
12
- return toInsertDateTime();
13
- }
14
-
15
- function toNullableIso(value) {
16
- if (!value) {
17
- return null;
18
- }
19
- return toIsoString(value);
20
- }
21
-
22
9
  function uniqueSorted(values) {
23
10
  return [...new Set(values)].sort((left, right) => String(left).localeCompare(String(right)));
24
11
  }
@@ -43,15 +30,12 @@ function toDbJson(value, fallback = {}) {
43
30
  }
44
31
 
45
32
  export {
46
- toNullableDateTime,
47
33
  toIsoString,
48
34
  isDuplicateEntryError,
49
35
  normalizeText,
50
36
  normalizeLowerText,
51
37
  normalizeRecordId,
52
38
  normalizeDbRecordId,
53
- nowDb,
54
- toNullableIso,
55
39
  uniqueSorted,
56
40
  parseJson,
57
41
  toDbJson,
@@ -5,7 +5,6 @@ import {
5
5
  normalizeLowerText,
6
6
  normalizeRecordId,
7
7
  normalizeText,
8
- nowDb,
9
8
  toIsoString
10
9
  } from "./repositoryUtils.js";
11
10
  import {
@@ -89,7 +88,7 @@ function normalizeCreatePayload(payload = {}) {
89
88
  normalized.avatarVersion = normalizeNullableVersion(source.avatarVersion);
90
89
  }
91
90
  if (Object.hasOwn(source, "avatarUpdatedAt")) {
92
- normalized.avatarUpdatedAt = source.avatarUpdatedAt == null ? null : new Date(source.avatarUpdatedAt);
91
+ normalized.avatarUpdatedAt = source.avatarUpdatedAt == null ? null : toIsoString(source.avatarUpdatedAt);
93
92
  }
94
93
 
95
94
  return normalized;
@@ -238,7 +237,7 @@ function createRepository({ api, knex } = {}) {
238
237
  RESOURCE_TYPE,
239
238
  {
240
239
  displayName,
241
- updatedAt: new Date()
240
+ updatedAt: new Date().toISOString()
242
241
  },
243
242
  {
244
243
  id: normalizedUserId
@@ -265,8 +264,8 @@ function createRepository({ api, knex } = {}) {
265
264
  {
266
265
  avatarStorageKey: avatar.avatarStorageKey ?? null,
267
266
  avatarVersion: avatar.avatarVersion ?? null,
268
- avatarUpdatedAt: avatar.avatarUpdatedAt ?? nowDb(),
269
- updatedAt: new Date()
267
+ avatarUpdatedAt: toIsoString(avatar.avatarUpdatedAt ?? new Date()),
268
+ updatedAt: new Date().toISOString()
270
269
  },
271
270
  {
272
271
  id: normalizedUserId
@@ -294,7 +293,7 @@ function createRepository({ api, knex } = {}) {
294
293
  avatarStorageKey: null,
295
294
  avatarVersion: null,
296
295
  avatarUpdatedAt: null,
297
- updatedAt: new Date()
296
+ updatedAt: new Date().toISOString()
298
297
  },
299
298
  {
300
299
  id: normalizedUserId
@@ -350,7 +349,7 @@ function createRepository({ api, knex } = {}) {
350
349
  email,
351
350
  displayName,
352
351
  username,
353
- updatedAt: new Date()
352
+ updatedAt: new Date().toISOString()
354
353
  },
355
354
  {
356
355
  id: normalizeDbRecordId(existing.id, { fallback: null })
@@ -378,7 +377,7 @@ function createRepository({ api, knex } = {}) {
378
377
  email,
379
378
  displayName,
380
379
  username,
381
- createdAt: new Date()
380
+ createdAt: new Date().toISOString()
382
381
  }),
383
382
  transaction: trx
384
383
  },
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  normalizeRecordId,
3
- nowDb,
4
3
  isDuplicateEntryError,
5
4
  createWithTransaction
6
5
  } from "./repositoryUtils.js";
@@ -146,7 +145,7 @@ function createRepository({ api, knex } = {}) {
146
145
  RESOURCE_TYPE,
147
146
  {
148
147
  ...updatePayload,
149
- updatedAt: nowDb()
148
+ updatedAt: new Date().toISOString()
150
149
  },
151
150
  {
152
151
  id: normalizedUserId
@@ -235,9 +235,9 @@ test("userProfilesRepository.upsert patches existing profiles with resource-back
235
235
  assert.equal(attributes.email, "ada.renamed@example.com");
236
236
  assert.equal(attributes.displayName, "Ada Renamed");
237
237
  assert.equal(attributes.username, "ada");
238
- assert.ok(attributes.updatedAt instanceof Date);
238
+ assert.equal(typeof attributes.updatedAt, "string");
239
239
  assert.equal(record?.id, "7");
240
- assert.equal(record?.updatedAt, attributes.updatedAt.toISOString());
240
+ assert.equal(record?.updatedAt, attributes.updatedAt);
241
241
  });
242
242
 
243
243
  test("userProfilesRepository profile patch helpers stamp updatedAt through the resource contract", async () => {
@@ -285,7 +285,7 @@ test("userProfilesRepository profile patch helpers stamp updatedAt through the r
285
285
  assert.equal(calls.length, 3);
286
286
  for (const call of calls) {
287
287
  assert.equal(call.transaction, trx);
288
- assert.ok(call.inputRecord?.data?.attributes?.updatedAt instanceof Date);
288
+ assert.equal(typeof call.inputRecord?.data?.attributes?.updatedAt, "string");
289
289
  }
290
290
  assert.deepEqual(Object.keys(calls[0].inputRecord.data.attributes).sort(), ["displayName", "updatedAt"]);
291
291
  assert.deepEqual(Object.keys(calls[1].inputRecord.data.attributes).sort(), [
@@ -296,7 +296,7 @@ test("userProfilesRepository profile patch helpers stamp updatedAt through the r
296
296
  ]);
297
297
  assert.equal(calls[1].inputRecord.data.attributes.avatarStorageKey, "avatars/7.png");
298
298
  assert.equal(calls[1].inputRecord.data.attributes.avatarVersion, "v1");
299
- assert.equal(calls[1].inputRecord.data.attributes.avatarUpdatedAt, avatarUpdatedAt);
299
+ assert.equal(calls[1].inputRecord.data.attributes.avatarUpdatedAt, avatarUpdatedAt.toISOString());
300
300
  assert.deepEqual(calls[2].inputRecord.data.attributes.avatarStorageKey, null);
301
301
  assert.deepEqual(calls[2].inputRecord.data.attributes.avatarVersion, null);
302
302
  assert.deepEqual(calls[2].inputRecord.data.attributes.avatarUpdatedAt, null);