@modernpoacher/halacious 7.0.395 → 7.0.397

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/husky.mjs CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ if (process.env.CI === 'true') process.exit(0)
4
+
3
5
  // @ts-ignore
4
6
  Promise.resolve(import('husky'))
5
7
  .then(({ default: husky }) => { husky() })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernpoacher/halacious",
3
- "version": "7.0.395",
3
+ "version": "7.0.397",
4
4
  "description": "A HAL processor for Hapi",
5
5
  "keywords": [
6
6
  "HAL",
@@ -44,7 +44,7 @@
44
44
  "debug": "^4.4.3",
45
45
  "joi": "^18.3.2",
46
46
  "lodash": "^4.18.1",
47
- "marked": "^18.1.3",
47
+ "marked": "^18.2.0",
48
48
  "negotiator": "^1.1.0",
49
49
  "pug": "^3.0.4",
50
50
  "urijs": "^1.19.11",
@@ -53,13 +53,13 @@
53
53
  "devDependencies": {
54
54
  "@hapi/hapi": "^21.4.13",
55
55
  "@hapi/vision": "^7.0.3",
56
- "@sequencemedia/eslint-config-standard": "0.2.132",
57
- "@sequencemedia/eslint-config-typescript": "0.1.230",
58
- "@sequencemedia/sinon-chai": "^0.0.242",
56
+ "@sequencemedia/eslint-config-standard": "0.3.2",
57
+ "@sequencemedia/eslint-config-typescript": "0.2.3",
58
+ "@sequencemedia/sinon-chai": "^0.0.244",
59
59
  "@types/negotiator": "^0.6.5",
60
60
  "chai": "^6.3.0",
61
61
  "cross-env": "^10.1.0",
62
- "eslint": "9.38.0",
62
+ "eslint": "10.14.0",
63
63
  "globals": "^17.14.0",
64
64
  "husky": "^9.1.7",
65
65
  "mocha": "^12.0.3",
package/src/plugin.mjs CHANGED
@@ -163,7 +163,7 @@ const namespaceSchema = joi.object({
163
163
  const relName = getName(rel)
164
164
  const rels = getRels(this)
165
165
 
166
- rels[relName] = rel /* Reflect.set(rels, relName, rel) */
166
+ rels[relName] = rel
167
167
 
168
168
  rel.namespace = this
169
169
 
@@ -376,8 +376,8 @@ export const plugin = {
376
376
  // shorthand prepare function
377
377
  if (_.isFunction(config)) config = { prepare: config }
378
378
 
379
- if ('links' in config) { /* Reflect.has(config, 'links') */
380
- const links = config.links /* Reflect.get(config, 'links') */
379
+ if ('links' in config) {
380
+ const links = config.links
381
381
 
382
382
  const entity = getRepresentationEntity(representation)
383
383
 
@@ -388,15 +388,15 @@ export const plugin = {
388
388
  representation.link(rel, representationLink)
389
389
 
390
390
  // grab query options
391
- if (config.query) {
391
+ if ('query' in config) {
392
392
  representationLink.href += config.query
393
393
  }
394
394
  })
395
395
  }
396
396
 
397
- if ('embedded' in config) { /* Reflect.has(config, 'embedded') */
397
+ if ('embedded' in config) {
398
398
  // configure embedded declarations. each rel entry is also a representation config object
399
- const embedded = config.embedded /* Reflect.get(config, 'embedded') */
399
+ const embedded = config.embedded
400
400
 
401
401
  const entity = getRepresentationEntity(representation)
402
402
 
@@ -783,7 +783,7 @@ export const plugin = {
783
783
  const relName = getName(rel)
784
784
  const rels = getRels(namespace)
785
785
 
786
- return rels[relName] /* Reflect.get(rels, relName) */
786
+ return rels[relName]
787
787
  }
788
788
 
789
789
  /**
@@ -813,7 +813,7 @@ export const plugin = {
813
813
  if (namespace) {
814
814
  const rels = getRels(namespace)
815
815
 
816
- if (!(relName in rels)) { /* Reflect.has(rels, relName) */
816
+ if (!(relName in rels)) {
817
817
  if (!settings.strict) {
818
818
  // lazily create the rel
819
819
  namespace.rel({ name: relName })
@@ -823,7 +823,7 @@ export const plugin = {
823
823
  }
824
824
  }
825
825
 
826
- rel = rels[relName] /* Reflect.get(rels, relName) */
826
+ rel = rels[relName]
827
827
  } else {
828
828
  // could be globally qualified (e.g. 'self')
829
829
  const { error, value } = relSchema.validate({ name: namespaceName })
@@ -98,33 +98,22 @@ export class Representation {
98
98
  const prefix = getPrefix(namespace)
99
99
 
100
100
  const root = this.getRoot()
101
-
102
101
  const namespaces = root.getNamespaces()
103
102
 
104
- if (prefix in namespaces) return // if (Reflect.has(namespaces, prefix)) return
103
+ if (prefix in namespaces) return
105
104
 
106
- namespaces[prefix] = namespace // Reflect.set(namespaces, prefix, namespace)
105
+ namespaces[prefix] = namespace
107
106
 
108
107
  const links = root.getLinks()
108
+ const curies = links.curies ?? []
109
109
 
110
- const curies = links.curies ?? [] // Reflect.get(links, 'curies') ?? []
111
-
112
- const request = this.getRequest()
113
-
114
- const namespaceUrl = this.getHalacious().namespaceUrl(request, namespace)
110
+ const namespaceUrl = this.getHalacious().namespaceUrl(this.getRequest(), namespace)
115
111
 
116
112
  links.curies = curies.concat({
117
113
  name: prefix,
118
114
  href: `${namespaceUrl}/{rel}`,
119
115
  templated: true
120
116
  })
121
-
122
- /*
123
- Reflect.set(links, 'curies', curies.concat({
124
- name: prefix,
125
- href: `${namespaceUrl}/{rel}`,
126
- templated: true
127
- })) */
128
117
  }
129
118
  }
130
119
 
@@ -200,7 +189,7 @@ export class Representation {
200
189
  JSON.stringify(entity, (key, value) => {
201
190
  if (!key) return value
202
191
 
203
- if (!ignore.has(key)) object[key] = value // Reflect.set(object, key, value)
192
+ if (!ignore.has(key)) object[key] = value
204
193
  })
205
194
 
206
195
  const embedded = this.getEmbedded()
@@ -223,7 +212,7 @@ export class Representation {
223
212
  JSON.stringify(entryValue, (key, value) => {
224
213
  if (!key) return value
225
214
 
226
- if (!ignore.has(key)) currentValue[key] = value // Reflect.set(currentValue, key, value)
215
+ if (!ignore.has(key)) currentValue[key] = value
227
216
  })
228
217
 
229
218
  return (
@@ -257,7 +246,7 @@ export class Representation {
257
246
  const links = this.getLinks()
258
247
 
259
248
  if (Array.isArray(link)) {
260
- if (!(key in links)) links[key] = [] // if (!Reflect.has(links, key)) Reflect.set(links, key, [])
249
+ if (!(key in links)) links[key] = []
261
250
 
262
251
  return (
263
252
  link.map((href) => this.link(relName, href))
@@ -268,7 +257,6 @@ export class Representation {
268
257
  this.curie(rel.namespace)
269
258
 
270
259
  const href = getHref(getSelf(links)) ?? ''
271
-
272
260
  link = halacious.link(link, href)
273
261
 
274
262
  if (TEMPLATE.test(link.href)) link.templated = true
@@ -280,13 +268,6 @@ export class Representation {
280
268
  : link
281
269
  )
282
270
 
283
- /*
284
- Reflect.set(links, key, (
285
- Reflect.has(links, key)
286
- ? [].concat(Reflect.get(links, key), link)
287
- : link
288
- )) */
289
-
290
271
  return link
291
272
  }
292
273
 
@@ -339,7 +320,7 @@ export class Representation {
339
320
  const embedded = this.getEmbedded()
340
321
 
341
322
  if (Array.isArray(entity)) {
342
- if (!(key in embedded)) embedded[key] = [] // if (!Reflect.has(embedded, key)) Reflect.set(embedded, key, [])
323
+ if (!(key in embedded)) embedded[key] = []
343
324
 
344
325
  return (
345
326
  entity.map((entity) => this.embed(relName, self, entity))
@@ -347,9 +328,7 @@ export class Representation {
347
328
  }
348
329
 
349
330
  const href = getHref(getSelf(this.getLinks())) ?? ''
350
-
351
331
  self = halacious.link(self, href)
352
-
353
332
  const root = this.getRoot()
354
333
 
355
334
  const embed = this.factory.create(entity, self, root)
@@ -360,13 +339,6 @@ export class Representation {
360
339
  : embed
361
340
  )
362
341
 
363
- /*
364
- Reflect.set(embedded, key, (
365
- Reflect.has(embedded, key)
366
- ? [].concat(Reflect.get(embedded, key), embed)
367
- : embed
368
- )) */
369
-
370
342
  return embed
371
343
  }
372
344
 
@@ -1,7 +1,7 @@
1
1
  function reduce (accumulator, fieldName) {
2
2
  return (
3
- fieldName in accumulator // Reflect.has(accumulator, fieldName)
4
- ? accumulator[fieldName] // Reflect.get(accumulator, fieldName)
3
+ fieldName in accumulator
4
+ ? accumulator[fieldName]
5
5
  : accumulator
6
6
  )
7
7
  }
@@ -16,15 +16,13 @@ export default function getTemplateContext (template, context) {
16
16
 
17
17
  while ((matches = REG.exec(template))) {
18
18
  if (Array.isArray(matches)) {
19
- const [
20
- , // input,
19
+ const [, // input,
21
20
  path
22
21
  ] = matches
23
22
 
24
23
  if (path) {
25
24
  const fieldValue = getFieldValueByPath(path, context)
26
-
27
- if (fieldValue) templateContext[path] = String(fieldValue) /* Reflect.set(templateContext, path, fieldValue.toString()) */
25
+ if (fieldValue) templateContext[path] = String(fieldValue)
28
26
  }
29
27
  }
30
28
  }