@turystack/entity 0.0.3 → 0.0.4

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,2 +1,2 @@
1
- export { Entity } from './entity.js';
1
+ export * from './entity.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -1,2 +1,2 @@
1
- export { Entity } from './entity.js';
1
+ export * from './entity.js';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entity/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=exceptions.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.test.d.ts","sourceRoot":"","sources":["../../src/exceptions/exceptions.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,59 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { createExceptions } from './exceptions.js';
3
+ describe('createExceptions', () => {
4
+ it('should create exceptions with not_found default', () => {
5
+ const exceptions = createExceptions((e) => ({
6
+ user: e.module('user', []),
7
+ }));
8
+ expect(exceptions.user.not_found).toBe('user.not_found');
9
+ });
10
+ it('should prefix custom codes with module name', () => {
11
+ const exceptions = createExceptions((e) => ({
12
+ billing: e.module('billing_threshold', [
13
+ 'cannot_deactivate',
14
+ 'currency_not_compatible',
15
+ ]),
16
+ }));
17
+ expect(exceptions.billing.not_found).toBe('billing_threshold.not_found');
18
+ expect(exceptions.billing.cannot_deactivate).toBe('billing_threshold.cannot_deactivate');
19
+ expect(exceptions.billing.currency_not_compatible).toBe('billing_threshold.currency_not_compatible');
20
+ });
21
+ it('should support multiple modules', () => {
22
+ const exceptions = createExceptions((e) => ({
23
+ coupon: e.module('coupon', [
24
+ 'code_already_exists',
25
+ 'not_available',
26
+ ]),
27
+ invoice: e.module('invoice', [
28
+ 'not_expired',
29
+ 'not_payable',
30
+ ]),
31
+ }));
32
+ expect(exceptions.coupon.not_found).toBe('coupon.not_found');
33
+ expect(exceptions.coupon.code_already_exists).toBe('coupon.code_already_exists');
34
+ expect(exceptions.invoice.not_found).toBe('invoice.not_found');
35
+ expect(exceptions.invoice.not_payable).toBe('invoice.not_payable');
36
+ });
37
+ it('should match billing-service pattern', () => {
38
+ const exceptions = createExceptions((e) => ({
39
+ billingThreshold: e.module('billing_threshold', [
40
+ 'cannot_deactivate',
41
+ 'cannot_reactivate',
42
+ 'currency_not_compatible',
43
+ 'not_available',
44
+ ]),
45
+ customer: e.module('customer', [
46
+ 'no_active_subscription',
47
+ 'no_had_subscription',
48
+ 'organization_id_already_exists',
49
+ ]),
50
+ voucher: e.module('voucher', []),
51
+ }));
52
+ expect(exceptions.billingThreshold.not_found).toBe('billing_threshold.not_found');
53
+ expect(exceptions.billingThreshold.cannot_deactivate).toBe('billing_threshold.cannot_deactivate');
54
+ expect(exceptions.customer.not_found).toBe('customer.not_found');
55
+ expect(exceptions.customer.organization_id_already_exists).toBe('customer.organization_id_already_exists');
56
+ expect(exceptions.voucher.not_found).toBe('voucher.not_found');
57
+ });
58
+ });
59
+ //# sourceMappingURL=exceptions.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.test.js","sourceRoot":"","sources":["../../src/exceptions/exceptions.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EA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C,CAAA;QAChE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC,IAAI,CAC9D,yCAAyC,CACzC,CAAA;QACD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,2 +1,2 @@
1
- export {};
1
+ export * from './exceptions.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
@@ -1,59 +1,2 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { createExceptions } from './exceptions.js';
3
- describe('createExceptions', () => {
4
- it('should create exceptions with not_found default', () => {
5
- const exceptions = createExceptions((e) => ({
6
- user: e.module('user', []),
7
- }));
8
- expect(exceptions.user.not_found).toBe('user.not_found');
9
- });
10
- it('should prefix custom codes with module name', () => {
11
- const exceptions = createExceptions((e) => ({
12
- billing: e.module('billing_threshold', [
13
- 'cannot_deactivate',
14
- 'currency_not_compatible',
15
- ]),
16
- }));
17
- expect(exceptions.billing.not_found).toBe('billing_threshold.not_found');
18
- expect(exceptions.billing.cannot_deactivate).toBe('billing_threshold.cannot_deactivate');
19
- expect(exceptions.billing.currency_not_compatible).toBe('billing_threshold.currency_not_compatible');
20
- });
21
- it('should support multiple modules', () => {
22
- const exceptions = createExceptions((e) => ({
23
- coupon: e.module('coupon', [
24
- 'code_already_exists',
25
- 'not_available',
26
- ]),
27
- invoice: e.module('invoice', [
28
- 'not_expired',
29
- 'not_payable',
30
- ]),
31
- }));
32
- expect(exceptions.coupon.not_found).toBe('coupon.not_found');
33
- expect(exceptions.coupon.code_already_exists).toBe('coupon.code_already_exists');
34
- expect(exceptions.invoice.not_found).toBe('invoice.not_found');
35
- expect(exceptions.invoice.not_payable).toBe('invoice.not_payable');
36
- });
37
- it('should match billing-service pattern', () => {
38
- const exceptions = createExceptions((e) => ({
39
- billingThreshold: e.module('billing_threshold', [
40
- 'cannot_deactivate',
41
- 'cannot_reactivate',
42
- 'currency_not_compatible',
43
- 'not_available',
44
- ]),
45
- customer: e.module('customer', [
46
- 'no_active_subscription',
47
- 'no_had_subscription',
48
- 'organization_id_already_exists',
49
- ]),
50
- voucher: e.module('voucher', []),
51
- }));
52
- expect(exceptions.billingThreshold.not_found).toBe('billing_threshold.not_found');
53
- expect(exceptions.billingThreshold.cannot_deactivate).toBe('billing_threshold.cannot_deactivate');
54
- expect(exceptions.customer.not_found).toBe('customer.not_found');
55
- expect(exceptions.customer.organization_id_already_exists).toBe('customer.organization_id_already_exists');
56
- expect(exceptions.voucher.not_found).toBe('voucher.not_found');
57
- });
58
- });
1
+ export * from './exceptions.js';
59
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAElD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QAC1D,MAAM,UAAU,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;SAC1B,CAAC,CAAC,CAAA;QAEH,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;IACzD,CAAC,CAAC,CAAA;IAE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BAAqB,CAAC,CAAA;IACnE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC/C,MAAM,UAAU,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC3C,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC,mBAAmB,EAAE;gBAC/C,mBAAmB;gBACnB,mBAAmB;gBACnB,yBAAyB;gBACzB,eAAe;aACf,CAAC;YACF,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE;gBAC9B,wBAAwB;gBACxB,qBAAqB;gBACrB,gCAAgC;aAChC,CAAC;YACF,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC;SAChC,CAAC,CAAC,CAAA;QAEH,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,IAAI,CACjD,6BAA6B,CAC7B,CAAA;QACD,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,IAAI,CACzD,qCAAqC,CACrC,CAAA;QACD,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;QAChE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC,IAAI,CAC9D,yCAAyC,CACzC,CAAA;QACD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from './entity/index.js';
2
- export * from './exceptions/index.js';
2
+ export * from './exceptions/exceptions.test.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,iCAAiC,CAAA"}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from './entity/index.js';
2
- export * from './exceptions/index.js';
2
+ export * from './exceptions/exceptions.test.js';
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,iCAAiC,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turystack/entity",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",