UNPKG

34.6 kBMarkdownView Raw
1# README #
2
3# sri-client #
4
5* this is the project with all kind of utilities for clients which are using A [sri4node][sri4node-project] API.
6* version 1.1.2
7
8## sri-clients ##
9The project contains two client modules with all kind of functions to do API requests according to [SRI (Standard ROA Interface)][sri-documentation]:
10
11* an Angular 1 module
12* a node module
13
14They both have the same generic interface
15
16### generic interface ###
17
18* **get(href, parameters, options):** http get of the href with the given parameters. Returns a promise with the exact result from the api.
19* **getList(href, parameters, options):** http get of the href with the given parameters where href is suposed to be a list resource.
20Returns a promise with the array of the expanded results that match the query (so not an object with an href and $$expanded, but the object that is $$expanded.
21The list of results is limited to only one API call so the lenght will be maximum the limit. The resulting array will also have properties count and next from the original $$meta section.
22* **getAll(href, parameters, options):** http get of the href with the given parameters where href is suposed to be a list resource.
23Returns a promise with the array of the expanded results that match the query (so not an object with an href and $$expanded, but the object that is $$expanded.
24The list of results is all the results that match the query, because the next links are requested as well and concatenated to the result.
25The resulting array will also have properties count and next from the original $$meta section.
26* **put(href, payload, options):** http put to href with the given payload.
27* **updateResouce(resource, options):** http put to resource.$$meta.permalink with resource as payload. Compact function to do an update of an existing resource.
28* **post(href, payload, options):** http post to href with the given payload.
29* **delete(href, options):** http delete to href.
30* **getAllHrefs(hrefs, parameters, options):** returns an array of all objects for hrefs, a given array with permalinks.
31* **getAllHrefs(hrefs, batchHref, parameters, options):** returns an array of all objects for hrefs, a given array with permalinks.
32All these parameters need to be of the same resource type! You can provide expansion (or other) parameters with parameters.
33It will get all these permalinks in the most efficient way if an href to the corresponding batch url is provided.
34If the batch url is null it will get them in individual request in groups of 100 (can be overwritten with options.groupBy) permalinks in order to not make the request url too long.
35* **getAllReferencesTo(baseHref, params, referencingParameterName, hrefsArray, options):** Same as getAll but you can add a referencingParameterName and an array of hrefs.
36It will add referencingParameterName as a parameter and add the hrefsArray as a comma separated string,
37but it will only request them in groups of 100 (can be overwritten with options.groupBy) to make sure the request url does not get too long.
38If the name of the resource is too long you might have to use options.groupBy to decrease the number of hrefs it groups in one request
39
40All these methods return a promise. If the response status >= 400, the result will return an error object with:
41
42* **status:** the http status of the response, null if there was no response.
43* **body:** the body of the response if it was present.
44* **getResponseHeader(headerName):** method that returns the value of the given headerName of the response.
45
46If the result of put, updateResouce or post was < 300 the promise returns an object with:
47
48* **getResponseHeader(headerName):** method that returns the value of the given headerName of the response.
49
50All methods have an **options** object that you can pass on as a parameter. You can specify the following properties:
51
52* **common**
53 * **baseUrl:** sends the http request to this baseUrl instead of the default baseUrl that is set in the initialisation of the configuration.
54 * **headers:** An object with headers that are added on the http request. f.e.: {'foo': 'bar'} adds a header foo with value bar.
55 * **caching:** An object with properties timeout (in seconds) which overwrites the default timeout (you don't need to set up default caching, you can just start caching several requests). The resource will be get from the cache if it it is not older than the timeout in seconds.
56 * **inBatch:** Specify the href where the batch needs to be send to. This is for GET methods (getAll, getList, etc.) and wraps the regular request into a batch request. This can be usefull when their is a potential of an request url that becomes too long.
57 * **expand:** array with property paths that you want to expand client side. You can expand as deep as you want and don't need to add $$expanded to the path. See the examples.
58 You can also replace a property path string with an object to pass on more advanced options. The object contains the following proerties:
59 * property: [required] the property path.
60 * required: default is true. If true an error will be thrown if a property in the property path can not be found. This is to help the user detect typo's.
61 If required is false, no error will be thrown and expansion will be ignored for objects that do not have a property in the property path. If the property path contains properties that are not required you need to set this proeprty to false.
62 * include: you can include resources within the expanded resources. Works the same as the include property on the root of the options.
63 * caching: overwrite the caching options from this point onwards. For example when you can not cache the resource you are getting but the resources that are expanded can be cached for a very long time.
64 Example: api.getAll('/responsibilities/relations', {to: #{an href to a responsibility}}, {expand: [from.organisationalunit]}) expands in two steps first all froms in the resultset, and in a second step all organisationalunits of those froms.
65 * **include:** array of objects with configuration to include a property of the/all resrouce(s) (in the resultset). The configuration can contain the following properties:
66 * alias: [required] An {{alias}} property will be added to the resource or every resource in the resultset if it is a list. It is recommended to add a $$ prefix in front of them so the client will not send this back to the server on PUT.
67 * href: [required] The href on which the included resources can be found
68 * reference: an object with the following properties:
69 * property: [required] The property name that references $$meta.permalink of the resource for which you are including resources
70 * parameterName: This is the parameter name on the href to reference the $$meta.permalink of the resource you are including resources.
71 If not added the property name will be taken as parameter name because in many cases this is the same. There is also a short notation where the value of reference is just the property name as a string instead of an object.
72 * filters: filter on the resources you are including (for example include only external identifiers of type INSTITUTION_NUMBER when you are including external identifiers in an organisational unit)
73 * expanded: true is default so you don't need to add this property if true. If false all results will be unexpanded and you will get only the hrefs
74 * singleton: false is default so you don't need to add this property if false. The value of '$${{alias}}' will be an object (the first object in the resultset) instead of an array. It will be null if there are no results.
75 * expand: client side expansion of properties within the included resources. Works the same as the expand property on the root of the options.
76 * include: include resources within the included resources. This is just recursive and works the same as the include property on the root of the options.
77 * **limit:** return a limited number of results for getList, the limit can also be higher than the maximum limit that the server allows. =TODO
78 * **raw:** boolean that can be used for getList and getAll. If set to true the array of results will contain the raw result of the body.results, so the items will be an object with an href and a $$expanded object.
79 * **asMap:** boolean that can be used for getAllHrefs. If set to true an object with be returned which contains all the hrefs as keys and the object to which it refers as value.
80* **fetch-sri-client**
81 * **cancel**: A promise that will cancel the request when resolved
82 * **credentials**: omit (default) || include (adds the cookies to the request)
83 * **fullResponse**: the response will be an object with properties body and headers
84* **ng-sri-client specific**
85 * **raw** default is false. The response will be parsed. If raw is true the response will not be parsed.
86 * **cancelPromise:** A promise that will cancel the request, if it gets resolved.
87 * **pending:** boolean that will be set to true by every method when the request starts and set to false once the result is fetched.
88* **node-sri-client specific**
89 * **timeout:** The number of miliseconds to wait before the request times out. (default timeout is 10 seconds for a GET, 30 seconds for a sendPayload and 120 seconds for a batch)
90 * **maxAttempts:** The number of times the request will be attempted. The default is 3 times (so 2 retries).
91 * **retryStrategy:** You can pass on your own strategy on when to retry a request. The default is to retry on network errors (ECONNRESET, ENOTFOUND, ESOCKETTIMEDOUT, ETIMEDOUT, ECONNREFUSED, EHOSTUNREACH, EPIPE, EAI_AGAIN) or on http errors with status 5xx. See the documentation of [requestretry][npm-requestretry-strategy] to see how to define your own delay strategy.
92 * **retryDelay:** The number of miliseconds of delay untill another attempt is made for this same request. The default is 5000 miliseconds.
93 * **delayStrategy:** You can pass on your own strategy on how to delay a request. The default is to have a fixed time (options.retryDelay) in between the requests. See the documentation of [requestretry][npm-requestretry-delaystrategey] to see how to define your own delay strategy.
94 * **strip$$Properties:** strips the $$-properties from the payload. The default is true.
95 * **logging:** logs the response body if the status code >= 400 to the console for any value. Any value always logs errors. Otherwise you can add a string containing values: 'get','put','post','delete','caching','expand'.
96
97#### examples ####
98
99```javascript
100 const respsOfTeam = await sriClient.getAll('/responsibilities', {organisationalUnit: '/organisationalunits/eb745d58-b818-4569-a06e-68733fe2e5b3'}, {logging: 'debug'});
101 const personHrefs = respsOfTeam.map(resp => resp.person.href);
102 const persons = await vskoApi.getAllHrefs(personHrefs, '/persons/batch', undefined, {asMap: true});
103 // persons is a map with as key the href of a person and as value the resource of that person.
104
105 const externalIdentifierWithOrganisationalUnitExpanded = await sriClient.get(
106 '/organisationalunits/externalidentifiers',
107 {value: '032557'},
108 {
109 expand: [
110 'organisationalUnit.$$contactDetails.phone.organisationalUnit', // this is circular so not very usefull, but this shows you can expand as deep as you want to
111 'organisationalUnit.$$contactDetails.email'
112 ]
113 });
114
115 const organisationalUnitWithInstitutionNumberIncluded = await sriClient.get('/organisationalunits/a2c36c96-a3a4-11e3-ace8-005056872b95', undefined, {include: {
116 alias: '$$institutionNumber',
117 href: '/organisationalunits/externalidentifiers',
118 filters: {type: 'INSTITUTION_NUMBER'},
119 reference: 'organisationalUnit',
120 singleton: true
121 }});
122
123 const personWithResponsibilitiesIncluded = await sriClient.get('/persons/94417de5-840c-4df4-a10d-fe30683d99e1', undefined, {include: {
124 alias: '$$responsibilities',
125 href: '/responsibilities',
126 reference: {
127 property: 'person',
128 parameterName: 'personIn'
129 },
130 expand: ['organisationalUnit']
131 }});
132
133 // give all the responsibilies of an organisationalunit (this is the team)
134 // and expand the person (client side).
135 // Include for this person all his responsibilities
136 // and expand the organisationalunits of these responsibilities
137 sriClient.getAll('/responsibilies',
138 {
139 organisationalunit: '/organisationalunits/eb745d58-b818-4569-a06e-68733fe2e5b3',
140 expand: 'position' // expand position server side
141 },
142 {
143 expand: [{
144 property: 'person', // expand all person properties client side,
145 required: false,
146 include: [{
147 alias: '$$responsibilities', // A $$responsibilities property will be added to every resource in the resultset
148 href: '/responsibilities',
149 reference: {
150 property: 'person',
151 parameterName: 'personIn',
152 }
153 expand: ['organisationalUnit'], // client side expansion of properties within the included resources
154 }]
155 }]
156 }
157 );
158 // for each responsibility in the resultset, the expanded person will have an added property $$responsibilities,
159 // which is an array of all the responsibilities that reference this person.
160 // Within these last responsibilities the organisationalUnit will be expanded
161 ```
162
163
164### initialisation ###
165
166It is recommended to initialise the library with some default configuration which can have te following properties:
167
168* baseUrl: the default baseUrl for all the api calls.
169* logging: For every request logs the response body if the status code >= 400 to the console for any value. Any value always logs errors. Otherwise you can add a string containing values: 'get','put','post','delete','caching','expand'.
170* caching: object with properties
171 * timeout: default timeout in seconds that will be used for every call that does not specify it's own caching in the options (default is 0 = no caching)
172 * maxSize: maximum size of the cache in MB. When this size is reached the 25% of the hrefs that were not used for the longest time will be removed from the cache. (default is 10MB)
173 * initialisation: array of objects
174 * hrefs: array of hrefs that should be called
175 * timeout: optional timeout that these initial hrefs should be cached. If not mentioned the default timeout above will be taken.
176
177and the following properties are for the node-sri-client only:
178
179* username: username for basic authentication calls.
180* password: password for basic authentication calls.
181* headers: each request will have the headers specified added in the request header.
182* accessToken: an object with properties name and value. Each request will have a request header added with the given name and value. This is added to the headers if they are specified.
183
184#### fetch-sri-client ####
185
186This module uses the Fetch API.
187Here is an example how to use the module.
188
189```javascript
190const configuration = {
191 baseUrl: 'https://api.katholiekonderwijs.vlaanderen',
192 caching: {
193 timeout: 400,
194 initialise: [{
195 timeout: 10000,
196 hrefs: ['/commons/cities', '/commons/countries']
197 ]
198 }
199}
200
201const api = require('@kathondvla/sri-client/fetch-sri-client')(configuration)
202
203let secondarySchools = await api.get('/schools', {educationLevels: 'SECUNDAIR'});
204```
205
206#### ng-sri-client ####
207
208```javascript
209const basicConfig = const configuration = {
210 name: 'api',
211 baseUrl: 'https://api.katholiekonderwijs.vlaanderen'
212}
213
214const fastlyConfig = const configuration = {
215 name: 'cachedApi',
216 baseUrl: 'https://fastly-api.be'
217}
218
219
220// if you only need one version of an API you can just pass on an object as an argument instead of an array: require('@kathondvla/sri-client/ng-sri-client')(basicConfig]);
221const app = angular.module('MyApp', [require('@kathondvla/sri-client/ng-sri-client')([basicConfig, fastlyConfig])]);
222
223//inside a component
224
225['api', 'cachedApi', function (api, cachedApi) {
226 let secondarySchools = await api.get('/schools', {educationLevels: 'SECUNDAIR'});
227 let cities = await cachedApi.getAll('/cities');
228}];
229```
230#### node-sri-client ####
231
232This module is build upon [requestretry][npm-requestretry] which itself is build upon [request][npm-request].
233Here is an example how to use the module.
234
235```javascript
236const configuration = {
237 baseUrl: 'https://api.katholiekonderwijs.vlaanderen',
238 username: 'foo',
239 password: 'bar',
240 caching: {
241 timeout: 400,
242 initialise: [{
243 timeout: 10000,
244 hrefs: ['/commons/cities', '/commons/countries']
245 ]
246 }
247}
248
249const api = require('@kathondvla/sri-client/node-sri-client')(configuration)
250
251let secondarySchools = await api.get('/schools', {educationLevels: 'SECUNDAIR'});
252```
253
254### caching ###
255
256There is always a cache assigned to the client. If no configuration is added the timout will be 0 and the maxSize is null.
257The default timeout can be overwritten by both the get method with options or in options.expand. An empty object for caching configuration or caching = false is the same thing as timeout = 0
258which always goes to the api and the response is not stored in the cache.
259When timeout is greater than 0 the cache will be checked. There will be a miss when the item is not there or age is larger than timeout in seconds, It will be retrieved from the API and the promise will be added/replaced in the cache.
260So if two resources ask the same href close to each other the call will only be done once.
261When a list resource is asked, all the individual resources will be added in the cache as well on the condition that no server side expansion is added (or expand=summary).
262
263A PUT or DELETE operation might alter the information in the cache therefore the cache distinguishes 3 kinds of hrefs:
264* single resources: they will be only removed on a PUT or DELETE on the resource itself
265* basic lists: this are lists which only have basic parameters limit, offset, keyOffset, hrefs or expand=full, summary or none. They will be removed on a PUT or DELETE of a resource with the same resource path.
266* complex hrefs: All lists with other parameters or server side expanded single resources. They will be deleted on any PUT or DELETE because they can even be invalid because of the changing of other resources.
267
268Be carefull with server side expansion because they are not cached very well.
269
270### batch ###
271
272To write more compacter code there is a Batch class which helps you to add things in batch just in one line.
273On a Batch class you can do the following methods:
274* get(href): adds an object to the batch with GET as verb and href as href.
275* put(href, payload): adds an object to the batch with PUT as verb, href as href, and resource as body.
276* put(resource): adds an object to the batch with PUT as verb, resource.$$meta.permalink as href, and resource as body.
277* post(href, payload): adds an object to the batch with POST as verb, href as href, and resource as body.
278* delete(href): adds an object to the batch with DELETE as verb and href as href.
279* getPayload(): returns the array of the batch. (you can also do batch.array for the same result)
280* send(href, sriClient): does a PUT to href with the build up batch array as payload using sriClient. If you have initialised the batch with a client or got the batch from the client [sriClient.createBatch()] you don't have to add the sriClient here.
281```javascript
282const api = require('@kathondvla/sri-client/node-sri-client')(configuration);
283const Batch = require('@kathondvla/sri-client/batch');
284
285try {
286 const batch = new Batch(api); // OR api.createBatch();
287 batch.put(person.$$meta.permalink, person);
288 batch.delete(person.$$emails.primary.href);
289 batch.post('/persons/changepassword', passwordPayload);
290 await batch.send('/persons/batch'); // OR await api.put('/persons/batch', batch.array)
291} catch (error) {
292 if(error instanceof SriClientError) {
293 console.error(util.inspect(error.body, {depth:7}));
294 console.error(error.stack);
295 } else {
296 console.error(error);
297 }
298}
299```
300
301### error handling ###
302
303If the response is different from status code 200 or 201 or there is no response the response is rejected and an error object is returned of type SriClientError.
304So you can catch errors coming from the sri client and catch http error by filtering on this error, for example:
305
306```javascript
307const SriClientError = require('@kathondvla/sri-client/sri-client-error');
308// create a batch array
309try {
310 await api.put('/batch', batch);
311} catch (error) {
312 if(error instanceof SriClientError) {
313 console.error(util.inspect(error.body, {depth:7}));
314 console.error(error.stack);
315 } else {
316 console.error(error);
317 }
318}
319```
320
321An SriClientError has the following properties:
322
323* status: the status code of the response (null if there was no response)
324* body: payload of the response.
325* getResponseHeader(): function that returns the whole responseHeader [is not working yet]
326* stack: stack trace that leads back to where the api was called from in the code
327
328## common-utils ##
329
330This is a library with common utility functions
331
332#### usage ####
333```javascript
334const commonUtils = require('@kathondvla/sri-client/common-utils');
335```
336
337#### interface ####
338
339* **generateUUID():** returns a generated uuid of version 4.
340* **splitPermalink(permalink):** returns an object with properties key (the key of the permalink) and path (the path of the permalink without the key)
341* **getKeyFromPermalink(permalink):** returns the key within the permalink
342* **getPathFromPermalink(permalink):** returns the pathe of the permalink without the key,
343* **parametersToString(href, parameters):** returns the full path for the combination of the base href and the object of parameters. The parameter names and values are URL encoded.
344* **strip$$Properties(object):** returns a copy of the object with all the properties that start with '$$' removed
345* **strip$$PropertiesFromBatch(batchArray):** returns a copy of the batchArray with all the properties of the body in the batch objects that start with '$$' removed
346
347## date-utils ##
348
349This is a library with utility functions for string dates as specified in the sri api in the format yyyy-MM-dd.
350So if we talk about a date as a string it is in that format.
351If a date as a string is null or undefined it is interpreted as infinitely in the future.
352
353#### usage ####
354```javascript
355const dateUtils = require('@kathondvla/sri-client/date-utils');
356```
357
358#### interface ####
359
360* **getNow():** returns the current date as a string
361* **setNow(dateString):** sets now to another date for the whole library. From now on getNow() will return this date.
362* **toString(date):** return the javascript date as a string
363* **parse(dateString):** returns the dateString as a javascript date
364* **stripTime(isoDateString):** returns the received isoDateString without the time section. YYYY-MM-DDTHH:mm:ss.sssZ -> YYYY-MM-DD
365* **isBeforeOrEqual(a,b):** returns true if a is before or on the same day as b, where a and b are dates as strings
366* **isAfterOrEqual(a,b):** returns true if a is after or on the same day as b, where a and b are dates as strings
367* **isBefore(a,b):** returns true if a is strictly before b, where a and b are dates as strings
368* **isAfter(a,b):** returns true if a is strictly after b, where a and b are dates as strings
369* **getFirst(arrayOfDateStrings):** returns the date that is first in time from arrayOfDateStrings
370* **getLast(arrayOfDateStrings):** returns the date that is last in time from arrayOfDateStrings
371* **isOverlapping(a, b):** returns true if there is an overlapping period between a en b where a and b are objects with a property startDate and endDate (which can be null/undefined)
372* **isCovering(a, b):** returns true if the period of b is completely within the period of a.
373* **isConsecutive(a, b):**: returns true if the periods of a and b are strictly following each other in any order. So b starts on the same date as a ends or a starts on the same date as b ends.
374* **isConsecutiveWithOneDayInBetween(a, b):**: returns true if the periods of a and b are strictly following each other in any order with one day in between. So b starts the day after a ends or a starts the day after b ends.
375* **getStartOfSchoolYear(dateString):** returns the first of september before datestring (the first of september before getNow() if dateString is null),
376* **getEndOfSchoolYear(dateString):** returns the first of september after dateString (the first of september after getNow() if dateString is null),
377* **getClosestSchoolYearSwitch(dateString):** returns the first of september which is the closest to the dateString (the first of september after getNow() if dateString is null) [for all dates in march untill august it returns getEndOfSchoolYear(), for all dates in setember untill februari it returns getStartOfSchoolYear()],
378* **getPreviousDay(dateString, nbOfDays):** returns the date which is the given number of days before dateString, as a string. nbOfDays is optional, the default is 1.
379* **getNextDay(dateString, nbOfDays):** returns the date which is the given number of days after dateString, as a string. nbOfDays is optional, the default is 1.
380* **getPreviousMonth(dateString, nbOfMonths):** returns the date which is the given number of months before dateString, as a string. nbOfMonths is optional, the default is 1.
381* **getNexMonth(dateString, nbOfMonths):** returns the date which is the given number of months after dateString, as a string. nbOfMonths is optional, the default is 1.
382* **getPreviousYear(dateString, nbOfYears):** returns the date which is a given number of years before dateString, as a string. nbOfYears is optional, the default is 1.
383* **getNextYear(dateString, nbOfYears):** returns the date which is the given number of years after dateString, as a string. nbOfYears is optional, the default is 1.
384* **getActiveResources(arrayOfResources, referenceDateString):** returns a new array with only the resources that are active on the referenceDateString (getNow() if dateString is null) from array,
385which is an array of resources with a period. array can also be an array of hrefs that is expanded.
386* **getNonAbolishedResources(arrayOfResources, referenceDateString):** returns a new array with only the resources that are not abolished on the referenceDateString (getNow() if dateString is null) from array,
387which is an array of resources with a period. array can also be an array of hrefs that is expanded.
388* **manageDeletes(resource, options, sriClient):** manages the propagation of deletes for the given resource to it's dependencies. It needs sriClient to query these dependenies. The options are:
389 * batch: a batch array. All references to this resource that should be deleted as well will be added to this batch array. If a depending resource is already present in the batch, it will be removed from the batch since this no longer seems necessary.
390 * references: an array of objects (or one object) with configuration to find the other resources referencing this resource and by consequence should be deleted as well. The configuration has the following properties [we explain this by the example where we delete a basket containing apples and oranges. If we delete the basket, the cookies and the oranges should be deleted as well]:
391 * alias: not required but if you add an alias, the function will return an object with the given alias as a property which contains the referencing resources that should be deleted as well. [For example 'apples', the returnin object will have a property 'apples' which is an array of the apples that were in the basket, which will be the given resource]
392 * href: the path on which the referencing resources can be found. [for example /fruits/apples, we want to delete all apples that reference the given basket]
393 * property: the property name/parameter name of the referencing resource pointing to the given resource. [for example 'basket', the property name within /fruits/apples that is a reference to the baket]
394 * commonReference: If a referencing resource is not referencing directly to the given resource but they are related to each other because they are referencing to the same resource. [For example you are not deleting the basket. But the apples and oranges both refer to a promotion which gave two free apples when buying an orange, upon deleting the orange you want to delete all apples that reference the same 'promotion', it is required that apples an oranges both have a property that have the same property name 'promotion']
395 * subResources: array with property paths to subResources of the reference which also need to be deleted.
396 * parameters: optional parameters to filter on the references. [For example only delete the green apples upon deleting the basket]
397 * filter: function that filters out certain resources in memory
398 * options: an options object that will be passed on as a parameter to the sriClient.getAll function.
399* **manageDateChanges(resource, options, sriClient):** manages the propagation of date changes for the given resource to it's dependencies. It needs an sriClient to query for this dependencies [This works in the same way as deletes but with updates on the period instead of deletes]. The options are:
400 * oldStartDate: the old startDate of the resource before it was updated.
401 * oldEndDate: the old endDate of the resource before it was updated.
402 * batch: a batch array. All references to this resource that should be updated as well will be added to this batch array. If a depending resource is already present in the batch, it will update the body of that batch element.
403 * properties: an array of strings containing the property names of the resource that have a period which should be updated together with the main period of the resource.
404 * intermediateStrategy: strategy to handle resources which start in between the new and the old startDate (or in between the new and the old endDate). Possible values are: 'NONE' (nothing is done with intermediate resources, validation errors will stop the period change from happening), 'ERROR' (this is the default, if there are intermediate resources an error is thrown of type DateError), 'FORCE' (intermediate resources are forced to adapt their period so there are no conflicts)
405 * references: an array of objects (or one object) with configuration to find the other resources referencing this resource and by consequence should have their period updated as well. The configuration has the following properties:
406 * alias: not required but if you add an alias, the function will return an object with the given alias as a property which contains the referencing resources that should be updated as well. If there was no period change the returned object is null.
407 * href: the path on which the referencing resources can be found.
408 * property: the property name/parameter name of the referencing resource pointing to the given resource.
409 * intermediateStrategy: overwrite the general intermediateStrategy for this reference.
410 * commonReference: If a referencing resource is not referencing directly to the given resource but they are related to each other because they are referencing to the same resource.
411 * subResources: array with property paths to subResources of the reference which also need to be updated.
412 * onlyEnlargePeriod: boolean (default is false). If true the period of the referencing is enlarged if the period of the given resource is enlarged, the period will never be shortened.
413 * onlyShortenPeriod: boolean (default is false). If true the period of the referencing is shortened if the period of the given resource is shortened, the period will never be enlarged.
414 * parameters: optional parameters to filter on the references.
415 * filter: function that filters out certain resources in memory
416 * options: an options object that will be passed on as a parameter to the sriClient.getAll function.
417If an error occurs when hanling a periodic reference to the given resource, a DateError is thrown with two properties, a message and the periodic.
418
419## address-utils ##
420
421This is a library with utility functions for address objects as specified in the sri api.
422
423#### usage ####
424```javascript
425const addressUtils = require('@kathondvla/sri-client/address-utils');
426```
427
428#### interface ####
429
430* **printAddress(address):** returns the address as a string in the format {street} {houseNumber} {mailboxNumber}, {zipCode} {subCity}
431* **isSameHouseNumberAndMailbox(a, b):** returns true if sri address a and sri address b have the same mailboxNumber and houseNumber. The match is case insensitive and ingores white spaces and underscores.
432* **isSameStreet(a, b):** returns true if sri address a and sri address b are the same streets. This means a match on the street name in the same city. If both addresses have a streetHref a match is done based on this reference because it is a reference to the same street, independent of how it is spelled. Otherwise A match on street name is case insensitive and takes into account that parts of the name are abbreviated with a dot. For example 'F. Lintsstraat' matches with 'Frederik lintsstraat'.
433* **addSubCityHref(sriAddress, api) [async]:** adds a subCityHref reference to the sriAddress. api is an instance of an sri-client library (can be both the ng-sri-client or the node-sri-client)
434* **addStreetHref(sriAddress, api) [async]:** adds a streetHref reference to the sriAddress. api is an instance of an sri-client library (can be both the ng-sri-client or the node-sri-client)
435
436### Questions ###
437
438Mail to matthias.snellings@katholiekonderwijs.vlaanderen, gunther.claes@katholiekonderwijs.vlaanderen.
439
440[sri-documentation]: https://github.com/dimitrydhondt/sri
441[sri4node-project]: https://github.com/katholiek-onderwijs-vlaanderen/sri4node
442[npm-requestretry]: https://www.npmjs.com/package/requestretry
443[npm-requestretry-strategy]: https://www.npmjs.com/package/requestretry#how-to-define-your-own-retry-strategy
444[npm-requestretry-delaystrategey]: https://www.npmjs.com/package/requestretry#how-to-define-your-own-delay-strategy
445[npm-request]: https://www.npmjs.com/package/request
\No newline at end of file