@venizia/ignis-helpers 0.5.0-1 → 0.5.0-3
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/README.md +2 -2
- package/dist/esm/common/const-class.d.ts +22 -0
- package/dist/esm/common/const-class.js +41 -0
- package/dist/esm/common/const-class.js.map +1 -0
- package/dist/esm/common/constants/duration.d.ts +3 -4
- package/dist/esm/common/constants/duration.js +3 -15
- package/dist/esm/common/constants/duration.js.map +1 -1
- package/dist/esm/common/constants/http.d.ts +2 -3
- package/dist/esm/common/constants/http.js +2 -5
- package/dist/esm/common/constants/http.js.map +1 -1
- package/dist/esm/common/constants/mime.d.ts +3 -6
- package/dist/esm/common/constants/mime.js +3 -66
- package/dist/esm/common/constants/mime.js.map +1 -1
- package/dist/esm/common/index.d.ts +1 -0
- package/dist/esm/common/index.js +1 -0
- package/dist/esm/common/index.js.map +1 -1
- package/dist/esm/core.d.ts +2 -2
- package/dist/esm/core.js +2 -2
- package/dist/esm/core.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/aes.constants.d.ts +2 -3
- package/dist/esm/modules/crypto/algorithms/aes.constants.js +2 -5
- package/dist/esm/modules/crypto/algorithms/aes.constants.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/credential.algorithm.d.ts +1 -1
- package/dist/esm/modules/crypto/algorithms/credential.algorithm.js +11 -11
- package/dist/esm/modules/crypto/algorithms/credential.algorithm.js.map +1 -1
- package/dist/esm/modules/crypto/common/constants.d.ts +6 -11
- package/dist/esm/modules/crypto/common/constants.js +6 -23
- package/dist/esm/modules/crypto/common/constants.js.map +1 -1
- package/dist/esm/modules/logger/common/constants.d.ts +2 -3
- package/dist/esm/modules/logger/common/constants.js +2 -5
- package/dist/esm/modules/logger/common/constants.js.map +1 -1
- package/dist/esm/modules/logger/pino/common/constants.d.ts +2 -3
- package/dist/esm/modules/logger/pino/common/constants.js +2 -5
- package/dist/esm/modules/logger/pino/common/constants.js.map +1 -1
- package/dist/esm/modules/logger/winston/formats.js +2 -2
- package/dist/esm/modules/logger/winston/formats.js.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/base-fetcher.js +2 -2
- package/dist/esm/modules/network/http-request/fetcher/base-fetcher.js.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/common/types.d.ts +1 -1
- package/dist/esm/modules/network/http-request/fetcher/common/types.js.map +1 -1
- package/dist/esm/modules/queue/kafka/common/constants.d.ts +3 -4
- package/dist/esm/modules/queue/kafka/common/constants.js +2 -5
- package/dist/esm/modules/queue/kafka/common/constants.js.map +1 -1
- package/dist/esm/modules/redis/base/abstract.helper.js +2 -2
- package/dist/esm/modules/redis/base/abstract.helper.js.map +1 -1
- package/dist/esm/modules/redis/common/constants.d.ts +1 -1
- package/dist/esm/modules/redis/common/constants.js +1 -1
- package/dist/esm/modules/redis/common/constants.js.map +1 -1
- package/dist/esm/modules/retry/common/constants.d.ts +3 -6
- package/dist/esm/modules/retry/common/constants.js +3 -15
- package/dist/esm/modules/retry/common/constants.js.map +1 -1
- package/dist/esm/modules/retry/index.d.ts +1 -1
- package/dist/esm/modules/retry/index.js +1 -1
- package/dist/esm/modules/retry/index.js.map +1 -1
- package/dist/esm/modules/secrets/common/constants.d.ts +3 -6
- package/dist/esm/modules/secrets/common/constants.js +3 -10
- package/dist/esm/modules/secrets/common/constants.js.map +1 -1
- package/dist/esm/modules/slug/index.d.ts +1 -1
- package/dist/esm/modules/slug/index.js +1 -1
- package/dist/esm/modules/slug/index.js.map +1 -1
- package/dist/esm/modules/socket/socket-io/common/constants.d.ts +2 -4
- package/dist/esm/modules/socket/socket-io/common/constants.js +2 -9
- package/dist/esm/modules/socket/socket-io/common/constants.js.map +1 -1
- package/dist/esm/modules/socket/websocket/common/constants.d.ts +4 -9
- package/dist/esm/modules/socket/websocket/common/constants.js +4 -29
- package/dist/esm/modules/socket/websocket/common/constants.js.map +1 -1
- package/dist/esm/modules/temporal/abstract.js +1 -1
- package/dist/esm/modules/temporal/abstract.js.map +1 -1
- package/dist/esm/modules/temporal/common/constants.d.ts +6 -15
- package/dist/esm/modules/temporal/common/constants.js +6 -40
- package/dist/esm/modules/temporal/common/constants.js.map +1 -1
- package/dist/esm/modules/temporal/duration/duration.js +1 -1
- package/dist/esm/modules/temporal/duration/duration.js.map +1 -1
- package/dist/esm/modules/temporal/helper.js +1 -1
- package/dist/esm/modules/temporal/helper.js.map +1 -1
- package/dist/esm/modules/uid/common/constants.d.ts +3 -6
- package/dist/esm/modules/uid/common/constants.js +3 -10
- package/dist/esm/modules/uid/common/constants.js.map +1 -1
- package/dist/esm/modules/uid/opaque.js +1 -1
- package/dist/esm/modules/uid/opaque.js.map +1 -1
- package/dist/esm/modules/uid/token.js +1 -1
- package/dist/esm/modules/uid/token.js.map +1 -1
- package/dist/esm/utilities/request.utility.d.ts +2 -3
- package/dist/esm/utilities/request.utility.js +2 -5
- package/dist/esm/utilities/request.utility.js.map +1 -1
- package/dist/esm/{modules/retry/helper.d.ts → utilities/retry.utility.d.ts} +6 -7
- package/dist/esm/{modules/retry/helper.js → utilities/retry.utility.js} +21 -22
- package/dist/esm/utilities/retry.utility.js.map +1 -0
- package/dist/esm/{modules/slug/helper.d.ts → utilities/slug.utility.d.ts} +2 -3
- package/dist/esm/{modules/slug/helper.js → utilities/slug.utility.js} +3 -4
- package/dist/esm/utilities/slug.utility.js.map +1 -0
- package/package.json +3 -3
- package/dist/esm/modules/retry/helper.js.map +0 -1
- package/dist/esm/modules/slug/helper.js.map +0 -1
package/README.md
CHANGED
|
@@ -59,8 +59,8 @@ A helper that imports an optional peer as a value lives only on its own sub-path
|
|
|
59
59
|
|
|
60
60
|
| Sub-path | What it gives | Extra peers |
|
|
61
61
|
|---|---|---|
|
|
62
|
-
| `.` | Everything peer-free: `LoggerFactory`, `ILogger`, `HfLogger`, Redis helpers (`RedisHelperFactory`), `SequentialQueueHelper`, disk and in-memory storage, `AES` / `RSA` / `ECDH`, fetch and TCP / TLS / UDP helpers, Bun WebSocket server, `SecretsHelperFactory`, `ApplicationEnvironment`, `WorkerPoolHelper`, `
|
|
63
|
-
| `./core` | Browser-safe runtime classes: `BaseHelper`, the error module, `
|
|
62
|
+
| `.` | Everything peer-free: `LoggerFactory`, `ILogger`, `HfLogger`, Redis helpers (`RedisHelperFactory`), `SequentialQueueHelper`, disk and in-memory storage, `AES` / `RSA` / `ECDH`, fetch and TCP / TLS / UDP helpers, Bun WebSocket server, `SecretsHelperFactory`, `ApplicationEnvironment`, `WorkerPoolHelper`, `RetryUtility`, `TemporalHelper`, `UuidHelper`, `SnowflakeUidHelper`, `ModuleUtility`, `getError` | none to load. `ioredis` to use Redis; `hono` for the JSX types |
|
|
63
|
+
| `./core` | Browser-safe runtime classes: `BaseHelper`, the error module, `RetryUtility`, `TemporalHelper`, `UuidHelper`, `TreeBuilder`, `TreeWalker`, `SlugUtility`, `UrlPolicy`, parse utilities | none |
|
|
64
64
|
| `./common` | Constants, types, redaction and resolvers | none |
|
|
65
65
|
| `./uuid` | `UuidHelper` and the standalone `UuidV4Generator`, `UuidV5Generator`, `UuidV7Generator` | none |
|
|
66
66
|
| `./temporal` | `TemporalHelper` and the `Native`, `Dayjs`, `Luxon` temporal adapters | none (your own `dayjs` or `luxon` if you pick that adapter) |
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TConstValue } from './types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base of a const class: a class whose `static readonly` string members are its values. Extend it and the
|
|
4
|
+
* class reads its own values (`values`) and checks a candidate against them (`isValid`), so no class keeps a
|
|
5
|
+
* `SCHEME_SET` and an `isValid` of its own.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* class ArtifactTypes extends ConstClass {
|
|
9
|
+
* static readonly SERVICE = 'service';
|
|
10
|
+
* static readonly COMPONENT = 'component';
|
|
11
|
+
* }
|
|
12
|
+
* ArtifactTypes.isValid(input); // narrows `input` to 'service' | 'component'
|
|
13
|
+
* z.enum(ArtifactTypes.values());
|
|
14
|
+
*/
|
|
15
|
+
export declare class ConstClass {
|
|
16
|
+
#private;
|
|
17
|
+
/** The string values of this class and of the classes it extends, base class first. Throws when there are none. */
|
|
18
|
+
static values<T extends typeof ConstClass>(this: T): readonly [TConstValue<T>, ...TConstValue<T>[]];
|
|
19
|
+
/** `true` when `value` is one of this class's values; narrows it to their union. */
|
|
20
|
+
static isValid<T extends typeof ConstClass>(this: T, value: unknown): value is TConstValue<T>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=const-class.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getError } from '@venizia/ignis-inversion';
|
|
2
|
+
/**
|
|
3
|
+
* Base of a const class: a class whose `static readonly` string members are its values. Extend it and the
|
|
4
|
+
* class reads its own values (`values`) and checks a candidate against them (`isValid`), so no class keeps a
|
|
5
|
+
* `SCHEME_SET` and an `isValid` of its own.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* class ArtifactTypes extends ConstClass {
|
|
9
|
+
* static readonly SERVICE = 'service';
|
|
10
|
+
* static readonly COMPONENT = 'component';
|
|
11
|
+
* }
|
|
12
|
+
* ArtifactTypes.isValid(input); // narrows `input` to 'service' | 'component'
|
|
13
|
+
* z.enum(ArtifactTypes.values());
|
|
14
|
+
*/
|
|
15
|
+
export class ConstClass {
|
|
16
|
+
static #cache = new WeakMap();
|
|
17
|
+
/** The string values of this class and of the classes it extends, base class first. Throws when there are none. */
|
|
18
|
+
static values() {
|
|
19
|
+
let values = ConstClass.#cache.get(this);
|
|
20
|
+
if (!values) {
|
|
21
|
+
// A subclass lists the values it inherits too, the base class's first.
|
|
22
|
+
const chain = [];
|
|
23
|
+
for (let base = this; base !== ConstClass && base !== Function.prototype; base = Object.getPrototypeOf(base)) {
|
|
24
|
+
chain.unshift(base);
|
|
25
|
+
}
|
|
26
|
+
values = [
|
|
27
|
+
...new Set(chain.flatMap((base) => Object.values(base).filter((value) => typeof value === 'string'))),
|
|
28
|
+
];
|
|
29
|
+
if (values.length === 0) {
|
|
30
|
+
throw getError({ message: `${this.name} has no values` });
|
|
31
|
+
}
|
|
32
|
+
ConstClass.#cache.set(this, values);
|
|
33
|
+
}
|
|
34
|
+
return values;
|
|
35
|
+
}
|
|
36
|
+
/** `true` when `value` is one of this class's values; narrows it to their union. */
|
|
37
|
+
static isValid(value) {
|
|
38
|
+
return typeof value === 'string' && this.values().includes(value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=const-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const-class.js","sourceRoot":"","sources":["../../../src/common/const-class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIpD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,UAAU;IACrB,MAAM,CAAU,MAAM,GAAG,IAAI,OAAO,EAA6B,CAAC;IAElE,mHAAmH;IACnH,MAAM,CAAC,MAAM;QAGX,IAAI,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEzC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,uEAAuE;YACvE,MAAM,KAAK,GAAa,EAAE,CAAC;YAE3B,KACE,IAAI,IAAI,GAAW,IAAI,EACvB,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,QAAQ,CAAC,SAAS,EAClD,IAAI,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAClC,CAAC;gBACD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YAED,MAAM,GAAG;gBACP,GAAG,IAAI,GAAG,CACR,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CACrB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAClF,CACF;aACF,CAAC;YAEF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACxB,MAAM,QAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;YAC5D,CAAC;YAED,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,MAAmE,CAAC;IAC7E,CAAC;IAED,oFAAoF;IACpF,MAAM,CAAC,OAAO,CAAuC,KAAc;QACjE,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,IAAI,CAAC,MAAM,EAAwB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3F,CAAC","sourcesContent":["import { getError } from '@venizia/ignis-inversion';\n\nimport type { TConstValue } from './types';\n\n/**\n * Base of a const class: a class whose `static readonly` string members are its values. Extend it and the\n * class reads its own values (`values`) and checks a candidate against them (`isValid`), so no class keeps a\n * `SCHEME_SET` and an `isValid` of its own.\n *\n * @example\n * class ArtifactTypes extends ConstClass {\n * static readonly SERVICE = 'service';\n * static readonly COMPONENT = 'component';\n * }\n * ArtifactTypes.isValid(input); // narrows `input` to 'service' | 'component'\n * z.enum(ArtifactTypes.values());\n */\nexport class ConstClass {\n static readonly #cache = new WeakMap<object, readonly string[]>();\n\n /** The string values of this class and of the classes it extends, base class first. Throws when there are none. */\n static values<T extends typeof ConstClass>(\n this: T,\n ): readonly [TConstValue<T>, ...TConstValue<T>[]] {\n let values = ConstClass.#cache.get(this);\n\n if (!values) {\n // A subclass lists the values it inherits too, the base class's first.\n const chain: object[] = [];\n\n for (\n let base: object = this;\n base !== ConstClass && base !== Function.prototype;\n base = Object.getPrototypeOf(base)\n ) {\n chain.unshift(base);\n }\n\n values = [\n ...new Set(\n chain.flatMap((base) =>\n Object.values(base).filter((value): value is string => typeof value === 'string'),\n ),\n ),\n ];\n\n if (values.length === 0) {\n throw getError({ message: `${this.name} has no values` });\n }\n\n ConstClass.#cache.set(this, values);\n }\n\n return values as unknown as readonly [TConstValue<T>, ...TConstValue<T>[]];\n }\n\n /** `true` when `value` is one of this class's values; narrows it to their union. */\n static isValid<T extends typeof ConstClass>(this: T, value: unknown): value is TConstValue<T> {\n return typeof value === 'string' && (this.values() as readonly string[]).includes(value);\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type TConstValue } from '../types/index.js';
|
|
2
|
+
import { ConstClass } from '../const-class.js';
|
|
2
3
|
/** The time units a duration can be expressed in, smallest first. */
|
|
3
|
-
export declare class DurationUnits {
|
|
4
|
+
export declare class DurationUnits extends ConstClass {
|
|
4
5
|
static readonly MILLISECOND = "millisecond";
|
|
5
6
|
static readonly SECOND = "second";
|
|
6
7
|
static readonly MINUTE = "minute";
|
|
@@ -9,8 +10,6 @@ export declare class DurationUnits {
|
|
|
9
10
|
static readonly WEEK = "week";
|
|
10
11
|
static readonly MONTH = "month";
|
|
11
12
|
static readonly YEAR = "year";
|
|
12
|
-
static readonly SCHEME_SET: Set<string>;
|
|
13
|
-
static isValid(input: string): input is TDurationUnit;
|
|
14
13
|
}
|
|
15
14
|
/** One of the `DurationUnits` values, e.g. `'second'`. */
|
|
16
15
|
export type TDurationUnit = TConstValue<typeof DurationUnits>;
|
|
@@ -82,7 +81,7 @@ export declare class DurationMultipliers {
|
|
|
82
81
|
* `null` rather than a throw, so a caller that wants an error raises its own with its own context.
|
|
83
82
|
* Every method here answers the same way.
|
|
84
83
|
*
|
|
85
|
-
* The unit is checked against {@link DurationUnits.
|
|
84
|
+
* The unit is checked against {@link DurationUnits.isValid} first: a plain-object read alone
|
|
86
85
|
* would answer `'constructor'` or `'toString'` with a member of `Object.prototype`, not `undefined`.
|
|
87
86
|
*/
|
|
88
87
|
static toMilliseconds(opts: IDuration | null): number | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ConstClass } from '../const-class.js';
|
|
1
2
|
/** The time units a duration can be expressed in, smallest first. */
|
|
2
|
-
export class DurationUnits {
|
|
3
|
+
export class DurationUnits extends ConstClass {
|
|
3
4
|
static { this.MILLISECOND = 'millisecond'; }
|
|
4
5
|
static { this.SECOND = 'second'; }
|
|
5
6
|
static { this.MINUTE = 'minute'; }
|
|
@@ -8,19 +9,6 @@ export class DurationUnits {
|
|
|
8
9
|
static { this.WEEK = 'week'; }
|
|
9
10
|
static { this.MONTH = 'month'; }
|
|
10
11
|
static { this.YEAR = 'year'; }
|
|
11
|
-
static { this.SCHEME_SET = new Set([
|
|
12
|
-
this.MILLISECOND,
|
|
13
|
-
this.SECOND,
|
|
14
|
-
this.MINUTE,
|
|
15
|
-
this.HOUR,
|
|
16
|
-
this.DAY,
|
|
17
|
-
this.WEEK,
|
|
18
|
-
this.MONTH,
|
|
19
|
-
this.YEAR,
|
|
20
|
-
]); }
|
|
21
|
-
static isValid(input) {
|
|
22
|
-
return this.SCHEME_SET.has(input);
|
|
23
|
-
}
|
|
24
12
|
}
|
|
25
13
|
/**
|
|
26
14
|
* Written spellings that resolve to a unit. Member names are the spelling, upper-cased - so
|
|
@@ -122,7 +110,7 @@ export class DurationMultipliers {
|
|
|
122
110
|
* `null` rather than a throw, so a caller that wants an error raises its own with its own context.
|
|
123
111
|
* Every method here answers the same way.
|
|
124
112
|
*
|
|
125
|
-
* The unit is checked against {@link DurationUnits.
|
|
113
|
+
* The unit is checked against {@link DurationUnits.isValid} first: a plain-object read alone
|
|
126
114
|
* would answer `'constructor'` or `'toString'` with a member of `Object.prototype`, not `undefined`.
|
|
127
115
|
*/
|
|
128
116
|
static toMilliseconds(opts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../../../src/common/constants/duration.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,MAAM,OAAO,aAAa;aACR,gBAAW,GAAG,aAAa,CAAC;aAC5B,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,C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,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACvE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;IACxC,CAAC;IAED,2JAA2J;IAC3J,MAAM,CAAC,KAAK,CAAC,KAAa;QACxB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAEpD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,qGAAqG;IACrG,MAAM,CAAC,mBAAmB,CAAC,KAAa;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** The time units a duration can be expressed in, smallest first. */\nexport class DurationUnits {\n static readonly MILLISECOND = 'millisecond';\n static readonly SECOND = 'second';\n static readonly MINUTE = 'minute';\n static readonly HOUR = 'hour';\n static readonly DAY = 'day';\n static readonly WEEK = 'week';\n static readonly MONTH = 'month';\n static readonly YEAR = 'year';\n\n static readonly SCHEME_SET = new Set([\n this.MILLISECOND,\n this.SECOND,\n this.MINUTE,\n this.HOUR,\n this.DAY,\n this.WEEK,\n this.MONTH,\n this.YEAR,\n ]);\n\n static isValid(input: string): input is TDurationUnit {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** One of the `DurationUnits` values, e.g. `'second'`. */\nexport type TDurationUnit = TConstValue<typeof DurationUnits>;\n\n/**\n * Written spellings that resolve to a unit. Member names are the spelling, upper-cased - so\n * {@link resolve} upper-cases its input and reads one property, with no second table to keep in step.\n *\n * `M` is MINUTE and `MO` is MONTH - the same choice every duration library makes, and the one\n * ambiguity a reader will trip on. There is no single-letter month.\n */\nexport class DurationAliases {\n static readonly MS = DurationUnits.MILLISECOND;\n static readonly MSEC = DurationUnits.MILLISECOND;\n static readonly MILLISECOND = DurationUnits.MILLISECOND;\n static readonly MILLISECONDS = DurationUnits.MILLISECOND;\n\n static readonly S = DurationUnits.SECOND;\n static readonly SEC = DurationUnits.SECOND;\n static readonly SECOND = DurationUnits.SECOND;\n static readonly SECONDS = DurationUnits.SECOND;\n\n static readonly M = DurationUnits.MINUTE;\n static readonly MIN = DurationUnits.MINUTE;\n static readonly MINUTE = DurationUnits.MINUTE;\n static readonly MINUTES = DurationUnits.MINUTE;\n\n static readonly H = DurationUnits.HOUR;\n static readonly HR = DurationUnits.HOUR;\n static readonly HOUR = DurationUnits.HOUR;\n static readonly HOURS = DurationUnits.HOUR;\n\n static readonly D = DurationUnits.DAY;\n static readonly DAY = DurationUnits.DAY;\n static readonly DAYS = DurationUnits.DAY;\n\n static readonly W = DurationUnits.WEEK;\n static readonly WK = DurationUnits.WEEK;\n static readonly WEEK = DurationUnits.WEEK;\n static readonly WEEKS = DurationUnits.WEEK;\n\n static readonly MO = DurationUnits.MONTH;\n static readonly MON = DurationUnits.MONTH;\n static readonly MONTH = DurationUnits.MONTH;\n static readonly MONTHS = DurationUnits.MONTH;\n\n static readonly Y = DurationUnits.YEAR;\n static readonly YR = DurationUnits.YEAR;\n static readonly YEAR = DurationUnits.YEAR;\n static readonly YEARS = DurationUnits.YEAR;\n\n /** Resolves a written unit - `'d'`, `'days'`, `'DAY'` - to its canonical name, or `null`. */\n static resolve(input: string): TDurationUnit | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n // Try the input as given first. `trim().toUpperCase()` allocates two strings and costs ~55ns,\n // where the lookup itself is ~1ns - so the spellings callers actually pass (`'day'`, `'d'`,\n // `'DAYS'`) must not pay for it. Measured, both ways.\n //\n // The table is declared below because it is derived FROM this class; it is read at call time,\n // never at class-evaluation time.\n /* eslint-disable @typescript-eslint/no-use-before-define */\n return ALIAS_LOOKUP.get(input) ?? ALIAS_LOOKUP.get(input.trim().toUpperCase()) ?? null;\n /* eslint-enable @typescript-eslint/no-use-before-define */\n }\n}\n\n/**\n * Derived from the class once, never hand-listed, so the two cannot drift. Reading the class\n * directly is slower and would need `name`/`length`/`constructor` guarded out. Each spelling is\n * stored upper and lower so the common call allocates nothing.\n */\nconst ALIAS_LOOKUP: Map<string, TDurationUnit> = new Map(\n Object.entries(DurationAliases)\n .filter((entry): entry is [string, TDurationUnit] => DurationUnits.isValid(entry[1] as string))\n .flatMap(([spelling, unit]): Array<[string, TDurationUnit]> => [\n [spelling, unit],\n [spelling.toLowerCase(), unit],\n ]),\n);\n\n/** A parsed duration: a `value` counted in `unit`. The value may be negative or fractional. */\nexport interface IDuration {\n unit: TDurationUnit;\n value: number;\n}\n\n/** `30d`, `1500 ms`, `-2 Hours`. One number, optional space, one unit. */\nconst DURATION_PATTERN = /^([+-]?\\d+(?:\\.\\d+)?)\\s*([a-z]+)$/i;\n\n/**\n * A month is 30 days and a year 365, nominal. These size a WINDOW - a grace period, a cache TTL, a\n * near-expiry horizon - and must never compute a calendar date: adding `MONTH` to 31 January lands\n * on 2 March in a leap year and 3 March otherwise. Use a date library for calendar arithmetic.\n */\nexport class DurationMultipliers {\n static readonly MILLISECOND = 1;\n static readonly SECOND = 1000 * this.MILLISECOND;\n static readonly MINUTE = 60 * this.SECOND;\n static readonly HOUR = 60 * this.MINUTE;\n static readonly DAY = 24 * this.HOUR;\n static readonly WEEK = 7 * this.DAY;\n static readonly MONTH = 30 * this.DAY;\n static readonly YEAR = 365 * this.DAY;\n\n static readonly BY_UNIT: Record<string, number> = {\n [DurationUnits.MILLISECOND]: this.MILLISECOND,\n [DurationUnits.SECOND]: this.SECOND,\n [DurationUnits.MINUTE]: this.MINUTE,\n [DurationUnits.HOUR]: this.HOUR,\n [DurationUnits.DAY]: this.DAY,\n [DurationUnits.WEEK]: this.WEEK,\n [DurationUnits.MONTH]: this.MONTH,\n [DurationUnits.YEAR]: this.YEAR,\n };\n\n /** The multiplier of a known unit, `null` for anything else - inherited property names included. */\n private static multiplierOf(unit: unknown): number | null {\n return typeof unit === 'string' && DurationUnits.isValid(unit) ? this.BY_UNIT[unit] : null;\n }\n\n /**\n * `null` rather than a throw, so a caller that wants an error raises its own with its own context.\n * Every method here answers the same way.\n *\n * The unit is checked against {@link DurationUnits.SCHEME_SET} first: a plain-object read alone\n * would answer `'constructor'` or `'toString'` with a member of `Object.prototype`, not `undefined`.\n */\n static toMilliseconds(opts: IDuration | null): number | null {\n if (!opts) {\n return null;\n }\n\n const multiplier = this.multiplierOf(opts.unit);\n\n if (multiplier === null || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return Math.round(opts.value * multiplier);\n }\n\n /** The inverse of {@link toMilliseconds}. Fractional on purpose - rounding here would silently lose a 36-hour window asked for in days. */\n static fromMilliseconds(opts: { milliseconds: number; unit: TDurationUnit }): number | null {\n const multiplier = this.multiplierOf(opts?.unit);\n\n if (multiplier === null || !Number.isFinite(opts.milliseconds)) {\n return null;\n }\n\n return opts.milliseconds / multiplier;\n }\n\n /** Unit to unit, through milliseconds. Fractional, for the reason {@link fromMilliseconds} gives. */\n static convert(opts: { value: number; from: TDurationUnit; to: TDurationUnit }): number | null {\n const source = this.multiplierOf(opts?.from);\n const target = this.multiplierOf(opts?.to);\n\n if (source === null || target === null || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return (opts.value * source) / target;\n }\n\n /** Reads a written duration - `'30d'`, `'1500 ms'`, `'2 hours'` - into {@link IDuration}. Aliases and the `M`/`MO` rule are on {@link DurationAliases}. */\n static parse(input: string): IDuration | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n const matched = DURATION_PATTERN.exec(input.trim());\n\n if (!matched) {\n return null;\n }\n\n const unit = DurationAliases.resolve(matched[2]);\n const value = Number(matched[1]);\n\n if (!unit || !Number.isFinite(value)) {\n return null;\n }\n\n return { unit, value };\n }\n\n /** `'30d'` straight to milliseconds - the shape a TTL or a grace period is usually configured in. */\n static parseToMilliseconds(input: string): number | null {\n return this.toMilliseconds(this.parse(input));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../../../src/common/constants/duration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,qEAAqE;AACrE,MAAM,OAAO,aAAc,SAAQ,UAAU;aAC3B,gBAAW,GAAG,aAAa,CAAC;aAC5B,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,QAAG,GAAG,KAAK,CAAC;aACZ,SAAI,GAAG,MAAM,CAAC;aACd,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;;AAMhC;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;aACV,OAAE,GAAG,aAAa,CAAC,WAAW,CAAC;aAC/B,SAAI,GAAG,aAAa,CAAC,WAAW,CAAC;aACjC,gBAAW,GAAG,aAAa,CAAC,WAAW,CAAC;aACxC,iBAAY,GAAG,aAAa,CAAC,WAAW,CAAC;aAEzC,MAAC,GAAG,aAAa,CAAC,MAAM,CAAC;aACzB,QAAG,GAAG,aAAa,CAAC,MAAM,CAAC;aAC3B,WAAM,GAAG,aAAa,C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,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,qGAAqG;IACrG,MAAM,CAAC,mBAAmB,CAAC,KAAa;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC","sourcesContent":["import { type TConstValue } from '../types';\nimport { ConstClass } from '@/common/const-class';\n\n/** The time units a duration can be expressed in, smallest first. */\nexport class DurationUnits extends ConstClass {\n static readonly MILLISECOND = 'millisecond';\n static readonly SECOND = 'second';\n static readonly MINUTE = 'minute';\n static readonly HOUR = 'hour';\n static readonly DAY = 'day';\n static readonly WEEK = 'week';\n static readonly MONTH = 'month';\n static readonly YEAR = 'year';\n}\n\n/** One of the `DurationUnits` values, e.g. `'second'`. */\nexport type TDurationUnit = TConstValue<typeof DurationUnits>;\n\n/**\n * Written spellings that resolve to a unit. Member names are the spelling, upper-cased - so\n * {@link resolve} upper-cases its input and reads one property, with no second table to keep in step.\n *\n * `M` is MINUTE and `MO` is MONTH - the same choice every duration library makes, and the one\n * ambiguity a reader will trip on. There is no single-letter month.\n */\nexport class DurationAliases {\n static readonly MS = DurationUnits.MILLISECOND;\n static readonly MSEC = DurationUnits.MILLISECOND;\n static readonly MILLISECOND = DurationUnits.MILLISECOND;\n static readonly MILLISECONDS = DurationUnits.MILLISECOND;\n\n static readonly S = DurationUnits.SECOND;\n static readonly SEC = DurationUnits.SECOND;\n static readonly SECOND = DurationUnits.SECOND;\n static readonly SECONDS = DurationUnits.SECOND;\n\n static readonly M = DurationUnits.MINUTE;\n static readonly MIN = DurationUnits.MINUTE;\n static readonly MINUTE = DurationUnits.MINUTE;\n static readonly MINUTES = DurationUnits.MINUTE;\n\n static readonly H = DurationUnits.HOUR;\n static readonly HR = DurationUnits.HOUR;\n static readonly HOUR = DurationUnits.HOUR;\n static readonly HOURS = DurationUnits.HOUR;\n\n static readonly D = DurationUnits.DAY;\n static readonly DAY = DurationUnits.DAY;\n static readonly DAYS = DurationUnits.DAY;\n\n static readonly W = DurationUnits.WEEK;\n static readonly WK = DurationUnits.WEEK;\n static readonly WEEK = DurationUnits.WEEK;\n static readonly WEEKS = DurationUnits.WEEK;\n\n static readonly MO = DurationUnits.MONTH;\n static readonly MON = DurationUnits.MONTH;\n static readonly MONTH = DurationUnits.MONTH;\n static readonly MONTHS = DurationUnits.MONTH;\n\n static readonly Y = DurationUnits.YEAR;\n static readonly YR = DurationUnits.YEAR;\n static readonly YEAR = DurationUnits.YEAR;\n static readonly YEARS = DurationUnits.YEAR;\n\n /** Resolves a written unit - `'d'`, `'days'`, `'DAY'` - to its canonical name, or `null`. */\n static resolve(input: string): TDurationUnit | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n // Try the input as given first. `trim().toUpperCase()` allocates two strings and costs ~55ns,\n // where the lookup itself is ~1ns - so the spellings callers actually pass (`'day'`, `'d'`,\n // `'DAYS'`) must not pay for it. Measured, both ways.\n //\n // The table is declared below because it is derived FROM this class; it is read at call time,\n // never at class-evaluation time.\n /* eslint-disable @typescript-eslint/no-use-before-define */\n return ALIAS_LOOKUP.get(input) ?? ALIAS_LOOKUP.get(input.trim().toUpperCase()) ?? null;\n /* eslint-enable @typescript-eslint/no-use-before-define */\n }\n}\n\n/**\n * Derived from the class once, never hand-listed, so the two cannot drift. Reading the class\n * directly is slower and would need `name`/`length`/`constructor` guarded out. Each spelling is\n * stored upper and lower so the common call allocates nothing.\n */\nconst ALIAS_LOOKUP: Map<string, TDurationUnit> = new Map(\n Object.entries(DurationAliases)\n .filter((entry): entry is [string, TDurationUnit] => DurationUnits.isValid(entry[1] as string))\n .flatMap(([spelling, unit]): Array<[string, TDurationUnit]> => [\n [spelling, unit],\n [spelling.toLowerCase(), unit],\n ]),\n);\n\n/** A parsed duration: a `value` counted in `unit`. The value may be negative or fractional. */\nexport interface IDuration {\n unit: TDurationUnit;\n value: number;\n}\n\n/** `30d`, `1500 ms`, `-2 Hours`. One number, optional space, one unit. */\nconst DURATION_PATTERN = /^([+-]?\\d+(?:\\.\\d+)?)\\s*([a-z]+)$/i;\n\n/**\n * A month is 30 days and a year 365, nominal. These size a WINDOW - a grace period, a cache TTL, a\n * near-expiry horizon - and must never compute a calendar date: adding `MONTH` to 31 January lands\n * on 2 March in a leap year and 3 March otherwise. Use a date library for calendar arithmetic.\n */\nexport class DurationMultipliers {\n static readonly MILLISECOND = 1;\n static readonly SECOND = 1000 * this.MILLISECOND;\n static readonly MINUTE = 60 * this.SECOND;\n static readonly HOUR = 60 * this.MINUTE;\n static readonly DAY = 24 * this.HOUR;\n static readonly WEEK = 7 * this.DAY;\n static readonly MONTH = 30 * this.DAY;\n static readonly YEAR = 365 * this.DAY;\n\n static readonly BY_UNIT: Record<string, number> = {\n [DurationUnits.MILLISECOND]: this.MILLISECOND,\n [DurationUnits.SECOND]: this.SECOND,\n [DurationUnits.MINUTE]: this.MINUTE,\n [DurationUnits.HOUR]: this.HOUR,\n [DurationUnits.DAY]: this.DAY,\n [DurationUnits.WEEK]: this.WEEK,\n [DurationUnits.MONTH]: this.MONTH,\n [DurationUnits.YEAR]: this.YEAR,\n };\n\n /** The multiplier of a known unit, `null` for anything else - inherited property names included. */\n private static multiplierOf(unit: unknown): number | null {\n return typeof unit === 'string' && DurationUnits.isValid(unit) ? this.BY_UNIT[unit] : null;\n }\n\n /**\n * `null` rather than a throw, so a caller that wants an error raises its own with its own context.\n * Every method here answers the same way.\n *\n * The unit is checked against {@link DurationUnits.isValid} first: a plain-object read alone\n * would answer `'constructor'` or `'toString'` with a member of `Object.prototype`, not `undefined`.\n */\n static toMilliseconds(opts: IDuration | null): number | null {\n if (!opts) {\n return null;\n }\n\n const multiplier = this.multiplierOf(opts.unit);\n\n if (multiplier === null || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return Math.round(opts.value * multiplier);\n }\n\n /** The inverse of {@link toMilliseconds}. Fractional on purpose - rounding here would silently lose a 36-hour window asked for in days. */\n static fromMilliseconds(opts: { milliseconds: number; unit: TDurationUnit }): number | null {\n const multiplier = this.multiplierOf(opts?.unit);\n\n if (multiplier === null || !Number.isFinite(opts.milliseconds)) {\n return null;\n }\n\n return opts.milliseconds / multiplier;\n }\n\n /** Unit to unit, through milliseconds. Fractional, for the reason {@link fromMilliseconds} gives. */\n static convert(opts: { value: number; from: TDurationUnit; to: TDurationUnit }): number | null {\n const source = this.multiplierOf(opts?.from);\n const target = this.multiplierOf(opts?.to);\n\n if (source === null || target === null || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return (opts.value * source) / target;\n }\n\n /** Reads a written duration - `'30d'`, `'1500 ms'`, `'2 hours'` - into {@link IDuration}. Aliases and the `M`/`MO` rule are on {@link DurationAliases}. */\n static parse(input: string): IDuration | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n const matched = DURATION_PATTERN.exec(input.trim());\n\n if (!matched) {\n return null;\n }\n\n const unit = DurationAliases.resolve(matched[2]);\n const value = Number(matched[1]);\n\n if (!unit || !Number.isFinite(value)) {\n return null;\n }\n\n return { unit, value };\n }\n\n /** `'30d'` straight to milliseconds - the shape a TTL or a grace period is usually configured in. */\n static parseToMilliseconds(input: string): number | null {\n return this.toMilliseconds(this.parse(input));\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type TConstValue, type ValueOf } from '../types/index.js';
|
|
2
|
+
import { ConstClass } from '../const-class.js';
|
|
2
3
|
/** HTTP constants: header names, CORS headers, header values, methods, protocols and status codes. Header names, methods and protocols are lowercase. */
|
|
3
4
|
export declare class HTTP {
|
|
4
5
|
/** Standard and common HTTP headers (lowercase per HTTP/2 convention). */
|
|
@@ -199,11 +200,9 @@ export type THttpProtocol = ValueOf<typeof HTTP.Protocols> | Uppercase<ValueOf<t
|
|
|
199
200
|
/** A numeric HTTP status code from any class in `HTTP.ResultCodes`. */
|
|
200
201
|
export type THttpResultCode = ValueOf<typeof HTTP.ResultCodes>;
|
|
201
202
|
/** How a client treats a download: ATTACHMENT saves it, INLINE shows it. */
|
|
202
|
-
export declare class ContentDispositionTypes {
|
|
203
|
+
export declare class ContentDispositionTypes extends ConstClass {
|
|
203
204
|
static readonly ATTACHMENT = "attachment";
|
|
204
205
|
static readonly INLINE = "inline";
|
|
205
|
-
static readonly SCHEME_SET: Set<string>;
|
|
206
|
-
static isValid(value: string): boolean;
|
|
207
206
|
}
|
|
208
207
|
/** Valid Content-Disposition type values. */
|
|
209
208
|
export type TContentDispositionType = TConstValue<typeof ContentDispositionTypes>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConstClass } from '../const-class.js';
|
|
1
2
|
/** HTTP constants: header names, CORS headers, header values, methods, protocols and status codes. Header names, methods and protocols are lowercase. */
|
|
2
3
|
export class HTTP {
|
|
3
4
|
/** Standard and common HTTP headers (lowercase per HTTP/2 convention). */
|
|
@@ -219,12 +220,8 @@ export class HTTP {
|
|
|
219
220
|
}; }
|
|
220
221
|
}
|
|
221
222
|
/** How a client treats a download: ATTACHMENT saves it, INLINE shows it. */
|
|
222
|
-
export class ContentDispositionTypes {
|
|
223
|
+
export class ContentDispositionTypes extends ConstClass {
|
|
223
224
|
static { this.ATTACHMENT = 'attachment'; }
|
|
224
225
|
static { this.INLINE = 'inline'; }
|
|
225
|
-
static { this.SCHEME_SET = new Set([this.ATTACHMENT, this.INLINE]); }
|
|
226
|
-
static isValid(value) {
|
|
227
|
-
return this.SCHEME_SET.has(value);
|
|
228
|
-
}
|
|
229
226
|
}
|
|
230
227
|
//# sourceMappingURL=http.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../src/common/constants/http.ts"],"names":[],"mappings":"AAEA,yJAAyJ;AACzJ,MAAM,OAAO,IAAI;IACf,0EAA0E;aAC1D,YAAO,GAAG;QACxB,UAAU;QACV,mBAAmB,EAAE,qBAAqB;QAC1C,gBAAgB,EAAE,kBAAkB;QACpC,cAAc,EAAE,gBAAgB;QAChC,YAAY,EAAE,cAAc;QAC5B,aAAa,EAAE,eAAe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** HTTP constants: header names, CORS headers, header values, methods, protocols and status codes. Header names, methods and protocols are lowercase. */\nexport class HTTP {\n /** Standard and common HTTP headers (lowercase per HTTP/2 convention). */\n static readonly Headers = {\n // Content\n CONTENT_DISPOSITION: 'content-disposition',\n CONTENT_ENCODING: 'content-encoding',\n CONTENT_LENGTH: 'content-length',\n CONTENT_TYPE: 'content-type',\n CONTENT_RANGE: 'content-range',\n CONTENT_SECURITY_POLICY: 'content-security-policy',\n ACCEPT_RANGES: 'accept-ranges',\n RANGE: 'range',\n\n // Request - content negotiation & conditionals\n ACCEPT: 'accept',\n ACCEPT_ENCODING: 'accept-encoding',\n ACCEPT_LANGUAGE: 'accept-language',\n AUTHORIZATION: 'authorization',\n COOKIE: 'cookie',\n HOST: 'host',\n IF_MATCH: 'if-match',\n IF_MODIFIED_SINCE: 'if-modified-since',\n IF_NONE_MATCH: 'if-none-match',\n ORIGIN: 'origin',\n REFERER: 'referer',\n USER_AGENT: 'user-agent',\n\n // Response - caching, auth challenges & redirects\n ALLOW: 'allow',\n CACHE_CONTROL: 'cache-control',\n ETAG: 'etag',\n LAST_MODIFIED: 'last-modified',\n LOCATION: 'location',\n RETRY_AFTER: 'retry-after',\n SET_COOKIE: 'set-cookie',\n VARY: 'vary',\n WWW_AUTHENTICATE: 'www-authenticate',\n\n // CORS (RFC 6454 / Fetch spec)\n ACCESS_CONTROL_ALLOW_CREDENTIALS: 'access-control-allow-credentials',\n ACCESS_CONTROL_ALLOW_HEADERS: 'access-control-allow-headers',\n ACCESS_CONTROL_ALLOW_METHODS: 'access-control-allow-methods',\n ACCESS_CONTROL_ALLOW_ORIGIN: 'access-control-allow-origin',\n ACCESS_CONTROL_EXPOSE_HEADERS: 'access-control-expose-headers',\n ACCESS_CONTROL_MAX_AGE: 'access-control-max-age',\n ACCESS_CONTROL_REQUEST_HEADERS: 'access-control-request-headers',\n ACCESS_CONTROL_REQUEST_METHOD: 'access-control-request-method',\n\n // Transport\n CONNECTION: 'connection',\n TRANSFER_ENCODING: 'transfer-encoding',\n UPGRADE: 'upgrade',\n\n // Security\n STRICT_TRANSPORT_SECURITY: 'strict-transport-security',\n X_CONTENT_TYPE_OPTIONS: 'x-content-type-options',\n X_FRAME_OPTIONS: 'x-frame-options',\n\n // Proxy / forwarding (de facto standard)\n FORWARDED: 'forwarded',\n X_FORWARDED_FOR: 'x-forwarded-for',\n X_FORWARDED_HOST: 'x-forwarded-host',\n X_FORWARDED_PROTO: 'x-forwarded-proto',\n X_REAL_IP: 'x-real-ip',\n\n // Rate limiting (de facto standard)\n X_RATELIMIT_LIMIT: 'x-ratelimit-limit',\n X_RATELIMIT_REMAINING: 'x-ratelimit-remaining',\n X_RATELIMIT_RESET: 'x-ratelimit-reset',\n\n // IGNIS custom\n REQUEST_TRACING_ID: 'x-request-id',\n REQUEST_DEVICE_INFO: 'x-device-info',\n REQUEST_CHANNEL: 'x-request-channel',\n REQUEST_COUNT_DATA: 'x-request-count',\n REQUEST_EXTRA: 'x-request-extra',\n RESPONSE_COUNT_DATA: 'x-response-count',\n RESPONSE_FORMAT: 'x-response-format',\n RESPONSE_EXTRA: 'x-response-extra',\n\n // Client context\n AUTH_PROVIDER: 'x-auth-provider',\n LOCALE: 'x-locale',\n TIMEZONE: 'timezone',\n TIMEZONE_OFFSET: 'timezone-offset',\n } as const;\n\n /**\n * The headers IGNIS adds to a request and to a response, for a CORS configuration that lists them\n * by hand: spread `ALLOW` into the allowed request headers and `EXPOSE` into the exposed ones, so\n * a header IGNIS adds later needs no change there.\n */\n static readonly CorsHeaders = {\n ALLOW: [\n 'x-request-id',\n 'x-request-count',\n 'x-request-extra',\n 'x-request-channel',\n 'x-device-info',\n ],\n EXPOSE: [\n 'content-range',\n 'x-request-id',\n 'x-response-count',\n 'x-response-format',\n 'x-response-extra',\n ],\n } as const;\n\n /** Common MIME / Content-Type values. */\n static readonly HeaderValues = {\n // Application\n APPLICATION_FORM_URLENCODED: 'application/x-www-form-urlencoded',\n APPLICATION_GRAPHQL_JSON: 'application/graphql+json',\n APPLICATION_GZIP: 'application/gzip',\n APPLICATION_JAVASCRIPT: 'application/javascript',\n APPLICATION_JSON: 'application/json',\n /** A JSON body with its charset named, the value a client sends by default. */\n APPLICATION_JSON_UTF8: 'application/json; charset=utf-8',\n APPLICATION_MSGPACK: 'application/msgpack',\n APPLICATION_NDJSON: 'application/x-ndjson',\n APPLICATION_OCTET_STREAM: 'application/octet-stream',\n APPLICATION_PDF: 'application/pdf',\n APPLICATION_PROTOBUF: 'application/x-protobuf',\n APPLICATION_XML: 'application/xml',\n APPLICATION_ZIP: 'application/zip',\n\n // Multipart\n MULTIPART_FORM_DATA: 'multipart/form-data',\n\n // Text\n TEXT_CSS: 'text/css',\n TEXT_CSV: 'text/csv',\n TEXT_EVENT_STREAM: 'text/event-stream',\n TEXT_HTML: 'text/html',\n TEXT_PLAIN: 'text/plain',\n TEXT_XML: 'text/xml',\n\n // Image\n IMAGE_GIF: 'image/gif',\n IMAGE_JPEG: 'image/jpeg',\n IMAGE_PNG: 'image/png',\n IMAGE_SVG: 'image/svg+xml',\n IMAGE_WEBP: 'image/webp',\n\n // Range units\n RANGE_UNIT_BYTES: 'bytes',\n } as const;\n\n /** Standard HTTP methods (lowercase). */\n static readonly Methods = {\n GET: 'get',\n POST: 'post',\n PUT: 'put',\n PATCH: 'patch',\n DELETE: 'delete',\n HEAD: 'head',\n OPTIONS: 'options',\n QUERY: 'query',\n } as const;\n\n /** Standard HTTP protocols (lowercase). */\n static readonly Protocols = {\n HTTP: 'http',\n HTTPS: 'https',\n } as const;\n\n /** HTTP status codes grouped by class (1xx - 5xx). */\n static readonly ResultCodes = {\n /** 1xx - Informational. */\n RS_1: {\n Continue: 100,\n SwitchingProtocols: 101,\n EarlyHints: 103,\n },\n\n /** 2xx - Success. */\n RS_2: {\n Ok: 200,\n Created: 201,\n Accepted: 202,\n NonAuthoritativeInformation: 203,\n NoContent: 204,\n ResetContent: 205,\n PartialContent: 206,\n MultiStatus: 207,\n },\n\n /** 3xx - Redirection. */\n RS_3: {\n MovedPermanently: 301,\n Found: 302,\n NotModified: 304,\n TemporaryRedirect: 307,\n PermanentRedirect: 308,\n },\n\n /** 4xx - Client error. */\n RS_4: {\n BadRequest: 400,\n Unauthorized: 401,\n PaymentRequired: 402,\n Forbidden: 403,\n NotFound: 404,\n MethodNotAllowed: 405,\n NotAcceptable: 406,\n RequestTimeout: 408,\n Conflict: 409,\n Gone: 410,\n LengthRequired: 411,\n PreconditionFailed: 412,\n ContentTooLarge: 413,\n URITooLong: 414,\n UnsupportedMediaType: 415,\n RangeNotSatisfiable: 416,\n ExpectationFailed: 417,\n UnprocessableEntity: 422,\n Locked: 423,\n FailedDependency: 424,\n TooEarly: 425,\n UpgradeRequired: 426,\n PreconditionRequired: 428,\n TooManyRequests: 429,\n RequestHeaderFieldsTooLarge: 431,\n UnavailableForLegalReasons: 451,\n },\n\n /** 5xx - Server error. */\n RS_5: {\n InternalServerError: 500,\n NotImplemented: 501,\n BadGateway: 502,\n ServiceUnavailable: 503,\n GatewayTimeout: 504,\n HTTPVersionNotSupported: 505,\n InsufficientStorage: 507,\n LoopDetected: 508,\n NetworkAuthenticationRequired: 511,\n },\n } as const;\n}\n\n/** An HTTP method from `HTTP.Methods`, in lowercase or uppercase. */\nexport type THttpMethod = ValueOf<typeof HTTP.Methods> | Uppercase<ValueOf<typeof HTTP.Methods>>;\n/** An HTTP protocol from `HTTP.Protocols`, in lowercase or uppercase. */\nexport type THttpProtocol =\n | ValueOf<typeof HTTP.Protocols>\n | Uppercase<ValueOf<typeof HTTP.Protocols>>;\n/** A numeric HTTP status code from any class in `HTTP.ResultCodes`. */\nexport type THttpResultCode = ValueOf<typeof HTTP.ResultCodes>;\n\n/** How a client treats a download: ATTACHMENT saves it, INLINE shows it. */\nexport class ContentDispositionTypes {\n static readonly ATTACHMENT = 'attachment';\n static readonly INLINE = 'inline';\n\n static readonly SCHEME_SET = new Set<string>([this.ATTACHMENT, this.INLINE]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid Content-Disposition type values. */\nexport type TContentDispositionType = TConstValue<typeof ContentDispositionTypes>;\n"]}
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../src/common/constants/http.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,yJAAyJ;AACzJ,MAAM,OAAO,IAAI;IACf,0EAA0E;aAC1D,YAAO,GAAG;QACxB,UAAU;QACV,mBAAmB,EAAE,qBAAqB;QAC1C,gBAAgB,EAAE,kBAAkB;QACpC,cAAc,EAAE,gBAAgB;QAChC,YAAY,EAAE,cAAc;QAC5B,aAAa,EAAE,eAAe;QAC9B,uBAAuB,EAAE,yBAAyB;QAClD,aAAa,EAAE,eAAe;QAC9B,KAAK,EAAE,OAAO;QAEd,+CAA+C;QAC/C,MAAM,EAAE,QAAQ;QAChB,eAAe,EAAE,iBAAiB;QAClC,eAAe,EAAE,iBAAiB;QAClC,aAAa,EAAE,eAAe;QAC9B,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,UAAU;QACpB,iBAAiB,EAAE,mBAAmB;QACtC,aAAa,EAAE,eAAe;QAC9B,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,SAAS;QAClB,UAAU,EAAE,YAAY;QAExB,kDAAkD;QAClD,KAAK,EAAE,OAAO;QACd,aAAa,EAAE,eAAe;QAC9B,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,eAAe;QAC9B,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,aAAa;QAC1B,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,MAAM;QACZ,gBAAgB,EAAE,kBAAkB;QAEpC,+BAA+B;QAC/B,gCAAgC,EAAE,kCAAkC;QACpE,4BAA4B,EAAE,8BAA8B;QAC5D,4BAA4B,EAAE,8BAA8B;QAC5D,2BAA2B,EAAE,6BAA6B;QAC1D,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mB,EAAE,GAAG;YACxB,YAAY,EAAE,GAAG;YACjB,6BAA6B,EAAE,GAAG;SACnC;KACO,CAAC;;AAYb,4EAA4E;AAC5E,MAAM,OAAO,uBAAwB,SAAQ,UAAU;aACrC,eAAU,GAAG,YAAY,CAAC;aAC1B,WAAM,GAAG,QAAQ,CAAC","sourcesContent":["import { type TConstValue, type ValueOf } from '../types';\nimport { ConstClass } from '@/common/const-class';\n\n/** HTTP constants: header names, CORS headers, header values, methods, protocols and status codes. Header names, methods and protocols are lowercase. */\nexport class HTTP {\n /** Standard and common HTTP headers (lowercase per HTTP/2 convention). */\n static readonly Headers = {\n // Content\n CONTENT_DISPOSITION: 'content-disposition',\n CONTENT_ENCODING: 'content-encoding',\n CONTENT_LENGTH: 'content-length',\n CONTENT_TYPE: 'content-type',\n CONTENT_RANGE: 'content-range',\n CONTENT_SECURITY_POLICY: 'content-security-policy',\n ACCEPT_RANGES: 'accept-ranges',\n RANGE: 'range',\n\n // Request - content negotiation & conditionals\n ACCEPT: 'accept',\n ACCEPT_ENCODING: 'accept-encoding',\n ACCEPT_LANGUAGE: 'accept-language',\n AUTHORIZATION: 'authorization',\n COOKIE: 'cookie',\n HOST: 'host',\n IF_MATCH: 'if-match',\n IF_MODIFIED_SINCE: 'if-modified-since',\n IF_NONE_MATCH: 'if-none-match',\n ORIGIN: 'origin',\n REFERER: 'referer',\n USER_AGENT: 'user-agent',\n\n // Response - caching, auth challenges & redirects\n ALLOW: 'allow',\n CACHE_CONTROL: 'cache-control',\n ETAG: 'etag',\n LAST_MODIFIED: 'last-modified',\n LOCATION: 'location',\n RETRY_AFTER: 'retry-after',\n SET_COOKIE: 'set-cookie',\n VARY: 'vary',\n WWW_AUTHENTICATE: 'www-authenticate',\n\n // CORS (RFC 6454 / Fetch spec)\n ACCESS_CONTROL_ALLOW_CREDENTIALS: 'access-control-allow-credentials',\n ACCESS_CONTROL_ALLOW_HEADERS: 'access-control-allow-headers',\n ACCESS_CONTROL_ALLOW_METHODS: 'access-control-allow-methods',\n ACCESS_CONTROL_ALLOW_ORIGIN: 'access-control-allow-origin',\n ACCESS_CONTROL_EXPOSE_HEADERS: 'access-control-expose-headers',\n ACCESS_CONTROL_MAX_AGE: 'access-control-max-age',\n ACCESS_CONTROL_REQUEST_HEADERS: 'access-control-request-headers',\n ACCESS_CONTROL_REQUEST_METHOD: 'access-control-request-method',\n\n // Transport\n CONNECTION: 'connection',\n TRANSFER_ENCODING: 'transfer-encoding',\n UPGRADE: 'upgrade',\n\n // Security\n STRICT_TRANSPORT_SECURITY: 'strict-transport-security',\n X_CONTENT_TYPE_OPTIONS: 'x-content-type-options',\n X_FRAME_OPTIONS: 'x-frame-options',\n\n // Proxy / forwarding (de facto standard)\n FORWARDED: 'forwarded',\n X_FORWARDED_FOR: 'x-forwarded-for',\n X_FORWARDED_HOST: 'x-forwarded-host',\n X_FORWARDED_PROTO: 'x-forwarded-proto',\n X_REAL_IP: 'x-real-ip',\n\n // Rate limiting (de facto standard)\n X_RATELIMIT_LIMIT: 'x-ratelimit-limit',\n X_RATELIMIT_REMAINING: 'x-ratelimit-remaining',\n X_RATELIMIT_RESET: 'x-ratelimit-reset',\n\n // IGNIS custom\n REQUEST_TRACING_ID: 'x-request-id',\n REQUEST_DEVICE_INFO: 'x-device-info',\n REQUEST_CHANNEL: 'x-request-channel',\n REQUEST_COUNT_DATA: 'x-request-count',\n REQUEST_EXTRA: 'x-request-extra',\n RESPONSE_COUNT_DATA: 'x-response-count',\n RESPONSE_FORMAT: 'x-response-format',\n RESPONSE_EXTRA: 'x-response-extra',\n\n // Client context\n AUTH_PROVIDER: 'x-auth-provider',\n LOCALE: 'x-locale',\n TIMEZONE: 'timezone',\n TIMEZONE_OFFSET: 'timezone-offset',\n } as const;\n\n /**\n * The headers IGNIS adds to a request and to a response, for a CORS configuration that lists them\n * by hand: spread `ALLOW` into the allowed request headers and `EXPOSE` into the exposed ones, so\n * a header IGNIS adds later needs no change there.\n */\n static readonly CorsHeaders = {\n ALLOW: [\n 'x-request-id',\n 'x-request-count',\n 'x-request-extra',\n 'x-request-channel',\n 'x-device-info',\n ],\n EXPOSE: [\n 'content-range',\n 'x-request-id',\n 'x-response-count',\n 'x-response-format',\n 'x-response-extra',\n ],\n } as const;\n\n /** Common MIME / Content-Type values. */\n static readonly HeaderValues = {\n // Application\n APPLICATION_FORM_URLENCODED: 'application/x-www-form-urlencoded',\n APPLICATION_GRAPHQL_JSON: 'application/graphql+json',\n APPLICATION_GZIP: 'application/gzip',\n APPLICATION_JAVASCRIPT: 'application/javascript',\n APPLICATION_JSON: 'application/json',\n /** A JSON body with its charset named, the value a client sends by default. */\n APPLICATION_JSON_UTF8: 'application/json; charset=utf-8',\n APPLICATION_MSGPACK: 'application/msgpack',\n APPLICATION_NDJSON: 'application/x-ndjson',\n APPLICATION_OCTET_STREAM: 'application/octet-stream',\n APPLICATION_PDF: 'application/pdf',\n APPLICATION_PROTOBUF: 'application/x-protobuf',\n APPLICATION_XML: 'application/xml',\n APPLICATION_ZIP: 'application/zip',\n\n // Multipart\n MULTIPART_FORM_DATA: 'multipart/form-data',\n\n // Text\n TEXT_CSS: 'text/css',\n TEXT_CSV: 'text/csv',\n TEXT_EVENT_STREAM: 'text/event-stream',\n TEXT_HTML: 'text/html',\n TEXT_PLAIN: 'text/plain',\n TEXT_XML: 'text/xml',\n\n // Image\n IMAGE_GIF: 'image/gif',\n IMAGE_JPEG: 'image/jpeg',\n IMAGE_PNG: 'image/png',\n IMAGE_SVG: 'image/svg+xml',\n IMAGE_WEBP: 'image/webp',\n\n // Range units\n RANGE_UNIT_BYTES: 'bytes',\n } as const;\n\n /** Standard HTTP methods (lowercase). */\n static readonly Methods = {\n GET: 'get',\n POST: 'post',\n PUT: 'put',\n PATCH: 'patch',\n DELETE: 'delete',\n HEAD: 'head',\n OPTIONS: 'options',\n QUERY: 'query',\n } as const;\n\n /** Standard HTTP protocols (lowercase). */\n static readonly Protocols = {\n HTTP: 'http',\n HTTPS: 'https',\n } as const;\n\n /** HTTP status codes grouped by class (1xx - 5xx). */\n static readonly ResultCodes = {\n /** 1xx - Informational. */\n RS_1: {\n Continue: 100,\n SwitchingProtocols: 101,\n EarlyHints: 103,\n },\n\n /** 2xx - Success. */\n RS_2: {\n Ok: 200,\n Created: 201,\n Accepted: 202,\n NonAuthoritativeInformation: 203,\n NoContent: 204,\n ResetContent: 205,\n PartialContent: 206,\n MultiStatus: 207,\n },\n\n /** 3xx - Redirection. */\n RS_3: {\n MovedPermanently: 301,\n Found: 302,\n NotModified: 304,\n TemporaryRedirect: 307,\n PermanentRedirect: 308,\n },\n\n /** 4xx - Client error. */\n RS_4: {\n BadRequest: 400,\n Unauthorized: 401,\n PaymentRequired: 402,\n Forbidden: 403,\n NotFound: 404,\n MethodNotAllowed: 405,\n NotAcceptable: 406,\n RequestTimeout: 408,\n Conflict: 409,\n Gone: 410,\n LengthRequired: 411,\n PreconditionFailed: 412,\n ContentTooLarge: 413,\n URITooLong: 414,\n UnsupportedMediaType: 415,\n RangeNotSatisfiable: 416,\n ExpectationFailed: 417,\n UnprocessableEntity: 422,\n Locked: 423,\n FailedDependency: 424,\n TooEarly: 425,\n UpgradeRequired: 426,\n PreconditionRequired: 428,\n TooManyRequests: 429,\n RequestHeaderFieldsTooLarge: 431,\n UnavailableForLegalReasons: 451,\n },\n\n /** 5xx - Server error. */\n RS_5: {\n InternalServerError: 500,\n NotImplemented: 501,\n BadGateway: 502,\n ServiceUnavailable: 503,\n GatewayTimeout: 504,\n HTTPVersionNotSupported: 505,\n InsufficientStorage: 507,\n LoopDetected: 508,\n NetworkAuthenticationRequired: 511,\n },\n } as const;\n}\n\n/** An HTTP method from `HTTP.Methods`, in lowercase or uppercase. */\nexport type THttpMethod = ValueOf<typeof HTTP.Methods> | Uppercase<ValueOf<typeof HTTP.Methods>>;\n/** An HTTP protocol from `HTTP.Protocols`, in lowercase or uppercase. */\nexport type THttpProtocol =\n | ValueOf<typeof HTTP.Protocols>\n | Uppercase<ValueOf<typeof HTTP.Protocols>>;\n/** A numeric HTTP status code from any class in `HTTP.ResultCodes`. */\nexport type THttpResultCode = ValueOf<typeof HTTP.ResultCodes>;\n\n/** How a client treats a download: ATTACHMENT saves it, INLINE shows it. */\nexport class ContentDispositionTypes extends ConstClass {\n static readonly ATTACHMENT = 'attachment';\n static readonly INLINE = 'inline';\n}\n\n/** Valid Content-Disposition type values. */\nexport type TContentDispositionType = TConstValue<typeof ContentDispositionTypes>;\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type TConstValue } from '../types/index.js';
|
|
2
|
+
import { ConstClass } from '../const-class.js';
|
|
2
3
|
/** The top-level part of a MIME type (`image`, `video`, `text`), plus `unknown`. For the full content type see `ContentTypes`. */
|
|
3
4
|
export declare class MimeTypes {
|
|
4
5
|
static readonly UNKNOWN = "unknown";
|
|
@@ -9,7 +10,7 @@ export declare class MimeTypes {
|
|
|
9
10
|
/** One of the `MimeTypes` values. */
|
|
10
11
|
export type TMimeTypes = TConstValue<typeof MimeTypes>;
|
|
11
12
|
/** The leading dot is part of the value: `path.extname` returns one. */
|
|
12
|
-
export declare class FileExtensions {
|
|
13
|
+
export declare class FileExtensions extends ConstClass {
|
|
13
14
|
static readonly PNG = ".png";
|
|
14
15
|
static readonly JPG = ".jpg";
|
|
15
16
|
static readonly JPEG = ".jpeg";
|
|
@@ -37,13 +38,11 @@ export declare class FileExtensions {
|
|
|
37
38
|
static readonly PPT = ".ppt";
|
|
38
39
|
static readonly ODT = ".odt";
|
|
39
40
|
static readonly ODS = ".ods";
|
|
40
|
-
static readonly SCHEME_SET: Set<string>;
|
|
41
|
-
static isValid(value: string): boolean;
|
|
42
41
|
}
|
|
43
42
|
/** One of the `FileExtensions` values, with its leading dot. */
|
|
44
43
|
export type TFileExtension = TConstValue<typeof FileExtensions>;
|
|
45
44
|
/** Full content types, as they go on the wire. `MimeTypes` holds only the top-level part. */
|
|
46
|
-
export declare class ContentTypes {
|
|
45
|
+
export declare class ContentTypes extends ConstClass {
|
|
47
46
|
static readonly OCTET_STREAM = "application/octet-stream";
|
|
48
47
|
static readonly PNG = "image/png";
|
|
49
48
|
static readonly JPEG = "image/jpeg";
|
|
@@ -71,8 +70,6 @@ export declare class ContentTypes {
|
|
|
71
70
|
static readonly PPT = "application/vnd.ms-powerpoint";
|
|
72
71
|
static readonly ODT = "application/vnd.oasis.opendocument.text";
|
|
73
72
|
static readonly ODS = "application/vnd.oasis.opendocument.spreadsheet";
|
|
74
|
-
static readonly SCHEME_SET: Set<string>;
|
|
75
|
-
static isValid(value: string): boolean;
|
|
76
73
|
}
|
|
77
74
|
/** One of the `ContentTypes` values. */
|
|
78
75
|
export type TContentType = TConstValue<typeof ContentTypes>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConstClass } from '../const-class.js';
|
|
1
2
|
/** The top-level part of a MIME type (`image`, `video`, `text`), plus `unknown`. For the full content type see `ContentTypes`. */
|
|
2
3
|
export class MimeTypes {
|
|
3
4
|
static { this.UNKNOWN = 'unknown'; }
|
|
@@ -6,7 +7,7 @@ export class MimeTypes {
|
|
|
6
7
|
static { this.TEXT = 'text'; }
|
|
7
8
|
}
|
|
8
9
|
/** The leading dot is part of the value: `path.extname` returns one. */
|
|
9
|
-
export class FileExtensions {
|
|
10
|
+
export class FileExtensions extends ConstClass {
|
|
10
11
|
static { this.PNG = '.png'; }
|
|
11
12
|
static { this.JPG = '.jpg'; }
|
|
12
13
|
static { this.JPEG = '.jpeg'; }
|
|
@@ -34,41 +35,9 @@ export class FileExtensions {
|
|
|
34
35
|
static { this.PPT = '.ppt'; }
|
|
35
36
|
static { this.ODT = '.odt'; }
|
|
36
37
|
static { this.ODS = '.ods'; }
|
|
37
|
-
static { this.SCHEME_SET = new Set([
|
|
38
|
-
this.PNG,
|
|
39
|
-
this.JPG,
|
|
40
|
-
this.JPEG,
|
|
41
|
-
this.GIF,
|
|
42
|
-
this.WEBP,
|
|
43
|
-
this.SVG,
|
|
44
|
-
this.PDF,
|
|
45
|
-
this.JSON,
|
|
46
|
-
this.TXT,
|
|
47
|
-
this.HTML,
|
|
48
|
-
this.CSS,
|
|
49
|
-
this.JS,
|
|
50
|
-
this.MP4,
|
|
51
|
-
this.WEBM,
|
|
52
|
-
this.MP3,
|
|
53
|
-
this.WAV,
|
|
54
|
-
this.ZIP,
|
|
55
|
-
this.CSV,
|
|
56
|
-
this.XML,
|
|
57
|
-
this.XLSX,
|
|
58
|
-
this.XLS,
|
|
59
|
-
this.DOCX,
|
|
60
|
-
this.DOC,
|
|
61
|
-
this.PPTX,
|
|
62
|
-
this.PPT,
|
|
63
|
-
this.ODT,
|
|
64
|
-
this.ODS,
|
|
65
|
-
]); }
|
|
66
|
-
static isValid(value) {
|
|
67
|
-
return this.SCHEME_SET.has(value);
|
|
68
|
-
}
|
|
69
38
|
}
|
|
70
39
|
/** Full content types, as they go on the wire. `MimeTypes` holds only the top-level part. */
|
|
71
|
-
export class ContentTypes {
|
|
40
|
+
export class ContentTypes extends ConstClass {
|
|
72
41
|
static { this.OCTET_STREAM = 'application/octet-stream'; }
|
|
73
42
|
static { this.PNG = 'image/png'; }
|
|
74
43
|
static { this.JPEG = 'image/jpeg'; }
|
|
@@ -96,38 +65,6 @@ export class ContentTypes {
|
|
|
96
65
|
static { this.PPT = 'application/vnd.ms-powerpoint'; }
|
|
97
66
|
static { this.ODT = 'application/vnd.oasis.opendocument.text'; }
|
|
98
67
|
static { this.ODS = 'application/vnd.oasis.opendocument.spreadsheet'; }
|
|
99
|
-
static { this.SCHEME_SET = new Set([
|
|
100
|
-
this.OCTET_STREAM,
|
|
101
|
-
this.PNG,
|
|
102
|
-
this.JPEG,
|
|
103
|
-
this.GIF,
|
|
104
|
-
this.WEBP,
|
|
105
|
-
this.SVG,
|
|
106
|
-
this.PDF,
|
|
107
|
-
this.JSON,
|
|
108
|
-
this.PLAIN_TEXT,
|
|
109
|
-
this.HTML,
|
|
110
|
-
this.CSS,
|
|
111
|
-
this.JAVASCRIPT,
|
|
112
|
-
this.MP4,
|
|
113
|
-
this.WEBM,
|
|
114
|
-
this.MPEG_AUDIO,
|
|
115
|
-
this.WAV,
|
|
116
|
-
this.ZIP,
|
|
117
|
-
this.CSV,
|
|
118
|
-
this.XML,
|
|
119
|
-
this.XLSX,
|
|
120
|
-
this.XLS,
|
|
121
|
-
this.DOCX,
|
|
122
|
-
this.DOC,
|
|
123
|
-
this.PPTX,
|
|
124
|
-
this.PPT,
|
|
125
|
-
this.ODT,
|
|
126
|
-
this.ODS,
|
|
127
|
-
]); }
|
|
128
|
-
static isValid(value) {
|
|
129
|
-
return this.SCHEME_SET.has(value);
|
|
130
|
-
}
|
|
131
68
|
}
|
|
132
69
|
/** The extension table and the lookup that reads it, together - the `DurationMultipliers` shape. */
|
|
133
70
|
export class ContentTypeTable {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mime.js","sourceRoot":"","sources":["../../../../src/common/constants/mime.ts"],"names":[],"mappings":"AAEA,kIAAkI;AAClI,MAAM,OAAO,SAAS;aACJ,YAAO,GAAG,SAAS,CAAC;aACpB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;;AAKhC,wEAAwE;AACxE,MAAM,OAAO,cAAc;aACT,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,OAAE,GAAG,KAAK,CAAC;aACX,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,QAA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Y,CAAC;IACnE,CAAC;;AAGH,gGAAgG;AAChG,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC,YAAY,CAAC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** The top-level part of a MIME type (`image`, `video`, `text`), plus `unknown`. For the full content type see `ContentTypes`. */\nexport class MimeTypes {\n static readonly UNKNOWN = 'unknown';\n static readonly IMAGE = 'image';\n static readonly VIDEO = 'video';\n static readonly TEXT = 'text';\n}\n/** One of the `MimeTypes` values. */\nexport type TMimeTypes = TConstValue<typeof MimeTypes>;\n\n/** The leading dot is part of the value: `path.extname` returns one. */\nexport class FileExtensions {\n static readonly PNG = '.png';\n static readonly JPG = '.jpg';\n static readonly JPEG = '.jpeg';\n static readonly GIF = '.gif';\n static readonly WEBP = '.webp';\n static readonly SVG = '.svg';\n static readonly PDF = '.pdf';\n static readonly JSON = '.json';\n static readonly TXT = '.txt';\n static readonly HTML = '.html';\n static readonly CSS = '.css';\n static readonly JS = '.js';\n static readonly MP4 = '.mp4';\n static readonly WEBM = '.webm';\n static readonly MP3 = '.mp3';\n static readonly WAV = '.wav';\n static readonly ZIP = '.zip';\n static readonly CSV = '.csv';\n static readonly XML = '.xml';\n static readonly XLSX = '.xlsx';\n static readonly XLS = '.xls';\n static readonly DOCX = '.docx';\n static readonly DOC = '.doc';\n static readonly PPTX = '.pptx';\n static readonly PPT = '.ppt';\n static readonly ODT = '.odt';\n static readonly ODS = '.ods';\n\n static readonly SCHEME_SET = new Set<string>([\n this.PNG,\n this.JPG,\n this.JPEG,\n this.GIF,\n this.WEBP,\n this.SVG,\n this.PDF,\n this.JSON,\n this.TXT,\n this.HTML,\n this.CSS,\n this.JS,\n this.MP4,\n this.WEBM,\n this.MP3,\n this.WAV,\n this.ZIP,\n this.CSV,\n this.XML,\n this.XLSX,\n this.XLS,\n this.DOCX,\n this.DOC,\n this.PPTX,\n this.PPT,\n this.ODT,\n this.ODS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n/** One of the `FileExtensions` values, with its leading dot. */\nexport type TFileExtension = TConstValue<typeof FileExtensions>;\n\n/** Full content types, as they go on the wire. `MimeTypes` holds only the top-level part. */\nexport class ContentTypes {\n static readonly OCTET_STREAM = 'application/octet-stream';\n static readonly PNG = 'image/png';\n static readonly JPEG = 'image/jpeg';\n static readonly GIF = 'image/gif';\n static readonly WEBP = 'image/webp';\n static readonly SVG = 'image/svg+xml';\n static readonly PDF = 'application/pdf';\n static readonly JSON = 'application/json';\n static readonly PLAIN_TEXT = 'text/plain';\n static readonly HTML = 'text/html';\n static readonly CSS = 'text/css';\n static readonly JAVASCRIPT = 'text/javascript';\n static readonly MP4 = 'video/mp4';\n static readonly WEBM = 'video/webm';\n static readonly MPEG_AUDIO = 'audio/mpeg';\n static readonly WAV = 'audio/wav';\n static readonly ZIP = 'application/zip';\n static readonly CSV = 'text/csv';\n static readonly XML = 'application/xml';\n static readonly XLSX = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';\n static readonly XLS = 'application/vnd.ms-excel';\n static readonly DOCX = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';\n static readonly DOC = 'application/msword';\n static readonly PPTX =\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation';\n\n static readonly PPT = 'application/vnd.ms-powerpoint';\n static readonly ODT = 'application/vnd.oasis.opendocument.text';\n static readonly ODS = 'application/vnd.oasis.opendocument.spreadsheet';\n\n static readonly SCHEME_SET = new Set<string>([\n this.OCTET_STREAM,\n this.PNG,\n this.JPEG,\n this.GIF,\n this.WEBP,\n this.SVG,\n this.PDF,\n this.JSON,\n this.PLAIN_TEXT,\n this.HTML,\n this.CSS,\n this.JAVASCRIPT,\n this.MP4,\n this.WEBM,\n this.MPEG_AUDIO,\n this.WAV,\n this.ZIP,\n this.CSV,\n this.XML,\n this.XLSX,\n this.XLS,\n this.DOCX,\n this.DOC,\n this.PPTX,\n this.PPT,\n this.ODT,\n this.ODS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n/** One of the `ContentTypes` values. */\nexport type TContentType = TConstValue<typeof ContentTypes>;\n\n/** The extension table and the lookup that reads it, together - the `DurationMultipliers` shape. */\nexport class ContentTypeTable {\n /** `satisfies` makes the table total; the declared `string` key keeps a lookup cast-free. */\n static readonly BY_EXTENSION: Readonly<Partial<Record<string, TContentType>>> = {\n [FileExtensions.PNG]: ContentTypes.PNG,\n [FileExtensions.JPG]: ContentTypes.JPEG,\n [FileExtensions.JPEG]: ContentTypes.JPEG,\n [FileExtensions.GIF]: ContentTypes.GIF,\n [FileExtensions.WEBP]: ContentTypes.WEBP,\n [FileExtensions.SVG]: ContentTypes.SVG,\n [FileExtensions.PDF]: ContentTypes.PDF,\n [FileExtensions.JSON]: ContentTypes.JSON,\n [FileExtensions.TXT]: ContentTypes.PLAIN_TEXT,\n [FileExtensions.HTML]: ContentTypes.HTML,\n [FileExtensions.CSS]: ContentTypes.CSS,\n [FileExtensions.JS]: ContentTypes.JAVASCRIPT,\n [FileExtensions.MP4]: ContentTypes.MP4,\n [FileExtensions.WEBM]: ContentTypes.WEBM,\n [FileExtensions.MP3]: ContentTypes.MPEG_AUDIO,\n [FileExtensions.WAV]: ContentTypes.WAV,\n [FileExtensions.ZIP]: ContentTypes.ZIP,\n [FileExtensions.CSV]: ContentTypes.CSV,\n [FileExtensions.XML]: ContentTypes.XML,\n [FileExtensions.XLSX]: ContentTypes.XLSX,\n [FileExtensions.XLS]: ContentTypes.XLS,\n [FileExtensions.DOCX]: ContentTypes.DOCX,\n [FileExtensions.DOC]: ContentTypes.DOC,\n [FileExtensions.PPTX]: ContentTypes.PPTX,\n [FileExtensions.PPT]: ContentTypes.PPT,\n [FileExtensions.ODT]: ContentTypes.ODT,\n [FileExtensions.ODS]: ContentTypes.ODS,\n } satisfies Readonly<Record<TFileExtension, TContentType>>;\n\n /**\n * The content type an object name implies. `node:path` is deliberately not used: this file is\n * reachable from the browser-pure `./common` subpath, and an extension is the tail after the last\n * dot either way.\n */\n static resolve(opts: { filename: string }): TContentType {\n const { filename } = opts;\n const lastDot = filename.lastIndexOf('.');\n const extension = lastDot === -1 ? '' : filename.slice(lastDot).toLowerCase();\n\n return this.BY_EXTENSION[extension] ?? ContentTypes.OCTET_STREAM;\n }\n}\n\n/** Published before the table moved onto the class; kept as the one-line delegate it now is. */\nexport const CONTENT_TYPE_BY_EXTENSION = ContentTypeTable.BY_EXTENSION;\n"]}
|
|
1
|
+
{"version":3,"file":"mime.js","sourceRoot":"","sources":["../../../../src/common/constants/mime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,kIAAkI;AAClI,MAAM,OAAO,SAAS;aACJ,YAAO,GAAG,SAAS,CAAC;aACpB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;;AAKhC,wEAAwE;AACxE,MAAM,OAAO,cAAe,SAAQ,UAAU;aAC5B,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,OAAE,GAAG,KAAK,CAAC;aACX,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,M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CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,IAAI;QACxC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,GAAG;QACtC,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,IAAI;QACxC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,GAAG;QACtC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,GAAG;QACtC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,GAAG;KACkB,CAAC;IAE3D;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,IAA0B;QACvC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAC1B,MAAM,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QAE9E,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,YAAY,CAAC,YAAY,CAAC;IACnE,CAAC;;AAGH,gGAAgG;AAChG,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC,YAAY,CAAC","sourcesContent":["import { type TConstValue } from '../types';\nimport { ConstClass } from '@/common/const-class';\n\n/** The top-level part of a MIME type (`image`, `video`, `text`), plus `unknown`. For the full content type see `ContentTypes`. */\nexport class MimeTypes {\n static readonly UNKNOWN = 'unknown';\n static readonly IMAGE = 'image';\n static readonly VIDEO = 'video';\n static readonly TEXT = 'text';\n}\n/** One of the `MimeTypes` values. */\nexport type TMimeTypes = TConstValue<typeof MimeTypes>;\n\n/** The leading dot is part of the value: `path.extname` returns one. */\nexport class FileExtensions extends ConstClass {\n static readonly PNG = '.png';\n static readonly JPG = '.jpg';\n static readonly JPEG = '.jpeg';\n static readonly GIF = '.gif';\n static readonly WEBP = '.webp';\n static readonly SVG = '.svg';\n static readonly PDF = '.pdf';\n static readonly JSON = '.json';\n static readonly TXT = '.txt';\n static readonly HTML = '.html';\n static readonly CSS = '.css';\n static readonly JS = '.js';\n static readonly MP4 = '.mp4';\n static readonly WEBM = '.webm';\n static readonly MP3 = '.mp3';\n static readonly WAV = '.wav';\n static readonly ZIP = '.zip';\n static readonly CSV = '.csv';\n static readonly XML = '.xml';\n static readonly XLSX = '.xlsx';\n static readonly XLS = '.xls';\n static readonly DOCX = '.docx';\n static readonly DOC = '.doc';\n static readonly PPTX = '.pptx';\n static readonly PPT = '.ppt';\n static readonly ODT = '.odt';\n static readonly ODS = '.ods';\n}\n/** One of the `FileExtensions` values, with its leading dot. */\nexport type TFileExtension = TConstValue<typeof FileExtensions>;\n\n/** Full content types, as they go on the wire. `MimeTypes` holds only the top-level part. */\nexport class ContentTypes extends ConstClass {\n static readonly OCTET_STREAM = 'application/octet-stream';\n static readonly PNG = 'image/png';\n static readonly JPEG = 'image/jpeg';\n static readonly GIF = 'image/gif';\n static readonly WEBP = 'image/webp';\n static readonly SVG = 'image/svg+xml';\n static readonly PDF = 'application/pdf';\n static readonly JSON = 'application/json';\n static readonly PLAIN_TEXT = 'text/plain';\n static readonly HTML = 'text/html';\n static readonly CSS = 'text/css';\n static readonly JAVASCRIPT = 'text/javascript';\n static readonly MP4 = 'video/mp4';\n static readonly WEBM = 'video/webm';\n static readonly MPEG_AUDIO = 'audio/mpeg';\n static readonly WAV = 'audio/wav';\n static readonly ZIP = 'application/zip';\n static readonly CSV = 'text/csv';\n static readonly XML = 'application/xml';\n static readonly XLSX = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';\n static readonly XLS = 'application/vnd.ms-excel';\n static readonly DOCX = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';\n static readonly DOC = 'application/msword';\n static readonly PPTX =\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation';\n\n static readonly PPT = 'application/vnd.ms-powerpoint';\n static readonly ODT = 'application/vnd.oasis.opendocument.text';\n static readonly ODS = 'application/vnd.oasis.opendocument.spreadsheet';\n}\n/** One of the `ContentTypes` values. */\nexport type TContentType = TConstValue<typeof ContentTypes>;\n\n/** The extension table and the lookup that reads it, together - the `DurationMultipliers` shape. */\nexport class ContentTypeTable {\n /** `satisfies` makes the table total; the declared `string` key keeps a lookup cast-free. */\n static readonly BY_EXTENSION: Readonly<Partial<Record<string, TContentType>>> = {\n [FileExtensions.PNG]: ContentTypes.PNG,\n [FileExtensions.JPG]: ContentTypes.JPEG,\n [FileExtensions.JPEG]: ContentTypes.JPEG,\n [FileExtensions.GIF]: ContentTypes.GIF,\n [FileExtensions.WEBP]: ContentTypes.WEBP,\n [FileExtensions.SVG]: ContentTypes.SVG,\n [FileExtensions.PDF]: ContentTypes.PDF,\n [FileExtensions.JSON]: ContentTypes.JSON,\n [FileExtensions.TXT]: ContentTypes.PLAIN_TEXT,\n [FileExtensions.HTML]: ContentTypes.HTML,\n [FileExtensions.CSS]: ContentTypes.CSS,\n [FileExtensions.JS]: ContentTypes.JAVASCRIPT,\n [FileExtensions.MP4]: ContentTypes.MP4,\n [FileExtensions.WEBM]: ContentTypes.WEBM,\n [FileExtensions.MP3]: ContentTypes.MPEG_AUDIO,\n [FileExtensions.WAV]: ContentTypes.WAV,\n [FileExtensions.ZIP]: ContentTypes.ZIP,\n [FileExtensions.CSV]: ContentTypes.CSV,\n [FileExtensions.XML]: ContentTypes.XML,\n [FileExtensions.XLSX]: ContentTypes.XLSX,\n [FileExtensions.XLS]: ContentTypes.XLS,\n [FileExtensions.DOCX]: ContentTypes.DOCX,\n [FileExtensions.DOC]: ContentTypes.DOC,\n [FileExtensions.PPTX]: ContentTypes.PPTX,\n [FileExtensions.PPT]: ContentTypes.PPT,\n [FileExtensions.ODT]: ContentTypes.ODT,\n [FileExtensions.ODS]: ContentTypes.ODS,\n } satisfies Readonly<Record<TFileExtension, TContentType>>;\n\n /**\n * The content type an object name implies. `node:path` is deliberately not used: this file is\n * reachable from the browser-pure `./common` subpath, and an extension is the tail after the last\n * dot either way.\n */\n static resolve(opts: { filename: string }): TContentType {\n const { filename } = opts;\n const lastDot = filename.lastIndexOf('.');\n const extension = lastDot === -1 ? '' : filename.slice(lastDot).toLowerCase();\n\n return this.BY_EXTENSION[extension] ?? ContentTypes.OCTET_STREAM;\n }\n}\n\n/** Published before the table moved onto the class; kept as the one-line delegate it now is. */\nexport const CONTENT_TYPE_BY_EXTENSION = ContentTypeTable.BY_EXTENSION;\n"]}
|
package/dist/esm/common/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC","sourcesContent":["export * from './constants';\nexport * from './redact';\nexport * from './resolvers';\nexport * from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC","sourcesContent":["export * from './const-class';\nexport * from './constants';\nexport * from './redact';\nexport * from './resolvers';\nexport * from './types';\n"]}
|
package/dist/esm/core.d.ts
CHANGED
|
@@ -22,8 +22,8 @@ export * from './modules/network/utilities/url-builder.js';
|
|
|
22
22
|
export { RetryBackoffStrategies, RetryJitterModes } from './modules/retry/common/constants.js';
|
|
23
23
|
export type { TRetryBackoffStrategy, TRetryJitterMode } from './modules/retry/common/constants.js';
|
|
24
24
|
export type { IRetryBackoffOptions, IRetryContext } from './modules/retry/common/types.js';
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
25
|
+
export { RetryUtility } from './utilities/retry.utility.js';
|
|
26
|
+
export { SlugUtility } from './utilities/slug.utility.js';
|
|
27
27
|
export { TreeBuilder } from './modules/tree/builder.js';
|
|
28
28
|
export type { IBuildOptions, IHeightWhereOptions, ILeavesOptions, INodeWithPath, IPrintOptions, ITreeNode, IWalkAsyncOptions, IWalkOptions, TNodePredicate, TOnVisit, TOnVisitAsync, } from './modules/tree/common/types.js';
|
|
29
29
|
export { TreeWalker } from './modules/tree/walk.js';
|
package/dist/esm/core.js
CHANGED
|
@@ -27,8 +27,8 @@ export * from './modules/network/utilities/url-safety/policy.js';
|
|
|
27
27
|
export * from './modules/network/utilities/query-string.js';
|
|
28
28
|
export * from './modules/network/utilities/url-builder.js';
|
|
29
29
|
export { RetryBackoffStrategies, RetryJitterModes } from './modules/retry/common/constants.js';
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
30
|
+
export { RetryUtility } from './utilities/retry.utility.js';
|
|
31
|
+
export { SlugUtility } from './utilities/slug.utility.js';
|
|
32
32
|
export { TreeBuilder } from './modules/tree/builder.js';
|
|
33
33
|
export { TreeWalker } from './modules/tree/walk.js';
|
|
34
34
|
// Pure value/type utilities that already live under the root barrel's `./utilities` re-export -
|
package/dist/esm/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,6FAA6F;AAC7F,8DAA8D;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,6HAA6H;AAC7H,iHAAiH;AACjH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,cAAc,qDAAqD,CAAC;AACpE,cAAc,+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CAAC;AAMxE,OAAO,EACL,aAAa,EACb,eAAe,GAChB,MAAM,sDAAsD,CAAC;AAC9D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0CAA0C,CAAC;AACzD,cAAc,yCAAyC,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAG5F,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAcrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,gGAAgG;AAChG,6FAA6F;AAC7F,iGAAiG;AACjG,0DAA0D;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,uHAAuH;AACvH,gGAAgG;AAChG,0EAA0E;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AACzF,OAAO,EAAE,IAAI,EAAE,MAAM,4CAA4C,CAAC;AAOlE,+FAA+F;AAC/F,6GAA6G;AAC7G,wCAAwC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC","sourcesContent":["export { BaseHelper } from './modules/base';\n// By name, never `export *` from `./modules/env`: that barrel also carries `Environment` and\n// `applicationEnvironment`, both of which read `process.env`.\nexport { EnvironmentNames } from './modules/env/names';\nexport * from './modules/error';\nexport { LogLevels } from './modules/logger/common/types';\nexport type { ILogger, ILoggerProvider, TLogLevel } from './modules/logger/common/types';\n// The one way to get a logger, the same in the browser and on the server: `LoggerFactory` imports nothing from node, and its\n// default provider is the console. An application chooses another with `LoggerFactory.use({ provider, level })`.\nexport { ConsoleLogger } from './modules/logger/base/console';\nexport { LoggerFactory } from './modules/logger/factory';\nexport * from './modules/network/http-request/fetcher/base-fetcher';\nexport * from './modules/network/http-request/fetcher/common';\n// The node fetcher carries no node builtin - its one `querystring.stringify` is written out - so the\n// framework HTTP layer is reachable from a browser bundle, and a connector on HTTP need not\n// re-implement one.\nexport * from './modules/network/http-request/fetcher/native-fetcher';\nexport * from './modules/network/http-request/base-network-request.helper';\nexport * from './modules/pool';\nexport * from './modules/queue/internal/hf';\nexport * from './modules/temporal';\nexport * from './modules/uid';\n// The url guard, pure half only: `UrlPolicy` decides a url and a literal address with string and\n// number work. Its sibling `UrlGuard` reaches `node:dns` and stays out of this subpath.\nexport * from './modules/network/utilities/url-safety/common/constants';\nexport type {\n IUrlSafetyPolicy,\n IUrlTrustedHosts,\n TTrustedOrigin,\n} from './modules/network/utilities/url-safety/common/types';\nexport {\n UrlFetchError,\n UrlSafetyErrors,\n} from './modules/network/utilities/url-safety/common/errors';\nexport * from './modules/network/utilities/url-safety/policy';\nexport * from './modules/network/utilities/query-string';\nexport * from './modules/network/utilities/url-builder';\nexport { RetryBackoffStrategies, RetryJitterModes } from './modules/retry/common/constants';\nexport type { TRetryBackoffStrategy, TRetryJitterMode } from './modules/retry/common/constants';\nexport type { IRetryBackoffOptions, IRetryContext } from './modules/retry/common/types';\nexport { RetryUtility } from './utilities/retry.utility';\nexport { SlugUtility } from './utilities/slug.utility';\nexport { TreeBuilder } from './modules/tree/builder';\nexport type {\n IBuildOptions,\n IHeightWhereOptions,\n ILeavesOptions,\n INodeWithPath,\n IPrintOptions,\n ITreeNode,\n IWalkAsyncOptions,\n IWalkOptions,\n TNodePredicate,\n TOnVisit,\n TOnVisitAsync,\n} from './modules/tree/common/types';\nexport { TreeWalker } from './modules/tree/walk';\n\n// Pure value/type utilities that already live under the root barrel's `./utilities` re-export -\n// that barrel also carries node-only siblings (module.utility.ts, request.utility.ts), so it\n// cannot itself become a subpath. Named one at a time here instead of widening the barrel: every\n// symbol below is verified free of node builtins/globals.\nexport { BuildInfoRegistry } from './utilities/build-info.utility';\nexport type { IBuildInfo, TBuildInfoRecord } from './utilities/build-info.utility';\nexport { EchoUtility } from './utilities/echo.utility';\nexport { ParseUtility } from './utilities/parse.utility';\nexport { PerformanceUtility } from './utilities/performance.utility';\nexport { PromiseUtility } from './utilities/promise.utility';\nexport { RecordUtility } from './utilities/record.utility';\nexport { FormBodyUtility, RequestBodyErrors } from './utilities/form-body.utility';\nexport { ProjectRootRegistry } from './utilities/project-root.utility';\n\n// `ECDH` is the one crypto algorithm that is browser-pure: it runs over `crypto.subtle`, `btoa` and `atob`. It and its\n// base class come by leaf path, never the algorithms barrel, which also carries `AES` and `RSA`\n// (server code: they use `Buffer`, and `AES` reads files with `node:fs`).\nexport { AbstractCryptoAlgorithm } from './modules/crypto/algorithms/abstract.algorithm';\nexport { ECDH } from './modules/crypto/algorithms/ecdh.algorithm';\nexport type {\n ECDHAlgorithmType,\n IECDHEncryptedPayload,\n IECDHExtraOptions,\n} from './modules/crypto/algorithms/ecdh.algorithm';\n\n// Type-only: erased at compile time, so re-exporting these carries no runtime/bundle cost even\n// though the concrete classes they describe (the other crypto algorithms, the ioredis-backed helper) are not\n// themselves part of this pure surface.\nexport { AESAlgorithms } from './modules/crypto/algorithms/aes.constants';\nexport type { AESAlgorithmType } from './modules/crypto/algorithms/aes.constants';\nexport type { IRedisHelper } from './modules/redis/common/interfaces';\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { TConstValue } from '../../../common/types/index.js';
|
|
2
|
+
import { ConstClass } from '../../../common/const-class.js';
|
|
2
3
|
/** The ciphers `AES` supports. */
|
|
3
|
-
export declare class AESAlgorithms {
|
|
4
|
+
export declare class AESAlgorithms extends ConstClass {
|
|
4
5
|
static readonly AES_256_CBC = "aes-256-cbc";
|
|
5
6
|
static readonly AES_256_GCM = "aes-256-gcm";
|
|
6
|
-
static readonly SCHEME_SET: Set<string>;
|
|
7
|
-
static isValid(value: string): boolean;
|
|
8
7
|
}
|
|
9
8
|
/** Valid AES algorithm values. */
|
|
10
9
|
export type AESAlgorithmType = TConstValue<typeof AESAlgorithms>;
|