@inditextech/weave-types 0.27.3 → 0.28.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/README.md +18 -249
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,279 +4,48 @@ SPDX-FileCopyrightText: 2025 2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.
|
|
|
4
4
|
SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
-->
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
[](https://github.com/prettier/prettier)
|
|
7
|
+
# Weave.js / Types
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
This package generates the `@inditextech/weave-types` package, where all (or most of) Weave Types and constants are defined.
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
## Setup
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
This project requires NodeJS (version 8 or later) and NPM.
|
|
17
|
-
[Node](http://nodejs.org/) and [NPM](https://npmjs.org/) are really easy to install.
|
|
18
|
-
To make sure you have them available on your machine,
|
|
19
|
-
try running the following command.
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
$ npm -v && node -v
|
|
23
|
-
6.4.1
|
|
24
|
-
v8.16.0
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Table of contents
|
|
28
|
-
|
|
29
|
-
- [Project Name](#project-name)
|
|
30
|
-
- [Prerequisites](#prerequisites)
|
|
31
|
-
- [Table of contents](#table-of-contents)
|
|
32
|
-
- [Getting Started](#getting-started)
|
|
33
|
-
- [Installation](#installation)
|
|
34
|
-
- [Usage](#usage)
|
|
35
|
-
- [Serving the app](#serving-the-app)
|
|
36
|
-
- [Running the tests](#running-the-tests)
|
|
37
|
-
- [Building a distribution version](#building-a-distribution-version)
|
|
38
|
-
- [Serving the distribution version](#serving-the-distribution-version)
|
|
39
|
-
- [API](#api)
|
|
40
|
-
- [useBasicFetch](#usebasicfetch)
|
|
41
|
-
- [Options](#options)
|
|
42
|
-
- [fetchData](#fetchdata)
|
|
43
|
-
- [Contributing](#contributing)
|
|
44
|
-
- [Credits](#credits)
|
|
45
|
-
- [Built With](#built-with)
|
|
46
|
-
- [Versioning](#versioning)
|
|
47
|
-
- [Authors](#authors)
|
|
48
|
-
- [License](#license)
|
|
49
|
-
|
|
50
|
-
## Getting Started
|
|
51
|
-
|
|
52
|
-
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
|
|
53
|
-
|
|
54
|
-
## Installation
|
|
55
|
-
|
|
56
|
-
**BEFORE YOU INSTALL:** please read the [prerequisites](#prerequisites)
|
|
57
|
-
|
|
58
|
-
Start with cloning this repo on your local machine:
|
|
59
|
-
|
|
60
|
-
```sh
|
|
61
|
-
$ git clone https://github.com/ORG/PROJECT.git
|
|
62
|
-
$ cd PROJECT
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
To install and set up the library, run:
|
|
66
|
-
|
|
67
|
-
```sh
|
|
68
|
-
$ npm install -S myLib
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Or if you prefer using Yarn:
|
|
13
|
+
This is a monorepo, to install this package dependencies, just setup the monorepo, this can be done by locating on the `/code` project and execute the following command.
|
|
72
14
|
|
|
73
15
|
```sh
|
|
74
|
-
$
|
|
16
|
+
$ npm install
|
|
75
17
|
```
|
|
76
18
|
|
|
77
19
|
## Usage
|
|
78
20
|
|
|
79
|
-
|
|
21
|
+
This is a monorepo, this commands need to be from the `/code` folder of the repo.
|
|
80
22
|
|
|
81
|
-
|
|
82
|
-
$ npm start
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Running the tests
|
|
23
|
+
### Build the package
|
|
86
24
|
|
|
87
25
|
```sh
|
|
88
|
-
$ npm
|
|
26
|
+
$ npm run build --workspace=@inditextech/weave-types
|
|
89
27
|
```
|
|
90
28
|
|
|
91
|
-
###
|
|
29
|
+
### Link the package
|
|
92
30
|
|
|
93
31
|
```sh
|
|
94
|
-
$ npm run
|
|
32
|
+
$ npm run link --workspace=@inditextech/weave-types
|
|
95
33
|
```
|
|
96
34
|
|
|
97
|
-
|
|
98
|
-
inside your local `dist/` folder
|
|
99
|
-
|
|
100
|
-
### Serving the distribution version
|
|
35
|
+
### Lint the package
|
|
101
36
|
|
|
102
37
|
```sh
|
|
103
|
-
$ npm run
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
This will use `lite-server` for servign your already
|
|
107
|
-
generated distribution version of the project.
|
|
108
|
-
|
|
109
|
-
_Note_ this requires
|
|
110
|
-
[Building a distribution version](#building-a-distribution-version) first.
|
|
111
|
-
|
|
112
|
-
## API
|
|
113
|
-
|
|
114
|
-
### useBasicFetch
|
|
115
|
-
|
|
116
|
-
```js
|
|
117
|
-
useBasicFetch(((url: string) = ''), ((delay: number) = 0));
|
|
38
|
+
$ npm run lint --workspace=@inditextech/weave-types
|
|
118
39
|
```
|
|
119
40
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
#### Options
|
|
123
|
-
|
|
124
|
-
`url`
|
|
125
|
-
|
|
126
|
-
| Type | Default value |
|
|
127
|
-
| ------ | ------------- |
|
|
128
|
-
| string | '' |
|
|
129
|
-
|
|
130
|
-
If present, the request will be performed as soon as the component is mounted
|
|
131
|
-
|
|
132
|
-
Example:
|
|
133
|
-
|
|
134
|
-
```tsx
|
|
135
|
-
const MyComponent: React.FC = () => {
|
|
136
|
-
const { data, error, loading } = useBasicFetch(
|
|
137
|
-
'https://api.icndb.com/jokes/random'
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
if (error) {
|
|
141
|
-
return <p>Error</p>;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (loading) {
|
|
145
|
-
return <p>Loading...</p>;
|
|
146
|
-
}
|
|
41
|
+
### Test the package
|
|
147
42
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
<h2>Chuck Norris Joke of the day</h2>
|
|
151
|
-
{data && data.value && <p>{data.value.joke}</p>}
|
|
152
|
-
</div>
|
|
153
|
-
);
|
|
154
|
-
};
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
`delay`
|
|
158
|
-
|
|
159
|
-
| Type | Default value | Description |
|
|
160
|
-
| ------ | ------------- | -------------------- |
|
|
161
|
-
| number | 0 | Time in milliseconds |
|
|
162
|
-
|
|
163
|
-
If present, the request will be delayed by the given amount of time
|
|
164
|
-
|
|
165
|
-
Example:
|
|
166
|
-
|
|
167
|
-
```tsx
|
|
168
|
-
type Joke = {
|
|
169
|
-
value: {
|
|
170
|
-
id: number;
|
|
171
|
-
joke: string;
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const MyComponent: React.FC = () => {
|
|
176
|
-
const { data, error, loading } = useBasicFetch<Joke>(
|
|
177
|
-
'https://api.icndb.com/jokes/random',
|
|
178
|
-
2000
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
if (error) {
|
|
182
|
-
return <p>Error</p>;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (loading) {
|
|
186
|
-
return <p>Loading...</p>;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return (
|
|
190
|
-
<div className="App">
|
|
191
|
-
<h2>Chuck Norris Joke of the day</h2>
|
|
192
|
-
{data && data.value && <p>{data.value.joke}</p>}
|
|
193
|
-
</div>
|
|
194
|
-
);
|
|
195
|
-
};
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### fetchData
|
|
199
|
-
|
|
200
|
-
```js
|
|
201
|
-
fetchData(url: string)
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
Perform an asynchronous http request against a given url
|
|
205
|
-
|
|
206
|
-
```tsx
|
|
207
|
-
type Joke = {
|
|
208
|
-
value: {
|
|
209
|
-
id: number;
|
|
210
|
-
joke: string;
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
const ChuckNorrisJokes: React.FC = () => {
|
|
215
|
-
const { data, fetchData, error, loading } = useBasicFetch<Joke>();
|
|
216
|
-
const [jokeId, setJokeId] = useState(1);
|
|
217
|
-
|
|
218
|
-
useEffect(() => {
|
|
219
|
-
fetchData(`https://api.icndb.com/jokes/${jokeId}`);
|
|
220
|
-
}, [jokeId, fetchData]);
|
|
221
|
-
|
|
222
|
-
const handleNext = () => setJokeId(jokeId + 1);
|
|
223
|
-
|
|
224
|
-
if (error) {
|
|
225
|
-
return <p>Error</p>;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const jokeData = data && data.value;
|
|
229
|
-
|
|
230
|
-
return (
|
|
231
|
-
<div className="Comments">
|
|
232
|
-
{loading && <p>Loading...</p>}
|
|
233
|
-
{!loading && jokeData && (
|
|
234
|
-
<div>
|
|
235
|
-
<p>Joke ID: {jokeData.id}</p>
|
|
236
|
-
<p>{jokeData.joke}</p>
|
|
237
|
-
</div>
|
|
238
|
-
)}
|
|
239
|
-
{!loading && jokeData && !jokeData.joke && <p>{jokeData}</p>}
|
|
240
|
-
<button disabled={loading} onClick={handleNext}>
|
|
241
|
-
Next Joke
|
|
242
|
-
</button>
|
|
243
|
-
</div>
|
|
244
|
-
);
|
|
245
|
-
};
|
|
43
|
+
```sh
|
|
44
|
+
$ npm run test --workspace=@inditextech/weave-types
|
|
246
45
|
```
|
|
247
46
|
|
|
248
|
-
## Contributing
|
|
249
|
-
|
|
250
|
-
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
|
|
251
|
-
|
|
252
|
-
1. Fork it!
|
|
253
|
-
2. Create your feature branch: `git checkout -b my-new-feature`
|
|
254
|
-
3. Add your changes: `git add .`
|
|
255
|
-
4. Commit your changes: `git commit -am 'Add some feature'`
|
|
256
|
-
5. Push to the branch: `git push origin my-new-feature`
|
|
257
|
-
6. Submit a pull request :sunglasses:
|
|
258
|
-
|
|
259
|
-
## Credits
|
|
260
|
-
|
|
261
|
-
TODO: Write credits
|
|
262
|
-
|
|
263
|
-
## Built With
|
|
264
|
-
|
|
265
|
-
- Dropwizard - Bla bla bla
|
|
266
|
-
- Maven - Maybe
|
|
267
|
-
- Atom - ergaerga
|
|
268
|
-
- Love
|
|
269
|
-
|
|
270
|
-
## Versioning
|
|
271
|
-
|
|
272
|
-
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
|
|
273
|
-
|
|
274
|
-
## Authors
|
|
275
|
-
|
|
276
|
-
- **John Doe** - _Initial work_ - [JohnDoe](https://github.com/JohnDoe)
|
|
277
|
-
|
|
278
|
-
See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.
|
|
279
|
-
|
|
280
47
|
## License
|
|
281
48
|
|
|
282
|
-
[
|
|
49
|
+
This project is licensed under the terms of the [Apache-2.0](LICENSE) license.
|
|
50
|
+
|
|
51
|
+
© 2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.)
|