@ama-sdk/schematics 9.1.0-alpha.25 → 9.1.0-alpha.26
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/package.json +7 -7
- package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen-tests.jar +0 -0
- package/schematics/java/client-core/swagger-codegen-java-client/target/javaClient-swagger-codegen.jar +0 -0
- package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator-tests.jar +0 -0
- package/schematics/typescript/core/openapi-codegen-typescript/target/typescriptFetch-openapi-generator.jar +0 -0
- package/schematics/typescript/shell/templates/base/readme.md +87 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ama-sdk/schematics",
|
|
3
|
-
"version": "9.1.0-alpha.
|
|
3
|
+
"version": "9.1.0-alpha.26",
|
|
4
4
|
"description": "Swagger specification SDK Generator by schematics",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"nx": "nx",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@ama-sdk/core": "^9.1.0-alpha.
|
|
44
|
+
"@ama-sdk/core": "^9.1.0-alpha.26",
|
|
45
45
|
"@angular-devkit/core": "~16.0.5",
|
|
46
46
|
"@angular-devkit/schematics": "~16.0.5",
|
|
47
47
|
"@angular-devkit/schematics-cli": "~16.0.5",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@angular-devkit/core": "~16.0.5",
|
|
54
54
|
"@angular-devkit/schematics": "~16.0.5",
|
|
55
|
-
"@o3r/dev-tools": "^9.1.0-alpha.
|
|
55
|
+
"@o3r/dev-tools": "^9.1.0-alpha.26",
|
|
56
56
|
"js-yaml": "^4.1.0",
|
|
57
57
|
"minimatch": "^9.0.0",
|
|
58
58
|
"rxjs": "^7.8.1",
|
|
@@ -61,14 +61,14 @@
|
|
|
61
61
|
"tslib": "^2.5.3"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@ama-sdk/core": "^9.1.0-alpha.
|
|
64
|
+
"@ama-sdk/core": "^9.1.0-alpha.26",
|
|
65
65
|
"@angular-devkit/schematics-cli": "~16.0.5",
|
|
66
66
|
"@angular-eslint/eslint-plugin": "~16.0.3",
|
|
67
67
|
"@angular/cli": "~16.0.5",
|
|
68
68
|
"@nx/jest": "~16.5.0",
|
|
69
|
-
"@o3r/build-helpers": "^9.1.0-alpha.
|
|
70
|
-
"@o3r/eslint-plugin": "^9.1.0-alpha.
|
|
71
|
-
"@o3r/schematics": "^9.1.0-alpha.
|
|
69
|
+
"@o3r/build-helpers": "^9.1.0-alpha.26",
|
|
70
|
+
"@o3r/eslint-plugin": "^9.1.0-alpha.26",
|
|
71
|
+
"@o3r/schematics": "^9.1.0-alpha.26",
|
|
72
72
|
"@openapitools/openapi-generator-cli": "~2.7.0",
|
|
73
73
|
"@schematics/angular": "~16.0.5",
|
|
74
74
|
"@types/jest": "~29.5.2",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -109,11 +109,95 @@ You can build and run UT with:
|
|
|
109
109
|
yarn test
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
##
|
|
112
|
+
## Manage dates
|
|
113
|
+
|
|
114
|
+
### The timezone issue
|
|
115
|
+
Managing dates with timezones has always been a bit painful in front end applications.
|
|
116
|
+
Let's give a concrete example to understand the problem:
|
|
117
|
+
An API returns the date and hour of your flight in the timezone of the airport location. In our use case, let's say the departure airport is on GTM+7 : 2023-07-10T00:37:00.000+07:00.
|
|
118
|
+
The timezone sent is the one from the airport, here GMT+7. If you just use the Date(), the computer browser will convert this in its own timezone.
|
|
119
|
+
For example, if the user is in GMT+2 you will end up displaying the following: 2023-07-09T19:37:00.000+02:00.
|
|
120
|
+
This is not what you want. You want the exact date time of the flight at the airport timezone, not the one of your user's computer.
|
|
121
|
+
However, there might be cases where you might still need the timezone information.
|
|
122
|
+
For example, you want to be able to display that the flight is in X hours.
|
|
123
|
+
You will need to compute this information with the two timezones -- the airport's and the user's.
|
|
124
|
+
|
|
125
|
+
### Solution proposed to remove the timezone: utils.DateTime
|
|
126
|
+
We have introduced the utils.Date object to replace the Date implementation and ignore the timezone.
|
|
127
|
+
As we need to get rid of the timezones more often than not, this will be our default behavior.
|
|
128
|
+
By default, the Date models are replaced with utils.Date.
|
|
129
|
+
|
|
130
|
+
When we need to keep the timezone information, we create a new field directly in the SDK.
|
|
131
|
+
As this field does not exist in the specification, it will not be part of the base model but of the core model instead.
|
|
132
|
+
|
|
133
|
+
Simple example:
|
|
134
|
+
```yaml
|
|
135
|
+
Flight:
|
|
136
|
+
type: "object"
|
|
137
|
+
required:
|
|
138
|
+
- departureDateTime
|
|
139
|
+
properties:
|
|
140
|
+
departureDateTime:
|
|
141
|
+
type: string
|
|
142
|
+
format: date-time
|
|
143
|
+
```
|
|
144
|
+
Base model generated
|
|
145
|
+
```typescript
|
|
146
|
+
// flight.ts generated in base models
|
|
147
|
+
export interface Flight {
|
|
148
|
+
/** @see utils.DateTime */
|
|
149
|
+
departureDateTime: utils.DateTime;
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
You need to create a core model to store the timezone information (src/models/core/flight.ts):
|
|
153
|
+
```typescript
|
|
154
|
+
import type { IgnoreEnum } from '@ama-sdk/core';
|
|
155
|
+
import type { Flight } from '../../base/flight/flight';
|
|
156
|
+
export type FlightStopCoreIfy<T extends IgnoreEnum<Flight>> = T & {
|
|
157
|
+
/** Departure date time of the flight considering timezone */
|
|
158
|
+
departureDateTimeConsideringTimezone?: Date;
|
|
159
|
+
};
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
And an associated reviver (src/models/core/flight.reviver.ts):
|
|
163
|
+
```typescript
|
|
164
|
+
import type { Flight } from '../../base/flight/flight';
|
|
165
|
+
import type { reviveFlight } from '../../base/flight/flight.reviver';
|
|
166
|
+
import type { FlightCoreIfy } from './flight';
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @param baseRevive
|
|
170
|
+
*/
|
|
171
|
+
export function reviveFlightFactory<R extends typeof reviveFlight>(baseRevive: R) {
|
|
172
|
+
const reviver = <T extends Flight = Flight>(data: any, dictionaries?: any) => {
|
|
173
|
+
const originalData: any = {...data};
|
|
174
|
+
const revivedData = baseRevive<FlightCoreIfy<T>>(data, dictionaries);
|
|
175
|
+
if (!revivedData) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
revivedData.departureDateTimeConsideringTimezone = originalData.departureDateTimeConsideringTimezone && new Date(originalData.departureDateTimeConsideringTimezone)
|
|
179
|
+
|| originalData.departureDateTime && new Date(originalData.departureDateTime);
|
|
180
|
+
return revivedData;
|
|
181
|
+
};
|
|
182
|
+
return reviver;
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
And export it here (src/models/core/flight/index.ts):
|
|
187
|
+
```typescript
|
|
188
|
+
export * from './flight';
|
|
189
|
+
export * from './flight.reviver';
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
And here (src/models/core/index.ts):
|
|
193
|
+
```typescript
|
|
194
|
+
export * from './flight/index';
|
|
195
|
+
```
|
|
113
196
|
|
|
114
|
-
|
|
197
|
+
You can now use departureDateTimeConsideringTimezone to access the timezone information.
|
|
198
|
+
See [utils.Date](https://github.com/AmadeusITGroup/otter/blob/main/packages/%40ama-sdk/core/src/fwk/date.ts) for more information.
|
|
115
199
|
|
|
116
|
-
###
|
|
200
|
+
### How to keep the timezone (prevent Date replacement with utils.Date)
|
|
117
201
|
|
|
118
202
|
In order to add the timezone to your timestamp property you can add the x-date-timezone extension in your yaml, for example:
|
|
119
203
|
|