@actor-system/mail 0.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.
- package/dist/__bundle__/shared/dist/guards.js +6 -0
- package/dist/__bundle__/shared/dist/match.d.ts +12 -0
- package/dist/__bundle__/shared/dist/match.internal.d.ts +12 -0
- package/dist/__bundle__/shared/dist/match.js +8 -0
- package/dist/envelope.d.ts +11 -0
- package/dist/envelope.internal.d.ts +11 -0
- package/dist/envelope.js +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.internal.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/letter.d.ts +16 -0
- package/dist/letter.internal.d.ts +16 -0
- package/dist/letter.js +11 -0
- package/package.json +40 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
|
+
const isNonNullObject = (value) => typeof value === "object" && value !== null;
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
+
const isFunction = (value) => typeof value === "function";
|
|
5
|
+
|
|
6
|
+
export { isFunction, isNonNullObject };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type Matchers<Discriminator extends PropertyKey, Value extends Record<Discriminator, PropertyKey>, Result> = {
|
|
2
|
+
[Key in Value[Discriminator]]?: (value: Extract<Value, Record<Discriminator, Key>>) => Result;
|
|
3
|
+
} & {
|
|
4
|
+
_: (value: Value) => Result;
|
|
5
|
+
};
|
|
6
|
+
type ExhaustiveMatchers<Discriminator extends PropertyKey, Value extends Record<Discriminator, PropertyKey>, Result> = {
|
|
7
|
+
[Key in Value[Discriminator]]: (value: Extract<Value, Record<Discriminator, Key>>) => Result;
|
|
8
|
+
} & {
|
|
9
|
+
_?: (value: Value) => Result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type { ExhaustiveMatchers, Matchers };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type Matchers<Discriminator extends PropertyKey, Value extends Record<Discriminator, PropertyKey>, Result> = {
|
|
2
|
+
[Key in Value[Discriminator]]?: (value: Extract<Value, Record<Discriminator, Key>>) => Result;
|
|
3
|
+
} & {
|
|
4
|
+
_: (value: Value) => Result;
|
|
5
|
+
};
|
|
6
|
+
type ExhaustiveMatchers<Discriminator extends PropertyKey, Value extends Record<Discriminator, PropertyKey>, Result> = {
|
|
7
|
+
[Key in Value[Discriminator]]: (value: Extract<Value, Record<Discriminator, Key>>) => Result;
|
|
8
|
+
} & {
|
|
9
|
+
_?: (value: Value) => Result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type { ExhaustiveMatchers, Matchers };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const createMatch = (discriminator) => (value, handlers) => {
|
|
2
|
+
const handler = handlers[value[discriminator]] ?? handlers._;
|
|
3
|
+
if (!handler)
|
|
4
|
+
throw new Error(`No handler for ${String(discriminator)}: ${String(value[discriminator])}`);
|
|
5
|
+
return handler(value);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { createMatch };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Typename } from '@actor-system/rehydration';
|
|
2
|
+
import { Letter } from './letter.js';
|
|
3
|
+
|
|
4
|
+
type EnvelopeLabel = string;
|
|
5
|
+
interface Envelope<Label extends EnvelopeLabel> extends Letter<Label>, Typename {
|
|
6
|
+
}
|
|
7
|
+
declare const isEnvelope: <E extends Envelope<EnvelopeLabel>>(value: unknown, ...labels: E["label"][]) => value is E;
|
|
8
|
+
declare const envelopeGuard: <E extends Envelope<EnvelopeLabel>>(...labels: E["label"][]) => (value: unknown) => value is E;
|
|
9
|
+
|
|
10
|
+
export { envelopeGuard, isEnvelope };
|
|
11
|
+
export type { Envelope, EnvelopeLabel };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Typename } from '@actor-system/rehydration/internal';
|
|
2
|
+
import { Letter } from './letter.internal.js';
|
|
3
|
+
|
|
4
|
+
type EnvelopeLabel = string;
|
|
5
|
+
interface Envelope<Label extends EnvelopeLabel> extends Letter<Label>, Typename {
|
|
6
|
+
}
|
|
7
|
+
declare const isEnvelope: <E extends Envelope<EnvelopeLabel>>(value: unknown, ...labels: E["label"][]) => value is E;
|
|
8
|
+
declare const envelopeGuard: <E extends Envelope<EnvelopeLabel>>(...labels: E["label"][]) => (value: unknown) => value is E;
|
|
9
|
+
|
|
10
|
+
export { envelopeGuard, isEnvelope };
|
|
11
|
+
export type { Envelope, EnvelopeLabel };
|
package/dist/envelope.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { isLetter } from './letter.js';
|
|
2
|
+
|
|
3
|
+
const isEnvelope = (value, ...labels) => isLetter(value, ...labels) &&
|
|
4
|
+
"__typename" in value &&
|
|
5
|
+
typeof value.__typename === "string";
|
|
6
|
+
const envelopeGuard = (...labels) => (value) => isEnvelope(value, ...labels);
|
|
7
|
+
|
|
8
|
+
export { envelopeGuard, isEnvelope };
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/letter.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Matchers, ExhaustiveMatchers } from './__bundle__/shared/dist/match.js';
|
|
2
|
+
|
|
3
|
+
type LetterLabel = PropertyKey;
|
|
4
|
+
interface Letter<Label extends LetterLabel> {
|
|
5
|
+
readonly label: Label;
|
|
6
|
+
}
|
|
7
|
+
declare namespace Letter {
|
|
8
|
+
type ExcludeLabel<L extends Letter<LetterLabel>> = Omit<L, typeof $label>;
|
|
9
|
+
}
|
|
10
|
+
declare const $label = "label";
|
|
11
|
+
declare const isLetter: <L extends Letter<LetterLabel>>(value: unknown, ...labels: L[typeof $label][]) => value is L;
|
|
12
|
+
declare const letterGuard: <L extends Letter<LetterLabel>>(...labels: L[typeof $label][]) => (value: unknown) => value is L;
|
|
13
|
+
declare const letterMatch: <Value extends Record<"label", PropertyKey>, Result>(value: Value, handlers: Matchers<"label", Value, NoInfer<Result>> | ExhaustiveMatchers<"label", Value, NoInfer<Result>>) => Result;
|
|
14
|
+
|
|
15
|
+
export { $label, Letter, isLetter, letterGuard, letterMatch };
|
|
16
|
+
export type { LetterLabel };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Matchers, ExhaustiveMatchers } from './__bundle__/shared/dist/match.internal.js';
|
|
2
|
+
|
|
3
|
+
type LetterLabel = PropertyKey;
|
|
4
|
+
interface Letter<Label extends LetterLabel> {
|
|
5
|
+
readonly label: Label;
|
|
6
|
+
}
|
|
7
|
+
declare namespace Letter {
|
|
8
|
+
type ExcludeLabel<L extends Letter<LetterLabel>> = Omit<L, typeof $label>;
|
|
9
|
+
}
|
|
10
|
+
declare const $label = "label";
|
|
11
|
+
declare const isLetter: <L extends Letter<LetterLabel>>(value: unknown, ...labels: L[typeof $label][]) => value is L;
|
|
12
|
+
declare const letterGuard: <L extends Letter<LetterLabel>>(...labels: L[typeof $label][]) => (value: unknown) => value is L;
|
|
13
|
+
declare const letterMatch: <Value extends Record<"label", PropertyKey>, Result>(value: Value, handlers: Matchers<"label", Value, NoInfer<Result>> | ExhaustiveMatchers<"label", Value, NoInfer<Result>>) => Result;
|
|
14
|
+
|
|
15
|
+
export { $label, Letter, isLetter, letterGuard, letterMatch };
|
|
16
|
+
export type { LetterLabel };
|
package/dist/letter.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isNonNullObject, isFunction } from './__bundle__/shared/dist/guards.js';
|
|
2
|
+
import { createMatch } from './__bundle__/shared/dist/match.js';
|
|
3
|
+
|
|
4
|
+
const $label = "label";
|
|
5
|
+
const isLetter = (value, ...labels) => (isNonNullObject(value) || isFunction(value)) &&
|
|
6
|
+
"label" in value &&
|
|
7
|
+
labels.includes(value.label);
|
|
8
|
+
const letterGuard = (...labels) => (value) => isLetter(value, ...labels);
|
|
9
|
+
const letterMatch = createMatch($label);
|
|
10
|
+
|
|
11
|
+
export { $label, isLetter, letterGuard, letterMatch };
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@actor-system/mail",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"lint": "eslint src",
|
|
7
|
+
"lint:fix": "eslint src --fix",
|
|
8
|
+
"publint": "publint",
|
|
9
|
+
"build:tsc:internal": "tsc -b src",
|
|
10
|
+
"build:tsc:trimmed": "tsc -b src/tsconfig.trimmed.json",
|
|
11
|
+
"build:rollup": "rollup -c node:config/rollup-config"
|
|
12
|
+
},
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./internal": {
|
|
25
|
+
"types": "./dist/index.internal.d.ts",
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"bundleDependencies": [
|
|
31
|
+
"@actor-system/shared"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@actor-system/rehydration": "0.0.1"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@actor-system/shared": "0.0.1",
|
|
38
|
+
"config": "^1.0.0"
|
|
39
|
+
}
|
|
40
|
+
}
|