@startinblox/core 0.19.14 → 0.19.15-beta.2

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -35
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11397,10 +11397,6 @@ class Store {
11397
11397
  if (options.headers)
11398
11398
  options.headers = this._convertHeaders(options.headers);
11399
11399
  return fetch(iri, options).then(function(response) {
11400
- if (options.method === "PURGE" && !response.ok && response.status === 404) {
11401
- const err = new Error("PURGE call is returning 404");
11402
- throw err;
11403
- }
11404
11400
  return response;
11405
11401
  });
11406
11402
  }
@@ -11659,35 +11655,6 @@ class Store {
11659
11655
  async patch(resource, id2) {
11660
11656
  return this._updateResource("PATCH", resource, id2);
11661
11657
  }
11662
- /**
11663
- * Send a PURGE request to remove a resource from REDIS AD cache
11664
- * @param id - uri of the resource to patch
11665
- *
11666
- * @returns id of the edited resource
11667
- */
11668
- async purge(id2) {
11669
- await this.fetchAuthn(id2, {
11670
- method: "PURGE",
11671
- headers: this.headers
11672
- }).catch(function(error2) {
11673
- console.warn("No purge method allowed: " + error2);
11674
- });
11675
- try {
11676
- const fullURL = new URL(id2);
11677
- var pathArray = fullURL.pathname.split("/");
11678
- var containerUrl = fullURL.origin + "/" + pathArray[1] + "/";
11679
- const headers = { ...this.headers, "X-Cache-Purge-Match": "startswith" };
11680
- await this.fetchAuthn(containerUrl, {
11681
- method: "PURGE",
11682
- headers
11683
- }).catch(function(error2) {
11684
- console.warn("No purge method allowed: " + error2);
11685
- });
11686
- } catch (error2) {
11687
- console.warn("The resource ID is not a complete URL: " + error2);
11688
- return;
11689
- }
11690
- }
11691
11658
  /**
11692
11659
  * Send a DELETE request to delete a resource
11693
11660
  * @param id - uri of the resource to delete
@@ -51106,8 +51073,12 @@ const WidgetMixin = {
51106
51073
  return [];
51107
51074
  let fields = [];
51108
51075
  for (const prop2 of resource.properties) {
51109
- if (!prop2.startsWith("@") && !(prop2 === "permissions") && await resource[prop2])
51110
- fields.push(prop2);
51076
+ if (!prop2.startsWith("@") && !(prop2 === "permissions")) {
51077
+ if (!this.isAlias(prop2) && await resource[prop2])
51078
+ fields.push(prop2);
51079
+ else if (this.isAlias(prop2))
51080
+ fields.push(prop2);
51081
+ }
51111
51082
  }
51112
51083
  return fields;
51113
51084
  },
@@ -51156,9 +51127,21 @@ const WidgetMixin = {
51156
51127
  let foundSets = this.fields.match(this.getSetRegexp(field));
51157
51128
  return foundSets ? foundSets.length > 0 : false;
51158
51129
  },
51130
+ /**
51131
+ * Return true if "field" is a string
51132
+ * @param field - string
51133
+ */
51159
51134
  isString(field) {
51160
51135
  return field.startsWith("'") || field.startsWith('"');
51161
51136
  },
51137
+ /**
51138
+ * Return true if "field" is an alias (contains " as ")
51139
+ * @param field - string
51140
+ */
51141
+ isAlias(field) {
51142
+ const aliasRegex = /^[\w@.]+\s+as\s+[\w@.]+$/;
51143
+ return aliasRegex.test(field);
51144
+ },
51162
51145
  /**
51163
51146
  * Return the value of "resource" for predicate "field"
51164
51147
  * @param field - string
@@ -51194,6 +51177,10 @@ const WidgetMixin = {
51194
51177
  if (this.element.hasAttribute("value-" + field)) {
51195
51178
  return this.element.getAttribute("value-" + field);
51196
51179
  }
51180
+ if (this.isAlias(field)) {
51181
+ const alias = field.split(" as ");
51182
+ return await this.fetchValue(alias[0], resource);
51183
+ }
51197
51184
  let resourceValue = await this.fetchValue(field, resource);
51198
51185
  if (resourceValue === void 0 || resourceValue === "" || resourceValue === null)
51199
51186
  return this.element.hasAttribute("default-" + field) ? this.element.getAttribute("default-" + field) : "";
@@ -51221,6 +51208,8 @@ const WidgetMixin = {
51221
51208
  * @param isSet - boolean
51222
51209
  */
51223
51210
  getWidget(field, isSet2 = false) {
51211
+ if (this.isAlias(field))
51212
+ field = field.split(" as ")[1];
51224
51213
  const widget = this.element.getAttribute("widget-" + field);
51225
51214
  if (widget)
51226
51215
  return this.widgetFromTagName(widget);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/core",
3
- "version": "0.19.14",
3
+ "version": "0.19.15-beta.2",
4
4
  "description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",