@openstax/ts-utils 1.15.2 → 1.15.3

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,6 +1,7 @@
1
1
  import { BatchGetItemCommand, DynamoDB, GetItemCommand, PutItemCommand, ScanCommand, UpdateItemCommand } from '@aws-sdk/client-dynamodb';
2
2
  import { once } from '../../..';
3
3
  import { resolveConfigValue } from '../../../config';
4
+ import { NotFoundError } from '../../../errors';
4
5
  import { ifDefined } from '../../../guards';
5
6
  import { decodeDynamoDocument, encodeDynamoAttribute, encodeDynamoDocument } from '../dynamoEncoding';
6
7
  const dynamodb = once(() => new DynamoDB({ apiVersion: '2012-08-10' }));
@@ -59,7 +60,7 @@ export const dynamoUnversionedDocumentStore = (initializer) => () => (configProv
59
60
  var _a;
60
61
  const result = (_a = item.Attributes) === null || _a === void 0 ? void 0 : _a[field]['N'];
61
62
  if (!result) {
62
- throw new Error(`Item with ${key} "${id}" does not exist`);
63
+ throw new NotFoundError(`Item with ${key} "${id}" does not exist`);
63
64
  }
64
65
  return parseFloat(result);
65
66
  });
@@ -2,6 +2,7 @@ import * as fsModule from 'fs';
2
2
  import path from 'path';
3
3
  import { hashValue } from '../../..';
4
4
  import { resolveConfigValue } from '../../../config';
5
+ import { NotFoundError } from '../../../errors';
5
6
  import { ifDefined, isDefined } from '../../../guards';
6
7
  export const fileSystemUnversionedDocumentStore = (initializer) => () => (configProvider) => (_, hashKey) => {
7
8
  const tableName = resolveConfigValue(configProvider[initializer.configSpace || 'fileSystem'].tableName);
@@ -72,7 +73,7 @@ export const fileSystemUnversionedDocumentStore = (initializer) => () => (config
72
73
  await mkTableDir;
73
74
  const data = await load(filename);
74
75
  if (!data) {
75
- throw new Error(`Item with ${hashKey.toString()} "${id}" does not exist`);
76
+ throw new NotFoundError(`Item with ${hashKey.toString()} "${id}" does not exist`);
76
77
  }
77
78
  const newItem = { ...data, ...item };
78
79
  return new Promise((resolve, reject) => {
@@ -1,4 +1,4 @@
1
- import { fileSystemUnversionedDocumentStore } from "../unversioned/file-system";
1
+ import { fileSystemUnversionedDocumentStore } from '../unversioned/file-system';
2
2
  const PAGE_LIMIT = 5;
3
3
  export const fileSystemVersionedDocumentStore = (initializer) => () => (configProvider) => (_, hashKey, getAuthor) => {
4
4
  const unversionedDocuments = fileSystemUnversionedDocumentStore(initializer)()(configProvider)({}, 'id');