@imbricate/core 0.1.0 → 1.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.
- package/definition/listable.d.ts +6 -0
- package/definition/listable.js +7 -0
- package/definition/promise.d.ts +6 -0
- package/definition/promise.js +7 -0
- package/definition/script.d.ts +9 -0
- package/definition/script.js +7 -0
- package/index.d.ts +15 -0
- package/index.js +27 -4
- package/origin/collection/interface.d.ts +22 -0
- package/origin/collection/interface.js +7 -0
- package/origin/collection/least-common-identifier.d.ts +10 -0
- package/origin/collection/least-common-identifier.js +54 -0
- package/origin/interface.d.ts +29 -0
- package/origin/interface.js +7 -0
- package/package.json +10 -2
- package/sandbox/definition/config.d.ts +6 -0
- package/sandbox/definition/config.js +7 -0
- package/sandbox/definition/environment.d.ts +11 -0
- package/sandbox/definition/environment.js +7 -0
- package/sandbox/definition/implementation.d.ts +6 -0
- package/sandbox/definition/implementation.js +7 -0
- package/sandbox/feature/builder.d.ts +18 -0
- package/sandbox/feature/builder.js +35 -0
- package/sandbox/feature/feature.d.ts +16 -0
- package/sandbox/feature/feature.js +28 -0
- package/sandbox/provide/feature.d.ts +8 -0
- package/sandbox/provide/feature.js +26 -0
- package/sandbox/sandbox.d.ts +11 -0
- package/sandbox/sandbox.js +42 -0
- package/search/prefix.d.ts +7 -0
- package/search/prefix.js +25 -0
- package/search/snippet.d.ts +22 -0
- package/search/snippet.js +17 -0
- package/builder/interface.js +0 -54
- package/schema/interface.js +0 -6
- package/util/writable.js +0 -6
- package/verify/interface.js +0 -20
package/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @description Index
|
|
4
|
+
*/
|
|
5
|
+
export * from "./definition/listable";
|
|
6
|
+
export * from "./definition/promise";
|
|
7
|
+
export * from "./definition/script";
|
|
8
|
+
export * from "./origin/collection/interface";
|
|
9
|
+
export * from "./origin/collection/least-common-identifier";
|
|
10
|
+
export * from "./origin/interface";
|
|
11
|
+
export * from "./sandbox/feature/builder";
|
|
12
|
+
export * from "./sandbox/feature/feature";
|
|
13
|
+
export * from "./sandbox/sandbox";
|
|
14
|
+
export * from "./search/prefix";
|
|
15
|
+
export * from "./search/snippet";
|
package/index.js
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @author WMXPY
|
|
3
4
|
* @description Index
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./definition/listable"), exports);
|
|
22
|
+
__exportStar(require("./definition/promise"), exports);
|
|
23
|
+
__exportStar(require("./definition/script"), exports);
|
|
24
|
+
__exportStar(require("./origin/collection/interface"), exports);
|
|
25
|
+
__exportStar(require("./origin/collection/least-common-identifier"), exports);
|
|
26
|
+
__exportStar(require("./origin/interface"), exports);
|
|
27
|
+
__exportStar(require("./sandbox/feature/builder"), exports);
|
|
28
|
+
__exportStar(require("./sandbox/feature/feature"), exports);
|
|
29
|
+
__exportStar(require("./sandbox/sandbox"), exports);
|
|
30
|
+
__exportStar(require("./search/prefix"), exports);
|
|
31
|
+
__exportStar(require("./search/snippet"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Origin_Collection
|
|
4
|
+
* @description Interface
|
|
5
|
+
*/
|
|
6
|
+
import { IMBRICATE_SEARCH_SNIPPET_TYPE, ImbricateSearchSnippet } from "../../search/snippet";
|
|
7
|
+
export type ImbricateOriginCollectionListPagesResponse = {
|
|
8
|
+
readonly title: string;
|
|
9
|
+
readonly identifier: string;
|
|
10
|
+
};
|
|
11
|
+
export interface IImbricateOriginCollection {
|
|
12
|
+
readonly collectionName: string;
|
|
13
|
+
readonly description?: string;
|
|
14
|
+
findScripts(...onActivities: string[]): Promise<void>;
|
|
15
|
+
listPages(): Promise<ImbricateOriginCollectionListPagesResponse[]>;
|
|
16
|
+
createPage(title: string, initialContent?: string): Promise<ImbricateOriginCollectionListPagesResponse>;
|
|
17
|
+
deletePage(identifier: string, title: string): Promise<void>;
|
|
18
|
+
openPage(title: string): Promise<void>;
|
|
19
|
+
readPage(identifier: string): Promise<string>;
|
|
20
|
+
hasPage(title: string): Promise<boolean>;
|
|
21
|
+
searchPages(keyword: string): Promise<Array<ImbricateSearchSnippet<IMBRICATE_SEARCH_SNIPPET_TYPE.PAGE>>>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Origin_Collection
|
|
4
|
+
* @description Least Common Identifier
|
|
5
|
+
*/
|
|
6
|
+
export type LeastCommonIdentifierItem = {
|
|
7
|
+
readonly key: string;
|
|
8
|
+
readonly identifier: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const mapLeastCommonIdentifier: (identifiers: LeastCommonIdentifierItem[]) => Record<string, string>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author WMXPY
|
|
4
|
+
* @namespace Origin_Collection
|
|
5
|
+
* @description Least Common Identifier
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.mapLeastCommonIdentifier = void 0;
|
|
9
|
+
class TrieNode {
|
|
10
|
+
static create() {
|
|
11
|
+
return new TrieNode();
|
|
12
|
+
}
|
|
13
|
+
constructor() {
|
|
14
|
+
this._items = [];
|
|
15
|
+
this._children = {};
|
|
16
|
+
}
|
|
17
|
+
get items() {
|
|
18
|
+
return this._items;
|
|
19
|
+
}
|
|
20
|
+
getChild(key) {
|
|
21
|
+
if (!this._children[key]) {
|
|
22
|
+
this._children[key] = TrieNode.create();
|
|
23
|
+
}
|
|
24
|
+
return this._children[key];
|
|
25
|
+
}
|
|
26
|
+
pushItem(item) {
|
|
27
|
+
this._items.push(item);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const mapLeastCommonIdentifier = (identifiers) => {
|
|
31
|
+
const root = TrieNode.create();
|
|
32
|
+
for (const identifier of identifiers) {
|
|
33
|
+
let current = root;
|
|
34
|
+
for (const char of identifier.identifier) {
|
|
35
|
+
current.pushItem(identifier.key);
|
|
36
|
+
current = current.getChild(char);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const result = {};
|
|
40
|
+
for (const identifier of identifiers) {
|
|
41
|
+
let current = root;
|
|
42
|
+
let currentIdentifier = "";
|
|
43
|
+
for (const char of identifier.identifier) {
|
|
44
|
+
current = current.getChild(char);
|
|
45
|
+
currentIdentifier += char;
|
|
46
|
+
if (current.items.length === 1) {
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
result[identifier.key] = currentIdentifier;
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
exports.mapLeastCommonIdentifier = mapLeastCommonIdentifier;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Origin
|
|
4
|
+
* @description Interface
|
|
5
|
+
*/
|
|
6
|
+
import { MarkedResult } from "@sudoo/marked";
|
|
7
|
+
import { PromiseOr } from "../definition/promise";
|
|
8
|
+
import { ImbricateScriptMetadata } from "../definition/script";
|
|
9
|
+
import { SandboxExecuteConfig } from "../sandbox/definition/config";
|
|
10
|
+
import { IImbricateOriginCollection } from "./collection/interface";
|
|
11
|
+
export type ImbricateOriginMetadata = {
|
|
12
|
+
readonly type: string;
|
|
13
|
+
};
|
|
14
|
+
export interface IImbricateOrigin {
|
|
15
|
+
readonly metadata: ImbricateOriginMetadata;
|
|
16
|
+
readonly payloads: Record<string, any>;
|
|
17
|
+
createCollection(collectionName: string, description?: string): PromiseOr<void>;
|
|
18
|
+
hasCollection(collectionName: string): PromiseOr<boolean>;
|
|
19
|
+
getCollection(collectionName: string): PromiseOr<IImbricateOriginCollection | null>;
|
|
20
|
+
listCollections(): PromiseOr<IImbricateOriginCollection[]>;
|
|
21
|
+
removeCollection(): PromiseOr<void>;
|
|
22
|
+
createScript(scriptName: string, description?: string): PromiseOr<ImbricateScriptMetadata>;
|
|
23
|
+
hasScript(scriptName: string): PromiseOr<boolean>;
|
|
24
|
+
getScript(scriptIdentifier: string): PromiseOr<string | null>;
|
|
25
|
+
openScript(scriptIdentifier: string): PromiseOr<string>;
|
|
26
|
+
listScripts(): PromiseOr<ImbricateScriptMetadata[]>;
|
|
27
|
+
removeScript(scriptIdentifier: string, scriptName: string): PromiseOr<void>;
|
|
28
|
+
executeScript(scriptIdentifier: string, config: SandboxExecuteConfig): PromiseOr<MarkedResult | null>;
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imbricate/core",
|
|
3
3
|
"main": "index.js",
|
|
4
|
-
"version": "0.1
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"description": "Core for Imbricate",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -15,5 +15,13 @@
|
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/Imbricate/Imbricate-Core/issues"
|
|
17
17
|
},
|
|
18
|
-
"homepage": "https://imbricate.io"
|
|
18
|
+
"homepage": "https://imbricate.io",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@sudoo/marked": "^3.21.4",
|
|
21
|
+
"@sudoo/marked-mixin-date": "^1.0.0",
|
|
22
|
+
"@sudoo/marked-mixin-json": "^1.0.0",
|
|
23
|
+
"@sudoo/marked-mixin-math": "^1.4.0",
|
|
24
|
+
"@sudoo/marked-mixin-object": "^1.3.0",
|
|
25
|
+
"@sudoo/marked-mixin-parse": "^1.0.0"
|
|
26
|
+
}
|
|
19
27
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 fromScratch(): SandboxFeatureBuilder;
|
|
10
|
+
private _packageName;
|
|
11
|
+
private _methodName;
|
|
12
|
+
private _implementation;
|
|
13
|
+
private constructor();
|
|
14
|
+
withPackageName(packageName: string): this;
|
|
15
|
+
withMethodName(methodName: string): this;
|
|
16
|
+
withImplementation(implementation: SandboxImplementation): this;
|
|
17
|
+
build(): SandboxFeature;
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 fromScratch() {
|
|
12
|
+
return new SandboxFeatureBuilder();
|
|
13
|
+
}
|
|
14
|
+
constructor() {
|
|
15
|
+
this._packageName = "";
|
|
16
|
+
this._methodName = "";
|
|
17
|
+
this._implementation = () => null;
|
|
18
|
+
}
|
|
19
|
+
withPackageName(packageName) {
|
|
20
|
+
this._packageName = packageName;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
withMethodName(methodName) {
|
|
24
|
+
this._methodName = methodName;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
withImplementation(implementation) {
|
|
28
|
+
this._implementation = implementation;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
build() {
|
|
32
|
+
return feature_1.SandboxFeature.create(this._packageName, this._methodName, this._implementation);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.SandboxFeatureBuilder = SandboxFeatureBuilder;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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;
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
@@ -0,0 +1,26 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Sandbox
|
|
4
|
+
* @description Sandbox
|
|
5
|
+
*/
|
|
6
|
+
import { MarkedResult, Sandbox } from "@sudoo/marked";
|
|
7
|
+
import { SandboxExecuteConfig } 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, config: SandboxExecuteConfig) => Promise<MarkedResult>;
|
|
@@ -0,0 +1,42 @@
|
|
|
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, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
const sandbox = (0, exports.createSandbox)(features);
|
|
38
|
+
sandbox.inject("environment", environment);
|
|
39
|
+
sandbox.inject("config", config);
|
|
40
|
+
return yield sandbox.evaluate(script);
|
|
41
|
+
});
|
|
42
|
+
exports.executeSandboxScript = executeSandboxScript;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Search
|
|
4
|
+
* @description Prefix
|
|
5
|
+
*/
|
|
6
|
+
import { IMBRICATE_SEARCH_SNIPPET_TYPE, ImbricateSearchSnippet } from "./snippet";
|
|
7
|
+
export declare const getShortPrefixOfSnippet: (snippet: ImbricateSearchSnippet<IMBRICATE_SEARCH_SNIPPET_TYPE>) => string;
|
package/search/prefix.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author WMXPY
|
|
4
|
+
* @namespace Search
|
|
5
|
+
* @description Prefix
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.getShortPrefixOfSnippet = void 0;
|
|
9
|
+
const snippet_1 = require("./snippet");
|
|
10
|
+
const getShortPrefixOfSnippet = (snippet) => {
|
|
11
|
+
switch (snippet.type) {
|
|
12
|
+
case snippet_1.IMBRICATE_SEARCH_SNIPPET_TYPE.PAGE: {
|
|
13
|
+
switch (snippet.source) {
|
|
14
|
+
case snippet_1.IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE.TITLE: {
|
|
15
|
+
return "T";
|
|
16
|
+
}
|
|
17
|
+
case snippet_1.IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE.CONTENT: {
|
|
18
|
+
return "C";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return "?";
|
|
24
|
+
};
|
|
25
|
+
exports.getShortPrefixOfSnippet = getShortPrefixOfSnippet;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @namespace Search
|
|
4
|
+
* @description Snippet
|
|
5
|
+
*/
|
|
6
|
+
export declare enum IMBRICATE_SEARCH_SNIPPET_TYPE {
|
|
7
|
+
PAGE = "PAGE"
|
|
8
|
+
}
|
|
9
|
+
export declare enum IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE {
|
|
10
|
+
TITLE = "TITLE",
|
|
11
|
+
CONTENT = "CONTENT"
|
|
12
|
+
}
|
|
13
|
+
type IMBRICATE_SEARCH_SNIPPET_SNIPPET_SOURCE<T extends IMBRICATE_SEARCH_SNIPPET_TYPE> = T extends IMBRICATE_SEARCH_SNIPPET_TYPE.PAGE ? IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE : never;
|
|
14
|
+
export type ImbricateSearchSnippet<T extends IMBRICATE_SEARCH_SNIPPET_TYPE> = {
|
|
15
|
+
readonly type: T;
|
|
16
|
+
readonly scope: string;
|
|
17
|
+
readonly identifier: string;
|
|
18
|
+
readonly headline: string;
|
|
19
|
+
readonly source: IMBRICATE_SEARCH_SNIPPET_SNIPPET_SOURCE<T>;
|
|
20
|
+
readonly snippet: string;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @author WMXPY
|
|
4
|
+
* @namespace Search
|
|
5
|
+
* @description Snippet
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE = exports.IMBRICATE_SEARCH_SNIPPET_TYPE = void 0;
|
|
9
|
+
var IMBRICATE_SEARCH_SNIPPET_TYPE;
|
|
10
|
+
(function (IMBRICATE_SEARCH_SNIPPET_TYPE) {
|
|
11
|
+
IMBRICATE_SEARCH_SNIPPET_TYPE["PAGE"] = "PAGE";
|
|
12
|
+
})(IMBRICATE_SEARCH_SNIPPET_TYPE || (exports.IMBRICATE_SEARCH_SNIPPET_TYPE = IMBRICATE_SEARCH_SNIPPET_TYPE = {}));
|
|
13
|
+
var IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE;
|
|
14
|
+
(function (IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE) {
|
|
15
|
+
IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE["TITLE"] = "TITLE";
|
|
16
|
+
IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE["CONTENT"] = "CONTENT";
|
|
17
|
+
})(IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE || (exports.IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE = IMBRICATE_SEARCH_SNIPPET_PAGE_SNIPPET_SOURCE = {}));
|
package/builder/interface.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author WMXPY
|
|
3
|
-
* @namespace Builder
|
|
4
|
-
* @description Interface
|
|
5
|
-
*/
|
|
6
|
-
import { verifyInterface } from "../verify/interface";
|
|
7
|
-
var ImbricateInterfaceBuilder = /** @class */ (function () {
|
|
8
|
-
function ImbricateInterfaceBuilder() {
|
|
9
|
-
this._interface = {};
|
|
10
|
-
}
|
|
11
|
-
ImbricateInterfaceBuilder.fromScratch = function () {
|
|
12
|
-
return new ImbricateInterfaceBuilder();
|
|
13
|
-
};
|
|
14
|
-
ImbricateInterfaceBuilder.prototype.identifier = function (identifier) {
|
|
15
|
-
this._interface.identifier = identifier;
|
|
16
|
-
return this;
|
|
17
|
-
};
|
|
18
|
-
ImbricateInterfaceBuilder.prototype.version = function (version) {
|
|
19
|
-
this._interface.version = version;
|
|
20
|
-
return this;
|
|
21
|
-
};
|
|
22
|
-
ImbricateInterfaceBuilder.prototype.protocol = function (protocol) {
|
|
23
|
-
this._interface.protocol = protocol;
|
|
24
|
-
return this;
|
|
25
|
-
};
|
|
26
|
-
ImbricateInterfaceBuilder.prototype.matcher = function (matcher) {
|
|
27
|
-
this._interface.matcher = matcher;
|
|
28
|
-
return this;
|
|
29
|
-
};
|
|
30
|
-
ImbricateInterfaceBuilder.prototype.humanFriendlyName = function (humanFriendlyName) {
|
|
31
|
-
this._interface.humanFriendlyName = humanFriendlyName;
|
|
32
|
-
return this;
|
|
33
|
-
};
|
|
34
|
-
ImbricateInterfaceBuilder.prototype.description = function (description) {
|
|
35
|
-
this._interface.description = description;
|
|
36
|
-
return this;
|
|
37
|
-
};
|
|
38
|
-
ImbricateInterfaceBuilder.prototype.input = function () {
|
|
39
|
-
this._interface.input = {};
|
|
40
|
-
return this;
|
|
41
|
-
};
|
|
42
|
-
ImbricateInterfaceBuilder.prototype.output = function () {
|
|
43
|
-
this._interface.output = {};
|
|
44
|
-
return this;
|
|
45
|
-
};
|
|
46
|
-
ImbricateInterfaceBuilder.prototype.verify = function () {
|
|
47
|
-
return verifyInterface(this._interface);
|
|
48
|
-
};
|
|
49
|
-
ImbricateInterfaceBuilder.prototype.build = function () {
|
|
50
|
-
return this._interface;
|
|
51
|
-
};
|
|
52
|
-
return ImbricateInterfaceBuilder;
|
|
53
|
-
}());
|
|
54
|
-
export { ImbricateInterfaceBuilder };
|
package/schema/interface.js
DELETED
package/util/writable.js
DELETED
package/verify/interface.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author WMXPY
|
|
3
|
-
* @namespace Verify
|
|
4
|
-
* @description Interface
|
|
5
|
-
*/
|
|
6
|
-
export var verifyInterface = function (imbricateInterface) {
|
|
7
|
-
if (typeof imbricateInterface.identifier !== "string") {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
if (typeof imbricateInterface.version !== "string") {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
if (typeof imbricateInterface.protocol !== "string") {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
if (typeof imbricateInterface.matcher !== "string") {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
};
|