unconventional 1.18.0 → 2.0.1

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.
@@ -272,7 +272,7 @@ class AbstractBaseController {
272
272
  }
273
273
  return {
274
274
  headers: ctx.req.raw.headers,
275
- waitUntil: ctx.executionCtx.waitUntil,
275
+ waitUntil: ctx.executionCtx?.waitUntil.bind(ctx.executionCtx),
276
276
  body: body,
277
277
  params: ctx.req.param(),
278
278
  queries: ctx.req.query(),
@@ -9,12 +9,17 @@ interface BaseModelSchema {
9
9
  updatedField: string;
10
10
  };
11
11
  }
12
+ export declare enum IdType {
13
+ Number = "number",
14
+ UUID = "uuid"
15
+ }
12
16
  export declare class Document {
13
17
  static schema: BaseModelSchema;
14
18
  }
15
19
  export declare class BaseModel extends Document {
16
20
  static collection: string;
17
21
  static idField: string;
22
+ static idType: IdType;
18
23
  static keyField?: string;
19
24
  static ownerField?: string;
20
25
  static db: DB;
@@ -9,13 +9,18 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TimeStamped = exports.BaseModel = exports.Document = void 0;
12
+ exports.TimeStamped = exports.BaseModel = exports.Document = exports.IdType = void 0;
13
13
  const unconventional_pg_queries_1 = require("unconventional-pg-queries");
14
14
  const prop_decorator_1 = require("../decorators/prop.decorator");
15
15
  const timestamp_decorator_1 = require("../decorators/timestamp.decorator");
16
16
  const db_types_1 = require("../types/db.types");
17
17
  const db_utils_1 = require("../utils/db.utils");
18
18
  const utils_1 = require("../utils");
19
+ var IdType;
20
+ (function (IdType) {
21
+ IdType["Number"] = "number";
22
+ IdType["UUID"] = "uuid";
23
+ })(IdType || (exports.IdType = IdType = {}));
19
24
  class Document {
20
25
  static schema = { indexes: [], props: {} };
21
26
  }
@@ -23,6 +28,7 @@ exports.Document = Document;
23
28
  class BaseModel extends Document {
24
29
  static collection;
25
30
  static idField = 'id';
31
+ static idType = IdType.Number;
26
32
  static keyField;
27
33
  static ownerField;
28
34
  static db;
@@ -212,7 +218,7 @@ class BaseModel extends Document {
212
218
  }
213
219
  /** Gets the field name to use for the provided identifier */
214
220
  static getFieldName(identifier) {
215
- return !isNaN(+identifier) || (0, utils_1.isUUID)(`${identifier}`)
221
+ return (this.idType === IdType.Number && !isNaN(+identifier)) || (this.idType === IdType.UUID && (0, utils_1.isUUID)(`${identifier}`))
216
222
  ? this.idField
217
223
  : this.keyField || undefined;
218
224
  }
@@ -4,6 +4,7 @@ exports.BaseService = void 0;
4
4
  const unconventional_pg_queries_1 = require("unconventional-pg-queries");
5
5
  const api_error_1 = require("./api-error");
6
6
  const base_cache_1 = require("./base.cache");
7
+ const base_model_1 = require("./base.model");
7
8
  const db_utils_1 = require("../utils/db.utils");
8
9
  const utils_1 = require("../utils");
9
10
  class BaseService {
@@ -61,7 +62,7 @@ class BaseService {
61
62
  entity = await base_cache_1.BaseCache.getModel(cache, this.model, identifier, modifiers);
62
63
  }
63
64
  if (!entity) {
64
- if (!isNaN(+identifier) || (0, utils_1.isUUID)(`${identifier}`)) {
65
+ if ((this.model.idType === base_model_1.IdType.Number && !isNaN(+identifier)) || (this.model.idType === base_model_1.IdType.UUID && (0, utils_1.isUUID)(`${identifier}`))) {
65
66
  entity = await this.model.findById(identifier, modifiers);
66
67
  }
67
68
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unconventional",
3
- "version": "1.18.0",
3
+ "version": "2.0.1",
4
4
  "description": "A complete server built on Cloudflare Workers/Pages",
5
5
  "keywords": [
6
6
  "cloudflare",