@ldsg/instantiate-app-resource 0.0.0-stage → 0.3.46

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2014-present Wanxger and other contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ export * from "./utils";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -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("./utils"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./instantiate-app-resource";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,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("./instantiate-app-resource"), exports);
@@ -0,0 +1,16 @@
1
+ import { Resource } from "@ldsg/resource";
2
+ import { ResourceRecord } from "@ldsg/types";
3
+ interface InstantiateAppResourceParams {
4
+ resources?: Resource[];
5
+ resourceRecords?: ResourceRecord[];
6
+ }
7
+ type InstantiateAppResource = (params: InstantiateAppResourceParams) => Promise<Resource>;
8
+ /**
9
+ * 实例化应用资源
10
+ * 1. 实例化全部资源;
11
+ * 2. 初始化全部资源;
12
+ * 3. 返回根资源(parentId 为空)。
13
+ */
14
+ export declare const instantiateAppResource: InstantiateAppResource;
15
+ export {};
16
+ //# sourceMappingURL=instantiate-app-resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instantiate-app-resource.d.ts","sourceRoot":"","sources":["../../src/utils/instantiate-app-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,UAAU,4BAA4B;IACpC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;CACpC;AAED,KAAK,sBAAsB,GAAG,CAAC,MAAM,EAAE,4BAA4B,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,sBAsBpC,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.instantiateAppResource = void 0;
4
+ const resource_instantiator_1 = require("@ldsg/resource-instantiator");
5
+ /**
6
+ * 实例化应用资源
7
+ * 1. 实例化全部资源;
8
+ * 2. 初始化全部资源;
9
+ * 3. 返回根资源(parentId 为空)。
10
+ */
11
+ const instantiateAppResource = async (params) => {
12
+ const { resources: paramsResources, resourceRecords } = params;
13
+ const resources = paramsResources !== null && paramsResources !== void 0 ? paramsResources : (resourceRecords
14
+ ? (0, resource_instantiator_1.instantiateResourcesRequiredByApp)({ resourceRecords }).resources
15
+ : undefined);
16
+ if (!(resources === null || resources === void 0 ? void 0 : resources.length)) {
17
+ throw new Error("invalid app resources: resources or resourceRecords is required");
18
+ }
19
+ await Promise.all(resources.map((resource) => resource.init()));
20
+ const rootResource = resources.find((resource) => !resource.parentId);
21
+ if (!rootResource) {
22
+ throw new Error("invalid app resource: root resource not found");
23
+ }
24
+ return rootResource;
25
+ };
26
+ exports.instantiateAppResource = instantiateAppResource;
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@ldsg/instantiate-app-resource",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.3.46",
4
+ "description": "",
5
+ "license": "MIT",
6
+ "author": "wanxger",
7
+ "files": [
8
+ "dist/"
9
+ ],
10
+ "main": "dist/index.js",
11
+ "types": "dist",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "dependencies": {
16
+ "express": "^4.18.2",
17
+ "express-async-handler": "^1.2.0",
18
+ "@ldsg/resource": "0.3.46",
19
+ "@ldsg/application": "0.3.46",
20
+ "@ldsg/types": "0.3.46",
21
+ "@ldsg/resource-instantiator": "0.3.46"
22
+ },
23
+ "devDependencies": {
24
+ "@types/express": "^4.17.17",
25
+ "@types/jest": "^29.5.2",
26
+ "@types/node": "^20.13.0",
27
+ "@types/supertest": "^6.0.0",
28
+ "jest": "^29.5.0",
29
+ "oxfmt": "latest",
30
+ "oxlint": "latest",
31
+ "supertest": "^6.3.4",
32
+ "ts-jest": "^29.1.5",
33
+ "ts-node": "^10.9.2",
34
+ "tslib": "^2.6.2",
35
+ "typescript": "^5.8.3"
36
+ },
37
+ "scripts": {
38
+ "build": "tsc --project tsconfig.build.json",
39
+ "clean": "rm -rf dist",
40
+ "format": "oxfmt --write src/",
41
+ "lint": "oxlint src/"
42
+ }
6
43
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.