@bgord/bun 0.18.16 → 0.18.18

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": "@bgord/bun",
3
- "version": "0.18.16",
3
+ "version": "0.18.18",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": "Bartosz Gordon",
@@ -23,27 +23,27 @@
23
23
  "@biomejs/biome": "2.0.6",
24
24
  "@commitlint/cli": "19.8.1",
25
25
  "@commitlint/config-conventional": "19.8.1",
26
- "@types/bun": "1.2.19",
26
+ "@types/bun": "1.2.20",
27
27
  "@types/lodash": "4.17.20",
28
28
  "@types/mime-types": "3.0.1",
29
29
  "@types/nodemailer": "6.4.17",
30
30
  "@types/yazl": "3.3.0",
31
31
  "cspell": "9.2.0",
32
32
  "knip": "5.62.0",
33
- "lefthook": "1.12.2",
33
+ "lefthook": "1.12.3",
34
34
  "only-allow": "1.2.1",
35
35
  "shellcheck": "3.1.0",
36
36
  "typescript": "5.9.2"
37
37
  },
38
38
  "dependencies": {
39
39
  "@axiomhq/winston": "1.3.1",
40
- "@bgord/tools": "0.12.6",
40
+ "@bgord/tools": "0.12.8",
41
41
  "@hono/ua-blocker": "0.1.7",
42
- "better-auth": "1.3.4",
42
+ "better-auth": "1.3.5",
43
43
  "check-disk-space": "3.4.0",
44
44
  "croner": "9.1.0",
45
45
  "hcaptcha": "0.2.0",
46
- "hono": "4.8.12",
46
+ "hono": "4.9.1",
47
47
  "lodash": "4.17.21",
48
48
  "mime-types": "3.0.1",
49
49
  "node-cache": "5.1.2",
package/readme.md CHANGED
@@ -60,6 +60,8 @@ src/
60
60
  ├── i18n.service.ts
61
61
  ├── image-compressor.service.ts
62
62
  ├── image-exif.service.ts
63
+ ├── invariant-error-handler.service.ts
64
+ ├── invariant.service.ts
63
65
  ├── jobs.service.ts
64
66
  ├── logger.service.ts
65
67
  ├── mailer.port.ts
@@ -69,8 +71,6 @@ src/
69
71
  ├── noop-mailer.adapter.ts
70
72
  ├── open-graph.service.ts
71
73
  ├── path.vo.ts
72
- ├── policy-error-handler.service.ts
73
- ├── policy.service.ts
74
74
  ├── port.vo.ts
75
75
  ├── prerequisites
76
76
  │   ├── binary.ts
package/src/index.ts CHANGED
@@ -34,6 +34,8 @@ export * from "./http-logger.middleware";
34
34
  export * from "./i18n.service";
35
35
  export * from "./image-compressor.service";
36
36
  export * from "./image-exif.service";
37
+ export * from "./invariant.service";
38
+ export * from "./invariant-error-handler.service";
37
39
  export * from "./jobs.service";
38
40
  export * from "./logger.service";
39
41
  export * from "./mailer.port";
@@ -43,8 +45,6 @@ export * from "./node-env.vo";
43
45
  export * from "./noop-mailer.adapter";
44
46
  export * from "./open-graph.service";
45
47
  export * from "./path.vo";
46
- export * from "./policy.service";
47
- export * from "./policy-error-handler.service";
48
48
  export * from "./port.vo";
49
49
  export * from "./prerequisites/index";
50
50
  export * from "./prerequisites.service";
@@ -0,0 +1,23 @@
1
+ import type { Invariant } from "./invariant.service";
2
+
3
+ type BaseInvariantType = Invariant<any>;
4
+
5
+ type InvariantMessageType = BaseInvariantType["message"];
6
+ type InvariantCodeType = BaseInvariantType["code"];
7
+
8
+ type ErrorResponseTupleType = [{ message: InvariantMessageType; _known: true }, InvariantCodeType];
9
+
10
+ export class InvariantErrorHandler {
11
+ error: BaseInvariantType | undefined = undefined;
12
+
13
+ constructor(private readonly invariants: BaseInvariantType[]) {}
14
+
15
+ detect(error: unknown) {
16
+ this.error = this.invariants.find((invariant) => error instanceof invariant.error);
17
+ return this;
18
+ }
19
+
20
+ static respond(error: BaseInvariantType): ErrorResponseTupleType {
21
+ return [{ message: error.message, _known: true }, error.code];
22
+ }
23
+ }
@@ -1,9 +1,9 @@
1
1
  import type { Constructor } from "@bgord/tools";
2
2
  import type { ContentfulStatusCode } from "hono/utils/http-status";
3
3
 
4
- type BasePolicyConfig = Record<string, unknown>;
4
+ type BaseInvariantConfig = Record<string, unknown>;
5
5
 
6
- export abstract class Policy<T extends BasePolicyConfig> {
6
+ export abstract class Invariant<T extends BaseInvariantConfig> {
7
7
  abstract fails(config: T): boolean;
8
8
 
9
9
  abstract error: Constructor<Error>;
@@ -1,17 +0,0 @@
1
- import type { Policy } from "./policy.service";
2
- type BasePolicyType = Policy<any>;
3
- type PolicyMessageType = BasePolicyType["message"];
4
- type PolicyCodeType = BasePolicyType["code"];
5
- type ErrorResponseTupleType = [{
6
- message: PolicyMessageType;
7
- _known: true;
8
- }, PolicyCodeType];
9
- export declare class PolicyErrorHandler {
10
- private readonly policies;
11
- error: BasePolicyType | undefined;
12
- constructor(policies: BasePolicyType[]);
13
- detect(error: unknown): this;
14
- static respond(error: BasePolicyType): ErrorResponseTupleType;
15
- }
16
- export {};
17
- //# sourceMappingURL=policy-error-handler.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"policy-error-handler.service.d.ts","sourceRoot":"","sources":["../src/policy-error-handler.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,KAAK,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AAElC,KAAK,iBAAiB,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;AACnD,KAAK,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAE7C,KAAK,sBAAsB,GAAG,CAAC;IAAE,OAAO,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,IAAI,CAAA;CAAE,EAAE,cAAc,CAAC,CAAC;AAE7F,qBAAa,kBAAkB;IAGjB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,KAAK,EAAE,cAAc,GAAG,SAAS,CAAa;gBAEjB,QAAQ,EAAE,cAAc,EAAE;IAEvD,MAAM,CAAC,KAAK,EAAE,OAAO;IAKrB,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,sBAAsB;CAG9D"}
@@ -1,15 +0,0 @@
1
- export class PolicyErrorHandler {
2
- policies;
3
- error = undefined;
4
- constructor(policies) {
5
- this.policies = policies;
6
- }
7
- detect(error) {
8
- this.error = this.policies.find((policy) => error instanceof policy.error);
9
- return this;
10
- }
11
- static respond(error) {
12
- return [{ message: error.message, _known: true }, error.code];
13
- }
14
- }
15
- //# sourceMappingURL=policy-error-handler.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"policy-error-handler.service.js","sourceRoot":"","sources":["../src/policy-error-handler.service.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,kBAAkB;IAGA;IAF7B,KAAK,GAA+B,SAAS,CAAC;IAE9C,YAA6B,QAA0B;QAA1B,aAAQ,GAAR,QAAQ,CAAkB;IAAG,CAAC;IAE3D,MAAM,CAAC,KAAc;QACnB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,YAAY,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,KAAqB;QAClC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"policy.service.d.ts","sourceRoot":"","sources":["../src/policy.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEhD,8BAAsB,MAAM,CAAC,CAAC,SAAS,gBAAgB;IACrD,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO;IAElC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAEnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAEpC,KAAK;IAIL,OAAO,CAAC,MAAM,EAAE,CAAC;IAMjB,MAAM,CAAC,MAAM,EAAE,CAAC;CAGjB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"policy.service.js","sourceRoot":"","sources":["../src/policy.service.ts"],"names":[],"mappings":"AAKA,MAAM,OAAgB,MAAM;IAS1B,KAAK;QACH,MAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,MAAS;QACf,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IAED,MAAM,CAAC,MAAS;QACd,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;CACF"}
@@ -1,23 +0,0 @@
1
- import type { Policy } from "./policy.service";
2
-
3
- type BasePolicyType = Policy<any>;
4
-
5
- type PolicyMessageType = BasePolicyType["message"];
6
- type PolicyCodeType = BasePolicyType["code"];
7
-
8
- type ErrorResponseTupleType = [{ message: PolicyMessageType; _known: true }, PolicyCodeType];
9
-
10
- export class PolicyErrorHandler {
11
- error: BasePolicyType | undefined = undefined;
12
-
13
- constructor(private readonly policies: BasePolicyType[]) {}
14
-
15
- detect(error: unknown) {
16
- this.error = this.policies.find((policy) => error instanceof policy.error);
17
- return this;
18
- }
19
-
20
- static respond(error: BasePolicyType): ErrorResponseTupleType {
21
- return [{ message: error.message, _known: true }, error.code];
22
- }
23
- }