@enonic-types/lib-context 0.1.0 → 7.11.0-B1

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/context.d.ts +73 -73
  2. package/package.json +1 -5
package/context.d.ts CHANGED
@@ -1,73 +1,73 @@
1
- /**
2
- * Built-in context functions.
3
- *
4
- * @example
5
- * var contextLib = require('/lib/xp/context');
6
- *
7
- * @module context
8
- */
9
- declare global {
10
- interface XpLibraries {
11
- '/lib/xp/context': typeof import('./context');
12
- }
13
- }
14
- export interface Principal {
15
- type: string;
16
- key: string;
17
- displayName: string;
18
- modifiedTime: string;
19
- }
20
- export interface User extends Principal {
21
- disabled?: boolean;
22
- email?: string;
23
- login?: string;
24
- idProvider: string;
25
- profile?: Record<string, unknown>;
26
- }
27
- export interface AuthInfo {
28
- user?: User | null;
29
- principals?: string[] | null;
30
- }
31
- export declare type ContextAttributes = Record<string, number | string | boolean | Record<string, unknown>>;
32
- export interface Context {
33
- branch: string;
34
- repository: string;
35
- authInfo?: AuthInfo;
36
- attributes: ContextAttributes;
37
- }
38
- export interface ContextUserParams {
39
- login: string;
40
- idProvider?: string;
41
- }
42
- export interface ContextParams {
43
- repository?: string;
44
- branch?: string;
45
- user?: ContextUserParams;
46
- principals?: string[];
47
- attributes?: ContextAttributes;
48
- }
49
- /**
50
- * Runs a function within a specified context.
51
- *
52
- * @example-ref examples/context/run.js
53
- *
54
- * @param {object} context JSON parameters.
55
- * @param {string} [context.repository] Repository to execute the callback in. Default is the current repository set in portal.
56
- * @param {string} [context.branch] Name of the branch to execute the callback in. Default is the current branch set in portal.
57
- * @param {object} [context.user] User to execute the callback with. Default is the current user.
58
- * @param {string} context.user.login Login of the user.
59
- * @param {string} [context.user.idProvider] Id provider containing the user. By default, all the id providers will be used.
60
- * @param {array} [context.principals] Additional principals to execute the callback with.
61
- * @param {object} [context.attributes] Additional Context attributes.
62
- * @param {function} callback Function to execute.
63
- * @returns {object} Result of the function execution.
64
- */
65
- export declare function run<T>(context: ContextParams, callback: () => T): T;
66
- /**
67
- * Returns the current context.
68
- *
69
- * @example-ref examples/context/get.js
70
- *
71
- * @returns {object} Return the current context as JSON object.
72
- */
73
- export declare function get(): Context;
1
+ /**
2
+ * Built-in context functions.
3
+ *
4
+ * @example
5
+ * var contextLib = require('/lib/xp/context');
6
+ *
7
+ * @module context
8
+ */
9
+ declare global {
10
+ interface XpLibraries {
11
+ '/lib/xp/context': typeof import('./context');
12
+ }
13
+ }
14
+ export interface Principal {
15
+ type: string;
16
+ key: string;
17
+ displayName: string;
18
+ modifiedTime: string;
19
+ }
20
+ export interface User extends Principal {
21
+ disabled?: boolean;
22
+ email?: string;
23
+ login?: string;
24
+ idProvider: string;
25
+ profile?: Record<string, unknown>;
26
+ }
27
+ export interface AuthInfo {
28
+ user?: User | null;
29
+ principals?: string[] | null;
30
+ }
31
+ export declare type ContextAttributes = Record<string, number | string | boolean | Record<string, unknown>>;
32
+ export interface Context {
33
+ branch: string;
34
+ repository: string;
35
+ authInfo?: AuthInfo;
36
+ attributes: ContextAttributes;
37
+ }
38
+ export interface ContextUserParams {
39
+ login: string;
40
+ idProvider?: string;
41
+ }
42
+ export interface ContextParams {
43
+ repository?: string;
44
+ branch?: string;
45
+ user?: ContextUserParams;
46
+ principals?: string[];
47
+ attributes?: ContextAttributes;
48
+ }
49
+ /**
50
+ * Runs a function within a specified context.
51
+ *
52
+ * @example-ref examples/context/run.js
53
+ *
54
+ * @param {object} context JSON parameters.
55
+ * @param {string} [context.repository] Repository to execute the callback in. Default is the current repository set in portal.
56
+ * @param {string} [context.branch] Name of the branch to execute the callback in. Default is the current branch set in portal.
57
+ * @param {object} [context.user] User to execute the callback with. Default is the current user.
58
+ * @param {string} context.user.login Login of the user.
59
+ * @param {string} [context.user.idProvider] Id provider containing the user. By default, all the id providers will be used.
60
+ * @param {array} [context.principals] Additional principals to execute the callback with.
61
+ * @param {object} [context.attributes] Additional Context attributes.
62
+ * @param {function} callback Function to execute.
63
+ * @returns {object} Result of the function execution.
64
+ */
65
+ export declare function run<T>(context: ContextParams, callback: () => T): T;
66
+ /**
67
+ * Returns the current context.
68
+ *
69
+ * @example-ref examples/context/get.js
70
+ *
71
+ * @returns {object} Return the current context as JSON object.
72
+ */
73
+ export declare function get(): Context;
package/package.json CHANGED
@@ -1,15 +1,11 @@
1
1
  {
2
2
  "name": "@enonic-types/lib-context",
3
- "version": "0.1.0",
3
+ "version": "7.11.0-B1",
4
4
  "description": "Type definitions for lib-context.",
5
5
  "types": "context.d.ts",
6
6
  "files": [
7
7
  "context.d.ts"
8
8
  ],
9
- "scripts": {
10
- "pre": "npm run --prefix ../ pre",
11
- "packlist": "npx npm-packlist"
12
- },
13
9
  "repository": {
14
10
  "type": "git",
15
11
  "url": "git+https://github.com/enonic/xp.git#master"