@roastery/terroir 0.0.1 → 0.0.2

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.
Files changed (71) hide show
  1. package/dist/application-exception-Ck-CRA9W.d.cts +9 -0
  2. package/dist/application-exception-mi3iXk8r.d.ts +9 -0
  3. package/dist/chunk-EBPUXUYY.js +28 -0
  4. package/dist/chunk-N6MCTGZD.js +6 -0
  5. package/dist/chunk-UEZ4EF5Z.js +7 -0
  6. package/dist/chunk-WY3PDSMZ.js +27 -0
  7. package/dist/chunk-YBMFDZEW.js +53 -0
  8. package/dist/domain-exception-2mxDRlhr.d.ts +9 -0
  9. package/dist/domain-exception-BJknDTC7.d.cts +9 -0
  10. package/dist/exceptions/application/index.cjs +133 -0
  11. package/dist/exceptions/application/index.d.cts +6 -0
  12. package/dist/exceptions/application/index.d.ts +6 -0
  13. package/dist/exceptions/application/index.js +68 -0
  14. package/dist/exceptions/application/jwt/index.cjs +73 -0
  15. package/dist/exceptions/application/jwt/index.d.cts +20 -0
  16. package/dist/exceptions/application/jwt/index.d.ts +20 -0
  17. package/dist/exceptions/application/jwt/index.js +11 -0
  18. package/dist/{index.cjs → exceptions/core/index.cjs} +9 -8
  19. package/dist/exceptions/core/index.d.cts +11 -0
  20. package/dist/exceptions/core/index.d.ts +11 -0
  21. package/dist/exceptions/core/index.js +7 -0
  22. package/dist/exceptions/core/types/index.cjs +18 -0
  23. package/dist/exceptions/core/types/index.d.cts +3 -0
  24. package/dist/exceptions/core/types/index.d.ts +3 -0
  25. package/dist/exceptions/core/types/index.js +0 -0
  26. package/dist/exceptions/domain/index.cjs +86 -0
  27. package/dist/exceptions/domain/index.d.cts +5 -0
  28. package/dist/exceptions/domain/index.d.ts +5 -0
  29. package/dist/exceptions/domain/index.js +41 -0
  30. package/dist/exceptions/index.cjs +74 -0
  31. package/dist/exceptions/index.d.cts +4 -0
  32. package/dist/exceptions/index.d.ts +4 -0
  33. package/dist/exceptions/index.js +45 -0
  34. package/dist/exceptions/infra/index.cjs +158 -0
  35. package/dist/exceptions/infra/index.d.cts +5 -0
  36. package/dist/exceptions/infra/index.d.ts +5 -0
  37. package/dist/exceptions/infra/index.js +107 -0
  38. package/dist/exceptions/models/index.cjs +55 -0
  39. package/dist/exceptions/models/index.d.cts +6 -0
  40. package/dist/exceptions/models/index.d.ts +6 -0
  41. package/dist/exceptions/models/index.js +12 -0
  42. package/dist/exceptions/symbols/index.cjs +32 -0
  43. package/dist/exceptions/symbols/index.d.cts +3 -0
  44. package/dist/exceptions/symbols/index.d.ts +3 -0
  45. package/dist/exceptions/symbols/index.js +6 -0
  46. package/dist/exceptions/types/index.cjs +18 -0
  47. package/dist/exceptions/types/index.d.cts +30 -0
  48. package/dist/exceptions/types/index.d.ts +30 -0
  49. package/dist/exceptions/types/index.js +0 -0
  50. package/dist/index-0ZqtQ0BA.d.ts +89 -0
  51. package/dist/index-B_h1N1CO.d.cts +55 -0
  52. package/dist/index-C4-MCapS.d.ts +40 -0
  53. package/dist/index-CNApJ5kV.d.ts +35 -0
  54. package/dist/index-DaS_UsEv.d.cts +89 -0
  55. package/dist/index-E6KvVxtW.d.ts +55 -0
  56. package/dist/index-YFuBgYBS.d.cts +35 -0
  57. package/dist/index-g4_PChJX.d.cts +40 -0
  58. package/dist/infra-exception-1PUIDeP4.d.ts +9 -0
  59. package/dist/infra-exception-Dm1D9yrN.d.cts +9 -0
  60. package/dist/schema/formats/index.cjs +55 -0
  61. package/dist/schema/formats/index.d.cts +2 -0
  62. package/dist/schema/formats/index.d.ts +2 -0
  63. package/dist/schema/formats/index.js +1 -0
  64. package/dist/schema/index.cjs +195 -0
  65. package/dist/schema/index.d.cts +19 -0
  66. package/dist/schema/index.d.ts +19 -0
  67. package/dist/schema/index.js +115 -0
  68. package/package.json +7 -8
  69. package/dist/index.d.cts +0 -3
  70. package/dist/index.d.ts +0 -3
  71. package/dist/index.js +0 -5
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/schema/index.ts
21
+ var schema_exports = {};
22
+ __export(schema_exports, {
23
+ Schema: () => Schema,
24
+ SchemaManager: () => SchemaManager
25
+ });
26
+ module.exports = __toCommonJS(schema_exports);
27
+
28
+ // src/schema/formats/date-time.ts
29
+ var import_typebox = require("@sinclair/typebox");
30
+ import_typebox.FormatRegistry.Set("date-time", (value) => {
31
+ return !Number.isNaN(Date.parse(value));
32
+ });
33
+
34
+ // src/schema/formats/url.ts
35
+ var import_typebox2 = require("@sinclair/typebox");
36
+ import_typebox2.FormatRegistry.Set("url", (value) => {
37
+ try {
38
+ const url = new URL(value);
39
+ return url.hostname.includes(".");
40
+ } catch {
41
+ return false;
42
+ }
43
+ });
44
+
45
+ // src/schema/formats/uuid.ts
46
+ var import_typebox3 = require("@sinclair/typebox");
47
+ var import_uuid = require("uuid");
48
+ import_typebox3.FormatRegistry.Set("uuid", (value) => (0, import_uuid.validate)(value) && (0, import_uuid.version)(value) === 7);
49
+
50
+ // src/schema/formats/slug.ts
51
+ var import_typebox4 = require("@sinclair/typebox");
52
+ var slugPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
53
+ import_typebox4.FormatRegistry.Set("slug", (value) => slugPattern.test(value));
54
+
55
+ // src/schema/formats/email.ts
56
+ var import_typebox5 = require("@sinclair/typebox");
57
+ var emailPattern = /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i;
58
+ import_typebox5.FormatRegistry.Set("email", (value) => emailPattern.test(value));
59
+
60
+ // src/schema/formats/json.ts
61
+ var import_typebox6 = require("@sinclair/typebox");
62
+ import_typebox6.FormatRegistry.Set("json", (value) => {
63
+ try {
64
+ JSON.parse(value);
65
+ return true;
66
+ } catch {
67
+ return false;
68
+ }
69
+ });
70
+
71
+ // src/schema/formats/simple-url.ts
72
+ var import_typebox7 = require("@sinclair/typebox");
73
+ import_typebox7.FormatRegistry.Set("simple-url", (value) => {
74
+ try {
75
+ new URL(value);
76
+ return true;
77
+ } catch {
78
+ return false;
79
+ }
80
+ });
81
+
82
+ // src/schema/schema.ts
83
+ var import_value = require("@sinclair/typebox/value");
84
+ var import_compiler = require("@sinclair/typebox/compiler");
85
+ var Schema = class _Schema {
86
+ constructor(schema) {
87
+ this.schema = schema;
88
+ this.compiledSchema = import_compiler.TypeCompiler.Compile(this.schema);
89
+ }
90
+ compiledSchema;
91
+ static make(schema) {
92
+ return new _Schema(schema);
93
+ }
94
+ match(content) {
95
+ return this.compiledSchema.Check(content);
96
+ }
97
+ map(content) {
98
+ return import_value.Value.Clean(
99
+ this.schema,
100
+ import_value.Value.Cast(this.schema, import_value.Value.Convert(this.schema, content))
101
+ );
102
+ }
103
+ toString() {
104
+ return JSON.stringify(this.schema);
105
+ }
106
+ toJSON() {
107
+ return this.schema;
108
+ }
109
+ };
110
+
111
+ // src/schema/schema-manager.ts
112
+ var import_compiler2 = require("@sinclair/typebox/compiler");
113
+
114
+ // src/schema/utils/hydrate-schema.ts
115
+ var import_type = require("@sinclair/typebox/type");
116
+ function hydrateSchema(schema) {
117
+ if (typeof schema !== "object" || schema === null) return schema;
118
+ if (Array.isArray(schema)) return schema.map(hydrateSchema);
119
+ const newSchema = { ...schema };
120
+ if (newSchema.properties) {
121
+ for (const key in newSchema.properties) {
122
+ newSchema.properties[key] = hydrateSchema(
123
+ newSchema.properties[key]
124
+ );
125
+ }
126
+ }
127
+ if (newSchema.items) {
128
+ newSchema.items = hydrateSchema(newSchema.items);
129
+ }
130
+ if (newSchema.additionalProperties && typeof newSchema.additionalProperties === "object") {
131
+ newSchema.additionalProperties = hydrateSchema(
132
+ newSchema.additionalProperties
133
+ );
134
+ }
135
+ if (newSchema.anyOf) newSchema.anyOf = newSchema.anyOf.map(hydrateSchema);
136
+ if (newSchema.allOf) newSchema.allOf = newSchema.allOf.map(hydrateSchema);
137
+ if (newSchema.oneOf) newSchema.oneOf = newSchema.oneOf.map(hydrateSchema);
138
+ if (newSchema.not) newSchema.not = hydrateSchema(newSchema.not);
139
+ if (newSchema.type === "string") newSchema[import_type.Kind] = "String";
140
+ else if (newSchema.type === "number") newSchema[import_type.Kind] = "Number";
141
+ else if (newSchema.type === "integer") newSchema[import_type.Kind] = "Integer";
142
+ else if (newSchema.type === "boolean") newSchema[import_type.Kind] = "Boolean";
143
+ else if (newSchema.type === "array") newSchema[import_type.Kind] = "Array";
144
+ else if (newSchema.type === "object") newSchema[import_type.Kind] = "Object";
145
+ else if (newSchema.type === "null") newSchema[import_type.Kind] = "Null";
146
+ if (newSchema.anyOf) newSchema[import_type.Kind] = "Union";
147
+ if (newSchema.allOf) newSchema[import_type.Kind] = "Intersect";
148
+ if (newSchema.not) newSchema[import_type.Kind] = "Not";
149
+ if (newSchema.const !== void 0) newSchema[import_type.Kind] = "Literal";
150
+ if (newSchema.type === "array" && Array.isArray(newSchema.items)) {
151
+ newSchema[import_type.Kind] = "Tuple";
152
+ }
153
+ if (newSchema.type === "object" && newSchema.patternProperties && !newSchema.properties) {
154
+ newSchema[import_type.Kind] = "Record";
155
+ for (const key in newSchema.patternProperties) {
156
+ newSchema.patternProperties[key] = hydrateSchema(
157
+ newSchema.patternProperties[key]
158
+ );
159
+ }
160
+ } else if (newSchema.patternProperties) {
161
+ for (const key in newSchema.patternProperties) {
162
+ newSchema.patternProperties[key] = hydrateSchema(
163
+ newSchema.patternProperties[key]
164
+ );
165
+ }
166
+ }
167
+ if (Object.keys(newSchema).length === 0) {
168
+ newSchema[import_type.Kind] = "Any";
169
+ }
170
+ return newSchema;
171
+ }
172
+
173
+ // src/schema/schema-manager.ts
174
+ var SchemaManager = {
175
+ build(schema) {
176
+ const parsedSchema = JSON.parse(schema);
177
+ const hydrated = hydrateSchema(parsedSchema);
178
+ return new Schema(hydrated);
179
+ },
180
+ isSchema(schema) {
181
+ try {
182
+ if (typeof schema === "string") schema = JSON.parse(schema);
183
+ const hydrated = hydrateSchema(schema);
184
+ import_compiler2.TypeCompiler.Compile(hydrated);
185
+ return true;
186
+ } catch (_) {
187
+ return false;
188
+ }
189
+ }
190
+ };
191
+ // Annotate the CommonJS export names for ESM import in node:
192
+ 0 && (module.exports = {
193
+ Schema,
194
+ SchemaManager
195
+ });
@@ -0,0 +1,19 @@
1
+ import { TSchema, Static } from '@sinclair/typebox';
2
+
3
+ declare class Schema<SchemaType extends TSchema> {
4
+ private schema;
5
+ private compiledSchema;
6
+ constructor(schema: SchemaType);
7
+ static make<SchemaType extends TSchema>(schema: SchemaType): Schema<SchemaType>;
8
+ match(content: unknown): boolean;
9
+ map(content: unknown): Static<SchemaType>;
10
+ toString(): string;
11
+ toJSON(): typeof this.schema;
12
+ }
13
+
14
+ declare const SchemaManager: {
15
+ build<SchemaType extends TSchema>(schema: string): Schema<SchemaType>;
16
+ isSchema(schema: unknown): boolean;
17
+ };
18
+
19
+ export { Schema, SchemaManager };
@@ -0,0 +1,19 @@
1
+ import { TSchema, Static } from '@sinclair/typebox';
2
+
3
+ declare class Schema<SchemaType extends TSchema> {
4
+ private schema;
5
+ private compiledSchema;
6
+ constructor(schema: SchemaType);
7
+ static make<SchemaType extends TSchema>(schema: SchemaType): Schema<SchemaType>;
8
+ match(content: unknown): boolean;
9
+ map(content: unknown): Static<SchemaType>;
10
+ toString(): string;
11
+ toJSON(): typeof this.schema;
12
+ }
13
+
14
+ declare const SchemaManager: {
15
+ build<SchemaType extends TSchema>(schema: string): Schema<SchemaType>;
16
+ isSchema(schema: unknown): boolean;
17
+ };
18
+
19
+ export { Schema, SchemaManager };
@@ -0,0 +1,115 @@
1
+ import "../chunk-YBMFDZEW.js";
2
+
3
+ // src/schema/schema.ts
4
+ import { Value } from "@sinclair/typebox/value";
5
+ import { TypeCompiler } from "@sinclair/typebox/compiler";
6
+ var Schema = class _Schema {
7
+ constructor(schema) {
8
+ this.schema = schema;
9
+ this.compiledSchema = TypeCompiler.Compile(this.schema);
10
+ }
11
+ compiledSchema;
12
+ static make(schema) {
13
+ return new _Schema(schema);
14
+ }
15
+ match(content) {
16
+ return this.compiledSchema.Check(content);
17
+ }
18
+ map(content) {
19
+ return Value.Clean(
20
+ this.schema,
21
+ Value.Cast(this.schema, Value.Convert(this.schema, content))
22
+ );
23
+ }
24
+ toString() {
25
+ return JSON.stringify(this.schema);
26
+ }
27
+ toJSON() {
28
+ return this.schema;
29
+ }
30
+ };
31
+
32
+ // src/schema/schema-manager.ts
33
+ import { TypeCompiler as TypeCompiler2 } from "@sinclair/typebox/compiler";
34
+
35
+ // src/schema/utils/hydrate-schema.ts
36
+ import { Kind } from "@sinclair/typebox/type";
37
+ function hydrateSchema(schema) {
38
+ if (typeof schema !== "object" || schema === null) return schema;
39
+ if (Array.isArray(schema)) return schema.map(hydrateSchema);
40
+ const newSchema = { ...schema };
41
+ if (newSchema.properties) {
42
+ for (const key in newSchema.properties) {
43
+ newSchema.properties[key] = hydrateSchema(
44
+ newSchema.properties[key]
45
+ );
46
+ }
47
+ }
48
+ if (newSchema.items) {
49
+ newSchema.items = hydrateSchema(newSchema.items);
50
+ }
51
+ if (newSchema.additionalProperties && typeof newSchema.additionalProperties === "object") {
52
+ newSchema.additionalProperties = hydrateSchema(
53
+ newSchema.additionalProperties
54
+ );
55
+ }
56
+ if (newSchema.anyOf) newSchema.anyOf = newSchema.anyOf.map(hydrateSchema);
57
+ if (newSchema.allOf) newSchema.allOf = newSchema.allOf.map(hydrateSchema);
58
+ if (newSchema.oneOf) newSchema.oneOf = newSchema.oneOf.map(hydrateSchema);
59
+ if (newSchema.not) newSchema.not = hydrateSchema(newSchema.not);
60
+ if (newSchema.type === "string") newSchema[Kind] = "String";
61
+ else if (newSchema.type === "number") newSchema[Kind] = "Number";
62
+ else if (newSchema.type === "integer") newSchema[Kind] = "Integer";
63
+ else if (newSchema.type === "boolean") newSchema[Kind] = "Boolean";
64
+ else if (newSchema.type === "array") newSchema[Kind] = "Array";
65
+ else if (newSchema.type === "object") newSchema[Kind] = "Object";
66
+ else if (newSchema.type === "null") newSchema[Kind] = "Null";
67
+ if (newSchema.anyOf) newSchema[Kind] = "Union";
68
+ if (newSchema.allOf) newSchema[Kind] = "Intersect";
69
+ if (newSchema.not) newSchema[Kind] = "Not";
70
+ if (newSchema.const !== void 0) newSchema[Kind] = "Literal";
71
+ if (newSchema.type === "array" && Array.isArray(newSchema.items)) {
72
+ newSchema[Kind] = "Tuple";
73
+ }
74
+ if (newSchema.type === "object" && newSchema.patternProperties && !newSchema.properties) {
75
+ newSchema[Kind] = "Record";
76
+ for (const key in newSchema.patternProperties) {
77
+ newSchema.patternProperties[key] = hydrateSchema(
78
+ newSchema.patternProperties[key]
79
+ );
80
+ }
81
+ } else if (newSchema.patternProperties) {
82
+ for (const key in newSchema.patternProperties) {
83
+ newSchema.patternProperties[key] = hydrateSchema(
84
+ newSchema.patternProperties[key]
85
+ );
86
+ }
87
+ }
88
+ if (Object.keys(newSchema).length === 0) {
89
+ newSchema[Kind] = "Any";
90
+ }
91
+ return newSchema;
92
+ }
93
+
94
+ // src/schema/schema-manager.ts
95
+ var SchemaManager = {
96
+ build(schema) {
97
+ const parsedSchema = JSON.parse(schema);
98
+ const hydrated = hydrateSchema(parsedSchema);
99
+ return new Schema(hydrated);
100
+ },
101
+ isSchema(schema) {
102
+ try {
103
+ if (typeof schema === "string") schema = JSON.parse(schema);
104
+ const hydrated = hydrateSchema(schema);
105
+ TypeCompiler2.Compile(hydrated);
106
+ return true;
107
+ } catch (_) {
108
+ return false;
109
+ }
110
+ }
111
+ };
112
+ export {
113
+ Schema,
114
+ SchemaManager
115
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roastery/terroir",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Alan Reis",
@@ -34,26 +34,25 @@
34
34
  ],
35
35
  "scripts": {
36
36
  "build": "tsup 'src/**/index.ts' --format cjs,esm --dts --tsconfig tsconfig.build.json --clean",
37
- "test:unit": "vitest run",
38
- "test:ui": "vitest --ui",
39
- "test:coverage": "vitest run --coverage",
37
+ "test:unit": "bun test --env-file=.env.testing",
38
+ "test:coverage": "bun test --env-file=.env.testing --coverage",
40
39
  "setup": "bun run build && bun link",
41
40
  "prepare": "husky || true"
42
41
  },
43
42
  "devDependencies": {
44
43
  "@faker-js/faker": "^10.2.0",
45
- "@types/bun": "latest",
46
44
  "@vitest/coverage-v8": "^4.0.18",
47
45
  "@vitest/ui": "^4.0.18",
48
46
  "tsup": "^8.5.1",
49
- "vite-tsconfig-paths": "^6.0.5",
50
- "vitest": "^4.0.18",
51
47
  "@commitlint/cli": "^20.4.1",
52
48
  "@commitlint/config-conventional": "^20.4.1",
53
49
  "husky": "^9.1.7"
54
50
  },
55
51
  "peerDependencies": {
56
- "typescript": "^5"
52
+ "typescript": "^5",
53
+ "@sinclair/typebox": ">= 0.34.0 < 1",
54
+ "@types/bun": "latest",
55
+ "uuid": "^13.0.0"
57
56
  },
58
57
  "dependencies": {}
59
58
  }
package/dist/index.d.cts DELETED
@@ -1,3 +0,0 @@
1
- declare const hello = "world";
2
-
3
- export { hello };
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare const hello = "world";
2
-
3
- export { hello };
package/dist/index.js DELETED
@@ -1,5 +0,0 @@
1
- // src/hello.ts
2
- var hello = "world";
3
- export {
4
- hello
5
- };