@tempo-kit/plugin-dialects 0.0.0-stage → 2.0.0-rc.0
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/CHANGELOG.md +115 -0
- package/LICENSE +21 -0
- package/README.md +65 -2
- package/dist/compiler/dotnet.compiler.d.ts +28 -0
- package/dist/compiler/go.compiler.d.ts +28 -0
- package/dist/compiler/ldml.compiler.d.ts +28 -0
- package/dist/compiler/mysql.compiler.d.ts +21 -0
- package/dist/compiler/oracle.compiler.d.ts +39 -0
- package/dist/compiler/php.compiler.d.ts +30 -0
- package/dist/compiler/shared.compiler.d.ts +86 -0
- package/dist/compiler/sheet.compiler.d.ts +32 -0
- package/dist/compiler/strftime.compiler.d.ts +28 -0
- package/dist/constants.d.ts +54 -0
- package/dist/engine/convert.d.ts +14 -0
- package/dist/engine/dialect.registry.d.ts +40 -0
- package/dist/engine/dialect.shim.d.ts +4 -0
- package/dist/engine/explain.d.ts +13 -0
- package/dist/engine/export.d.ts +12 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.global.min.js +1 -0
- package/dist/index.js +5791 -0
- package/dist/install.d.ts +2 -0
- package/dist/install.global.min.js +1 -0
- package/dist/install.js +5794 -0
- package/dist/types.d.ts +152 -0
- package/package.json +70 -5
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { Tempo } from 'tempo-kit';
|
|
2
|
+
import type { Evaluable } from 'tempo-kit/library';
|
|
3
|
+
import type { Dialect } from './constants.js';
|
|
4
|
+
import type { MysqlSpecifier } from './compiler/mysql.compiler.js';
|
|
5
|
+
import type { DotNetSpecifier } from './compiler/dotnet.compiler.js';
|
|
6
|
+
import type { SheetSpecifier } from './compiler/sheet.compiler.js';
|
|
7
|
+
export type { MysqlSpecifier, DotNetSpecifier, SheetSpecifier };
|
|
8
|
+
export interface ExplainedToken {
|
|
9
|
+
readonly source: string;
|
|
10
|
+
readonly tempo: string;
|
|
11
|
+
readonly desc: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ExplainResult {
|
|
14
|
+
readonly dialect: Dialect;
|
|
15
|
+
readonly source: string;
|
|
16
|
+
readonly pattern: string;
|
|
17
|
+
readonly tokens: readonly ExplainedToken[];
|
|
18
|
+
toString(): string;
|
|
19
|
+
}
|
|
20
|
+
export interface ExportedToken {
|
|
21
|
+
readonly source: string;
|
|
22
|
+
readonly target: string;
|
|
23
|
+
readonly desc: string;
|
|
24
|
+
readonly supported: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ExportResult {
|
|
27
|
+
readonly dialect: Dialect;
|
|
28
|
+
readonly source: string;
|
|
29
|
+
readonly pattern: string;
|
|
30
|
+
readonly tokens: readonly ExportedToken[];
|
|
31
|
+
readonly unsupported: readonly string[];
|
|
32
|
+
toString(): string;
|
|
33
|
+
}
|
|
34
|
+
export interface ConvertResult {
|
|
35
|
+
readonly from: Dialect;
|
|
36
|
+
readonly to: Dialect;
|
|
37
|
+
readonly source: string;
|
|
38
|
+
readonly pattern: string;
|
|
39
|
+
readonly unsupported: readonly string[];
|
|
40
|
+
toString(): string;
|
|
41
|
+
}
|
|
42
|
+
export type DialectInput = Evaluable<string>;
|
|
43
|
+
export interface ExplainOptions {
|
|
44
|
+
readonly dialect?: DialectInput;
|
|
45
|
+
}
|
|
46
|
+
export interface ExportOptions {
|
|
47
|
+
readonly dialect?: DialectInput;
|
|
48
|
+
}
|
|
49
|
+
export interface ConvertOptions {
|
|
50
|
+
readonly from?: DialectInput;
|
|
51
|
+
readonly to: DialectInput;
|
|
52
|
+
}
|
|
53
|
+
export interface DialectsInstanceNamespace {
|
|
54
|
+
/**
|
|
55
|
+
* Formats this instance using Unicode LDML / Luxon tokens (e.g. 'yyyy-MM-dd HH:mm').
|
|
56
|
+
*/
|
|
57
|
+
ldml(mask: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Formats this instance using POSIX strftime specifiers (e.g. '%Y-%m-%d %H:%M:%S').
|
|
60
|
+
*/
|
|
61
|
+
strftime(mask: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Formats this instance using Oracle / SQL TO_CHAR format models (e.g. 'YYYY-MM-DD HH24:MI:SS').
|
|
64
|
+
*/
|
|
65
|
+
oracle(mask: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* Convenience helper for formatting using SQL / Oracle format models (e.g. 'YYYY-MM-DD HH24:MI:SS').
|
|
68
|
+
*/
|
|
69
|
+
sql(mask: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Formats this instance using PHP date format specifiers (e.g. 'Y-m-d H:i:s').
|
|
72
|
+
*/
|
|
73
|
+
php(mask: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Formats this instance using Go reference time format layout (e.g. '2006-01-02 15:04:05').
|
|
76
|
+
*/
|
|
77
|
+
go(mask: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* Formats this instance using MySQL / MariaDB DATE_FORMAT specifiers (e.g. '%Y-%m-%d %H:%i:%s').
|
|
80
|
+
*/
|
|
81
|
+
mysql(mask: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* Formats this instance using .NET custom or standard format specifiers (e.g. 'yyyy-MM-dd HH:mm:ss').
|
|
84
|
+
*/
|
|
85
|
+
dotnet(mask: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* Formats this instance using Excel / Google Sheets format masks (e.g. 'yyyy-mm-dd hh:mm:ss').
|
|
88
|
+
*/
|
|
89
|
+
sheet(mask: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Formats this instance using a specified dialect mask.
|
|
92
|
+
*/
|
|
93
|
+
format(mask: string, dialect?: DialectInput): string;
|
|
94
|
+
/**
|
|
95
|
+
* Explains an external dialect mask, translating it into native Tempo {token} syntax
|
|
96
|
+
* with detailed token mappings to guide incremental migration.
|
|
97
|
+
*/
|
|
98
|
+
explain(mask: string, dialectOrOptions?: DialectInput | ExplainOptions): ExplainResult;
|
|
99
|
+
/**
|
|
100
|
+
* Exports a native Tempo format pattern into the corresponding external dialect format model.
|
|
101
|
+
*/
|
|
102
|
+
export(mask: string, dialectOrOptions?: DialectInput | ExportOptions): ExportResult;
|
|
103
|
+
/**
|
|
104
|
+
* Converts a format mask directly from one dialect to another.
|
|
105
|
+
* If fromDialect is omitted, it will be automatically detected.
|
|
106
|
+
*/
|
|
107
|
+
convert(mask: string, options: ConvertOptions): ConvertResult;
|
|
108
|
+
convert(mask: string, toDialect: DialectInput): ConvertResult;
|
|
109
|
+
convert(mask: string, fromDialect: DialectInput, toDialect: DialectInput): ConvertResult;
|
|
110
|
+
}
|
|
111
|
+
export interface DialectsStaticNamespace {
|
|
112
|
+
/**
|
|
113
|
+
* Parses a date string using a format mask and dialect.
|
|
114
|
+
*/
|
|
115
|
+
parse(input: string, mask: string, dialect?: DialectInput, options?: Tempo.Options): Tempo;
|
|
116
|
+
parse(input: string, mask: string, options?: Tempo.Options): Tempo;
|
|
117
|
+
/**
|
|
118
|
+
* Parses a date string trying multiple candidate masks until one matches.
|
|
119
|
+
*/
|
|
120
|
+
fromFormats(input: string, masks: string[], dialect?: DialectInput, options?: Tempo.Options): Tempo;
|
|
121
|
+
fromFormats(input: string, masks: string[], options?: Tempo.Options): Tempo;
|
|
122
|
+
/**
|
|
123
|
+
* Explains an external dialect mask, translating it into native Tempo {token} syntax
|
|
124
|
+
* with detailed token mappings to guide incremental migration.
|
|
125
|
+
*/
|
|
126
|
+
explain(mask: string, dialectOrOptions?: DialectInput | ExplainOptions): ExplainResult;
|
|
127
|
+
/**
|
|
128
|
+
* Exports a native Tempo format pattern into the corresponding external dialect format model.
|
|
129
|
+
*/
|
|
130
|
+
export(mask: string, dialectOrOptions?: DialectInput | ExportOptions): ExportResult;
|
|
131
|
+
/**
|
|
132
|
+
* Converts a format mask directly from one dialect to another.
|
|
133
|
+
* If fromDialect is omitted, it will be automatically detected.
|
|
134
|
+
*/
|
|
135
|
+
convert(mask: string, options: ConvertOptions): ConvertResult;
|
|
136
|
+
convert(mask: string, toDialect: DialectInput): ConvertResult;
|
|
137
|
+
convert(mask: string, fromDialect: DialectInput, toDialect: DialectInput): ConvertResult;
|
|
138
|
+
}
|
|
139
|
+
declare module 'tempo-kit' {
|
|
140
|
+
namespace Tempo {
|
|
141
|
+
let dialects: DialectsStaticNamespace;
|
|
142
|
+
function fromFormat(input: string, mask: string, options?: Tempo.Options): Tempo;
|
|
143
|
+
function fromFormats(input: string, masks: string[], options?: Tempo.Options): Tempo;
|
|
144
|
+
}
|
|
145
|
+
interface Tempo {
|
|
146
|
+
readonly dialects: DialectsInstanceNamespace;
|
|
147
|
+
/**
|
|
148
|
+
* Luxon migration shim: formats using Unicode LDML mask.
|
|
149
|
+
*/
|
|
150
|
+
toFormat(mask: string, options?: Tempo.FormatOptions): string;
|
|
151
|
+
}
|
|
152
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,71 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@tempo-kit/plugin-dialects",
|
|
3
|
+
"version": "2.0.0-rc.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Tempo Community Plugin: Format dialects for Unicode LDML/Luxon, Moment, POSIX strftime, and Oracle/SQL TO_CHAR",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.mjs",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"./dist/install.js"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsup && tsc",
|
|
14
|
+
"prepublishOnly": "tempo-cli prepublish",
|
|
15
|
+
"test": "vitest run -c ../vitest.shared.ts"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"tempo-kit",
|
|
19
|
+
"tempo-kit-plugin",
|
|
20
|
+
"tempo",
|
|
21
|
+
"temporal",
|
|
22
|
+
"tempo-plugin",
|
|
23
|
+
"plugin",
|
|
24
|
+
"dialects",
|
|
25
|
+
"luxon",
|
|
26
|
+
"ldml",
|
|
27
|
+
"moment",
|
|
28
|
+
"strftime",
|
|
29
|
+
"date-fns",
|
|
30
|
+
"oracle",
|
|
31
|
+
"sql",
|
|
32
|
+
"postgres",
|
|
33
|
+
"snowflake",
|
|
34
|
+
"to_char"
|
|
35
|
+
],
|
|
36
|
+
"author": "Magma Computing",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/magmacomputing/magma.git",
|
|
41
|
+
"directory": "packages/plugins/dialects"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"README.md",
|
|
46
|
+
"CHANGELOG.md",
|
|
47
|
+
"LICENSE"
|
|
48
|
+
],
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"registry": "https://registry.npmjs.org/",
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"tempo-kit": "^5.0.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"tempo-kit": "^5.0.0"
|
|
58
|
+
},
|
|
59
|
+
"exports": {
|
|
60
|
+
".": {
|
|
61
|
+
"types": "./dist/index.d.ts",
|
|
62
|
+
"import": "./dist/index.js",
|
|
63
|
+
"default": "./dist/index.js"
|
|
64
|
+
},
|
|
65
|
+
"./install": {
|
|
66
|
+
"types": "./dist/install.d.ts",
|
|
67
|
+
"import": "./dist/install.js",
|
|
68
|
+
"default": "./dist/install.js"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|