namirasoft-core 1.4.114 → 1.4.116
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/SKILL.md +223 -0
- package/dist/NamingConvention.js +2 -1
- package/dist/NamingConvention.js.map +1 -1
- package/dist/TimeZone.d.ts +9 -0
- package/dist/TimeZone.js +51 -0
- package/dist/TimeZone.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/logo.png +0 -0
- package/package.json +5 -5
- package/src/NamingConvention.ts +2 -1
- package/src/TimeZone.ts +60 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +3 -0
package/SKILL.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: namirasoft-core
|
|
3
|
+
description: Use the namirasoft-core package when working in any TypeScript/Node project that depends on it. Provides foundational utilities (BaseServer HTTP client, IStorage abstraction, BaseMeta* metadata classes, FilterItem/SortItem query primitives, Countries DB, ConvertService env/cookie/object readers, NamingConvention case converter, BaseUUID, time/string/hash/url operations, HTTPError). Trigger when a project's package.json depends on "namirasoft-core", when imports come from "namirasoft-core", when wiring an axios-based API client, when reading env/cookie values that need typed conversion, when defining tabular metadata (BaseMetaDatabase/Table/Column), or when parsing/encoding filter or sort query strings.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# namirasoft-core
|
|
7
|
+
|
|
8
|
+
The foundational TypeScript utility package that the rest of the Namirasoft stack (`namirasoft-schema`, `namirasoft-site-react`, `namirasoft-api-*`, etc.) is built on. Pure utilities, abstract base classes, and shared types — no UI, no framework lock-in.
|
|
9
|
+
|
|
10
|
+
## When this skill applies
|
|
11
|
+
|
|
12
|
+
Trigger when the project's `package.json` lists `namirasoft-core` as a dependency, when code imports from `"namirasoft-core"`, or when a sibling Namirasoft package (which depends on this one) re-exports a type whose original definition lives here (`BaseMetaTable`, `SortItem`, `FilterItem`, `IStorage`, `NamingConvention`, `HTTPError`, `BaseUUID`, etc.). Skip for projects on a different stack — these are opinionated abstractions tailored to Namirasoft conventions.
|
|
13
|
+
|
|
14
|
+
## Cardinal rules
|
|
15
|
+
|
|
16
|
+
1. **Prefer this package's abstractions over raw alternatives.** If you reach for `axios.get` directly, stop — extend `BaseServer`. If you reach for `process.env.X`, stop — use `new EnvService("X").getString()`. If you parse a query string filter by hand, use `FilterItem.parse` / `FilterItem.encode`. If you compare semver strings, use `VersionOperation`. If you compute date offsets, use `TimeOperation` / `TimeUnitOperation` instead of hand-rolling `setDate(...)`. The point of the package is consistency across services.
|
|
17
|
+
2. **Always import from the package root**: `import { BaseServer, EnvService, BaseUUID } from "namirasoft-core";` — never deep-import from `dist/...`.
|
|
18
|
+
3. **`BaseServer` is abstract**: subclass it, implement `protected onError(error: Error): void`, and pass the `base_url` to the parent constructor. Use the `_get` / `_post` / `_put` / `_patch` / `_delete` helpers; they handle URL composition (`URLOperation.getLink`), HMAC signing, before/after hooks, and error normalization for you. Don't call `axios` directly inside subclasses.
|
|
19
|
+
4. **Use `IStorage` as the storage contract** — never reach for `localStorage` / `sessionStorage` / `document.cookie` directly. Pick the right implementation: `IStorageLocal` (browser), `IStorageSession` (browser), `IStorageCookie` (browser/SSR cookie), `IStorageMemoryDedicated` (per-instance in-memory), `IStorageMemoryShared` (process-wide static), `IStorageJsonFile` (Node, persisted JSON file). All extend `IStorage` with `get(name, defaultValue)` / `set(name, value)` / `del(name)`.
|
|
20
|
+
5. **Throw `HTTPError` (or use `ErrorOperation.throwHTTP(code, message, ...args)`) for application errors** — not raw `Error`. `BaseServer.isErrorCode(e, 401)` and the `code` field on `HTTPError` are how downstream code branches on status.
|
|
21
|
+
6. **`ConvertService` subclasses (`EnvService`, `CookieService`, `ObjectService`) all expose the same typed readers**: `getString`, `getInt`, `getFloat`, `getBoolean`, `getDate`, `getEnum`, `getStringArray`, `getIntArray`, etc., plus their `getNull*` variants. Pass `mandatory: true` to the constructor when missing values must throw.
|
|
22
|
+
7. **Honor the `NAMIRASOFT_MUTE` escape hatch.** When `process.env.NAMIRASOFT_MUTE` is set, `ConvertService` skips its mandatory-error path. If you write your own `ConvertService` subclass, mirror this in `onMandatoryError`.
|
|
23
|
+
8. **`BaseUUID.SIZE === 20`** and IDs follow a `<short>-<random>` (or `<short>-<random>@<child>`) shape. Use `BaseUUID.uuid()` for raw IDs, `new BaseUUID("usr").new()` for typed ones, and `BaseUUID.isValid(id)` to validate — don't write your own regex.
|
|
24
|
+
|
|
25
|
+
## API surface
|
|
26
|
+
|
|
27
|
+
### HTTP client
|
|
28
|
+
|
|
29
|
+
| Use case | Class / method |
|
|
30
|
+
|---|---|
|
|
31
|
+
| Build a typed REST client | `extends BaseServer` + implement `onError` |
|
|
32
|
+
| Issue requests inside a subclass | `this._get`, `this._post`, `this._put`, `this._patch`, `this._delete` |
|
|
33
|
+
| Per-request hooks / signing / suppression | pass a `BaseServerConfig<ReqData>` (extends `AxiosRequestConfig`) with `sign`, `onBeforeRequest`, `onAfterRequest`, `onError`, `error_suppress`, `error_verbose` |
|
|
34
|
+
| Global hooks | `addOnBeforeRequest(fn)`, `addOnAfterRequest(fn)` |
|
|
35
|
+
| Match status code on caught error | `BaseServer.isErrorCode(err, 404)` |
|
|
36
|
+
| HTTP method enum | `HTTPMethod.GET / POST / PUT / PATCH / DELETE` |
|
|
37
|
+
| Application error type | `HTTPError(code, message)` / `ErrorOperation.throwHTTP(code, msg)` / `ErrorOperation.getHTTP(code, msg, ...fmtArgs)` |
|
|
38
|
+
| URL composition | `URLOperation.getLink(domain, sub, query)`, `URLOperation.merge(...parts)`, `URLOperation.getQuery(query)`, `URLOperation.isEqual(a, b)` |
|
|
39
|
+
|
|
40
|
+
### Configuration / typed value readers (extend `ConvertService`)
|
|
41
|
+
|
|
42
|
+
| Source | Class | Constructor |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| `process.env` | `EnvService` | `new EnvService(name, mandatory?)` |
|
|
45
|
+
| Raw cookie header string | `CookieService` | `new CookieService(cookies, name, mandatory?)` |
|
|
46
|
+
| Arbitrary `ParsedNameValue` | `ObjectService` | `new ObjectService(value, mandatory?)` |
|
|
47
|
+
|
|
48
|
+
All expose `getString` / `getNullString` / `getInt` / `getNullInt` / `getFloat` / `getNullFloat` / `getDate` / `getNullDate` / `getBoolean` / `getNullBoolean` / `getEnum<T>(enumObj, default)` / `getNullEnum<T>` / `getStringArray(delim?)` / `getIntArray` / `getFloatArray` / `getDateArray` / `getEnumArray<T>`. Set `.repair = true` on the instance to apply `StringOperation.repair` (collapse whitespace, trim).
|
|
49
|
+
|
|
50
|
+
### Storage
|
|
51
|
+
|
|
52
|
+
`IStorage` (abstract) with implementations: `IStorageLocal`, `IStorageSession`, `IStorageCookie`, `IStorageMemoryDedicated`, `IStorageMemoryShared`, `IStorageJsonFile(base_path)`. All have the same three-method interface.
|
|
53
|
+
|
|
54
|
+
### Caching
|
|
55
|
+
|
|
56
|
+
`CacheService<T>` — versioned, expiring cache backed by any `IStorage`. Construct with `name`, `storage`, `duration_minutes`, `getVersion: () => Promise<string>`, `getFromSource: () => Promise<T>`. Optional `runGetOn?: Mutex` (from `async-mutex`) for single-flight; optional `onExpired?` callback. Methods: `get()`, `set(data, version?)`, `del()`.
|
|
57
|
+
|
|
58
|
+
### Tabular metadata & query primitives
|
|
59
|
+
|
|
60
|
+
| Class / type | Purpose |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `BaseDatabaseRow<ID>` | Standard row shape: `{ id, createdAt, updatedAt, deletedAt }` |
|
|
63
|
+
| `BaseMetaDatabase` (abstract) | Holds `tables: { [name]: BaseMetaTable }`, with `forEachTable`, `getTables<MT>()`, `hasTable(name)` |
|
|
64
|
+
| `BaseMetaTable` | `{ database, name, text, columns }` + `forEachColumn`, `getColumns<MC>()`, `hasColumn(name)` |
|
|
65
|
+
| `BaseMetaColumn` | `{ table, name, text, type, required }` |
|
|
66
|
+
| `FilterItem` | Typed filter w/ `table`, `column`, `not`, `operator`, `values`. Static `encode/decode` (Base64) and `stringify/parse` (`;`-delimited) for query-string transport. |
|
|
67
|
+
| `FilterItemOperator` | Catalog under `FilterItemOperator.all.{equals, contains, regex, empty, exists, includes, startswith, endswith, lessthan, lessthanequal, morethan, morethanequal}`. Use `getByName` / `getBySign` / `getAllByType(type, required)`. |
|
|
68
|
+
| `FilterItemColumnType` | enum: `Unknown / Boolean / Number / String / Date / Time / DateTime` |
|
|
69
|
+
| `SortItem` | `{ table, column, ascending }` with the same `encode/decode/stringify/parse` API |
|
|
70
|
+
|
|
71
|
+
### Identity / strings / encoding
|
|
72
|
+
|
|
73
|
+
| Need | Use |
|
|
74
|
+
|---|---|
|
|
75
|
+
| Generate ID | `BaseUUID.uuid(length?, seed?)`, `new BaseUUID("xyz").new()` |
|
|
76
|
+
| Validate ID shape | `BaseUUID.isValid(id)`, `BaseUUID.isValidShort(id, "xyz")` |
|
|
77
|
+
| Child IDs | `BaseUUID.changeToChild(owner_id, name)`, `BaseUUID.isChild(id)`, `BaseUUID.getShort(id)` |
|
|
78
|
+
| Convert case | `NamingConvention.<from>.convert(name, NamingConvention.<to>)` — pick from `lower_case`, `UPPER_CASE`, `Pascal_Case`, `camel_Case`, plus `_underscore`, `_dash`, `_dot`, `_space`, `_slash` variants, plus `auto` (parse only) |
|
|
79
|
+
| Format / repair string | `StringOperation.format("Hello {0}", name)`, `StringOperation.repair(s)`, `StringOperation.split(s)` |
|
|
80
|
+
| Base64 (UTF-8 safe) | `EncodingOperation.Base64Encode(s)`, `EncodingOperation.Base64Decode(s)` |
|
|
81
|
+
| Hash | `HashOperation.SHA256(value)`, `HashOperation.SHA256Secret(secret, value)`, `isValidSHA256`, `isValidSHA256Secret` |
|
|
82
|
+
| Random password | `PasswordOperation.new(length)` |
|
|
83
|
+
| Search match | `SearchOperation.filter(arr, item => item.name, "two tokens")`, `SearchOperation.match(value, search)`, `SearchOperation.getTokens(search)` |
|
|
84
|
+
| Bytes | `ByteOperation.format(value, ByteUnit.MB)`, `ByteOperation.convert(value, from, to)` |
|
|
85
|
+
|
|
86
|
+
### Time
|
|
87
|
+
|
|
88
|
+
- `TimeOperation` — `format(date, fmt)` (moment), `toDBFormat(date)` ("YYYY-MM-DD HH:mm:ss"), `beginningOfYear/Month/Week/Day/Hour`, `endOfMonth/Week/Day`, `daysAgo/Later`, `hoursAgo/Later`, `minutesAgo/Later`, `secondsAgo/Later`, `getDuration(start, end, zeroAllOnPassed?)`, `calculateAge(date)`, `isValidDate/Time/DateTime`. Returns/uses native `Date`.
|
|
89
|
+
- `TimeUnitOperation` — `later(value, DurationUnit, date?)`, `ago(...)`, `toMilliseconds/Seconds/Minutes/Hours/Days(value, unit)` keyed off `DurationUnit.{Millisecond, Second, Minute, Hour, Day, Week, Month, Year}`.
|
|
90
|
+
- `CronOperation` — validate / parse cron-style fields (`*`, `*/5`, `0-10`, `2-10/3`, `0,4,5-10/2`). `isValid`, `check`, `getNumbers(pattern, min, max)`, `getNext(current, pattern, min, max?)`.
|
|
91
|
+
- `SetTimeouService` — debounced setTimeout. `setTimeoutIfNotCalledAgain(cb, ms)` and `setTimeoutIfFarArrival(cb, ms)`.
|
|
92
|
+
- `VersionOperation` — semver compare: `isGreaterThan`, `isLessThan`, `isEqual`, `isGreaterThanOrEqual`, `isLessThanOrEqual`.
|
|
93
|
+
|
|
94
|
+
### Country / phone / geo / pricing
|
|
95
|
+
|
|
96
|
+
- `Country` — `{ continent, name, iso2, iso3, code, european_union, coeff, other }`.
|
|
97
|
+
- `Countries` — static catalog (`Countries.Afghanistan`, `Countries.United_States`, etc.); use `Countries.getAll()` (referenced internally).
|
|
98
|
+
- `CountryOperation` — `find(input)` (matches name/iso2/iso3/phone code/aliases), `findPhone(input)`, `isPhoneFromCountry(input, country)`, `areEqual([...])`, `getCoeff(code, amount, times?)`.
|
|
99
|
+
- `PhoneOperation.isValid(number)` — wraps the `phone` library.
|
|
100
|
+
- `GeoOperation.distance(lat1, lng1, lat2, lng2)` — Haversine, returns km.
|
|
101
|
+
- `PriceOperation` — millicent unit conversion: `millicent_to_cent`, `millicent_to_fiat`, `cent_to_millicent`, `fiat_to_millicent`. **Money is stored as integer millicents.**
|
|
102
|
+
|
|
103
|
+
### Misc
|
|
104
|
+
|
|
105
|
+
- `ConsoleOperation` — colored logging: `log`, `info`, `trace`, `debug`, `success`, `warning`, `error` plus `format*Color` helpers.
|
|
106
|
+
- `FileOperation` (Node only) — `findUp(fileName)` walks up to `process.cwd()`, `foreach(base, handler, folders?, files?, level?)` recursive walker.
|
|
107
|
+
- `PackageService` (Node only) — `PackageService.getMain()` / `getThis()` / `get(path)`. Reads `package.json` and exposes `getName`, `getTitle`, `getDescription`, `getIcon`, `getLogo`, `getVersion`. Static `MainJson` / `ThisJson` overrides for prebundled environments.
|
|
108
|
+
- `ParsedNameValue` — `undefined | null | boolean | number | string | string[] | (string|null)[] | any` (used as the value type in URL queries / object readers).
|
|
109
|
+
|
|
110
|
+
## Canonical examples
|
|
111
|
+
|
|
112
|
+
### Subclassing `BaseServer`
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import { BaseServer, BaseServerConfig, ConsoleOperation, ErrorOperation } from "namirasoft-core";
|
|
116
|
+
|
|
117
|
+
interface User { id: string; name: string; }
|
|
118
|
+
|
|
119
|
+
export class UserServer extends BaseServer {
|
|
120
|
+
constructor(base_url: string) {
|
|
121
|
+
super(base_url);
|
|
122
|
+
}
|
|
123
|
+
protected override onError(error: Error): void {
|
|
124
|
+
ConsoleOperation.error(error.message);
|
|
125
|
+
}
|
|
126
|
+
async list(page: number, size: number) {
|
|
127
|
+
const { data } = await this._get<{ rows: User[]; count: number }>(
|
|
128
|
+
"/users",
|
|
129
|
+
{ page, size },
|
|
130
|
+
);
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
133
|
+
async create(user: User, signKey: string) {
|
|
134
|
+
const config: BaseServerConfig<User> = {
|
|
135
|
+
sign: { header: "x-signature", key: signKey },
|
|
136
|
+
};
|
|
137
|
+
const { data } = await this._post<User, User>("/users", undefined, user, config);
|
|
138
|
+
return data;
|
|
139
|
+
}
|
|
140
|
+
async getOrThrow(id: string): Promise<User> {
|
|
141
|
+
try {
|
|
142
|
+
const { data } = await this._get<User>(`/users/${id}`);
|
|
143
|
+
return data;
|
|
144
|
+
} catch (e) {
|
|
145
|
+
if (BaseServer.isErrorCode(e, 404))
|
|
146
|
+
ErrorOperation.throwHTTP(404, "User {0} not found", id);
|
|
147
|
+
throw e;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Reading env vars with typed defaults
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import { EnvService } from "namirasoft-core";
|
|
157
|
+
|
|
158
|
+
const port = new EnvService("PORT").getInt(3000);
|
|
159
|
+
const debug = new EnvService("DEBUG").getBoolean(false);
|
|
160
|
+
const apiKey = new EnvService("API_KEY", true).getString(); // throws if missing
|
|
161
|
+
const origins = new EnvService("ALLOW_ORIGINS").getStringArray(",");
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Versioned cache with shared in-memory storage
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import { CacheService, IStorageMemoryShared, EnvService } from "namirasoft-core";
|
|
168
|
+
|
|
169
|
+
const featureFlags = new CacheService<Record<string, boolean>>(
|
|
170
|
+
"feature-flags",
|
|
171
|
+
new IStorageMemoryShared(),
|
|
172
|
+
/* duration_minutes */ 5,
|
|
173
|
+
async () => new EnvService("DEPLOY_VERSION").getString("dev"),
|
|
174
|
+
async () => fetchFlagsFromServer(),
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const flags = await featureFlags.get();
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Encoding filters for a query string
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
import { FilterItem, FilterItemOperator, BaseMetaTable, BaseMetaColumn } from "namirasoft-core";
|
|
184
|
+
|
|
185
|
+
const tbl = new BaseMetaTable(null, "user", "User");
|
|
186
|
+
const col = new BaseMetaColumn(tbl, "email", "Email", "String", true);
|
|
187
|
+
|
|
188
|
+
const filters = [
|
|
189
|
+
new FilterItem(tbl, col, /* not */ false, FilterItemOperator.all.contains, "@namirasoft.com"),
|
|
190
|
+
];
|
|
191
|
+
const encoded = FilterItem.encode(filters); // base64, safe for URL
|
|
192
|
+
const decoded = FilterItem.decode(encoded); // FilterItem[]
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Case conversion
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
import { NamingConvention } from "namirasoft-core";
|
|
199
|
+
|
|
200
|
+
NamingConvention.camel_Case.convert("userId", NamingConvention.lower_case_underscore); // "user_id"
|
|
201
|
+
NamingConvention.lower_case_underscore.convert("first_name", NamingConvention.Pascal_Case); // "FirstName"
|
|
202
|
+
NamingConvention.auto.getWords("HTTPRequest-handler.v2"); // ["HTTP", "Request", "handler", "v", "2"]
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Common mistakes to avoid
|
|
206
|
+
|
|
207
|
+
- Reading `process.env.X` directly when `EnvService` would give you a typed value with mandatory-checks and the `NAMIRASOFT_MUTE` escape hatch.
|
|
208
|
+
- Calling `axios.*` directly from code that should be an HTTP client — extend `BaseServer` instead so signing, hooks, and error normalization apply uniformly.
|
|
209
|
+
- Throwing `new Error("not found")` instead of `ErrorOperation.throwHTTP(404, "...")` — downstream code branches on `HTTPError.code` / `BaseServer.isErrorCode`.
|
|
210
|
+
- Touching `localStorage` / `sessionStorage` / `document.cookie` directly when an `IStorage` implementation already exists.
|
|
211
|
+
- Storing money as a float dollar amount — use **integer millicents** and `PriceOperation` to convert.
|
|
212
|
+
- Hand-rolling case conversion — every supported case is a static on `NamingConvention`.
|
|
213
|
+
- Re-implementing semver compare — use `VersionOperation`.
|
|
214
|
+
- Forgetting that `BaseUUID.SIZE === 20` and that valid IDs must start with a `^[a-z]{3}$` short prefix segment. Custom-format IDs will fail `isValid`.
|
|
215
|
+
- Importing from `"namirasoft-core/dist/..."` — only the package root is supported.
|
|
216
|
+
|
|
217
|
+
## Peer expectations
|
|
218
|
+
|
|
219
|
+
Runtime dependencies (already declared): `axios`, `moment`, `uuid`, `phone`, `async-mutex`, `@types/node`. Node-only modules (`fs`, `path`, `node:crypto`) are imported from `PackageService`, `FileOperation`, `IStorageJsonFile`, `HashOperation`, and `PasswordOperation`; these will not work in a pure browser bundle. Browser-only globals (`localStorage`, `sessionStorage`, `document.cookie`, `window`, `btoa`/`atob`, `TextEncoder`/`TextDecoder`) are used by `IStorageLocal`, `IStorageSession`, `IStorageCookie`, and `EncodingOperation` — pick the right `IStorage` for your runtime.
|
|
220
|
+
|
|
221
|
+
Environment variables read by the package itself:
|
|
222
|
+
- `BASESERVER_ERROR_VERBOSE` — when `true`, `BaseServer` prefixes thrown errors with the failing URL.
|
|
223
|
+
- `NAMIRASOFT_MUTE` — when set, suppresses mandatory-value errors thrown by `ConvertService` subclasses (`EnvService`, `CookieService`, `ObjectService`).
|
package/dist/NamingConvention.js
CHANGED
|
@@ -59,7 +59,8 @@ NamingConvention.abbreviations = [
|
|
|
59
59
|
"URL", "URI", "UTC", "XML", "CLI", "FIFO", "LIFO", "GPU", "GCP", "SMS",
|
|
60
60
|
"EBS", "EFS", "S3",
|
|
61
61
|
"KB", "MB", "GB", "TB", "PB",
|
|
62
|
-
"SSO", "OIDC"
|
|
62
|
+
"SSO", "OIDC",
|
|
63
|
+
"LLM", "SID",
|
|
63
64
|
];
|
|
64
65
|
NamingConvention.formatter_lower = (word) => {
|
|
65
66
|
if (word)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NamingConvention.js","sourceRoot":"","sources":["../src/NamingConvention.ts"],"names":[],"mappings":";;;;AAAA,MAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"NamingConvention.js","sourceRoot":"","sources":["../src/NamingConvention.ts"],"names":[],"mappings":";;;;AAAA,MAAa,gBAAgB;IAUzB,MAAM,CAAC,uB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ortName: string;
|
|
4
|
+
Minutes: number;
|
|
5
|
+
constructor(FullName: string, ShortName: string, minutes: number);
|
|
6
|
+
static from(ianaName: string, at?: Date): TimeZone;
|
|
7
|
+
private static offsetMinutes;
|
|
8
|
+
static list(at?: Date): TimeZone[];
|
|
9
|
+
}
|
package/dist/TimeZone.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeZone = void 0;
|
|
4
|
+
class TimeZone {
|
|
5
|
+
constructor(FullName, ShortName, minutes) {
|
|
6
|
+
this.FullName = "";
|
|
7
|
+
this.ShortName = "";
|
|
8
|
+
this.Minutes = 0;
|
|
9
|
+
this.FullName = FullName;
|
|
10
|
+
this.ShortName = ShortName;
|
|
11
|
+
this.Minutes = minutes;
|
|
12
|
+
}
|
|
13
|
+
static from(ianaName, at = new Date()) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
16
|
+
timeZone: ianaName,
|
|
17
|
+
timeZoneName: "short",
|
|
18
|
+
}).formatToParts(at);
|
|
19
|
+
const shortName = (_b = (_a = parts.find(p => p.type === "timeZoneName")) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "";
|
|
20
|
+
const minutes = TimeZone.offsetMinutes(ianaName, at);
|
|
21
|
+
return new TimeZone(ianaName, shortName, minutes);
|
|
22
|
+
}
|
|
23
|
+
static offsetMinutes(ianaName, at) {
|
|
24
|
+
const dtf = new Intl.DateTimeFormat("en-US", {
|
|
25
|
+
timeZone: ianaName,
|
|
26
|
+
hour12: false,
|
|
27
|
+
year: "numeric",
|
|
28
|
+
month: "2-digit",
|
|
29
|
+
day: "2-digit",
|
|
30
|
+
hour: "2-digit",
|
|
31
|
+
minute: "2-digit",
|
|
32
|
+
second: "2-digit",
|
|
33
|
+
});
|
|
34
|
+
const parts = {};
|
|
35
|
+
for (const p of dtf.formatToParts(at)) {
|
|
36
|
+
if (p.type !== "literal")
|
|
37
|
+
parts[p.type] = p.value;
|
|
38
|
+
}
|
|
39
|
+
const hour = (+parts.hour) % 24;
|
|
40
|
+
const asUTC = Date.UTC(+parts.year, +parts.month - 1, +parts.day, hour, +parts.minute, +parts.second);
|
|
41
|
+
return Math.round((asUTC - at.getTime()) / 60000);
|
|
42
|
+
}
|
|
43
|
+
static list(at = new Date()) {
|
|
44
|
+
const names = Intl.supportedValuesOf
|
|
45
|
+
? Intl.supportedValuesOf("timeZone")
|
|
46
|
+
: [];
|
|
47
|
+
return names.map(name => TimeZone.from(name, at));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.TimeZone = TimeZone;
|
|
51
|
+
//# sourceMappingURL=TimeZone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeZone.js","sourceRoot":"","sources":["../src/TimeZone.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAQ;IAKjB,YAAY,QAAgB,EAAE,SAAiB,EAAE,OAAe;QAHhE,aAAQ,GAAW,EAAE,CAAC;QACtB,cAAS,GAAW,EAAE,CAAC;QACvB,YAAO,GAAW,CAAC,CAAC;QAGhB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,QAAgB,EAAE,KAAW,IAAI,IAAI,EAAE;;QAE/C,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;YAC3C,QAAQ,EAAE,QAAQ;YAClB,YAAY,EAAE,OAAO;SACxB,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACrB,MAAM,SAAS,GAAG,MAAA,MAAA,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAA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KAAW,IAAI,IAAI,EAAE;QAE7B,MAAM,KAAK,GAAc,IAAY,CAAC,iBAAiB;YACnD,CAAC,CAAE,IAAY,CAAC,iBAAiB,CAAC,UAAU,CAAC;YAC7C,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;CACJ;AA3DD,4BA2DC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -60,6 +60,7 @@ __exportStar(require("./SortItem"), exports);
|
|
|
60
60
|
__exportStar(require("./StringOperation"), exports);
|
|
61
61
|
__exportStar(require("./TimeOperation"), exports);
|
|
62
62
|
__exportStar(require("./TimeUnitOperation"), exports);
|
|
63
|
+
__exportStar(require("./TimeZone"), exports);
|
|
63
64
|
__exportStar(require("./URLOperation"), exports);
|
|
64
65
|
__exportStar(require("./VersionOperation"), exports);
|
|
65
66
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,mDAAiC;AACjC,qDAAmC;AACnC,kDAAgC;AAChC,+CAA6B;AAC7B,6CAA2B;AAC3B,kDAAgC;AAChC,iDAA+B;AAC/B,qDAAmC;AACnC,mDAAiC;AACjC,kDAAgC;AAChC,8CAA4B;AAC5B,4CAA0B;AAC1B,qDAAmC;AACnC,kDAAgC;AAChC,sDAAoC;AACpC,+CAA6B;AAC7B,mDAAiC;AACjC,kDAAgC;AAChC,+CAA6B;AAC7B,yDAAuC;AACvC,uDAAqC;AACrC,iDAA+B;AAC/B,kDAAgC;AAChC,8CAA4B;AAC5B,+CAA6B;AAC7B,6CAA2B;AAC3B,mDAAiC;AACjC,qDAAmC;AACnC,kDAAgC;AAChC,4DAA0C;AAC1C,yDAAuC;AACvC,oDAAkC;AAClC,qDAAmC;AACnC,kDAAgC;AAChC,mDAAiC;AACjC,oDAAkC;AAClC,sDAAoC;AACpC,mDAAiC;AACjC,mDAAiC;AACjC,oDAAkC;AAClC,qDAAmC;AACnC,6CAA2B;AAC3B,oDAAkC;AAClC,kDAAgC;AAChC,sDAAoC;AACpC,iDAA+B;AAC/B,qDAAmC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,mDAAiC;AACjC,qDAAmC;AACnC,kDAAgC;AAChC,+CAA6B;AAC7B,6CAA2B;AAC3B,kDAAgC;AAChC,iDAA+B;AAC/B,qDAAmC;AACnC,mDAAiC;AACjC,kDAAgC;AAChC,8CAA4B;AAC5B,4CAA0B;AAC1B,qDAAmC;AACnC,kDAAgC;AAChC,sDAAoC;AACpC,+CAA6B;AAC7B,mDAAiC;AACjC,kDAAgC;AAChC,+CAA6B;AAC7B,yDAAuC;AACvC,uDAAqC;AACrC,iDAA+B;AAC/B,kDAAgC;AAChC,8CAA4B;AAC5B,+CAA6B;AAC7B,6CAA2B;AAC3B,mDAAiC;AACjC,qDAAmC;AACnC,kDAAgC;AAChC,4DAA0C;AAC1C,yDAAuC;AACvC,oDAAkC;AAClC,qDAAmC;AACnC,kDAAgC;AAChC,mDAAiC;AACjC,oDAAkC;AAClC,sDAAoC;AACpC,mDAAiC;AACjC,mDAAiC;AACjC,oDAAkC;AAClC,qDAAmC;AACnC,6CAA2B;AAC3B,oDAAkC;AAClC,kDAAgC;AAChC,sDAAoC;AACpC,6CAA2B;AAC3B,iDAA+B;AAC/B,qDAAmC"}
|
package/logo.png
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"framework": "npm",
|
|
9
9
|
"application": "package",
|
|
10
10
|
"private": false,
|
|
11
|
-
"version": "1.4.
|
|
12
|
-
"author": "Amir Abolhasani
|
|
11
|
+
"version": "1.4.116",
|
|
12
|
+
"author": "Amir Abolhasani",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"build": ""
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@types/node": "^25.
|
|
20
|
+
"@types/node": "^25.9.1",
|
|
21
21
|
"async-mutex": "^0.5.0",
|
|
22
|
-
"axios": "^1.
|
|
22
|
+
"axios": "^1.16.1",
|
|
23
23
|
"moment": "^2.30.1",
|
|
24
24
|
"phone": "^3.1.71",
|
|
25
|
-
"uuid": "^
|
|
25
|
+
"uuid": "^14.0.0"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/src/NamingConvention.ts
CHANGED
|
@@ -5,7 +5,8 @@ export class NamingConvention
|
|
|
5
5
|
"URL", "URI", "UTC", "XML", "CLI", "FIFO", "LIFO", "GPU", "GCP", "SMS",
|
|
6
6
|
"EBS", "EFS", "S3",
|
|
7
7
|
"KB", "MB", "GB", "TB", "PB",
|
|
8
|
-
"SSO", "OIDC"
|
|
8
|
+
"SSO", "OIDC",
|
|
9
|
+
"LLM", "SID",
|
|
9
10
|
];
|
|
10
11
|
static combineSingleCharacters(words: string[])
|
|
11
12
|
{
|
package/src/TimeZone.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export class TimeZone
|
|
2
|
+
{
|
|
3
|
+
FullName: string = "";
|
|
4
|
+
ShortName: string = "";
|
|
5
|
+
Minutes: number = 0;
|
|
6
|
+
constructor(FullName: string, ShortName: string, minutes: number)
|
|
7
|
+
{
|
|
8
|
+
this.FullName = FullName;
|
|
9
|
+
this.ShortName = ShortName;
|
|
10
|
+
this.Minutes = minutes;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static from(ianaName: string, at: Date = new Date()): TimeZone
|
|
14
|
+
{
|
|
15
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
16
|
+
timeZone: ianaName,
|
|
17
|
+
timeZoneName: "short",
|
|
18
|
+
}).formatToParts(at);
|
|
19
|
+
const shortName = parts.find(p => p.type === "timeZoneName")?.value ?? "";
|
|
20
|
+
const minutes = TimeZone.offsetMinutes(ianaName, at);
|
|
21
|
+
return new TimeZone(ianaName, shortName, minutes);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private static offsetMinutes(ianaName: string, at: Date): number
|
|
25
|
+
{
|
|
26
|
+
const dtf = new Intl.DateTimeFormat("en-US", {
|
|
27
|
+
timeZone: ianaName,
|
|
28
|
+
hour12: false,
|
|
29
|
+
year: "numeric",
|
|
30
|
+
month: "2-digit",
|
|
31
|
+
day: "2-digit",
|
|
32
|
+
hour: "2-digit",
|
|
33
|
+
minute: "2-digit",
|
|
34
|
+
second: "2-digit",
|
|
35
|
+
});
|
|
36
|
+
const parts: Record<string, string> = {};
|
|
37
|
+
for (const p of dtf.formatToParts(at))
|
|
38
|
+
{
|
|
39
|
+
if (p.type !== "literal") parts[p.type] = p.value;
|
|
40
|
+
}
|
|
41
|
+
const hour = (+parts.hour) % 24;
|
|
42
|
+
const asUTC = Date.UTC(
|
|
43
|
+
+parts.year,
|
|
44
|
+
+parts.month - 1,
|
|
45
|
+
+parts.day,
|
|
46
|
+
hour,
|
|
47
|
+
+parts.minute,
|
|
48
|
+
+parts.second,
|
|
49
|
+
);
|
|
50
|
+
return Math.round((asUTC - at.getTime()) / 60000);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static list(at: Date = new Date()): TimeZone[]
|
|
54
|
+
{
|
|
55
|
+
const names: string[] = (Intl as any).supportedValuesOf
|
|
56
|
+
? (Intl as any).supportedValuesOf("timeZone")
|
|
57
|
+
: [];
|
|
58
|
+
return names.map(name => TimeZone.from(name, at));
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/index.ts
CHANGED