@jahia/javascript-modules-library 0.0.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.
Files changed (87) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +35 -0
  3. package/core/index.js +1 -0
  4. package/core/server/components/AbsoluteArea.js +1 -0
  5. package/core/server/components/AddContentButtons.js +1 -0
  6. package/core/server/components/AddResources.js +1 -0
  7. package/core/server/components/Area.js +1 -0
  8. package/core/server/components/index.js +1 -0
  9. package/core/server/components/render/HydrateInBrowser.js +1 -0
  10. package/core/server/components/render/Render.js +1 -0
  11. package/core/server/components/render/RenderInBrowser.js +1 -0
  12. package/core/server/components/render/index.js +1 -0
  13. package/core/server/components/render/internal/InBrowser.js +1 -0
  14. package/core/server/framework/defineJahiaComponent.js +1 -0
  15. package/core/server/framework/index.js +1 -0
  16. package/core/server/framework/register.js +1 -0
  17. package/core/server/hooks/index.js +1 -0
  18. package/core/server/hooks/useGQLQuery.js +1 -0
  19. package/core/server/hooks/useJCRQuery.js +1 -0
  20. package/core/server/hooks/useServerContext.js +1 -0
  21. package/core/server/hooks/useUrlBuilder.js +1 -0
  22. package/core/server/index.js +1 -0
  23. package/core/server/utils/index.js +1 -0
  24. package/core/server/utils/jcr/getChildNodes.js +1 -0
  25. package/core/server/utils/jcr/getNodeFromPathOrId.js +1 -0
  26. package/core/server/utils/jcr/getNodeProps.js +1 -0
  27. package/core/server/utils/jcr/getNodesByJCRQuery.js +1 -0
  28. package/core/server/utils/jcr/index.js +1 -0
  29. package/core/server/utils/urlBuilder/index.js +1 -0
  30. package/core/server/utils/urlBuilder/urlBuilder.js +1 -0
  31. package/index.js +1 -0
  32. package/nav/index.js +1 -0
  33. package/nav/server/index.js +1 -0
  34. package/nav/server/navBuilder/index.js +1 -0
  35. package/nav/server/navBuilder/navBuilder.js +24 -0
  36. package/package.json +60 -0
  37. package/types/@jahia/javascript-modules-library-private.d.ts +60 -0
  38. package/types/core/index.d.ts +1 -0
  39. package/types/core/server/components/AbsoluteArea.d.ts +29 -0
  40. package/types/core/server/components/AddContentButtons.d.ts +13 -0
  41. package/types/core/server/components/AddResources.d.ts +31 -0
  42. package/types/core/server/components/Area.d.ts +27 -0
  43. package/types/core/server/components/index.d.ts +5 -0
  44. package/types/core/server/components/render/HydrateInBrowser.d.ts +13 -0
  45. package/types/core/server/components/render/Render.d.ts +23 -0
  46. package/types/core/server/components/render/RenderInBrowser.d.ts +13 -0
  47. package/types/core/server/components/render/index.d.ts +3 -0
  48. package/types/core/server/components/render/internal/InBrowser.d.ts +8 -0
  49. package/types/core/server/framework/defineJahiaComponent.d.ts +41 -0
  50. package/types/core/server/framework/index.d.ts +2 -0
  51. package/types/core/server/framework/register.d.ts +7 -0
  52. package/types/core/server/hooks/index.d.ts +4 -0
  53. package/types/core/server/hooks/useGQLQuery.d.ts +5 -0
  54. package/types/core/server/hooks/useJCRQuery.d.ts +3 -0
  55. package/types/core/server/hooks/useServerContext.d.ts +14 -0
  56. package/types/core/server/hooks/useUrlBuilder.d.ts +31 -0
  57. package/types/core/server/index.d.ts +4 -0
  58. package/types/core/server/utils/index.d.ts +2 -0
  59. package/types/core/server/utils/jcr/getChildNodes.d.ts +9 -0
  60. package/types/core/server/utils/jcr/getNodeFromPathOrId.d.ts +12 -0
  61. package/types/core/server/utils/jcr/getNodeProps.d.ts +7 -0
  62. package/types/core/server/utils/jcr/getNodesByJCRQuery.d.ts +9 -0
  63. package/types/core/server/utils/jcr/index.d.ts +4 -0
  64. package/types/core/server/utils/urlBuilder/index.d.ts +1 -0
  65. package/types/core/server/utils/urlBuilder/urlBuilder.d.ts +27 -0
  66. package/types/globals.d.ts +11 -0
  67. package/types/index.d.ts +19 -0
  68. package/types/java.io.d.ts +694 -0
  69. package/types/java.net.d.ts +190 -0
  70. package/types/java.security.d.ts +27 -0
  71. package/types/java.util.d.ts +1536 -0
  72. package/types/javax.jcr.d.ts +1250 -0
  73. package/types/javax.servlet.d.ts +426 -0
  74. package/types/javax.servlet.http.d.ts +1431 -0
  75. package/types/nav/index.d.ts +1 -0
  76. package/types/nav/server/index.d.ts +1 -0
  77. package/types/nav/server/navBuilder/index.d.ts +1 -0
  78. package/types/nav/server/navBuilder/navBuilder.d.ts +78 -0
  79. package/types/org.jahia.modules.npm.modules.engine.js.server.d.ts +292 -0
  80. package/types/org.jahia.services.content.d.ts +1463 -0
  81. package/types/org.jahia.services.content.decorator.d.ts +92 -0
  82. package/types/org.jahia.services.query.d.ts +35 -0
  83. package/types/org.jahia.services.render.d.ts +168 -0
  84. package/types/org.jahia.services.usermanager.d.ts +85 -0
  85. package/types/org.osgi.framework.d.ts +1004 -0
  86. package/types/server.d.ts +27 -0
  87. package/types/servercontext.d.ts +29 -0
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Will render the given React component server side and hydrate it in the browser to make it dynamic.
3
+ * Be careful, the component will not have access to the '@jahia/javascript-modules-library' library from the browser.
4
+ *
5
+ * @param {object} params The React component.
6
+ * @param {object} params.child The React component.
7
+ * @param {object} [params.props] The React component props, this props will be serialized/deserialized to be usable server and client side. The serialization and deserialization is done using JSON.stringify server side and JSON.parse in the browser. Please make sure that the props are serializable.
8
+ * @returns {JSX.Element} The component to be hydrated in the browser
9
+ */
10
+ export function HydrateInBrowser({ child: Child, props }: {
11
+ child: object;
12
+ props?: object;
13
+ }): JSX.Element;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Render a content node
3
+ * @param {object} props the properties for the render
4
+ * @param {object} [props.content] the content node to render
5
+ * @param {object} [props.node] the node to render
6
+ * @param {string} [props.path] the path to render
7
+ * @param {boolean} [props.editable] if the content should be editable
8
+ * @param {string} [props.advanceRenderingConfig] specifies if we should render a node or simply include a view. Acceptable values are : none, INCLUDE or OPTION
9
+ * @param {string} [props.templateType] the template type to use (html, json, ...)
10
+ * @param {string} [props.view] the name of the view variant to use
11
+ * @param {object} [props.parameters] the parameters to pass to the view
12
+ * @returns {JSX.Element} the rendered output of the view for the specified content
13
+ */
14
+ export function Render({ content, node, path, editable, advanceRenderingConfig, templateType, view, parameters }: {
15
+ content?: object;
16
+ node?: object;
17
+ path?: string;
18
+ editable?: boolean;
19
+ advanceRenderingConfig?: string;
20
+ templateType?: string;
21
+ view?: string;
22
+ parameters?: object;
23
+ }): JSX.Element;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Will render the given React component in the browser.
3
+ * Be careful, the component will not have access to the '@jahia/javascript-modules-library' library from the browser.
4
+ *
5
+ * @param {object} params The React component.
6
+ * @param {object} params.child The React component.
7
+ * @param {object} [params.props] The React component props, this props will be serialized/deserialized to be usable server and client side. The serialization and deserialization is done using JSON.stringify server side and JSON.parse in the browser. Please make sure that the props are serializable.
8
+ * @returns {JSX.Element} The component to be rendered in the browser
9
+ * */
10
+ export function RenderInBrowser({ child: Child, props }: {
11
+ child: object;
12
+ props?: object;
13
+ }): JSX.Element;
@@ -0,0 +1,3 @@
1
+ export * from "./Render";
2
+ export * from "./HydrateInBrowser";
3
+ export * from "./RenderInBrowser";
@@ -0,0 +1,8 @@
1
+ export default InBrowser;
2
+ declare function InBrowser({ child: Child, props, dataKey, preRender }: {
3
+ child: any;
4
+ props: any;
5
+ dataKey: any;
6
+ preRender: any;
7
+ }): React.JSX.Element;
8
+ import React from "react";
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @typedef {Object} JahiaComponent
3
+ * @property {string} [id] - The ID of the component (autogenerated but can be overridden)
4
+ * @property {string} name - The name of the component.
5
+ * @property {string} [displayName] - The display name of the component (in jahia's UI), optional.
6
+ * @property {"template"|"view"} componentType - The type of the component.
7
+ * @property {string} nodeType - The content node type the component applies to.
8
+ * @property {Record<string, string>} [properties] - Properties to add on the component, optional.
9
+ */
10
+ /**
11
+ * Using this function provides autocomplete on the jahiaComponent properties.
12
+ * @param {JahiaComponent} jahiaComponent - An object containing the Jahia component to define.
13
+ * @returns {JahiaComponent} The jahiaComponent object.
14
+ */
15
+ export function defineJahiaComponent(jahiaComponent: JahiaComponent): JahiaComponent;
16
+ export type JahiaComponent = {
17
+ /**
18
+ * - The ID of the component (autogenerated but can be overridden)
19
+ */
20
+ id?: string;
21
+ /**
22
+ * - The name of the component.
23
+ */
24
+ name: string;
25
+ /**
26
+ * - The display name of the component (in jahia's UI), optional.
27
+ */
28
+ displayName?: string;
29
+ /**
30
+ * - The type of the component.
31
+ */
32
+ componentType: "template" | "view";
33
+ /**
34
+ * - The content node type the component applies to.
35
+ */
36
+ nodeType: string;
37
+ /**
38
+ * - Properties to add on the component, optional.
39
+ */
40
+ properties?: Record<string, string>;
41
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./register";
2
+ export * from "./defineJahiaComponent";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Registers Jahia components into the global registry as views
3
+ * @param {object} jahiaComponents an object containing the jahia components to register
4
+ * @returns {void}
5
+ * TODO We will probably want to revisit this function once we handle global component registration in ticket https://jira.jahia.org/browse/BACKLOG-22400
6
+ */
7
+ export function registerJahiaComponents(jahiaComponents: object): void;
@@ -0,0 +1,4 @@
1
+ export * from "./useGQLQuery";
2
+ export * from "./useJCRQuery";
3
+ export * from "./useServerContext";
4
+ export * from "./useUrlBuilder";
@@ -0,0 +1,5 @@
1
+ export function useGQLQuery({ query, variables, operationName }: {
2
+ query: string;
3
+ variables: object;
4
+ operationName: string;
5
+ }): object;
@@ -0,0 +1,3 @@
1
+ export function useJCRQuery({ query }: {
2
+ query: string;
3
+ }): object;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Returns the current server context
3
+ * @returns {import('@jahia/javascript-modules-library').ServerContext} the server context
4
+ */
5
+ export function useServerContext(): import('@jahia/javascript-modules-library').ServerContext;
6
+ export function ServerContextProvider({ renderContext, currentResource, currentNode, mainNode, bundleKey, children }: {
7
+ renderContext: any;
8
+ currentResource: any;
9
+ currentNode: any;
10
+ mainNode: any;
11
+ bundleKey: any;
12
+ children: any;
13
+ }): React.JSX.Element;
14
+ import React from "react";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @typedef {Object} UrlBuilderType
3
+ * @property {function({assetPath: string, moduleName?: string, parameters?: object}): string} buildStaticUrl
4
+ * @property {function({nodePath: string, extension?: string, language?:string, mode?:string, parameters?: object}): string} buildNodeUrl
5
+ * @property {function({nodePath: string, extension?: string, language?:string, mode?:string, parameters?: object}): string} buildHtmlFragmentUrl
6
+ */
7
+ /**
8
+ * @returns {UrlBuilderType}
9
+ */
10
+ export function useUrlBuilder(): UrlBuilderType;
11
+ export type UrlBuilderType = {
12
+ buildStaticUrl: (arg0: {
13
+ assetPath: string;
14
+ moduleName?: string;
15
+ parameters?: object;
16
+ }) => string;
17
+ buildNodeUrl: (arg0: {
18
+ nodePath: string;
19
+ extension?: string;
20
+ language?: string;
21
+ mode?: string;
22
+ parameters?: object;
23
+ }) => string;
24
+ buildHtmlFragmentUrl: (arg0: {
25
+ nodePath: string;
26
+ extension?: string;
27
+ language?: string;
28
+ mode?: string;
29
+ parameters?: object;
30
+ }) => string;
31
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./components";
2
+ export * from "./framework";
3
+ export * from "./hooks";
4
+ export * from "./utils";
@@ -0,0 +1,2 @@
1
+ export * from "./jcr";
2
+ export * from "./urlBuilder";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns an array of child nodes of a given node.
3
+ * @param {import("org.jahia.services.content").JCRNodeWrapper} node - The node to get the child nodes from.
4
+ * @param {number} limit the maximum number of nodes to return (-1 to return all nodes, but be careful with this as it can be very slow and memory consuming, it's better to use a reasonable limit and use pagination if needed)
5
+ * @param {number} [offset=0] the offset to start from
6
+ * @param {function} [filter] - A function to filter the nodes to be returned.
7
+ * @returns {import("org.jahia.services.content").JCRNodeWrapper[]} An array of child nodes.
8
+ */
9
+ export function getChildNodes(node: import("org.jahia.services.content").JCRNodeWrapper, limit: number, offset?: number, filter?: Function): import("org.jahia.services.content").JCRNodeWrapper[];
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Returns a node from a path or identifier
3
+ * @param {object} props - The properties object containing either the node identifier or the node path.
4
+ * @param {string} [props.identifier] - The node identifier.
5
+ * @param {string} [props.path] - The node path.
6
+ * @param {import("org.jahia.services.content").JCRSessionWrapper} session - The JCR session.
7
+ * @returns {import("org.jahia.services.content").JCRNodeWrapper} The node.
8
+ */
9
+ export function getNodeFromPathOrId(props: {
10
+ identifier?: string;
11
+ path?: string;
12
+ }, session: import("org.jahia.services.content").JCRSessionWrapper): import("org.jahia.services.content").JCRNodeWrapper;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Extracts the properties from a node
3
+ * @param {import("org.jahia.services.content").JCRNodeWrapper} node the node on which to extract the properties
4
+ * @param {Array} props the name of the properties to extract
5
+ * @returns {Object} an object containing the property values
6
+ */
7
+ export function getNodeProps(node: import("org.jahia.services.content").JCRNodeWrapper, props: any[]): any;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Execute a JCR SQL2 query and return the result as an array of nodes
3
+ * @param {import("org.jahia.services.content").JCRSessionWrapper} session the JCR session to use
4
+ * @param {string} query the JCR SQL2 query to execute
5
+ * @param {number} limit the maximum number of nodes to return (-1 to return all nodes, but be careful with this as it can be very slow and memory consuming, it's better to use a reasonable limit and use pagination if needed)
6
+ * @param {number} [offset=0] the offset to start from
7
+ * @returns {import('org.jahia.services.content').JCRNodeWrapper[]} an array containing the nodes returned by the query
8
+ */
9
+ export function getNodesByJCRQuery(session: import("org.jahia.services.content").JCRSessionWrapper, query: string, limit: number, offset?: number): import('org.jahia.services.content').JCRNodeWrapper[];
@@ -0,0 +1,4 @@
1
+ export * from "./getChildNodes";
2
+ export * from "./getNodeFromPathOrId";
3
+ export * from "./getNodeProps";
4
+ export * from "./getNodesByJCRQuery";
@@ -0,0 +1 @@
1
+ export * from "./urlBuilder";
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Initialize the registry with default url builders
3
+ * @returns {void}
4
+ */
5
+ export function initUrlBuilder(): void;
6
+ /**
7
+ * Provide URL generation for contents/files
8
+ * If parameters are not valid, or if a node couldn't be found, it will log an warning and return '#'
9
+ * @param {object} props props used to build the URL
10
+ * @param {string} [props.value] the value to use to build the URL
11
+ * @param {string} [props.path] the path of the resource to build the URL for
12
+ * @param {object} [props.parameters] the parameters to append to the URL
13
+ * @param {string} [props.mode] the mode to use to build the URL
14
+ * @param {string} [props.language] the language to use to build the URL
15
+ * @param {string} [props.extension] the extension to use to build the URL
16
+ * @param {import('org.jahia.services.render').RenderContext} renderContext the current renderContext
17
+ * @param {import('org.jahia.services.render').Resource} currentResource the current resource
18
+ * @returns {string} the final URL
19
+ */
20
+ export function buildUrl(props: {
21
+ value?: string;
22
+ path?: string;
23
+ parameters?: object;
24
+ mode?: string;
25
+ language?: string;
26
+ extension?: string;
27
+ }, renderContext: import('org.jahia.services.render').RenderContext, currentResource: import('org.jahia.services.render').Resource): string;
@@ -0,0 +1,11 @@
1
+ import {Bundle} from 'org.osgi.framework';
2
+
3
+ /**
4
+ * The global declarations, where top-level objects are exposed to server-side scripts
5
+ */
6
+ declare global {
7
+ /**
8
+ * Exposed only during the server-side initial script registration process, not available during rendering
9
+ */
10
+ export const bundle : Bundle;
11
+ }
@@ -0,0 +1,19 @@
1
+ export * from "./core";
2
+ export * from "./nav";
3
+ export * from './globals';
4
+ export * from './java.io';
5
+ export * from './java.net';
6
+ export * from './java.security';
7
+ export * from './java.util';
8
+ export * from './javax.jcr';
9
+ export * from './javax.servlet';
10
+ export * from './javax.servlet.http';
11
+ export * from './org.jahia.modules.npm.modules.engine.js.server';
12
+ export * from './org.jahia.services.content';
13
+ export * from './org.jahia.services.content.decorator';
14
+ export * from './org.jahia.services.query';
15
+ export * from './org.jahia.services.render';
16
+ export * from './org.jahia.services.usermanager';
17
+ export * from './org.osgi.framework';
18
+ export * from './server';
19
+ export * from './servercontext';