Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enonic-types

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enonic-types - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

static.d.ts

2

admin.d.ts

@@ -40,3 +40,3 @@ /**

*/
getPhrases(): any;
getPhrases(): string;
/**

@@ -43,0 +43,0 @@ * Returns the URL for an admin tool of specific application.

@@ -97,2 +97,6 @@ declare module "*/lib/xp/admin" {

}
declare module "*/lib/enonic/static" {
const lib: import("./static").StaticLibrary;
export = lib;
}
declare module "*/lib/xp/task" {

@@ -99,0 +103,0 @@ const lib: import("./task").TaskLibrary;

@@ -26,2 +26,3 @@ export interface EnonicLibraryMap {

"/lib/session": import("./session").SessionLibrary;
"/lib/enonic/static": import("./static").StaticLibrary;
"/lib/xp/task": import("./task").TaskLibrary;

@@ -28,0 +29,0 @@ "/lib/xp/testing": import("./testing").TestingLibrary;

@@ -1,2 +0,2 @@

import { Aggregation, AggregationsResponse, ByteSource, Highlight, PermissionsParams } from "./content";
import { Aggregation, AggregationsResponse, BasicFilters, BooleanFilter, ByteSource, Highlight, PermissionsParams } from "./content";
export interface NodeLibrary {

@@ -57,3 +57,3 @@ /**

*/
readonly filters?: any;
readonly filters?: BasicFilters | BooleanFilter;
/**

@@ -60,0 +60,0 @@ * Sorting expression.

{
"name": "enonic-types",
"sideEffects": false,
"version": "0.2.0",
"version": "0.2.1",
"description": "TypeScript types for Enonic XP",

@@ -6,0 +6,0 @@ "typings": "index.d.ts",

@@ -14,3 +14,3 @@ import { ByteSource, Content, Site } from "./content";

export interface Region {
components: Array<Component<any>>;
components: Array<Component<unknown>>;
name: string;

@@ -17,0 +17,0 @@ }

@@ -12,6 +12,7 @@ # TypeScript types for Enonic XP

```bash
npm i --save enonic-types
npm i --save-dev enonic-types
```
Add support to use typed `import` updating your *tsconfig.json* file with the `"types"` field:
Add support to use typed `import` updating your *tsconfig.json* file (or *src/main/resources/tsconfig.server.json* if
you are using the [webpack-starter](https://github.com/enonic/starter-webpack)) with the `"types"` field:

@@ -21,3 +22,2 @@ ```json

"compilerOptions": {
...
"types": ["node", "enonic-types"]

@@ -42,5 +42,4 @@ }

import { Article } from "../../site/content-types/article/article"; // 1
import contentLib from "/lib/xp/content"; // 2
const contentLib = __non_webpack_require__("/lib/xp/content"); // 2
export function get(req: Request): Response { // 3

@@ -60,4 +59,4 @@ const content = contentLib.get<Article>({ key: req.params.id! });

1. We import an `interface Article { ... }` generated by [xp-codegen-plugin](https://github.com/ItemConsulting/xp-codegen-plugin).
2. When we import something with `__non_webpack_require__`, it will automatically look up the correct interfaces for
XP-libraries if `__non_webpack_require__` is defined correctly (see below).
2. If you added *enonic-types* to the types in your *tsconfig.json* or *tsconfig.server.json* (see above), TypeScript should now
be able to add types to all the standard XP-libraries.
3. We use the imported `Request` and `Response` to control the shape of our controller.

@@ -64,0 +63,0 @@ 4. `content` is of the type `Content<Article> | null`, so we have to do a null check before proceiding.

export interface RecaptchaLibrary {
getSiteKey(): string;
getSecretKey(): string;
verify(res: any): boolean;
verify(res: string): VerifyResponse;
isConfigured(): boolean;
}
export interface VerifyResponse {
/**
* Whether this request was a valid reCAPTCHA token for your site
*/
success: boolean;
/**
* The score for this request (0.0 - 1.0)
*/
score: number;
/**
* the action name for this request (important to verify)
*/
action: string;
/**
* Timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ)
*/
challenge_ts: string;
/**
* The hostname of the site where the reCAPTCHA was solved
*/
hostname: string;
/**
* Error codes
*/
errorcodes?: Array<string>;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc