how to globally override a blueprint action in sails 1.0 - sails.js

I might be wrong but overriding a blueprint action appears to be gone in sails 1.0.
what I'm trying to do is for the output of find to be:
{
"data": [...],
"meta": {
"count": 10,
}
},

Indeed it looks to have been removed from 1.0. https://github.com/sgress454/sails-hook-custom-blueprints provides a workaround.

This answer is true for V0.12: If you want to call the same action for "find" you can create your own find.js file in /api/blueprints. This globally overrides the action "find", provided that your controllers do not have any custom "find" methods themselves.
For the version 1.0, the documentation suggests this link

Related

How do I create a custom Semantic Token for VSCode?

I'm creating a color theme and I found out that the only way to target function parameters with italic is by using semantic highlight. The problem is that since semantic highlight overrides some settings, I lost the ability to target support.function.console - the "log" of console.log, for instance.
.log is a member.defaultLibrary, but if I target that by semantic, some other things would also be styled with the same color. That wouldn't be bad if member.defaultLibrary wasn't so inconsistent, some things you would expect to be styled, is not, which leads to inconsistency, which is certainly not desirable.
querySelector() is styled by member.defaultLibrary but not querySelectorAll(), for instance. I also tried to not use anything that can be overridden by semantics but then, it creates too many exceptions and some functions and methods would be let without any style, which is much worse.
I've tried Semantic Token Classification and tried to add a custom semantic token to the package.json file of the extension but I don't know how to "wire" that up:
{
"contributes": {
"semanticTokenTypes": [
{
"id": "consoleSupport",
"description": "console support"
}
],
"semanticTokenScopes": [
{
"scopes": {
"consoleSupport": ["support.function.console"]
}
}
]
}
}
When using development host, it does recognize the "new" consoleSupport when I try to add to "semanticTokenColors", it suggests the auto-complete, so I'm probably half-way there but I don't know how to actually create the new token and how to make it work.

Refer separately deployed components for reuse in an ui5 app

i'm developing some apps, for which everyone needs to show a document in the same way. For this i created a new component which handles my documents in a separate component. I then just want to reuse this component from my different apps.
To embed my reuse component i used something like this in my view.xml:
<core:ComponentContainer
name="de.mycomp.base.DocViewer"
component="de.mycomp.base.DocViewer"
settings='\{"param1":"value1"\}'/>
To access it during runtime i have to declare the namespace of the reuse component and associate it with an resource-url. To achive this, i used the following coding in the init-method of my Component.js which uses my reuse-component DocViewer.
jQuery.sap.registerModulePath("de.mycomp.base.DocViewer", "/sap/bc/ui5_ui5/sap/zdocviewer");
zdocviewer in this case is the name of the bsp-application to which the reuse-component was deployed on premise. To have this also work in webide and on SAP-Cloud-Plattform i needed to add an entry to neo-app.json
like this:
{
"path": "/sap/bc/ui5_ui5/sap/zdocviewer",
"target": {
"type": "application",
"name": "docviewer"
},
"description": "my base document viewer"
},
where docviewer is the name of the deployed app with the reuse component on SCP.
The type application implies that this destination is an app.
This works so far on premise and on sap cloud.
but my problem is that i dont want to have the registerModulePath in my Component.js. Nearly every configuration of components takes place in the manifest.json file. So i tried to move this coding line to configuration in manifest.json, but i failed so far.
Here's what i did:
i added a dependency in section sap.ui5 and there in the dependency-entry like this:
"components": {
"de.dvelop.base.DvelopBaseDocViewer": {
"lazy": true
}
}
i added the following entry to sap.ui5 part
"resourceRoots": {
"de.dvelop.base.DvelopBaseDocViewer": "/sap/bc/ui5_ui5/sap/zdocviewer"
},
The problem here is, that its not allowed to use absolute paths in the value-part of the resource-root entries. So this is invalid:
- /sap/bc/ui5_ui5/sap/zdocviewer
- ../sap/bc/ui5_ui5/sap/zdocviewer
Only this is valid:
- sap/bc/ui5_ui5/sap/zdocviewer
- ./sap/bc/ui5_ui5/sap/zdocviewer
So this annotation is only usable for embedded components, where the reuse-component is in the same deployed project. But this is not my understanding of a reuseable component. So changing something in that component would make it neccessary to copy the files to all the app-projects using the component. And they all have to be deployed again.
So for now i made a fallback to the jquery.sap.registerModulePath because this works with deployed components to refer them from other independent components.
Or does anybody have an idea how to handle this better or more proper within manifest.json?
kind regards
Matthias
see here: ui5 reuse components: https://github.com/Yelcho/UI5-Comp-Routing
you mixed up here old and new approches, wrinting all steps in this answer would be very long. Here brief step to step approche:
define your componentUsages
"componentUsages": {
"myDoc": {
"name": "com.company.myDoc",
"settings": {},
"componentData": {},
"lazy": true
}}
define path mapping, in resourceRoots
"resourceRoots": {
"com.company.myDoc": "/sap/bc/ui5_ui5/sap/zdocviewer"
},
define a targed type component
"targets": {
"myDocTarget": {
"type": "Component",
"usage": "myDoc"
}
use nested routing
.getRouter()
.navTo("myDocRoute", {
id: oBindingContext.getProperty("CategoryID")
}, {
products: {
route: "list",
parameters: {
}
}
});

Am I understanding this VS Code API behavior correctly? Non-default *object* settings (when provided) are always merged?

I'm working on a VS Code Extension, and I think maybe I'm missing something in the docs, or else the behavior I'm seeing just isn't specified there, and my assumptions are wrong...?
I've defined some default settings for my extension, like so...
package.json
"contributes": {
"configuration": {
"title": "ToggleSettingsChanges",
"properties": {
"toggleSettingsChanges.settingsToToggle": {
"scope": "resource",
"type": "object",
"default": {
"window.zoomLevel": 2,
"editor.fontSize": 22,
"terminal.integrated.fontSize": 16,
"scm.diffDecorations": "none",
"workbench.statusBar.visible": false,
"editor.cursorBlinking": "solid",
"workbench.activityBar.visible": false
},
"description": "[ snip ]"
}
}
}
},
extension.js
// In the "main" method that runs when a command is activated:
const config = vscode.workspace.getConfiguration("toggleSettingsChanges");
const settingsToToggle = config.get("settingsToToggle");
const inspectedSettingsToToggle = config.inspect("settingsToToggle");
console.log("settingsToToggle:", JSON.stringify(settingsToToggle), "\n\n")
console.log("inspected settingsToToggle:", JSON.stringify(inspectedSettingsToToggle), "\n\n")
return;
In the Extension Host instance, I can tweak and adjust the settings, to include this:
User or Workspace Settings JSON
// ...
"toggleSettingsChanges.settingsToToggle": {
"editor.fontSize": 11,
"pumpkins_are_great": true
},
In the console output, I'm seeing the following:
settingsToToggle: {"window.zoomLevel":2,"editor.fontSize":11,"terminal.integrated.fontSize":16,"scm.diffDecorations":"none","workbench.statusBar.visible":false,"editor.cursorBlinking":"solid","workbench.activityBar.visible":false,"pumpkins_are_great":true}
inspected settingsToToggle: {"key":"toggleSettingsChanges.settingsToToggle","defaultValue":{"window.zoomLevel":2,"editor.fontSize":22,"terminal.integrated.fontSize":16,"scm.diffDecorations":"none","workbench.statusBar.visible":false,"editor.cursorBlinking":"solid","workbench.activityBar.visible":false},"globalValue":{"editor.fontSize":11,"pumpkins_are_great":true}}
For the settingsToToggle line, I expected to see only the following settings:
{"editor.fontSize":11,"pumpkins_are_great":true}
It seems that if you provide an object default, any configuration provided is merged with that object, instead of replacing it entirely.
Is that the case? Have I missed this in the documentation?
It seems to me that a value (even an object) would be overwritten, and not simply merged.
The documentation may have been updated since this question was posted. The way it's written now, seems pretty clear to me. I'm writing because I feel I have found a discrepancy in the API, which may help out the OP.
Reference
Note: Only object value types are merged and all other value types are overridden.
-- VS Code API - WorkspaceConfiguration
Additional information
I want my default values to be merged with the user settings, as is described above. I was confused by seeing my defaults overriden. This question helped me understand what is happening. I'll share my approach since OP may be interested. My observations:
Default values provided in package.json are merged with user settings, as described in the documentation (link above).
Default values passed programmatically with WorkspaceConfiguration.get(section, defaultValue) do not exhibit the merging behavior. It's not clear if this is intentional or not. Update: this behavior is working as intended, reference #105598.

What are the rules for class names in IBM Watson Visual Recognition service?

I'm exploring IBM Watson Visual Recognition service and when I create a classifier using classnames like 'black-dog' (i.e. black-dog_positive_example), this classname is later returned as 'black_dog' (with underscore replacing dash) when I classify an image using the /v3/classify endpoint.
But when I retrieve the classifier details with the /v3/classifiers/{classifier_id} the class is correctly listed as 'black-dog'.
So, my result for GET /v3/classifiers/{classifier_id} is like:
{
"classifier_id": "dog_561932172",
"name": "dog",
"owner": "xxxxxxxx-xxx-xxx-xxx-xxxxxxxxxxxx",
"status": "ready",
"created": "2016-07-30T22:06:39.327Z",
"classes": [
{"class": "black-dog"}
]
}
While my result for GET /v3/classify is
{
"custom_classes": 1,
"images": [
{
"classifiers": [
{
"classes": [
{
"class": "black_dog",
"score": 0.546941
}
],
"classifier_id": "dog_561932172",
"name": "dog"
}
],
"image": "20160620_142113.jpg"
}
],
"images_processed": 1
}
So is this expected or a defect? Should I avoid using "-" in class names? Are there any other rules for the value of a classname?
Update:
Updated via Matt's answer.
Talked with the support team, and it is indeed a bug. Here was their response:
Thanks for pointing this out. I reproduced and confirmed with dev team, and we do consider this inconsistency between the listed class name and the class name in results is a bug.
And this is because the class name been altered in result from what is submitted.
I have raised a ticket for tracking on this. According to developer, currently the output can be either a document to list the substitutions or find a way to remove them.
...so they are currently working on it.
Are there any other rules for the value of a classname?
We made an update, and the service should no longer modify any class names like replacing a dash with an underscore. Instead, it will not accept class names with any of these characters for custom learning: \,|,*,{,},$,-,/,',`,"
(You'll see the dash is included in there.) Spaces are acceptable. The update is not retroactive, so existing class names that were modified during training are not affected.

Sensu custom parameter in event data

I would like to add custom key/value pairs to the event data in sensu. I added the keys to the event definition, but it's not there by the time it gets to the handlers.
So what i want to achieve is to have the data behind the "custom_values" key at the point the check data is passed to the handler. (see example)
{
"checks": {
"check-disk": {
"command": "/etc/sensu/plugins/check-disk.rb",
"interval": 60,
"handlers": [
"default"
],
"subscribers": [
"default"
],
"standalone": false
"custom_values": {
"custom1": "somevalue"
}
}
}
}
Mutators won't help, AFAIK they can only work with the check data, which is not containing the custom key when the mutator gets the check result.
Thanks
Not much to go on as to how you're trying to use it, but there are a couple items you'll want to be sure of.
First off, the checks json provided is malformed, prior to defining your custom_values, you need a comma after "standalone": false
As such:
"standalone": false,
"custom_values": {
"custom1": "somevalue"
}
Second, when you go to use this custom_value data in your handler, make sure you're addressing it as part of the check:
#event['check']['custom_values']['custom1']
and not just trying to use it directly off the event, i.e.
#event['custom_values']['custom1']
This should work. Can you be sure that this check is not defined in on the client as well?
Additionally, did you remember to restart the sensu server to pick up the new definition?