@enonic-types/global 7.14.4-RC1 → 7.15.0-A1

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 (2) hide show
  1. package/global.d.ts +76 -186
  2. package/package.json +4 -2
package/global.d.ts CHANGED
@@ -1,210 +1,100 @@
1
- interface XpLibraries {}
1
+ import type {
2
+ App,
3
+ DoubleUnderscore,
4
+ Log,
5
+ Resolve,
6
+ XpRequire,
7
+ } from '@enonic-types/core';
2
8
 
3
- interface XpBeans {}
4
9
 
5
- /**
6
- * The globally available app object holds information about the contextual application.
7
- * @example
8
- * var nameVersion = app.name + ' v' + app.version;
9
- *
10
- * @global
11
- * @namespace
12
- */
13
- declare const app: {
10
+ declare global {
14
11
  /**
15
- * The name of the application.
12
+ * The globally available app object holds information about the contextual application.
13
+ * @example
14
+ * var nameVersion = app.name + ' v' + app.version;
16
15
  *
17
- * @type string
16
+ * @global
17
+ * @namespace
18
18
  */
19
- name: string;
19
+ declare const app: App;
20
+
20
21
  /**
21
- * Version of the application.
22
+ * Logging functions.
22
23
  *
23
- * @type string
24
- */
25
- version: string;
26
- /**
27
- * Values from the application’s configuration file.
28
- * This can be set using $XP_HOME/config/<app.name>.cfg.
29
- * Every time the configuration is changed the app is restarted.
24
+ * @example
25
+ * // Log with simple message
26
+ * log.debug('My log message');
30
27
  *
31
- * @type Object
32
- */
33
- config: Record<string, string | undefined>;
34
- };
35
-
36
- /**
37
- * Logging functions.
38
- *
39
- * @example
40
- * // Log with simple message
41
- * log.debug('My log message');
42
- *
43
- * @example
44
- * // Log with placeholders
45
- * log.info('My %s message with %s', 'log', 'placeholders');
46
- *
47
- * @example
48
- * // Log a JSON object
49
- * log.warning('My JSON: %s', {a: 1});
50
- *
51
- * @example
52
- * // Log JSON object using string
53
- * log.error('My JSON: %s', JSON.stringify({a: 1}, null, 2));
54
- *
55
- * @global
56
- * @namespace
57
- */
58
- declare const log: {
59
- /**
60
- * Log debug message.
28
+ * @example
29
+ * // Log with placeholders
30
+ * log.info('My %s message with %s', 'log', 'placeholders');
61
31
  *
62
- * @param {Array} args... logging arguments.
63
- */
64
- debug: (...args: unknown[]) => void;
65
-
66
- /**
67
- * Log info message.
32
+ * @example
33
+ * // Log a JSON object
34
+ * log.warning('My JSON: %s', {a: 1});
68
35
  *
69
- * @param {Array} args... logging arguments.
70
- */
71
- info: (...args: unknown[]) => void;
72
-
73
- /**
74
- * Log warning message.
36
+ * @example
37
+ * // Log JSON object using string
38
+ * log.error('My JSON: %s', JSON.stringify({a: 1}, null, 2));
75
39
  *
76
- * @param {Array} args... logging arguments.
40
+ * @global
41
+ * @namespace
77
42
  */
78
- warning: (...args: unknown[]) => void;
43
+ declare const log: Log;
79
44
 
80
45
  /**
81
- * Log error message.
46
+ * Javascript to Java bridge functions.
47
+ *
48
+ * @example
49
+ * var bean = __.newBean('com.enonic.xp.MyJavaUtils');
50
+ *
51
+ * @example
52
+ * return __.toNativeObject(bean.findArray(arrayName));
82
53
  *
83
- * @param {Array} args... logging arguments.
54
+ * @global
55
+ * @namespace
84
56
  */
85
- error: (...args: unknown[]) => void;
86
- };
87
-
88
- declare interface ScriptValue {
89
- isArray(): boolean;
90
-
91
- isObject(): boolean;
92
-
93
- isValue(): boolean;
94
-
95
- isFunction(): boolean;
96
-
97
- getValue(): unknown;
98
-
99
- getKeys(): string[];
100
-
101
- hasMember(key: string): boolean;
102
-
103
- getMember(key: string): ScriptValue;
57
+ declare const __: DoubleUnderscore;
104
58
 
105
- getArray(): ScriptValue[];
106
-
107
- getMap(): Record<string, unknown>;
108
-
109
- getList(): object[];
110
- }
111
-
112
- type NewBean = <T = unknown, Bean extends keyof XpBeans | string = string>(bean: Bean) =>
113
- Bean extends keyof XpBeans ? XpBeans[Bean] : T;
114
-
115
- /**
116
- * Javascript to Java bridge functions.
117
- *
118
- * @example
119
- * var bean = __.newBean('com.enonic.xp.MyJavaUtils');
120
- *
121
- * @example
122
- * return __.toNativeObject(bean.findArray(arrayName));
123
- *
124
- * @global
125
- * @namespace
126
- */
127
- declare const __: {
128
- /**
129
- * Creates a new JavaScript bean that wraps the given Java class and makes its methods available to be called from JavaScript.
130
- */
131
- newBean: NewBean;
132
- /**
133
- * Converts arrays or complex Java objects to JSON.
134
- * @param value Value to convert
135
- */
136
- toNativeObject: <T = unknown>(value: T) => T;
137
- /**
138
- * Converts JSON to a Java Map structure that can be used as parameters to a Java method on a bean created with newBean.
139
- * @param value Value to convert
140
- */
141
- toScriptValue: <T = object>(value: T) => ScriptValue;
142
59
  /**
143
- * Add a disposer that is called when the app is stopped.
144
- * @param callback Function to call
145
- */
146
- disposer: (callback: (...args: unknown[]) => unknown) => void;
147
- /**
148
- * Converts a JavaScript variable that is undefined to a Java <code>null</code> object.
149
- * If the JavaScript variable is defined, it is returned as is.
150
- * @param value Value to convert
60
+ * This globally available function will load a JavaScript file and return the exports as objects.
61
+ * The function implements parts of the `CommonJS Modules Specification`.
62
+ *
63
+ * @example
64
+ * // Require relative to this
65
+ * var other = require('./other.js');
66
+ *
67
+ * @example
68
+ * // Require absolute
69
+ * var other = require('/path/to/other.js');
70
+ *
71
+ * @example
72
+ * // Require without .js extension
73
+ * var other = require('./other');
74
+ *
75
+ * @param {string} path Path for javascript file (relative or absolute and .js ending is optional).
76
+ * @returns {object} Exports from loaded javascript.
77
+ * @global
151
78
  */
152
- nullOrValue: <T = object>(value: T) => T | null | undefined;
79
+ declare const require: XpRequire;
153
80
 
154
81
  /**
155
- * Doc registerMock.
82
+ * Resolves a path to another file. Can use relative or absolute path.
156
83
  *
157
- * @param name Name of mock.
158
- * @param value Value to register.
84
+ * @example
85
+ * // Resolve relative to this
86
+ * var path = resolve('./other.html');
87
+ *
88
+ * @example
89
+ * // Resolve absolute
90
+ * var path = resolve('/path/to/other.html');
91
+ *
92
+ * @param {string} path Path to resolve.
93
+ * @returns {*} Reference to an object.
94
+ * @global
159
95
  */
160
- registerMock: (name: string, value: object) => void
161
- };
162
-
163
- declare type XpRequire = <Key extends keyof XpLibraries | string = string>(path: Key) =>
164
- Key extends keyof XpLibraries ? XpLibraries[Key] : unknown;
165
-
166
- /**
167
- * This globally available function will load a JavaScript file and return the exports as objects.
168
- * The function implements parts of the `CommonJS Modules Specification`.
169
- *
170
- * @example
171
- * // Require relative to this
172
- * var other = require('./other.js');
173
- *
174
- * @example
175
- * // Require absolute
176
- * var other = require('/path/to/other.js');
177
- *
178
- * @example
179
- * // Require without .js extension
180
- * var other = require('./other');
181
- *
182
- * @param {string} path Path for javascript file (relative or absolute and .js ending is optional).
183
- * @returns {object} Exports from loaded javascript.
184
- * @global
185
- */
186
- declare const require: XpRequire;
96
+ declare const resolve: Resolve;
97
+ }
187
98
 
188
- /**
189
- * Resolves a path to another file. Can use relative or absolute path.
190
- *
191
- * @example
192
- * // Resolve relative to this
193
- * var path = resolve('./other.html');
194
- *
195
- * @example
196
- * // Resolve absolute
197
- * var path = resolve('/path/to/other.html');
198
- *
199
- * @param {string} path Path to resolve.
200
- * @returns {*} Reference to an object.
201
- * @global
202
- */
203
- declare const resolve: (path: string) => {
204
- getApplicationKey(): string;
205
- getPath(): string;
206
- getUri(): string;
207
- isRoot(): boolean;
208
- getName(): string;
209
- getExtension(): string;
210
- };
99
+ // Making sure the file is a module
100
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enonic-types/global",
3
- "version": "7.14.4-RC1",
3
+ "version": "7.15.0-A1",
4
4
  "description": "Global variables and functions type definition.",
5
5
  "types": "global.d.ts",
6
6
  "files": [
@@ -26,7 +26,9 @@
26
26
  "url": "https://github.com/enonic/xp/issues"
27
27
  },
28
28
  "homepage": "https://github.com/enonic/xp/tree/master#readme",
29
- "dependencies": {},
29
+ "dependencies": {
30
+ "@enonic-types/core": "7.15.0-A1"
31
+ },
30
32
  "publishConfig": {
31
33
  "access": "public"
32
34
  }