dynamoose-utils 3.0.0-alpha.2 → 3.0.0-beta.12

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/lib/Error.ts ADDED
@@ -0,0 +1,24 @@
1
+ const makeError = (defaultMessage: string, errorName: string) => class CustomError extends Error { // eslint-disable-line @typescript-eslint/explicit-function-return-type
2
+ name: string;
3
+ message: string;
4
+
5
+ constructor (message: string) {
6
+ super();
7
+ this.name = errorName;
8
+ this.message = message || defaultMessage;
9
+ return this;
10
+ }
11
+ };
12
+
13
+ export = {
14
+ "MissingSchemaError": makeError("Missing Schema", "MissingSchemaError"),
15
+ "InvalidParameter": makeError("Invalid Parameter", "InvalidParameter"),
16
+ "InvalidParameterType": makeError("Invalid Parameter Type", "InvalidParameterType"),
17
+ "UnknownAttribute": makeError("The attribute can not be found", "UnknownAttribute"),
18
+ "InvalidType": makeError("Invalid Type", "InvalidType"),
19
+ "WaitForActiveTimeout": makeError("Waiting for table to be active has timed out", "WaitForActiveTimeout"),
20
+ "TypeMismatch": makeError("There was a type mismatch between the schema and document", "TypeMismatch"),
21
+ "InvalidFilterComparison": makeError("That filter comparison is invalid", "InvalidFilterComparison"),
22
+ "ValidationError": makeError("There was an validation error with the document", "ValidationError"),
23
+ "OtherError": makeError("There was an error", "OtherError")
24
+ };
package/lib/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ import wildcard_allowed_check from "./wildcard_allowed_check";
2
+ import CustomError = require("./Error");
3
+
4
+ export {
5
+ wildcard_allowed_check,
6
+ CustomError
7
+ };
@@ -0,0 +1,24 @@
1
+ export default (saveUnknown: string[] | boolean, checkKey: string, settings = {"splitString": ".", "prefixesDisallowed": true}): boolean => {
2
+ if (Array.isArray(saveUnknown)) {
3
+ return Boolean(saveUnknown.find((key) => {
4
+ const keyParts = key.split(settings.splitString);
5
+ const checkKeyParts = checkKey.split(settings.splitString);
6
+ let index = 0, keyPart = keyParts[0];
7
+ for (let i = 0; i < checkKeyParts.length; i++) {
8
+ if (keyPart === "**") {
9
+ return true;
10
+ }
11
+ if (keyPart !== "*" && checkKeyParts[i] !== keyPart) {
12
+ return false;
13
+ }
14
+ keyPart = keyParts[++index];
15
+ }
16
+ if (!settings.prefixesDisallowed && keyPart) {
17
+ return false;
18
+ }
19
+ return true;
20
+ }));
21
+ } else {
22
+ return saveUnknown;
23
+ }
24
+ };
package/package.json CHANGED
@@ -1,63 +1,26 @@
1
1
  {
2
2
  "name": "dynamoose-utils",
3
- "version": "3.0.0-alpha.2",
4
- "description": "Internal utilities for Dynamoose",
3
+ "version": "3.0.0-beta.12",
4
+ "description": "Dynamoose is a modeling tool for Amazon's DynamoDB (inspired by Mongoose)",
5
+ "homepage": "https://dynamoosejs.com",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
7
- "scripts": {
8
- "prepare": "npm run build:clean && npm run build",
9
- "build": "tsc",
10
- "build:sourcemap": "tsc --sourceMap",
11
- "build:clean": "rimraf dist",
12
- "build:watch": "npm run build -- -w",
13
- "lint": "eslint . --ext .ts,.js --max-warnings 0",
14
- "lint:fix": "npm run lint -- --fix"
15
- },
16
8
  "repository": {
17
9
  "type": "git",
18
- "url": "git+https://github.com/dynamoose/dynamoose-utils.git"
10
+ "url": "git+https://github.com/dynamoose/dynamoose.git"
19
11
  },
20
12
  "author": {
21
13
  "name": "Charlie Fish",
22
14
  "email": "fishcharlie.code@gmail.com",
23
15
  "url": "https://charlie.fish"
24
16
  },
25
- "contributors": [
26
- {
27
- "name": "Brandon Goode"
28
- }
29
- ],
30
- "license": "Unlicense",
31
- "keywords": [
32
- "dynamodb",
33
- "dynamo",
34
- "mongoose",
35
- "aws",
36
- "amazon",
37
- "document",
38
- "model",
39
- "schema",
40
- "database",
41
- "data",
42
- "datastore",
43
- "query",
44
- "scan",
45
- "nosql",
46
- "db",
47
- "nosql",
48
- "store",
49
- "document store",
50
- "table",
51
- "json",
52
- "object",
53
- "storage"
54
- ],
55
- "engines": {
56
- "node": ">=10.0.0"
17
+ "scripts": {
18
+ "build": "tsc"
57
19
  },
58
- "files": [
59
- "dist"
60
- ],
20
+ "dependencies": {
21
+ "js-object-utilities": "^2.1.0"
22
+ },
23
+ "license": "Unlicense",
61
24
  "funding": [
62
25
  {
63
26
  "type": "github-sponsors",
@@ -68,20 +31,5 @@
68
31
  "url": "https://opencollective.com/dynamoose"
69
32
  }
70
33
  ],
71
- "bugs": {
72
- "url": "https://github.com/dynamoose/dynamoose-utils/issues"
73
- },
74
- "homepage": "https://dynamoosejs.com",
75
- "devDependencies": {
76
- "@types/node": "^14.14.35",
77
- "@typescript-eslint/eslint-plugin": "^4.18.0",
78
- "@typescript-eslint/parser": "^4.18.0",
79
- "eslint": "^7.22.0",
80
- "nyc": "^15.1.0",
81
- "rimraf": "^3.0.2",
82
- "typescript": "^4.2.3"
83
- },
84
- "dependencies": {
85
- "js-object-utilities": "^2.0.0"
86
- }
34
+ "gitHead": "8a92a6554c20d8290fbdeb82470d5190318dcfdb"
87
35
  }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist"
5
+ },
6
+ "include": ["./lib/**/*"]
7
+ }