@gilles-coudert/pure-trace 1.0.3 → 1.0.5

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/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './pure_result_async';
2
+ export * from './pure_result';
3
+ export * from './pure_message';
package/lib/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./pure_result_async"), exports);
18
+ __exportStar(require("./pure_result"), exports);
19
+ __exportStar(require("./pure_message"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gilles-coudert/pure-trace",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "A TypeScript library providing standardized, localizable, and traceable error handling by design, with observability built-in.",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -1,2 +0,0 @@
1
- declare const _default: import("eslint/config").Config[];
2
- export default _default;
@@ -1,18 +0,0 @@
1
- import globals from 'globals';
2
- import tseslint from 'typescript-eslint';
3
- import { defineConfig } from 'eslint/config';
4
- import eslint from '@eslint/js';
5
- export default defineConfig(eslint.configs.recommended, tseslint.configs.recommendedTypeChecked, [
6
- {
7
- files: ['lib/**/*.{js,mjs,cjs,ts,mts,cts}'],
8
- plugins: {
9
- '@typescript-eslint': tseslint.plugin,
10
- },
11
- languageOptions: {
12
- globals: globals.node,
13
- parserOptions: {
14
- projectService: true,
15
- },
16
- },
17
- },
18
- ]);
@@ -1,3 +0,0 @@
1
- import type { Config } from '@jest/types';
2
- declare const config: Config.InitialOptions;
3
- export default config;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const config = {
4
- preset: 'ts-jest',
5
- testEnvironment: 'node',
6
- testMatch: ['**/*steps.ts'],
7
- transform: {
8
- '^.+\\.tsx?$': 'ts-jest',
9
- },
10
- };
11
- exports.default = config;
@@ -1 +0,0 @@
1
- export {};
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jest_cucumber_1 = require("jest-cucumber");
4
- const pure_result_1 = require("../../src/pure_result");
5
- const feature = (0, jest_cucumber_1.loadFeature)('tests/features/native_message.feature');
6
- (0, jest_cucumber_1.defineFeature)(feature, (test) => {
7
- test('Native message types', ({ given, when, then }) => {
8
- let success;
9
- given('an native success', () => {
10
- success = new pure_result_1.Success(true);
11
- });
12
- when(/^I trace a message of kind (.*) and type (.*) with code (.*) and data (.*)$/, (arg0, arg1, arg2, arg3) => {
13
- success = success.addTraces({
14
- kind: arg0,
15
- type: arg1,
16
- code: arg2,
17
- data: arg3 === 'undefined' ? undefined : JSON.parse(arg3),
18
- });
19
- });
20
- then(/^the success traces contains a single message of kind (.*) and type (.*) with code (.*) and data (.*)$/, (arg0, arg1, arg2, arg3) => {
21
- const traces = success.getTraces();
22
- expect(traces.length).toBe(1);
23
- const trace = traces[0];
24
- expect(trace.kind).toBe(arg0);
25
- expect(trace.type).toBe(arg1);
26
- expect(trace.code).toBe(arg2);
27
- expect(trace.data).toEqual(arg3 === 'undefined' ? undefined : JSON.parse(arg3));
28
- });
29
- });
30
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const jest_cucumber_1 = require("jest-cucumber");
4
- const pure_result_1 = require("../../src/pure_result");
5
- const feature = (0, jest_cucumber_1.loadFeature)('tests/features/native_success.feature');
6
- (0, jest_cucumber_1.defineFeature)(feature, (test) => {
7
- test('Tap idempotency', ({ given, when, then, and }) => {
8
- let result;
9
- given(/^a success with the value (.*) of type (.*)$/, (arg0, arg1) => {
10
- switch (arg1) {
11
- case 'number':
12
- result = new pure_result_1.Success(Number(arg0));
13
- break;
14
- case 'boolean':
15
- result = new pure_result_1.Success(arg0 === 'true');
16
- break;
17
- default: {
18
- result = new pure_result_1.Success(arg0.toString());
19
- }
20
- }
21
- });
22
- when(/^I tap it with a new trace "(.*)"$/, (arg0) => {
23
- result = result.tap((value) => {
24
- value.addTraces({
25
- code: arg0,
26
- kind: 'Information',
27
- type: 'Information',
28
- });
29
- });
30
- });
31
- and(/^the result is a success with the value (.*)$/, (arg0) => {
32
- expect(result.isSuccess()).toBe(true);
33
- if (result.isSuccess()) {
34
- expect(result.value.toString()).toEqual(arg0);
35
- }
36
- });
37
- and(/^its only trace is "(.*)"$/, (arg0) => {
38
- const traces = result.getTraces();
39
- expect(traces.length).toBe(1);
40
- expect(traces[0].code).toBe(arg0);
41
- });
42
- });
43
- });
File without changes
File without changes
File without changes