-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support generating legacy URL aliases for objects that change IDs during import. #149021
Changes from all commits
1124f42
84c4132
dadf104
3df1447
3780626
7295394
79790e5
79f8be8
f3d9b13
76597ba
261502f
8a8c8e5
4af273f
95cdcbe
5c9b344
a1e9192
0adb905
c7ff265
c7e8451
255bfea
9e3552e
ade2e1d
9ebaa3d
2a006ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2553,6 +2553,16 @@ export class SavedObjectsRepository implements ISavedObjectsRepository { | |
}); | ||
} | ||
|
||
/** | ||
* {@inheritDoc ISavedObjectsRepository.getCurrentNamespace} | ||
*/ | ||
getCurrentNamespace(namespace?: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: I had to expose this method from the repository and the client to get the current namespace in the import code. The current namespace is required to properly generate legacy URL alias ID. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fact that Do we really need to mirror the API definition of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's what I would like to explore further, I agree this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fully agreed on the universally despised namespace parameter (kind of wish I had changed this during the refactor). Would there ever be a scenario where spaces as a feature is enabled but the spaces SO extension is not? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think it can be the case (otherwise having or not having the weird
I removed it from the client's public method signature, but kept in the repository's signature since it's still used internally. |
||
if (this._spacesExtension) { | ||
return this._spacesExtension.getCurrentNamespace(namespace); | ||
} | ||
return normalizeNamespace(namespace); | ||
} | ||
|
||
/** | ||
* Returns index specified by the given type or the default index | ||
* | ||
|
@@ -2664,20 +2674,6 @@ export class SavedObjectsRepository implements ISavedObjectsRepository { | |
// any other error from this check does not matter | ||
} | ||
|
||
/** | ||
* If the spaces extension is enabled, we should use that to get the current namespace (and optionally throw an error if a consumer | ||
* attempted to specify the namespace option). | ||
* | ||
* If the spaces extension is *not* enabled, we should simply normalize the namespace option so that `'default'` can be used | ||
* interchangeably with `undefined`. | ||
*/ | ||
private getCurrentNamespace(namespace?: string) { | ||
if (this._spacesExtension) { | ||
return this._spacesExtension.getCurrentNamespace(namespace); | ||
} | ||
return normalizeNamespace(namespace); | ||
} | ||
|
||
/** The `initialNamespaces` field (create, bulkCreate) is used to create an object in an initial set of spaces. */ | ||
private validateInitialNamespaces(type: string, initialNamespaces: string[] | undefined) { | ||
if (!initialNamespaces) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question (just for my own sanity) - is there a reason why some API's expect options as query parameters and others as fields within the request body?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question, and I'm not quite sure. I don't think there is any good reason why
import
andcopy
APIs accept similar options differently.The
import
API uses query string parameters because the body is the raw file content, so it's understandable why it uses both body and query string parameters. As for thecopy
API, havingspaces
andobjects
parameters in the body makes sense since they might be quite large potentially, but I'd rather use query string for the rest of the parameters to be consistent with theimport
API. I guess, we put everything in the body just to make it simpler for us 🤷♂️