1598423700
AEM Querybuilder for JavaScript (Browser, Node, Deno)
$ npm install @adobe/helix-querybuilder
The AEM QueryBuilder is a Java and REST API for executing server-side queries using a custom Query Builder Language (QBL). QBL was designed to be:
The most common way of expressing queries is as a query string appended to the URL of the resource that is able to execute queries. In the context of Project Helix, this would be the Helix Data Embed Action.
An example query might look like this:
https://adobeioruntime.net/api/v1/web/helix/helix-services/data-embed@v1/https://blogs.adobe.com/psirt/?feed=atom&hlx_property=author&hlx_property.value=svishnoi
The query is encoded in the URL parameters hlx_property=author&hlx_property.value=svishnoi
.
This URL query string notation is most practical in day-to-day use, but a bit hard to read. Therefore a multi-line text notation is used that uses line breaks to separate key-value-pairs, does not use prefixes, nor URL-encoding:
property=author
property.value=svishnoi
When using QBL in configuration files or JavaScript applications, it can be convenient to represent QBL in JSON like this:
{
"property": {
"property": "author",
"value": "svishnoi"
}
}
or as YAML like:
property:
property: author
value: svishnoi
In the following examples the multi-line and YAML notation will be used.
Of course, repeating the name of the predicate is boring and tedious, so the short-hand _
can be used instead of the inner repetition of the predicate name:
{
"property": {
"_": "author",
"value": "svishnoi"
}
}
or as YAML like:
property:
_: author
value: svishnoi
import { qb } from '@adobe/querybuilder';
const filter = qb.filter(window.location.search);
const filtered = filter(dataarray);
// other loaders are availale, e.g. text and url
import { load } from '@adobe/querybuilder/src/loaders/json.js'
// other adapters will be made available soon
import { adapt } from '@adobe/querybuilder/src/adapters/filter.js'
const qb = load(JSON.parse(input));
const filter = adapt(qb);
filter([
{ foo: 'bar'}
]);
For more, see the API documentation.
filter
creates a function that filters an in-memory arrayalgolia
returns a pair of search string and options that can be used with algoliasearch
odata
creates an OData filter object that can be used with Azure cognitive search or Excel$ npm install
$ npm test
$ npm run lint
A loader must implement and export a load
function that accepts a Query Builder Language representation in any form and returns a Query Builder AST object.
If you have the QBL as key-value pairs, then you can use { nest } from '@adobe/querybuilder/src/utils.js'
for a quick transformation.
Author: adobe
Source Code: https://github.com/adobe/helix-querybuilder
#node #deno #nodejs #javascript
1598423700
AEM Querybuilder for JavaScript (Browser, Node, Deno)
$ npm install @adobe/helix-querybuilder
The AEM QueryBuilder is a Java and REST API for executing server-side queries using a custom Query Builder Language (QBL). QBL was designed to be:
The most common way of expressing queries is as a query string appended to the URL of the resource that is able to execute queries. In the context of Project Helix, this would be the Helix Data Embed Action.
An example query might look like this:
https://adobeioruntime.net/api/v1/web/helix/helix-services/data-embed@v1/https://blogs.adobe.com/psirt/?feed=atom&hlx_property=author&hlx_property.value=svishnoi
The query is encoded in the URL parameters hlx_property=author&hlx_property.value=svishnoi
.
This URL query string notation is most practical in day-to-day use, but a bit hard to read. Therefore a multi-line text notation is used that uses line breaks to separate key-value-pairs, does not use prefixes, nor URL-encoding:
property=author
property.value=svishnoi
When using QBL in configuration files or JavaScript applications, it can be convenient to represent QBL in JSON like this:
{
"property": {
"property": "author",
"value": "svishnoi"
}
}
or as YAML like:
property:
property: author
value: svishnoi
In the following examples the multi-line and YAML notation will be used.
Of course, repeating the name of the predicate is boring and tedious, so the short-hand _
can be used instead of the inner repetition of the predicate name:
{
"property": {
"_": "author",
"value": "svishnoi"
}
}
or as YAML like:
property:
_: author
value: svishnoi
import { qb } from '@adobe/querybuilder';
const filter = qb.filter(window.location.search);
const filtered = filter(dataarray);
// other loaders are availale, e.g. text and url
import { load } from '@adobe/querybuilder/src/loaders/json.js'
// other adapters will be made available soon
import { adapt } from '@adobe/querybuilder/src/adapters/filter.js'
const qb = load(JSON.parse(input));
const filter = adapt(qb);
filter([
{ foo: 'bar'}
]);
For more, see the API documentation.
filter
creates a function that filters an in-memory arrayalgolia
returns a pair of search string and options that can be used with algoliasearch
odata
creates an OData filter object that can be used with Azure cognitive search or Excel$ npm install
$ npm test
$ npm run lint
A loader must implement and export a load
function that accepts a Query Builder Language representation in any form and returns a Query Builder AST object.
If you have the QBL as key-value pairs, then you can use { nest } from '@adobe/querybuilder/src/utils.js'
for a quick transformation.
Author: adobe
Source Code: https://github.com/adobe/helix-querybuilder
#node #deno #nodejs #javascript
1600680240
A public-key signature system based on Ed25519 for the NATS ecosystem system for JavaScript.
The nkeys.js library works in Deno, Node.js, and the browser!
For your Deno projects:
import { createUser, fromPublic, fromSeed } from "https://deno.land/x/nkeys.js/modules/esm/mod.ts";
On node, and browsers you can get a build from npm:
npm install nkeys.js
In your node projects:
const {createUser, fromSeed, fromPublic} = require("nkeys.js");
On your browser projects, make available the node/nkeys.js/nkeys.mjs
, and then
import {
createUser,
fromPublic,
fromSeed,
} from "https://host/path/nkeys.mjs";
// create an user nkey KeyPair (can also create accounts, operators, etc).
const user = createUser();
// A seed is the public and private keys together.
const seed: Uint8Array = user.getSeed();
// Seeds are encoded into Uint8Array, and start with
// the letter 'S'. Seeds need to be kept safe and never shared
console.log(`seeds start with s: ${seed[0] === "S".charCodeAt(0)}`);
// A seed's second letter encodes it's type:
// `U` for user,
// `A` for account,
// `O` for operators
console.log(`nkey is for a user? ${seed[1] === "U".charCodeAt(0)}`);
// To view a seed, simply decode it:
console.log(new TextDecoder().decode(seed));
// you can recreate the keypair with its seed:
const priv = fromSeed(seed);
// Using the KeyPair, you can cryptographically sign content:
const data = new TextEncoder().encode("Hello World!");
const sig = priv.sign(data);
// and verify a signature:
const valid = user.verify(data, sig);
if (!valid) {
console.error("couldn't validate the data/signature against my key");
} else {
console.error("data was verified by my key");
}
// others can validate using your public key:
const publicKey = user.getPublicKey();
const pub = fromPublic(publicKey);
if (!pub.verify(data, sig)) {
console.error(`couldn't validate the data/signature with ${publicKey}`);
} else {
console.info(`data was verified by ${publicKey}`);
}
// when extracting with seeds or private keys
// you should clear them when done:
seed.fill(0);
// you should also clear the keypairs:
user.clear();
priv.clear();
Our support policy for Nodejs versions follows Nodejs release support. We will support and build nkeys.js on even-numbered Nodejs versions that are current or in LTS.
Author: nats-io
Source Code: https://github.com/nats-io/nkeys.js
#deno #nodejs #node #javascript
1595475300
Deno is the latest alternative to Node created by one of Node’s original founders. Will it match Node’s popularity? Tutorial and comparison.
#cto's guidebook #developer stories #node.js #backend #deno #javascript #node
1592728360
In this video, we will be talking about what is Deno? and Deno vs Node. Is Node.js going to die? so stay tuned and watch the complete video to understand what is Deno and the difference from Node.
#deno #node #javascript #typescript #developer
1589616572
Deno is the new hype and will it be better than Node.js?
What is Deno?
Deno is a runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language. It was created by Ryan Dahl, original creator of Node.js, and is focused on productivity. It was announced by Dahl in 2018 during his talk “10 Things I Regret About Node.js”.
#deno #node #javascript #typescript #rust