@ldsg/resource 0.0.1-beta1 → 0.1.0-alpha.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/README.md CHANGED
@@ -1,5 +1 @@
1
1
  # LDSG Resource
2
-
3
- 资源 Resource
4
- 资源配置 Resource Settings 每个资源的配置
5
- 资源定义 Resource Definition 也是一种资源
@@ -0,0 +1,3 @@
1
+ export * from "./resource";
2
+ export * from "./types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./resource"), exports);
18
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,29 @@
1
+ import { Manifest } from "./types/manifest";
2
+ export declare class Resource<T extends Manifest.ResourceSettings = Manifest.ResourceSettings> implements Manifest.Resource<T> {
3
+ /**
4
+ * Resource ID
5
+ */
6
+ id: string;
7
+ /**
8
+ * Resource Kind
9
+ */
10
+ kind: string;
11
+ /**
12
+ * Parent Resource ID
13
+ */
14
+ parentId: string;
15
+ /**
16
+ * Resource Settings
17
+ */
18
+ settings: T;
19
+ constructor(resource: Manifest.Resource<T>);
20
+ getId: () => string;
21
+ getKind: () => string;
22
+ getParentId: () => string;
23
+ /**
24
+ * Get Resource Settings
25
+ * @returns Resource Settings
26
+ */
27
+ getSettings: () => T;
28
+ }
29
+ //# sourceMappingURL=resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,qBAAa,QAAQ,CACnB,CAAC,SAAS,QAAQ,CAAC,gBAAgB,GAAG,QAAQ,CAAC,gBAAgB,CAC/D,YAAW,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,EAAE,CAAC,CAAC;gBAEA,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAS1C,KAAK,eAQH;IAEF,OAAO,eAQL;IAEF,WAAW,eAQT;IAEF;;;OAGG;IACH,WAAW,UAIT;CACH"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Resource = void 0;
4
+ class Resource {
5
+ constructor(resource) {
6
+ this.getId = () => {
7
+ const id = this.id;
8
+ if (!id) {
9
+ throw new Error("resource id is required");
10
+ }
11
+ return id;
12
+ };
13
+ this.getKind = () => {
14
+ const type = this.kind;
15
+ if (!type) {
16
+ throw new Error("resource kind is required");
17
+ }
18
+ return type;
19
+ };
20
+ this.getParentId = () => {
21
+ const parentId = this.parentId;
22
+ if (!parentId) {
23
+ throw new Error("resource parent id is required");
24
+ }
25
+ return parentId;
26
+ };
27
+ /**
28
+ * Get Resource Settings
29
+ * @returns Resource Settings
30
+ */
31
+ this.getSettings = () => {
32
+ var _a;
33
+ const settings = (_a = this.settings) !== null && _a !== void 0 ? _a : {};
34
+ return settings;
35
+ };
36
+ const { id, kind, parentId, settings } = resource;
37
+ this.id = id;
38
+ this.kind = kind;
39
+ this.parentId = parentId;
40
+ this.settings = settings;
41
+ }
42
+ }
43
+ exports.Resource = Resource;
@@ -0,0 +1,2 @@
1
+ export * from "./manifest";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./manifest"), exports);
@@ -0,0 +1,48 @@
1
+ export declare namespace Manifest {
2
+ /**
3
+ * Resource Settings
4
+ */
5
+ interface ResourceSettings {
6
+ /**
7
+ * Resource Title
8
+ */
9
+ title: string;
10
+ /**
11
+ * Resource Description
12
+ */
13
+ description: string;
14
+ /**
15
+ * Extra Key
16
+ */
17
+ [key: string]: any;
18
+ }
19
+ /**
20
+ * Resource
21
+ */
22
+ interface Resource<T extends ResourceSettings = ResourceSettings> {
23
+ /**
24
+ * Resource ID
25
+ */
26
+ id: string;
27
+ /**
28
+ * Resource Kind
29
+ * Connect uppercase letters with underscores
30
+ */
31
+ kind: string;
32
+ /**
33
+ * Parent Resource ID
34
+ */
35
+ parentId: string;
36
+ /**
37
+ * Resource Settings
38
+ */
39
+ settings: T;
40
+ }
41
+ }
42
+ /**
43
+ * Manifest
44
+ */
45
+ export interface Manifest {
46
+ resources: Manifest.Resource[];
47
+ }
48
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/types/manifest.ts"],"names":[],"mappings":"AAAA,yBAAiB,QAAQ,CAAC;IACxB;;OAEG;IACH,UAAiB,gBAAgB;QAC/B;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;QAEd;;WAEG;QACH,WAAW,EAAE,MAAM,CAAC;QAEpB;;WAEG;QACH,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB;IAED;;OAEG;IACH,UAAiB,QAAQ,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB;QACrE;;WAEG;QACH,EAAE,EAAE,MAAM,CAAC;QAEX;;;WAGG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;WAEG;QACH,QAAQ,EAAE,CAAC,CAAC;KACb;CACF;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC;CAChC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@ldsg/resource",
3
- "version": "0.0.1-beta1",
3
+ "version": "0.1.0-alpha.1",
4
4
  "description": "",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist/"
8
+ ],
9
+ "types": "dist",
6
10
  "keywords": [],
7
11
  "author": "wanxger",
8
12
  "license": "MIT",
@@ -10,6 +14,6 @@
10
14
  "access": "public"
11
15
  },
12
16
  "scripts": {
13
- "test": "echo \"Error: no test specified\" && exit 1"
17
+ "build": "tsc --project tsconfig.build.json"
14
18
  }
15
19
  }
@@ -1,5 +0,0 @@
1
- import { Resource } from "./resource";
2
-
3
- export interface Manifest {
4
- resources: Resource[]
5
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Resource Settings
3
- */
4
- export interface ResourceSettings {
5
- /**
6
- * Resource Title
7
- */
8
- title: string
9
-
10
- /**
11
- * Resource Description
12
- */
13
- description: string
14
- }
@@ -1,23 +0,0 @@
1
- import { ResourceSettings } from "./resource-settings"
2
-
3
- export interface Resource<T extends ResourceSettings = ResourceSettings> {
4
- /**
5
- * Resource ID
6
- */
7
- id: string
8
-
9
- /**
10
- * Resource Kind
11
- */
12
- kind: string
13
-
14
- /**
15
- * Parent Resource ID
16
- */
17
- parentId: string
18
-
19
- /**
20
- * Resource Settings
21
- */
22
- settings: T
23
- }