fable 3.0.86 → 3.0.87
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/debug/Harness.js +8 -10
- package/package.json +2 -2
- package/retold-harness/bookstore-serve-api.js +2 -2
- package/source/Fable.js +187 -50
- package/source/services/Fable-Service-Anticipate.js +1 -1
- package/source/services/Fable-Service-DataGeneration.js +1 -1
- package/source/services/Fable-Service-EnvironmentData-Web.js +1 -1
- package/source/services/Fable-Service-EnvironmentData.js +1 -1
- package/source/services/Fable-Service-FilePersistence-Web.js +2 -1
- package/source/services/Fable-Service-FilePersistence.js +25 -7
- package/source/services/Fable-Service-MetaTemplate.js +1 -1
- package/source/services/Fable-Service-Operation-DefaultSettings.js +4 -6
- package/source/services/Fable-Service-Operation.js +97 -2
- package/source/services/Fable-Service-RestClient.js +1 -1
- package/source/services/Fable-Service-Template.js +1 -1
- package/source/services/Fable-Service-Utility.js +3 -3
- package/test/Anticipate_tests.js +2 -2
- package/test/CSVParser_tests.js +1 -1
- package/test/Cache_tests.js +1 -1
- package/test/DataGeneration_tests.js +7 -7
- package/test/DateManipulation_tests.js +1 -1
- package/test/FableOperation_tests.js +33 -4
- package/test/FableServiceManager_tests.js +51 -51
- package/test/FilePersistence_tests.js +9 -9
- package/test/Manifest_tests.js +1 -1
- package/test/MetaTemplating_tests.js +1 -1
- package/test/RestClient_test.js +6 -6
- package/dist/fable.compatible.js +0 -3353
- package/dist/fable.compatible.min.js +0 -12
- package/dist/fable.compatible.min.js.map +0 -1
- package/dist/fable.js +0 -3353
- package/dist/fable.min.js +0 -12
- package/dist/fable.min.js.map +0 -1
- package/source/Fable-ServiceManager.js +0 -164
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fable Application Services Management
|
|
3
|
-
* @author <steven@velozo.com>
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const libFableServiceBase = require('fable-serviceproviderbase');
|
|
7
|
-
|
|
8
|
-
class FableService extends libFableServiceBase.CoreServiceProviderBase
|
|
9
|
-
{
|
|
10
|
-
constructor(pSettings, pServiceHash)
|
|
11
|
-
{
|
|
12
|
-
super(pSettings, pServiceHash);
|
|
13
|
-
|
|
14
|
-
this.serviceType = 'ServiceManager';
|
|
15
|
-
|
|
16
|
-
this.serviceTypes = [];
|
|
17
|
-
|
|
18
|
-
// A map of instantiated services
|
|
19
|
-
this.servicesMap = {};
|
|
20
|
-
|
|
21
|
-
// A map of the default instantiated service by type
|
|
22
|
-
this.services = {};
|
|
23
|
-
|
|
24
|
-
// A map of class constructors for services
|
|
25
|
-
this.serviceClasses = {};
|
|
26
|
-
|
|
27
|
-
// If we need extra service initialization capabilities
|
|
28
|
-
this.extraServiceInitialization = false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
addServiceType(pServiceType, pServiceClass)
|
|
32
|
-
{
|
|
33
|
-
if (this.servicesMap.hasOwnProperty(pServiceType))
|
|
34
|
-
{
|
|
35
|
-
// TODO: Check if any services are running?
|
|
36
|
-
this.fable.log.warn(`Adding a service type [${pServiceType}] that already exists.`);
|
|
37
|
-
}
|
|
38
|
-
else
|
|
39
|
-
{
|
|
40
|
-
// Add the container for instantiated services to go in
|
|
41
|
-
this.servicesMap[pServiceType] = {};
|
|
42
|
-
|
|
43
|
-
// Add the type to the list of types
|
|
44
|
-
this.serviceTypes.push(pServiceType);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Using the static member of the class is a much more reliable way to check if it is a service class than instanceof
|
|
48
|
-
if ((typeof(pServiceClass) == 'function') && (pServiceClass.isFableService))
|
|
49
|
-
{
|
|
50
|
-
// Add the class to the list of classes
|
|
51
|
-
this.serviceClasses[pServiceType] = pServiceClass;
|
|
52
|
-
}
|
|
53
|
-
else
|
|
54
|
-
{
|
|
55
|
-
// Add the base class to the list of classes
|
|
56
|
-
this.fable.log.error(`Attempted to add service type [${pServiceType}] with an invalid class. Using base service class, which will not crash but won't provide meaningful services.`);
|
|
57
|
-
this.serviceClasses[pServiceType] = libFableServiceBase;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// This is for the services that are meant to run mostly single-instance so need a default at initialization
|
|
62
|
-
addAndInstantiateServiceType(pServiceType, pServiceClass)
|
|
63
|
-
{
|
|
64
|
-
this.addServiceType(pServiceType, pServiceClass);
|
|
65
|
-
return this.instantiateServiceProvider(pServiceType, {}, `${pServiceType}-Default`);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Some services expect to be overloaded / customized class.
|
|
69
|
-
instantiateServiceProviderFromPrototype(pServiceType, pOptions, pCustomServiceHash, pServicePrototype)
|
|
70
|
-
{
|
|
71
|
-
// Instantiate the service
|
|
72
|
-
let tmpService = new pServicePrototype(this.fable, pOptions, pCustomServiceHash);
|
|
73
|
-
|
|
74
|
-
if (this.extraServiceInitialization)
|
|
75
|
-
{
|
|
76
|
-
tmpService = this.extraServiceInitialization(tmpService);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Add the service to the service map
|
|
80
|
-
this.servicesMap[pServiceType][tmpService.Hash] = tmpService;
|
|
81
|
-
|
|
82
|
-
// If this is the first service of this type, make it the default
|
|
83
|
-
if (!this.services.hasOwnProperty(pServiceType))
|
|
84
|
-
{
|
|
85
|
-
this.setDefaultServiceInstantiation(pServiceType, tmpService.Hash)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return tmpService;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
instantiateServiceProvider(pServiceType, pOptions, pCustomServiceHash)
|
|
93
|
-
{
|
|
94
|
-
// Instantiate the service
|
|
95
|
-
let tmpService = this.instantiateServiceProviderWithoutRegistration(pServiceType, pOptions, pCustomServiceHash);
|
|
96
|
-
|
|
97
|
-
// Add the service to the service map
|
|
98
|
-
this.servicesMap[pServiceType][tmpService.Hash] = tmpService;
|
|
99
|
-
|
|
100
|
-
// If this is the first service of this type, make it the default
|
|
101
|
-
if (!this.services.hasOwnProperty(pServiceType))
|
|
102
|
-
{
|
|
103
|
-
this.setDefaultServiceInstantiation(pServiceType, tmpService.Hash)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return tmpService;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Create a service provider but don't register it to live forever in fable.services
|
|
110
|
-
instantiateServiceProviderWithoutRegistration(pServiceType, pOptions, pCustomServiceHash)
|
|
111
|
-
{
|
|
112
|
-
// Instantiate the service
|
|
113
|
-
let tmpService = new this.serviceClasses[pServiceType](this.fable, pOptions, pCustomServiceHash);
|
|
114
|
-
if (this.extraServiceInitialization)
|
|
115
|
-
{
|
|
116
|
-
tmpService = this.extraServiceInitialization(tmpService);
|
|
117
|
-
}
|
|
118
|
-
return tmpService;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Connect an initialized service provider that came before Fable was initialized
|
|
122
|
-
connectPreinitServiceProviderInstance(pServiceInstance)
|
|
123
|
-
{
|
|
124
|
-
let tmpServiceType = pServiceInstance.serviceType;
|
|
125
|
-
let tmpServiceHash = pServiceInstance.Hash;
|
|
126
|
-
|
|
127
|
-
// The service should already be instantiated, so just connect it to fable
|
|
128
|
-
pServiceInstance.connectFable(this.fable);
|
|
129
|
-
|
|
130
|
-
if (!this.servicesMap.hasOwnProperty(tmpServiceType))
|
|
131
|
-
{
|
|
132
|
-
// If the core service hasn't registered itself yet, create the service container for it.
|
|
133
|
-
// This means you couldn't register another with this type unless it was later registered with a constructor class.
|
|
134
|
-
this.servicesMap[tmpServiceType] = {};
|
|
135
|
-
}
|
|
136
|
-
// Add the service to the service map
|
|
137
|
-
this.servicesMap[tmpServiceType][tmpServiceHash] = pServiceInstance;
|
|
138
|
-
|
|
139
|
-
// If this is the first service of this type, make it the default
|
|
140
|
-
if (!this.services.hasOwnProperty(tmpServiceType))
|
|
141
|
-
{
|
|
142
|
-
this.setDefaultServiceInstantiation(tmpServiceType, tmpServiceHash)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return pServiceInstance;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
setDefaultServiceInstantiation(pServiceType, pServiceHash)
|
|
149
|
-
{
|
|
150
|
-
if (this.servicesMap[pServiceType].hasOwnProperty(pServiceHash))
|
|
151
|
-
{
|
|
152
|
-
this.fable[pServiceType] = this.servicesMap[pServiceType][pServiceHash];
|
|
153
|
-
this.services[pServiceType] = this.servicesMap[pServiceType][pServiceHash];
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
module.exports = FableService;
|
|
162
|
-
|
|
163
|
-
module.exports.ServiceProviderBase = libFableServiceBase;
|
|
164
|
-
module.exports.CoreServiceProviderBase = libFableServiceBase.CoreServiceProviderBase;
|