fable 3.1.71 → 3.1.73
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/docs/README.md +30 -6
- package/docs/_brand.json +18 -0
- package/docs/_playground.json +10 -0
- package/docs/_sidebar.md +2 -0
- package/docs/_version.json +3 -3
- package/docs/architecture.md +201 -39
- package/docs/index.html +6 -7
- package/docs/pict-docuserve.min.js +91 -0
- package/docs/pict-docuserve.min.js.map +1 -0
- package/docs/playground.md +38 -0
- package/docs/retold-catalog.json +1 -1
- package/docs/retold-keyword-index.json +8721 -8105
- package/docs/services/README.md +26 -9
- package/docs/services/anticipate.md +104 -40
- package/docs/services/csv-parser.md +63 -35
- package/docs/services/data-format.md +154 -49
- package/docs/services/data-generation.md +77 -16
- package/docs/services/dates.md +103 -36
- package/docs/services/environment-data.md +13 -2
- package/docs/services/expression-parser.md +280 -68
- package/docs/services/file-persistence.md +142 -150
- package/docs/services/logging.md +93 -37
- package/docs/services/logic.md +70 -22
- package/docs/services/manifest.md +114 -26
- package/docs/services/math.md +168 -63
- package/docs/services/meta-template.md +312 -158
- package/docs/services/object-cache.md +94 -11
- package/docs/services/operation.md +68 -6
- package/docs/services/progress-time.md +74 -13
- package/docs/services/progress-tracker-set.md +101 -3
- package/docs/services/rest-client.md +136 -104
- package/docs/services/settings-manager.md +133 -40
- package/docs/services/template.md +71 -22
- package/docs/services/utility.md +121 -29
- package/docs/services/uuid.md +58 -10
- package/package.json +4 -4
- package/source/services/Fable-Service-RestClient.js +204 -7
- package/test/RestClient_test.js +342 -0
- package/.claude/settings.local.json +0 -8
|
@@ -5,20 +5,26 @@ The Manifest service (powered by [manyfest](https://github.com/stevenvelozo/many
|
|
|
5
5
|
## Access
|
|
6
6
|
|
|
7
7
|
```javascript
|
|
8
|
+
const libFable = require('fable');
|
|
9
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
10
|
+
|
|
8
11
|
// On-demand service - instantiate when needed
|
|
9
|
-
const
|
|
12
|
+
const manifestService = fable.instantiateServiceProvider('Manifest');
|
|
13
|
+
console.log('manifestService:', typeof manifestService);
|
|
10
14
|
|
|
11
15
|
// Or use the factory method (creates unregistered instance)
|
|
12
|
-
const
|
|
16
|
+
const manifestEmpty = fable.newManyfest();
|
|
17
|
+
console.log('manifestEmpty:', typeof manifestEmpty);
|
|
13
18
|
|
|
14
19
|
// With definition
|
|
15
|
-
const
|
|
20
|
+
const manifestDefined = fable.newManyfest({
|
|
16
21
|
Scope: 'User',
|
|
17
22
|
Descriptors: {
|
|
18
|
-
'Name':
|
|
23
|
+
'Name': { Hash: 'name', Type: 'String' },
|
|
19
24
|
'Email': { Hash: 'email', Type: 'String' }
|
|
20
25
|
}
|
|
21
26
|
});
|
|
27
|
+
console.log('manifestDefined scope:', manifestDefined.scope);
|
|
22
28
|
```
|
|
23
29
|
|
|
24
30
|
## Core Concepts
|
|
@@ -28,6 +34,10 @@ const manifest = fable.newManyfest({
|
|
|
28
34
|
Navigate objects using dot-notation paths:
|
|
29
35
|
|
|
30
36
|
```javascript
|
|
37
|
+
const libFable = require('fable');
|
|
38
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
39
|
+
const manifest = fable.instantiateServiceProvider('Manifest');
|
|
40
|
+
|
|
31
41
|
const obj = {
|
|
32
42
|
user: {
|
|
33
43
|
profile: {
|
|
@@ -39,8 +49,8 @@ const obj = {
|
|
|
39
49
|
}
|
|
40
50
|
};
|
|
41
51
|
|
|
42
|
-
manifest.getValueByHash(obj, 'user.profile.name'); // 'John'
|
|
43
|
-
manifest.getValueByHash(obj, 'user.profile.contacts[0].value'); // 'john@example.com'
|
|
52
|
+
console.log(manifest.getValueByHash(obj, 'user.profile.name')); // 'John'
|
|
53
|
+
console.log(manifest.getValueByHash(obj, 'user.profile.contacts[0].value')); // 'john@example.com'
|
|
44
54
|
```
|
|
45
55
|
|
|
46
56
|
## Getting Values
|
|
@@ -48,26 +58,39 @@ manifest.getValueByHash(obj, 'user.profile.contacts[0].value'); // 'john@example
|
|
|
48
58
|
### getValueByHash
|
|
49
59
|
|
|
50
60
|
```javascript
|
|
61
|
+
const libFable = require('fable');
|
|
62
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
63
|
+
const manifest = fable.instantiateServiceProvider('Manifest');
|
|
64
|
+
|
|
51
65
|
const data = { a: { b: { c: 'value' } } };
|
|
52
66
|
|
|
53
|
-
manifest.getValueByHash(data, 'a.b.c'); // 'value'
|
|
54
|
-
manifest.getValueByHash(data, 'a.b'); // { c: 'value' }
|
|
55
|
-
manifest.getValueByHash(data, 'x.y.z'); // undefined
|
|
67
|
+
console.log(manifest.getValueByHash(data, 'a.b.c')); // 'value'
|
|
68
|
+
console.log(manifest.getValueByHash(data, 'a.b')); // { c: 'value' }
|
|
69
|
+
console.log(manifest.getValueByHash(data, 'x.y.z')); // undefined
|
|
56
70
|
```
|
|
57
71
|
|
|
58
72
|
### With Default Value
|
|
59
73
|
|
|
60
74
|
```javascript
|
|
61
|
-
|
|
75
|
+
const libFable = require('fable');
|
|
76
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
77
|
+
const manifest = fable.instantiateServiceProvider('Manifest');
|
|
78
|
+
|
|
79
|
+
const data = { a: 'present' };
|
|
80
|
+
console.log(manifest.getValueByHash(data, 'missing.path', 'default')); // 'default'
|
|
62
81
|
```
|
|
63
82
|
|
|
64
83
|
### Array Access
|
|
65
84
|
|
|
66
85
|
```javascript
|
|
86
|
+
const libFable = require('fable');
|
|
87
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
88
|
+
const manifest = fable.instantiateServiceProvider('Manifest');
|
|
89
|
+
|
|
67
90
|
const data = { items: ['a', 'b', 'c'] };
|
|
68
91
|
|
|
69
|
-
manifest.getValueByHash(data, 'items[0]'); // 'a'
|
|
70
|
-
manifest.getValueByHash(data, 'items[2]'); // 'c'
|
|
92
|
+
console.log(manifest.getValueByHash(data, 'items[0]')); // 'a'
|
|
93
|
+
console.log(manifest.getValueByHash(data, 'items[2]')); // 'c'
|
|
71
94
|
```
|
|
72
95
|
|
|
73
96
|
## Setting Values
|
|
@@ -75,30 +98,43 @@ manifest.getValueByHash(data, 'items[2]'); // 'c'
|
|
|
75
98
|
### setValueByHash
|
|
76
99
|
|
|
77
100
|
```javascript
|
|
101
|
+
const libFable = require('fable');
|
|
102
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
103
|
+
const manifest = fable.instantiateServiceProvider('Manifest');
|
|
104
|
+
|
|
78
105
|
const data = {};
|
|
79
106
|
|
|
80
107
|
manifest.setValueByHash(data, 'user.name', 'John');
|
|
81
|
-
|
|
108
|
+
console.log('After name set:', data);
|
|
82
109
|
|
|
83
110
|
manifest.setValueByHash(data, 'user.age', 30);
|
|
84
|
-
|
|
111
|
+
console.log('After age set:', data);
|
|
85
112
|
```
|
|
86
113
|
|
|
87
114
|
### Creating Nested Structures
|
|
88
115
|
|
|
89
116
|
```javascript
|
|
117
|
+
const libFable = require('fable');
|
|
118
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
119
|
+
const manifest = fable.instantiateServiceProvider('Manifest');
|
|
120
|
+
|
|
90
121
|
const data = {};
|
|
91
122
|
manifest.setValueByHash(data, 'deep.nested.path.value', 'hello');
|
|
123
|
+
console.log('data:', data);
|
|
92
124
|
// Creates: { deep: { nested: { path: { value: 'hello' } } } }
|
|
93
125
|
```
|
|
94
126
|
|
|
95
127
|
### Array Setting
|
|
96
128
|
|
|
97
129
|
```javascript
|
|
130
|
+
const libFable = require('fable');
|
|
131
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
132
|
+
const manifest = fable.instantiateServiceProvider('Manifest');
|
|
133
|
+
|
|
98
134
|
const data = { items: [] };
|
|
99
135
|
manifest.setValueByHash(data, 'items[0]', 'first');
|
|
100
136
|
manifest.setValueByHash(data, 'items[1]', 'second');
|
|
101
|
-
|
|
137
|
+
console.log('data.items:', data.items);
|
|
102
138
|
```
|
|
103
139
|
|
|
104
140
|
## Checking Existence
|
|
@@ -106,11 +142,15 @@ manifest.setValueByHash(data, 'items[1]', 'second');
|
|
|
106
142
|
### checkAddressExists
|
|
107
143
|
|
|
108
144
|
```javascript
|
|
145
|
+
const libFable = require('fable');
|
|
146
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
147
|
+
const manifest = fable.instantiateServiceProvider('Manifest');
|
|
148
|
+
|
|
109
149
|
const data = { a: { b: 'value' } };
|
|
110
150
|
|
|
111
|
-
manifest.checkAddressExists(data, 'a.b'); // true
|
|
112
|
-
manifest.checkAddressExists(data, 'a.c'); // false
|
|
113
|
-
manifest.checkAddressExists(data, 'x.y.z'); // false
|
|
151
|
+
console.log(manifest.checkAddressExists(data, 'a.b')); // true
|
|
152
|
+
console.log(manifest.checkAddressExists(data, 'a.c')); // false
|
|
153
|
+
console.log(manifest.checkAddressExists(data, 'x.y.z')); // false
|
|
114
154
|
```
|
|
115
155
|
|
|
116
156
|
## Manifest Definitions
|
|
@@ -118,6 +158,9 @@ manifest.checkAddressExists(data, 'x.y.z'); // false
|
|
|
118
158
|
Define schemas for structured data:
|
|
119
159
|
|
|
120
160
|
```javascript
|
|
161
|
+
const libFable = require('fable');
|
|
162
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
163
|
+
|
|
121
164
|
const userManifest = fable.newManyfest({
|
|
122
165
|
Scope: 'User',
|
|
123
166
|
Descriptors: {
|
|
@@ -142,18 +185,33 @@ const userManifest = fable.newManyfest({
|
|
|
142
185
|
}
|
|
143
186
|
}
|
|
144
187
|
});
|
|
188
|
+
|
|
189
|
+
console.log('userManifest descriptors:', Object.keys(userManifest.elementDescriptors));
|
|
145
190
|
```
|
|
146
191
|
|
|
147
192
|
### Using Descriptors
|
|
148
193
|
|
|
149
194
|
```javascript
|
|
195
|
+
const libFable = require('fable');
|
|
196
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
197
|
+
|
|
198
|
+
const userManifest = fable.newManyfest({
|
|
199
|
+
Scope: 'User',
|
|
200
|
+
Descriptors: {
|
|
201
|
+
'Full Name': { Hash: 'profile.fullName', Type: 'String', Default: 'Unknown' },
|
|
202
|
+
'Age': { Hash: 'profile.age', Type: 'Number', Default: 0 },
|
|
203
|
+
'Email': { Hash: 'contact.email', Type: 'String' },
|
|
204
|
+
'Active': { Hash: 'status.isActive', Type: 'Boolean', Default: true }
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
150
208
|
// Get all descriptor names
|
|
151
209
|
const names = userManifest.getDescriptorNames();
|
|
152
|
-
|
|
210
|
+
console.log('names:', names);
|
|
153
211
|
|
|
154
212
|
// Get descriptor by name
|
|
155
213
|
const emailDescriptor = userManifest.getDescriptor('Email');
|
|
156
|
-
|
|
214
|
+
console.log('emailDescriptor:', emailDescriptor);
|
|
157
215
|
```
|
|
158
216
|
|
|
159
217
|
## Boxed Properties
|
|
@@ -161,13 +219,17 @@ const emailDescriptor = userManifest.getDescriptor('Email');
|
|
|
161
219
|
Access properties with special characters using brackets:
|
|
162
220
|
|
|
163
221
|
```javascript
|
|
222
|
+
const libFable = require('fable');
|
|
223
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
224
|
+
const manifest = fable.instantiateServiceProvider('Manifest');
|
|
225
|
+
|
|
164
226
|
const data = {
|
|
165
227
|
'my-special-key': 'value1',
|
|
166
228
|
'another key': 'value2'
|
|
167
229
|
};
|
|
168
230
|
|
|
169
|
-
manifest.getValueByHash(data, '["my-special-key"]'); // 'value1'
|
|
170
|
-
manifest.getValueByHash(data, "['another key']"); // 'value2'
|
|
231
|
+
console.log(manifest.getValueByHash(data, '["my-special-key"]')); // 'value1'
|
|
232
|
+
console.log(manifest.getValueByHash(data, "['another key']")); // 'value2'
|
|
171
233
|
```
|
|
172
234
|
|
|
173
235
|
## Use Cases
|
|
@@ -175,6 +237,9 @@ manifest.getValueByHash(data, "['another key']"); // 'value2'
|
|
|
175
237
|
### Dynamic Form Handling
|
|
176
238
|
|
|
177
239
|
```javascript
|
|
240
|
+
const libFable = require('fable');
|
|
241
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
242
|
+
|
|
178
243
|
function updateFormData(formData, fieldPath, value) {
|
|
179
244
|
const manifest = fable.newManyfest();
|
|
180
245
|
manifest.setValueByHash(formData, fieldPath, value);
|
|
@@ -186,11 +251,20 @@ let form = {};
|
|
|
186
251
|
form = updateFormData(form, 'user.firstName', 'John');
|
|
187
252
|
form = updateFormData(form, 'user.lastName', 'Doe');
|
|
188
253
|
form = updateFormData(form, 'user.address.city', 'New York');
|
|
254
|
+
|
|
255
|
+
console.log('form:', form);
|
|
189
256
|
```
|
|
190
257
|
|
|
191
258
|
### Configuration Access
|
|
192
259
|
|
|
193
260
|
```javascript
|
|
261
|
+
const libFable = require('fable');
|
|
262
|
+
const fable = new libFable({
|
|
263
|
+
Product: 'ManifestDemo',
|
|
264
|
+
API: { timeout: 5000 },
|
|
265
|
+
Logging: { debug: true }
|
|
266
|
+
});
|
|
267
|
+
|
|
194
268
|
function getConfig(path, defaultValue) {
|
|
195
269
|
const manifest = fable.newManyfest();
|
|
196
270
|
return manifest.getValueByHash(fable.settings, path, defaultValue);
|
|
@@ -198,12 +272,16 @@ function getConfig(path, defaultValue) {
|
|
|
198
272
|
|
|
199
273
|
// Usage
|
|
200
274
|
const timeout = getConfig('API.timeout', 30000);
|
|
201
|
-
const debug
|
|
275
|
+
const debug = getConfig('Logging.debug', false);
|
|
276
|
+
console.log('timeout:', timeout, 'debug:', debug);
|
|
202
277
|
```
|
|
203
278
|
|
|
204
279
|
### Data Transformation
|
|
205
280
|
|
|
206
281
|
```javascript
|
|
282
|
+
const libFable = require('fable');
|
|
283
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
284
|
+
|
|
207
285
|
function transformData(source, mappings) {
|
|
208
286
|
const manifest = fable.newManyfest();
|
|
209
287
|
const result = {};
|
|
@@ -219,16 +297,24 @@ function transformData(source, mappings) {
|
|
|
219
297
|
}
|
|
220
298
|
|
|
221
299
|
// Usage
|
|
300
|
+
const apiResponse = {
|
|
301
|
+
data: { user: { name: 'Alice', contact: { email: 'alice@example.com' } } },
|
|
302
|
+
metadata: { created: '2024-01-01' }
|
|
303
|
+
};
|
|
222
304
|
const transformed = transformData(apiResponse, {
|
|
223
|
-
'userName':
|
|
305
|
+
'userName': 'data.user.name',
|
|
224
306
|
'userEmail': 'data.user.contact.email',
|
|
225
307
|
'createdAt': 'metadata.created'
|
|
226
308
|
});
|
|
309
|
+
console.log('transformed:', transformed);
|
|
227
310
|
```
|
|
228
311
|
|
|
229
312
|
### Safe Property Access
|
|
230
313
|
|
|
231
314
|
```javascript
|
|
315
|
+
const libFable = require('fable');
|
|
316
|
+
const fable = new libFable({ Product: 'ManifestDemo', ProductVersion: '1.0.0' });
|
|
317
|
+
|
|
232
318
|
function safeGet(obj, path, defaultValue = null) {
|
|
233
319
|
const manifest = fable.newManyfest();
|
|
234
320
|
const value = manifest.getValueByHash(obj, path);
|
|
@@ -236,8 +322,10 @@ function safeGet(obj, path, defaultValue = null) {
|
|
|
236
322
|
}
|
|
237
323
|
|
|
238
324
|
// Safely access deeply nested properties
|
|
239
|
-
const
|
|
240
|
-
const
|
|
325
|
+
const user = { address: { city: 'NYC' }, contacts: [] };
|
|
326
|
+
const city = safeGet(user, 'address.city', 'Unknown');
|
|
327
|
+
const phone = safeGet(user, 'contacts[0].phone', 'N/A');
|
|
328
|
+
console.log('city:', city, 'phone:', phone);
|
|
241
329
|
```
|
|
242
330
|
|
|
243
331
|
## Integration with Other Services
|