@imbricate/core 1.30.0 → 1.32.0

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.
@@ -29,11 +29,9 @@ class ImbricateCapabilityBuilder {
29
29
  return this;
30
30
  }
31
31
  build() {
32
- return Object.keys(this._capabilities).map((key) => {
33
- return {
34
- [key]: this._capabilities[key],
35
- };
36
- });
32
+ return Object.keys(this._capabilities).reduce((previous, current) => {
33
+ return Object.assign(Object.assign({}, previous), { [current]: this._capabilities[current] });
34
+ }, {});
37
35
  }
38
36
  }
39
37
  exports.ImbricateCapabilityBuilder = ImbricateCapabilityBuilder;
@@ -3,5 +3,5 @@
3
3
  * @namespace Capability
4
4
  * @description Create
5
5
  */
6
- import type { ImbricateCapability, ImbricateCapabilityRecord } from "./definition";
7
- export declare const createImbricateCapabilityRecord: <T extends string>(list: T[], initialValue: ImbricateCapability) => ImbricateCapabilityRecord<T>;
6
+ import type { ImbricateCapability, ImbricateCapabilityKey, ImbricateCapabilityRecord } from "./definition";
7
+ export declare const createImbricateCapabilityRecord: <T extends ImbricateCapabilityKey>(list: T[], initialValue: ImbricateCapability) => ImbricateCapabilityRecord<T>;
@@ -11,9 +11,6 @@ const validateImbricateCapability = (capabilities, capability) => {
11
11
  if (!capabilities) {
12
12
  return false;
13
13
  }
14
- if (!Array.isArray(capabilities)) {
15
- return false;
16
- }
17
14
  const capabilityValue = capabilities[capability];
18
15
  if (!capabilityValue) {
19
16
  return false;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Execute
4
+ * @description Definition
5
+ */
6
+ export declare enum IMBRICATE_EXECUTABLE_VARIANT {
7
+ JAVASCRIPT_NODE = "javascript-node",
8
+ TYPESCRIPT_NODE = "typescript-node"
9
+ }
10
+ export declare const IMBRICATE_SCRIPT_VARIANT_LIST: IMBRICATE_EXECUTABLE_VARIANT[];
11
+ export declare enum IMBRICATE_EXECUTE_RESULT_CODE {
12
+ NOT_SUPPORT = "NOT_SUPPORT",
13
+ SUCCESS = "SUCCESS",
14
+ ERROR = "ERROR",
15
+ EXCEPTION = "EXCEPTION",
16
+ TIMEOUT = "TIMEOUT"
17
+ }
18
+ export type ImbricateExecuteResult = {
19
+ readonly code: IMBRICATE_EXECUTE_RESULT_CODE;
20
+ };
21
+ export type ImbricateExecuteParameters = Record<string, any>;
22
+ export type ImbricateExecuteEnvironment = Record<string, any>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Execute
5
+ * @description Definition
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.IMBRICATE_EXECUTE_RESULT_CODE = exports.IMBRICATE_SCRIPT_VARIANT_LIST = exports.IMBRICATE_EXECUTABLE_VARIANT = void 0;
9
+ var IMBRICATE_EXECUTABLE_VARIANT;
10
+ (function (IMBRICATE_EXECUTABLE_VARIANT) {
11
+ IMBRICATE_EXECUTABLE_VARIANT["JAVASCRIPT_NODE"] = "javascript-node";
12
+ IMBRICATE_EXECUTABLE_VARIANT["TYPESCRIPT_NODE"] = "typescript-node";
13
+ })(IMBRICATE_EXECUTABLE_VARIANT || (exports.IMBRICATE_EXECUTABLE_VARIANT = IMBRICATE_EXECUTABLE_VARIANT = {}));
14
+ exports.IMBRICATE_SCRIPT_VARIANT_LIST = [
15
+ IMBRICATE_EXECUTABLE_VARIANT.JAVASCRIPT_NODE,
16
+ IMBRICATE_EXECUTABLE_VARIANT.TYPESCRIPT_NODE,
17
+ ];
18
+ var IMBRICATE_EXECUTE_RESULT_CODE;
19
+ (function (IMBRICATE_EXECUTE_RESULT_CODE) {
20
+ IMBRICATE_EXECUTE_RESULT_CODE["NOT_SUPPORT"] = "NOT_SUPPORT";
21
+ IMBRICATE_EXECUTE_RESULT_CODE["SUCCESS"] = "SUCCESS";
22
+ IMBRICATE_EXECUTE_RESULT_CODE["ERROR"] = "ERROR";
23
+ IMBRICATE_EXECUTE_RESULT_CODE["EXCEPTION"] = "EXCEPTION";
24
+ IMBRICATE_EXECUTE_RESULT_CODE["TIMEOUT"] = "TIMEOUT";
25
+ })(IMBRICATE_EXECUTE_RESULT_CODE || (exports.IMBRICATE_EXECUTE_RESULT_CODE = IMBRICATE_EXECUTE_RESULT_CODE = {}));
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @author WMXPY
3
+ * @namespace Execute
4
+ * @description Extension
5
+ */
6
+ import { IMBRICATE_EXECUTABLE_VARIANT } from "./definition";
7
+ export declare const getImbricateExecutableExtension: (variant: IMBRICATE_EXECUTABLE_VARIANT, withDot?: boolean) => string;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * @author WMXPY
4
+ * @namespace Execute
5
+ * @description Extension
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.getImbricateExecutableExtension = void 0;
9
+ const definition_1 = require("./definition");
10
+ const fixExtension = (extension, withDot) => {
11
+ if (withDot) {
12
+ return `.${extension}`;
13
+ }
14
+ return extension;
15
+ };
16
+ const getImbricateExecutableExtension = (variant, withDot = true) => {
17
+ switch (variant) {
18
+ case definition_1.IMBRICATE_EXECUTABLE_VARIANT.JAVASCRIPT_NODE: return fixExtension("js", withDot);
19
+ case definition_1.IMBRICATE_EXECUTABLE_VARIANT.TYPESCRIPT_NODE: return fixExtension("ts", withDot);
20
+ }
21
+ return fixExtension("unknown", withDot);
22
+ };
23
+ exports.getImbricateExecutableExtension = getImbricateExecutableExtension;
package/index.d.ts CHANGED
@@ -20,6 +20,8 @@ export * from "./definition/listable";
20
20
  export * from "./definition/promise";
21
21
  export * from "./error/imbricate-error";
22
22
  export * from "./error/not-implemented";
23
+ export * from "./execute/definition";
24
+ export * from "./execute/extension";
23
25
  export * from "./function/base";
24
26
  export * from "./function/definition";
25
27
  export * from "./function/interface";
@@ -32,12 +34,6 @@ export * from "./page/interface";
32
34
  export * from "./query/definition";
33
35
  export * from "./query/page";
34
36
  export * from "./query/script";
35
- export * from "./sandbox/definition/config";
36
- export * from "./sandbox/definition/environment";
37
- export * from "./sandbox/definition/implementation";
38
- export * from "./sandbox/feature/builder";
39
- export * from "./sandbox/feature/feature";
40
- export * from "./sandbox/sandbox";
41
37
  export * from "./script-manager/base";
42
38
  export * from "./script-manager/definition";
43
39
  export * from "./script-manager/interface";
package/index.js CHANGED
@@ -36,6 +36,8 @@ __exportStar(require("./definition/listable"), exports);
36
36
  __exportStar(require("./definition/promise"), exports);
37
37
  __exportStar(require("./error/imbricate-error"), exports);
38
38
  __exportStar(require("./error/not-implemented"), exports);
39
+ __exportStar(require("./execute/definition"), exports);
40
+ __exportStar(require("./execute/extension"), exports);
39
41
  __exportStar(require("./function/base"), exports);
40
42
  __exportStar(require("./function/definition"), exports);
41
43
  __exportStar(require("./function/interface"), exports);
@@ -48,12 +50,6 @@ __exportStar(require("./page/interface"), exports);
48
50
  __exportStar(require("./query/definition"), exports);
49
51
  __exportStar(require("./query/page"), exports);
50
52
  __exportStar(require("./query/script"), exports);
51
- __exportStar(require("./sandbox/definition/config"), exports);
52
- __exportStar(require("./sandbox/definition/environment"), exports);
53
- __exportStar(require("./sandbox/definition/implementation"), exports);
54
- __exportStar(require("./sandbox/feature/builder"), exports);
55
- __exportStar(require("./sandbox/feature/feature"), exports);
56
- __exportStar(require("./sandbox/sandbox"), exports);
57
53
  __exportStar(require("./script-manager/base"), exports);
58
54
  __exportStar(require("./script-manager/definition"), exports);
59
55
  __exportStar(require("./script-manager/interface"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imbricate/core",
3
3
  "main": "index.js",
4
- "version": "1.30.0",
4
+ "version": "1.32.0",
5
5
  "description": "Imbricate Core, Notebook for Engineers",
6
6
  "repository": {
7
7
  "type": "git",
@@ -17,15 +17,5 @@
17
17
  "bugs": {
18
18
  "url": "https://github.com/Imbricate/Imbricate/issues"
19
19
  },
20
- "homepage": "https://imbricate.io",
21
- "dependencies": {
22
- "@sudoo/marked-mixin-date": "1.0.0",
23
- "@sudoo/marked-mixin-json": "1.0.0",
24
- "@sudoo/marked-mixin-math": "1.4.0",
25
- "@sudoo/marked-mixin-object": "1.3.0",
26
- "@sudoo/marked-mixin-parse": "1.0.0"
27
- },
28
- "peerDependencies": {
29
- "@sudoo/marked": "*"
30
- }
20
+ "homepage": "https://imbricate.io"
31
21
  }
@@ -8,10 +8,14 @@ import { IMBRICATE_SEARCH_RESULT_TYPE, ImbricateSearchResult, ImbricateSearchSni
8
8
  export type ImbricatePageAttributes = Record<string, string>;
9
9
  export type ImbricatePageSearchResult = ImbricateSearchResult<IMBRICATE_SEARCH_RESULT_TYPE.PAGE>;
10
10
  export type ImbricatePageSearchSnippet = ImbricateSearchSnippet<IMBRICATE_SEARCH_RESULT_TYPE.PAGE>;
11
+ export declare enum IMBRICATE_PAGE_VARIANT {
12
+ MARKDOWN = "markdown"
13
+ }
11
14
  export type ImbricatePageSnapshot = {
12
15
  readonly title: string;
13
16
  readonly directories: string[];
14
17
  readonly identifier: string;
18
+ readonly variant: IMBRICATE_PAGE_VARIANT;
15
19
  };
16
20
  export type ImbricatePageHistoryRecord = {
17
21
  readonly updatedAt: Date;
@@ -5,7 +5,11 @@
5
5
  * @description Definition
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.ImbricatePageCapabilityList = exports.IMBRICATE_PAGE_CAPABILITY_KEY = void 0;
8
+ exports.ImbricatePageCapabilityList = exports.IMBRICATE_PAGE_CAPABILITY_KEY = exports.IMBRICATE_PAGE_VARIANT = void 0;
9
+ var IMBRICATE_PAGE_VARIANT;
10
+ (function (IMBRICATE_PAGE_VARIANT) {
11
+ IMBRICATE_PAGE_VARIANT["MARKDOWN"] = "markdown";
12
+ })(IMBRICATE_PAGE_VARIANT || (exports.IMBRICATE_PAGE_VARIANT = IMBRICATE_PAGE_VARIANT = {}));
9
13
  var IMBRICATE_PAGE_CAPABILITY_KEY;
10
14
  (function (IMBRICATE_PAGE_CAPABILITY_KEY) {
11
15
  IMBRICATE_PAGE_CAPABILITY_KEY["READ"] = "imbricate.page.read";
package/script/base.d.ts CHANGED
@@ -3,12 +3,10 @@
3
3
  * @namespace Script
4
4
  * @description Base
5
5
  */
6
- import type { MarkedResult } from "@sudoo/marked";
7
6
  import { ImbricateCapabilityBuilder } from "../capability/builder";
8
7
  import { ImbricateCapability } from "../capability/definition";
9
8
  import type { PromiseOr } from "../definition/promise";
10
- import type { SandboxExecuteConfig, SandboxExecuteParameter } from "../sandbox/definition/config";
11
- import type { SandboxFeature } from "../sandbox/feature/feature";
9
+ import { ImbricateExecuteEnvironment, ImbricateExecuteParameters, ImbricateExecuteResult } from "../execute/definition";
12
10
  import { IMBRICATE_SCRIPT_CAPABILITY_KEY, ImbricateScriptAttributes, ImbricateScriptCapability, ImbricateScriptHistoryRecord } from "./definition";
13
11
  import type { IImbricateScript } from "./interface";
14
12
  export declare abstract class ImbricateScriptBase implements IImbricateScript {
@@ -31,5 +29,5 @@ export declare abstract class ImbricateScriptBase implements IImbricateScript {
31
29
  refreshUpdatedAt(_updatedAt: Date): PromiseOr<void>;
32
30
  refreshDigest(_digest: string): PromiseOr<void>;
33
31
  addHistoryRecord(_record: ImbricateScriptHistoryRecord): PromiseOr<void>;
34
- execute(_features: SandboxFeature[], _config: SandboxExecuteConfig, _parameter: SandboxExecuteParameter): PromiseOr<MarkedResult>;
32
+ execute(_parameters: ImbricateExecuteParameters, _environment: ImbricateExecuteEnvironment): PromiseOr<ImbricateExecuteResult>;
35
33
  }
package/script/base.js CHANGED
@@ -44,7 +44,7 @@ class ImbricateScriptBase {
44
44
  addHistoryRecord(_record) {
45
45
  throw not_implemented_1.ImbricateNotImplemented.create("AddHistoryRecord", definition_2.IMBRICATE_SCRIPT_CAPABILITY_KEY.UPDATE_HISTORY_RECORD);
46
46
  }
47
- execute(_features, _config, _parameter) {
47
+ execute(_parameters, _environment) {
48
48
  throw not_implemented_1.ImbricateNotImplemented.create("Execute", definition_2.IMBRICATE_SCRIPT_CAPABILITY_KEY.EXECUTE);
49
49
  }
50
50
  }
@@ -4,6 +4,7 @@
4
4
  * @description Definition
5
5
  */
6
6
  import { ImbricateCapability } from "../capability/definition";
7
+ import { IMBRICATE_EXECUTABLE_VARIANT } from "../execute/definition";
7
8
  import { IMBRICATE_SEARCH_RESULT_TYPE, ImbricateSearchResult, ImbricateSearchSnippet } from "../search/snippet";
8
9
  export type ImbricateScriptAttributes = Record<string, string>;
9
10
  export type ImbricateScriptSearchResult = ImbricateSearchResult<IMBRICATE_SEARCH_RESULT_TYPE.SCRIPT>;
@@ -11,6 +12,7 @@ export type ImbricateScriptSearchSnippet = ImbricateSearchSnippet<IMBRICATE_SEAR
11
12
  export type ImbricateScriptSnapshot = {
12
13
  readonly scriptName: string;
13
14
  readonly identifier: string;
15
+ readonly variant: IMBRICATE_EXECUTABLE_VARIANT;
14
16
  };
15
17
  export type ImbricateScriptHistoryRecord = {
16
18
  readonly updatedAt: Date;
@@ -3,11 +3,9 @@
3
3
  * @namespace Script
4
4
  * @description Interface
5
5
  */
6
- import { MarkedResult } from "@sudoo/marked";
7
6
  import { PromiseOr } from "../definition/promise";
8
- import { SandboxExecuteConfig, SandboxExecuteParameter } from "../sandbox/definition/config";
9
- import { SandboxFeature } from "../sandbox/feature/feature";
10
7
  import { ImbricateScriptAttributes, ImbricateScriptCapability, ImbricateScriptHistoryRecord } from "./definition";
8
+ import { ImbricateExecuteEnvironment, ImbricateExecuteParameters, ImbricateExecuteResult } from "../execute/definition";
11
9
  export interface IImbricateScript {
12
10
  readonly scriptName: string;
13
11
  readonly identifier: string;
@@ -25,5 +23,5 @@ export interface IImbricateScript {
25
23
  refreshUpdatedAt(updatedAt: Date): PromiseOr<void>;
26
24
  refreshDigest(digest: string): PromiseOr<void>;
27
25
  addHistoryRecord(record: ImbricateScriptHistoryRecord): PromiseOr<void>;
28
- execute(features: SandboxFeature[], config: SandboxExecuteConfig, parameter: SandboxExecuteParameter): PromiseOr<MarkedResult>;
26
+ execute(parameters: ImbricateExecuteParameters, environment: ImbricateExecuteEnvironment): PromiseOr<ImbricateExecuteResult>;
29
27
  }
@@ -3,15 +3,13 @@
3
3
  * @namespace ScriptManager
4
4
  * @description Base
5
5
  */
6
- import { MarkedResult } from "@sudoo/marked";
7
6
  import { ImbricateCapabilityBuilder } from "../capability/builder";
8
7
  import { ImbricateCapability } from "../capability/definition";
9
8
  import type { PromiseOr } from "../definition/promise";
9
+ import { IMBRICATE_EXECUTABLE_VARIANT, ImbricateExecuteEnvironment, ImbricateExecuteParameters, ImbricateExecuteResult } from "../execute/definition";
10
10
  import { ImbricateScriptQuery, ImbricateScriptQueryConfig, ImbricateSearchScriptConfig } from "../query/script";
11
- import { SandboxExecuteConfig, SandboxExecuteParameter } from "../sandbox/definition/config";
12
- import { SandboxFeature } from "../sandbox/feature/feature";
13
11
  import { IImbricateScriptManager } from "../script-manager/interface";
14
- import { ImbricateScriptMetadata, ImbricateScriptSnapshot } from "../script/definition";
12
+ import { ImbricateScriptMetadata, ImbricateScriptSearchResult, ImbricateScriptSnapshot } from "../script/definition";
15
13
  import { IImbricateScript } from "../script/interface";
16
14
  import { IMBRICATE_SCRIPT_MANAGER_CAPABILITY_KEY, ImbricateScriptManagerCapability } from "./definition";
17
15
  export declare abstract class ImbricateScriptManagerBase implements IImbricateScriptManager {
@@ -26,7 +24,7 @@ export declare abstract class ImbricateScriptManagerBase implements IImbricateSc
26
24
  hasScript(_scriptName: string): PromiseOr<boolean>;
27
25
  getScript(_identifier: string): PromiseOr<IImbricateScript | null>;
28
26
  listScripts(): PromiseOr<ImbricateScriptSnapshot[]>;
29
- searchScripts(_keyword: string, _config: ImbricateSearchScriptConfig): PromiseOr<any[]>;
27
+ searchScripts(_keyword: string, _config: ImbricateSearchScriptConfig): PromiseOr<ImbricateScriptSearchResult[]>;
30
28
  queryScripts(_query: ImbricateScriptQuery, _config: ImbricateScriptQueryConfig): PromiseOr<IImbricateScript[]>;
31
- executeScriptSnippet(_snippet: string, _features: SandboxFeature[], _config: SandboxExecuteConfig, _parameter: SandboxExecuteParameter): PromiseOr<MarkedResult>;
29
+ executeScriptSnippet(_snippet: string, _variant: IMBRICATE_EXECUTABLE_VARIANT, _parameters: ImbricateExecuteParameters, _environment: ImbricateExecuteEnvironment): PromiseOr<ImbricateExecuteResult>;
32
30
  }
@@ -47,7 +47,7 @@ class ImbricateScriptManagerBase {
47
47
  queryScripts(_query, _config) {
48
48
  throw not_implemented_1.ImbricateNotImplemented.create("QueryScripts", definition_2.IMBRICATE_SCRIPT_MANAGER_CAPABILITY_KEY.LIST_SCRIPTS);
49
49
  }
50
- executeScriptSnippet(_snippet, _features, _config, _parameter) {
50
+ executeScriptSnippet(_snippet, _variant, _parameters, _environment) {
51
51
  throw not_implemented_1.ImbricateNotImplemented.create("ExecuteScriptSnippet", definition_2.IMBRICATE_SCRIPT_MANAGER_CAPABILITY_KEY.EXECUTE_SCRIPT_SNIPPET);
52
52
  }
53
53
  }
@@ -3,11 +3,9 @@
3
3
  * @namespace ScriptManager
4
4
  * @description Interface
5
5
  */
6
- import { MarkedResult } from "@sudoo/marked";
7
6
  import { PromiseOr } from "../definition/promise";
7
+ import { IMBRICATE_EXECUTABLE_VARIANT, ImbricateExecuteEnvironment, ImbricateExecuteParameters, ImbricateExecuteResult } from "../execute/definition";
8
8
  import { ImbricateScriptQuery, ImbricateScriptQueryConfig, ImbricateSearchScriptConfig } from "../query/script";
9
- import { SandboxExecuteConfig, SandboxExecuteParameter } from "../sandbox/definition/config";
10
- import { SandboxFeature } from "../sandbox/feature/feature";
11
9
  import { ImbricateScriptMetadata, ImbricateScriptSearchResult, ImbricateScriptSnapshot } from "../script/definition";
12
10
  import { IImbricateScript } from "../script/interface";
13
11
  import { ImbricateScriptManagerCapability } from "./definition";
@@ -34,5 +32,5 @@ export interface IImbricateScriptManager {
34
32
  listScripts(): PromiseOr<ImbricateScriptSnapshot[]>;
35
33
  searchScripts(keyword: string, config: ImbricateSearchScriptConfig): PromiseOr<ImbricateScriptSearchResult[]>;
36
34
  queryScripts(query: ImbricateScriptQuery, config: ImbricateScriptQueryConfig): PromiseOr<IImbricateScript[]>;
37
- executeScriptSnippet(snippet: string, features: SandboxFeature[], config: SandboxExecuteConfig, parameter: SandboxExecuteParameter): PromiseOr<MarkedResult>;
35
+ executeScriptSnippet(snippet: string, variant: IMBRICATE_EXECUTABLE_VARIANT, parameters: ImbricateExecuteParameters, environment: ImbricateExecuteEnvironment): PromiseOr<ImbricateExecuteResult>;
38
36
  }
@@ -1,7 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Sandbox_Definition
4
- * @description Config
5
- */
6
- export type SandboxExecuteConfig = Record<string, any>;
7
- export type SandboxExecuteParameter = Record<string, any>;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Sandbox_Definition
5
- * @description Config
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Sandbox_Definition
4
- * @description Environment
5
- */
6
- export type SandboxEnvironmentOrigin = {
7
- readonly type: string;
8
- };
9
- export type SandboxEnvironment = {
10
- readonly origin: SandboxEnvironmentOrigin;
11
- };
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Sandbox_Definition
5
- * @description Environment
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Sandbox_Definition
4
- * @description Implementation
5
- */
6
- export type SandboxImplementation = (...args: any[]) => Promise<any> | any;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Sandbox_Definition
5
- * @description Implementation
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,22 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Sandbox_Feature
4
- * @description Builder
5
- */
6
- import { SandboxImplementation } from "../definition/implementation";
7
- import { SandboxFeature } from "./feature";
8
- export declare class SandboxFeatureBuilder {
9
- static providedByOrigin(): SandboxFeatureBuilder;
10
- static providedBySandbox(): SandboxFeatureBuilder;
11
- static providedByInterface(): SandboxFeatureBuilder;
12
- static providedBy(providedBy: string): SandboxFeatureBuilder;
13
- private readonly _provideBy;
14
- private _packageName;
15
- private _methodName;
16
- private _implementation;
17
- private constructor();
18
- withPackageName(packageName: string): this;
19
- withMethodName(methodName: string): this;
20
- withImplementation(implementation: SandboxImplementation): this;
21
- build(): SandboxFeature;
22
- }
@@ -1,45 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Sandbox_Feature
5
- * @description Builder
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.SandboxFeatureBuilder = void 0;
9
- const feature_1 = require("./feature");
10
- class SandboxFeatureBuilder {
11
- static providedByOrigin() {
12
- return new SandboxFeatureBuilder("origin");
13
- }
14
- static providedBySandbox() {
15
- return new SandboxFeatureBuilder("sandbox");
16
- }
17
- static providedByInterface() {
18
- return new SandboxFeatureBuilder("interface");
19
- }
20
- static providedBy(providedBy) {
21
- return new SandboxFeatureBuilder(providedBy);
22
- }
23
- constructor(provideBy) {
24
- this._provideBy = provideBy;
25
- this._packageName = "";
26
- this._methodName = "";
27
- this._implementation = () => null;
28
- }
29
- withPackageName(packageName) {
30
- this._packageName = packageName;
31
- return this;
32
- }
33
- withMethodName(methodName) {
34
- this._methodName = methodName;
35
- return this;
36
- }
37
- withImplementation(implementation) {
38
- this._implementation = implementation;
39
- return this;
40
- }
41
- build() {
42
- return feature_1.SandboxFeature.create(`${this._provideBy}:${this._packageName}`, this._methodName, this._implementation);
43
- }
44
- }
45
- exports.SandboxFeatureBuilder = SandboxFeatureBuilder;
@@ -1,16 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Sandbox_Feature
4
- * @description Feature
5
- */
6
- import { SandboxImplementation } from "../definition/implementation";
7
- export declare class SandboxFeature {
8
- static create(packageName: string, methodName: string, implementation: SandboxImplementation): SandboxFeature;
9
- private readonly _packageName;
10
- private readonly _methodName;
11
- private readonly _implementation;
12
- private constructor();
13
- get packageName(): string;
14
- get methodName(): string;
15
- get implementation(): SandboxImplementation;
16
- }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Sandbox_Feature
5
- * @description Feature
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.SandboxFeature = void 0;
9
- class SandboxFeature {
10
- static create(packageName, methodName, implementation) {
11
- return new SandboxFeature(packageName, methodName, implementation);
12
- }
13
- constructor(packageName, methodName, implementation) {
14
- this._packageName = packageName;
15
- this._methodName = methodName;
16
- this._implementation = implementation;
17
- }
18
- get packageName() {
19
- return this._packageName;
20
- }
21
- get methodName() {
22
- return this._methodName;
23
- }
24
- get implementation() {
25
- return this._implementation;
26
- }
27
- }
28
- exports.SandboxFeature = SandboxFeature;
@@ -1,8 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Sandbox_Provide
4
- * @description Feature
5
- */
6
- import { Sandbox } from "@sudoo/marked";
7
- import { SandboxFeature } from "../feature/feature";
8
- export declare const sandboxProvideFeatures: (sandbox: Sandbox, features: SandboxFeature[]) => void;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Sandbox_Provide
5
- * @description Feature
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.sandboxProvideFeatures = void 0;
9
- const mapFeatures = (features) => {
10
- const map = {};
11
- for (const feature of features) {
12
- if (!map[feature.packageName]) {
13
- map[feature.packageName] = {};
14
- }
15
- map[feature.packageName][feature.methodName] = feature.implementation;
16
- }
17
- return map;
18
- };
19
- const sandboxProvideFeatures = (sandbox, features) => {
20
- const mappedFeatures = mapFeatures(features);
21
- for (const packageName of Object.keys(mappedFeatures)) {
22
- const methods = mappedFeatures[packageName];
23
- sandbox.provide(packageName, methods);
24
- }
25
- };
26
- exports.sandboxProvideFeatures = sandboxProvideFeatures;
@@ -1,11 +0,0 @@
1
- /**
2
- * @author WMXPY
3
- * @namespace Sandbox
4
- * @description Sandbox
5
- */
6
- import { MarkedResult, Sandbox } from "@sudoo/marked";
7
- import { SandboxExecuteConfig, SandboxExecuteParameter } from "./definition/config";
8
- import { SandboxEnvironment } from "./definition/environment";
9
- import { SandboxFeature } from "./feature/feature";
10
- export declare const createSandbox: (features: SandboxFeature[]) => Sandbox;
11
- export declare const executeSandboxScript: (script: string, features: SandboxFeature[], environment: SandboxEnvironment, configuration: SandboxExecuteConfig, parameters: SandboxExecuteParameter) => Promise<MarkedResult>;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- /**
3
- * @author WMXPY
4
- * @namespace Sandbox
5
- * @description Sandbox
6
- */
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.executeSandboxScript = exports.createSandbox = void 0;
18
- const marked_1 = require("@sudoo/marked");
19
- const marked_mixin_date_1 = require("@sudoo/marked-mixin-date");
20
- const marked_mixin_json_1 = require("@sudoo/marked-mixin-json");
21
- const marked_mixin_math_1 = require("@sudoo/marked-mixin-math");
22
- const marked_mixin_object_1 = require("@sudoo/marked-mixin-object");
23
- const marked_mixin_parse_1 = require("@sudoo/marked-mixin-parse");
24
- const feature_1 = require("./provide/feature");
25
- const createSandbox = (features) => {
26
- const sandbox = marked_1.Sandbox.fromAllEvaluators();
27
- sandbox.use(marked_mixin_date_1.markedDateMixinFactory.createInjectMixin("Date"));
28
- sandbox.use(marked_mixin_json_1.markedJsonMixinFactory.createInjectMixin("Json"));
29
- sandbox.use(marked_mixin_math_1.markedMathMixinFactory.createInjectMixin("Math"));
30
- sandbox.use(marked_mixin_object_1.markedObjectMixinFactory.createInjectMixin("Object"));
31
- sandbox.use(marked_mixin_parse_1.markedParseMixinFactory.createInjectMixin("Parse"));
32
- (0, feature_1.sandboxProvideFeatures)(sandbox, features);
33
- return sandbox;
34
- };
35
- exports.createSandbox = createSandbox;
36
- const executeSandboxScript = (script, features, environment, configuration, parameters) => __awaiter(void 0, void 0, void 0, function* () {
37
- const sandbox = (0, exports.createSandbox)(features);
38
- sandbox.inject("environment", environment);
39
- sandbox.inject("configuration", configuration);
40
- sandbox.inject("parameters", parameters);
41
- return yield sandbox.evaluate(script);
42
- });
43
- exports.executeSandboxScript = executeSandboxScript;