@esri/hub-common 17.9.0 → 17.9.1
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/dist/esm/items/_internal/ensureUniqueEntitySlug.js +7 -0
- package/dist/esm/items/_internal/ensureUniqueEntitySlug.js.map +1 -1
- package/dist/esm/items/fetch.js +13 -1
- package/dist/esm/items/fetch.js.map +1 -1
- package/dist/node/items/_internal/ensureUniqueEntitySlug.js +7 -0
- package/dist/node/items/_internal/ensureUniqueEntitySlug.js.map +1 -1
- package/dist/node/items/fetch.js +13 -1
- package/dist/node/items/fetch.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { getUniqueSlug, setSlugKeyword } from "../slugs";
|
|
2
|
+
import { truncateSlug } from "./slugs";
|
|
2
3
|
// NOTE: this mutates the entity that is passed in
|
|
3
4
|
export const ensureUniqueEntitySlug = async (entity, requestOptions) => {
|
|
5
|
+
// if we got the entity from the entity editor, the slug will already have the orgUrlKey prefix
|
|
6
|
+
// but it might not have been edited with the entity editor...
|
|
7
|
+
// ie a dev might have just set the slug to "my-slug" and not "org|my-slug" (like i did)
|
|
8
|
+
if (entity.slug && !entity.slug.startsWith(`${entity.orgUrlKey}|`)) {
|
|
9
|
+
entity.slug = truncateSlug(entity.slug, entity.orgUrlKey);
|
|
10
|
+
}
|
|
4
11
|
// verify that the slug is unique
|
|
5
12
|
const { id: existingId, slug } = entity;
|
|
6
13
|
const slugInfo = existingId ? { slug, existingId } : { slug };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureUniqueEntitySlug.js","sourceRoot":"","sources":["../../../../src/items/_internal/ensureUniqueEntitySlug.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ensureUniqueEntitySlug.js","sourceRoot":"","sources":["../../../../src/items/_internal/ensureUniqueEntitySlug.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,kDAAkD;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EACzC,MAAsB,EACtB,cAAkC,EACT,EAAE;IAC3B,+FAA+F;IAC/F,8DAA8D;IAC9D,wFAAwF;IACxF,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,SAAS,GAAG,CAAC,EAAE;QAClE,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;KAC3D;IACD,iCAAiC;IACjC,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IACxC,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IAC9D,MAAM,CAAC,IAAI,GAAG,MAAM,aAAa,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAC5D,uBAAuB;IACvB,MAAM,CAAC,YAAY,GAAG,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACvE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/dist/esm/items/fetch.js
CHANGED
|
@@ -18,7 +18,19 @@ export function fetchItem(identifier, requestOptions) {
|
|
|
18
18
|
// first, ensure the slug has the org key
|
|
19
19
|
const fullyQualifiedSlug = addContextToSlug(slug, orgKey || requestOptions.siteOrgKey);
|
|
20
20
|
const slugKeyword = uriSlugToKeywordSlug(fullyQualifiedSlug);
|
|
21
|
-
return findItemsBySlug({ slug: slugKeyword }, requestOptions)
|
|
21
|
+
return findItemsBySlug({ slug: slugKeyword }, requestOptions)
|
|
22
|
+
.then((results) => {
|
|
23
|
+
if (results.length) {
|
|
24
|
+
return results;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// we had a bug where page slugs could have been stored without the org url key prefix
|
|
28
|
+
// we decided to fall back to looking for them without the prefix
|
|
29
|
+
const slugWithoutOrgKey = slugKeyword.split("|").slice(1).join("|");
|
|
30
|
+
return findItemsBySlug({ slug: slugWithoutOrgKey }, requestOptions);
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
.then((results) => {
|
|
22
34
|
if (results.length) {
|
|
23
35
|
// search results only include a subset of properties of the item, so
|
|
24
36
|
// issue a subsequent call to getItem to get the full item details
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/items/fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAWpD;;;;GAIG;AACH,MAAM,UAAU,SAAS,CACvB,UAAkB,EAClB,cAAiC;IAEjC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/items/fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4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15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ensureUniqueEntitySlug = void 0;
|
|
4
4
|
const slugs_1 = require("../slugs");
|
|
5
|
+
const slugs_2 = require("./slugs");
|
|
5
6
|
// NOTE: this mutates the entity that is passed in
|
|
6
7
|
exports.ensureUniqueEntitySlug = async (entity, requestOptions) => {
|
|
8
|
+
// if we got the entity from the entity editor, the slug will already have the orgUrlKey prefix
|
|
9
|
+
// but it might not have been edited with the entity editor...
|
|
10
|
+
// ie a dev might have just set the slug to "my-slug" and not "org|my-slug" (like i did)
|
|
11
|
+
if (entity.slug && !entity.slug.startsWith(`${entity.orgUrlKey}|`)) {
|
|
12
|
+
entity.slug = slugs_2.truncateSlug(entity.slug, entity.orgUrlKey);
|
|
13
|
+
}
|
|
7
14
|
// verify that the slug is unique
|
|
8
15
|
const { id: existingId, slug } = entity;
|
|
9
16
|
const slugInfo = existingId ? { slug, existingId } : { slug };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureUniqueEntitySlug.js","sourceRoot":"","sources":["../../../../src/items/_internal/ensureUniqueEntitySlug.ts"],"names":[],"mappings":";;;AAEA,oCAAyD;
|
|
1
|
+
{"version":3,"file":"ensureUniqueEntitySlug.js","sourceRoot":"","sources":["../../../../src/items/_internal/ensureUniqueEntitySlug.ts"],"names":[],"mappings":";;;AAEA,oCAAyD;AACzD,mCAAuC;AAEvC,kDAAkD;AACrC,QAAA,sBAAsB,GAAG,KAAK,EACzC,MAAsB,EACtB,cAAkC,EACT,EAAE;IAC3B,+FAA+F;IAC/F,8DAA8D;IAC9D,wFAAwF;IACxF,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,SAAS,GAAG,CAAC,EAAE;QAClE,MAAM,CAAC,IAAI,GAAG,oBAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;KAC3D;IACD,iCAAiC;IACjC,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IACxC,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IAC9D,MAAM,CAAC,IAAI,GAAG,MAAM,qBAAa,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAC5D,uBAAuB;IACvB,MAAM,CAAC,YAAY,GAAG,sBAAc,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACvE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/dist/node/items/fetch.js
CHANGED
|
@@ -21,7 +21,19 @@ function fetchItem(identifier, requestOptions) {
|
|
|
21
21
|
// first, ensure the slug has the org key
|
|
22
22
|
const fullyQualifiedSlug = content_1.addContextToSlug(slug, orgKey || requestOptions.siteOrgKey);
|
|
23
23
|
const slugKeyword = slugConverters_1.uriSlugToKeywordSlug(fullyQualifiedSlug);
|
|
24
|
-
return slugs_1.findItemsBySlug({ slug: slugKeyword }, requestOptions)
|
|
24
|
+
return slugs_1.findItemsBySlug({ slug: slugKeyword }, requestOptions)
|
|
25
|
+
.then((results) => {
|
|
26
|
+
if (results.length) {
|
|
27
|
+
return results;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// we had a bug where page slugs could have been stored without the org url key prefix
|
|
31
|
+
// we decided to fall back to looking for them without the prefix
|
|
32
|
+
const slugWithoutOrgKey = slugKeyword.split("|").slice(1).join("|");
|
|
33
|
+
return slugs_1.findItemsBySlug({ slug: slugWithoutOrgKey }, requestOptions);
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
.then((results) => {
|
|
25
37
|
if (results.length) {
|
|
26
38
|
// search results only include a subset of properties of the item, so
|
|
27
39
|
// issue a subsequent call to getItem to get the full item details
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/items/fetch.ts"],"names":[],"mappings":";;;AACA,iEAA0D;AAC1D,wCAA8C;AAC9C,mCAA0C;AAC1C,+DAAkE;AAClE,6CAAoD;AAWpD;;;;GAIG;AACH,SAAgB,SAAS,CACvB,UAAkB,EAClB,cAAiC;IAEjC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,uBAAe,CAAC,UAAU,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/items/fetch.ts"],"names":[],"mappings":";;;AACA,iEAA0D;AAC1D,wCAA8C;AAC9C,mCAA0C;AAC1C,+DAAkE;AAClE,6CAAoD;AAWpD;;;;GAIG;AACH,SAAgB,SAAS,CACvB,UAAkB,EAClB,cAAiC;IAEjC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,uBAAe,CAAC,UAAU,CAAC,CAAC;IAEzD,IAAI,EAAE,EAAE;QACN,+BAA+B;QAC/B,OAAO,4BAAO,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;KACpC;IAED,gCAAgC;IAChC,yCAAyC;IACzC,MAAM,kBAAkB,GAAG,0BAAgB,CACzC,IAAI,EACJ,MAAM,IAAI,cAAc,CAAC,UAAU,CACpC,CAAC;IAEF,MAAM,WAAW,GAAG,qCAAoB,CAAC,kBAAkB,CAAC,CAAC;IAE7D,OAAO,uBAAe,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,cAAc,CAAC;SAC1D,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QAChB,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,OAAO,OAAO,CAAC;SAChB;aAAM;YACL,sFAAsF;YACtF,iEAAiE;YACjE,MAAM,iBAAiB,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,C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