@blocklet/meta 1.16.32 → 1.16.33-beta-20240929-110332-9d5dfdc4
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/lib/blocklet.js +1 -1
- package/lib/schema.js +55 -1
- package/lib/types/schema.d.ts +3 -1
- package/lib/util.d.ts +3 -1
- package/lib/util.js +16 -2
- package/package.json +4 -4
package/lib/blocklet.js
CHANGED
|
@@ -47,7 +47,7 @@ const getComponentsInternalInfo = (app) => {
|
|
|
47
47
|
resourcesV2: getComponentResourcesPathV2(x),
|
|
48
48
|
group: x.meta.group,
|
|
49
49
|
};
|
|
50
|
-
const webInterface = (0, util_1.findWebInterface)(x);
|
|
50
|
+
const webInterface = (0, util_1.findWebInterface)(x) || (0, util_1.findDockerInterface)(x);
|
|
51
51
|
if (webInterface && (x.environments || []).find((y) => y.key === webInterface.port)) {
|
|
52
52
|
component.port = x.environments.find((y) => y.key === webInterface.port).value;
|
|
53
53
|
}
|
package/lib/schema.js
CHANGED
|
@@ -269,6 +269,11 @@ const interfaceSchema = Joi.object({
|
|
|
269
269
|
path: Joi.string().trim().default('/'),
|
|
270
270
|
// `*` means the interface can be mounted at any path prefix
|
|
271
271
|
prefix: Joi.string().trim().min(1).default(constant_2.BLOCKLET_DYNAMIC_PATH_PREFIX),
|
|
272
|
+
containerPort: Joi.number().port().optional(),
|
|
273
|
+
hostIP: Joi.string()
|
|
274
|
+
.trim()
|
|
275
|
+
.ip({ version: ['ipv4', 'ipv6'] })
|
|
276
|
+
.optional(),
|
|
272
277
|
protocol: Joi.string()
|
|
273
278
|
.lowercase()
|
|
274
279
|
.valid(...constant_2.BLOCKLET_INTERFACE_PROTOCOLS)
|
|
@@ -712,11 +717,60 @@ const createBlockletSchema = (baseDir, { ensureFiles = false, ensureDist = false
|
|
|
712
717
|
dist: ensureDist ? distSchema.required() : distSchema.optional(),
|
|
713
718
|
components: componentsSchema({ checkStore: ensureComponentStore }),
|
|
714
719
|
name: ensureName ? Joi.string().optional() : Joi.string().required(),
|
|
720
|
+
docker: Joi.object({
|
|
721
|
+
workdir: Joi.string().trim(),
|
|
722
|
+
image: Joi.string().trim().optional(),
|
|
723
|
+
dockerfile: ensureFiles ? Joi.file().trim().exists({ baseDir }).optional() : Joi.string().trim().optional(),
|
|
724
|
+
shell: Joi.string().trim().optional(),
|
|
725
|
+
network: Joi.string().valid('host', 'bridge', 'none').default('host').optional(),
|
|
726
|
+
volumes: Joi.array().items(Joi.string().trim()).optional(),
|
|
727
|
+
script: Joi.string().trim().optional(),
|
|
728
|
+
installNodeModules: Joi.boolean().optional(),
|
|
729
|
+
command: Joi.string().trim().optional(),
|
|
730
|
+
runBaseScript: Joi.boolean().optional(),
|
|
731
|
+
}).optional(),
|
|
715
732
|
})
|
|
716
733
|
.options({ stripUnknown: true, noDefaults: false, ...schemaOptions })
|
|
717
734
|
.rename('children', 'components')
|
|
718
735
|
.custom((data, helper) => {
|
|
719
|
-
const { did, name } = data;
|
|
736
|
+
const { did, name, docker } = data;
|
|
737
|
+
if (docker) {
|
|
738
|
+
const { image, dockerfile, exportPorts, network } = docker;
|
|
739
|
+
if (!image && !dockerfile) {
|
|
740
|
+
// @ts-ignore
|
|
741
|
+
return helper.message('Image or dockerfile must be set');
|
|
742
|
+
}
|
|
743
|
+
if (image && dockerfile) {
|
|
744
|
+
// @ts-ignore
|
|
745
|
+
return helper.message('Image and dockerfile cannot be set at the same time');
|
|
746
|
+
}
|
|
747
|
+
if (exportPorts && network) {
|
|
748
|
+
// @ts-ignore
|
|
749
|
+
return helper.message('ExportPorts and network cannot be set at the same time');
|
|
750
|
+
}
|
|
751
|
+
if (!exportPorts && !network) {
|
|
752
|
+
// @ts-ignore
|
|
753
|
+
return helper.message('ExportPorts or network must be set');
|
|
754
|
+
}
|
|
755
|
+
if (dockerfile) {
|
|
756
|
+
if (!data.files) {
|
|
757
|
+
data.files = [];
|
|
758
|
+
}
|
|
759
|
+
data.files.push(dockerfile);
|
|
760
|
+
}
|
|
761
|
+
if (docker.volumes) {
|
|
762
|
+
for (const volume of docker.volumes) {
|
|
763
|
+
if (!volume.startsWith('$BLOCKLET_APP_DIR/') && !volume.startsWith('$BLOCKLET_DATA_DIR/')) {
|
|
764
|
+
// @ts-ignore
|
|
765
|
+
return helper.message('Volume must start with $BLOCKLET_APP_DIR or $BLOCKLET_DATA_DIR');
|
|
766
|
+
}
|
|
767
|
+
if (volume.indexOf('..') > -1) {
|
|
768
|
+
// @ts-ignore
|
|
769
|
+
return helper.message('Volume cannot contain ".."');
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
720
774
|
let cacheError;
|
|
721
775
|
if ((0, did_1.isValid)(did)) {
|
|
722
776
|
try {
|
package/lib/types/schema.d.ts
CHANGED
|
@@ -182,7 +182,9 @@ export type TInstallBlockletDescription = string;
|
|
|
182
182
|
export type TInstallBlockletTitle = string;
|
|
183
183
|
export interface TInterface {
|
|
184
184
|
cacheable?: TPathPrefix[];
|
|
185
|
+
containerPort?: number;
|
|
185
186
|
endpoints?: TEndpoint[];
|
|
187
|
+
hostIP?: string;
|
|
186
188
|
name: string;
|
|
187
189
|
pageGroups?: string[];
|
|
188
190
|
path?: string;
|
|
@@ -193,7 +195,7 @@ export interface TInterface {
|
|
|
193
195
|
prefix?: string;
|
|
194
196
|
protocol?: 'tcp' | 'udp' | 'http';
|
|
195
197
|
services?: TService[];
|
|
196
|
-
type: 'web' | 'service' | 'wellknown';
|
|
198
|
+
type: 'web' | 'service' | 'wellknown' | 'docker';
|
|
197
199
|
}
|
|
198
200
|
export type TLogo = string;
|
|
199
201
|
export type TMountPoint = string;
|
package/lib/util.d.ts
CHANGED
|
@@ -116,6 +116,7 @@ declare const getAppDescription: (blocklet: BlockletState, onlyUseMeta?: boolean
|
|
|
116
116
|
export declare function getAppUrl(blocklet: BlockletState): string;
|
|
117
117
|
declare const fixBlockletStatus: (blocklet?: BlockletState) => void;
|
|
118
118
|
declare const findWebInterface: (blocklet?: BlockletState | TBlockletMeta) => any;
|
|
119
|
+
declare const findDockerInterface: (blocklet?: BlockletState | TBlockletMeta) => any;
|
|
119
120
|
declare const findWebInterfacePort: (blocklet?: BlockletState) => any;
|
|
120
121
|
declare const findServiceFromMeta: (meta?: TBlockletMeta, ServiceName?: string) => any;
|
|
121
122
|
declare const getWhoCanAccess: (blocklet?: BlockletState) => any;
|
|
@@ -151,7 +152,7 @@ declare const hasResourceType: (component: ComponentState, { type, did }?: {
|
|
|
151
152
|
type: string;
|
|
152
153
|
did: string;
|
|
153
154
|
}) => boolean;
|
|
154
|
-
export { isFreeBlocklet, isFreeComponent, forEachBlocklet, forEachBlockletSync, forEachChild, forEachChildSync, forEachComponentV2, forEachComponentV2Sync, isDeletableBlocklet, getSharedConfigObj, getAppMissingConfigs, getComponentMissingConfigs, isEnvShareableToClient, isEnvShareable, wipeSensitiveData, hasRunnableComponent, getAppName, getAppName as getDisplayName, getAppDescription, fixBlockletStatus, findWebInterface, findWebInterfacePort, findServiceFromMeta, getWhoCanAccess, getComponentWhoCanAccess, replaceSlotToIp, getComponentId, getComponentName, getComponentBundleId, findComponent, findComponentById, findComponentV2, findComponentByIdV2, filterComponentsV2, getParentComponentName, getConnectAppUrl, getChainInfo, getBlockletChainInfo, isExternalBlocklet, isPreferenceKey, getRolesFromAuthConfig, getBlockletAppIdList, getBlockletServices, isInProgress, isBeforeInstalled, isRunning, isAccessible, isGatewayBlocklet, isPackBlocklet, hasStartEngine, hasResourceType, };
|
|
155
|
+
export { isFreeBlocklet, isFreeComponent, forEachBlocklet, forEachBlockletSync, forEachChild, forEachChildSync, forEachComponentV2, forEachComponentV2Sync, isDeletableBlocklet, getSharedConfigObj, getAppMissingConfigs, getComponentMissingConfigs, isEnvShareableToClient, isEnvShareable, wipeSensitiveData, hasRunnableComponent, getAppName, getAppName as getDisplayName, getAppDescription, fixBlockletStatus, findWebInterface, findWebInterfacePort, findDockerInterface, findServiceFromMeta, getWhoCanAccess, getComponentWhoCanAccess, replaceSlotToIp, getComponentId, getComponentName, getComponentBundleId, findComponent, findComponentById, findComponentV2, findComponentByIdV2, filterComponentsV2, getParentComponentName, getConnectAppUrl, getChainInfo, getBlockletChainInfo, isExternalBlocklet, isPreferenceKey, getRolesFromAuthConfig, getBlockletAppIdList, getBlockletServices, isInProgress, isBeforeInstalled, isRunning, isAccessible, isGatewayBlocklet, isPackBlocklet, hasStartEngine, hasResourceType, };
|
|
155
156
|
declare const _default: {
|
|
156
157
|
isFreeBlocklet: (meta: TBlockletMeta) => boolean;
|
|
157
158
|
isFreeComponent: (meta: TBlockletMeta) => boolean;
|
|
@@ -191,6 +192,7 @@ declare const _default: {
|
|
|
191
192
|
fixBlockletStatus: (blocklet?: BlockletState) => void;
|
|
192
193
|
findWebInterface: (blocklet?: BlockletState | TBlockletMeta) => any;
|
|
193
194
|
findWebInterfacePort: (blocklet?: BlockletState) => any;
|
|
195
|
+
findDockerInterface: (blocklet?: BlockletState | TBlockletMeta) => any;
|
|
194
196
|
findServiceFromMeta: (meta?: TBlockletMeta, ServiceName?: string) => any;
|
|
195
197
|
getWhoCanAccess: (blocklet?: BlockletState) => any;
|
|
196
198
|
getComponentWhoCanAccess: (component: TComponent, app?: BlockletState) => string;
|
package/lib/util.js
CHANGED
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.hasResourceType = void 0;
|
|
6
|
+
exports.isPackBlocklet = exports.isGatewayBlocklet = exports.isAccessible = exports.isRunning = exports.isBeforeInstalled = exports.isInProgress = exports.getBlockletServices = exports.getBlockletAppIdList = exports.getRolesFromAuthConfig = exports.isPreferenceKey = exports.isExternalBlocklet = exports.getBlockletChainInfo = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.filterComponentsV2 = exports.findComponentByIdV2 = exports.findComponentV2 = exports.findComponentById = exports.findComponent = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.replaceSlotToIp = exports.getComponentWhoCanAccess = exports.getWhoCanAccess = exports.findServiceFromMeta = exports.findDockerInterface = exports.findWebInterfacePort = exports.findWebInterface = exports.fixBlockletStatus = exports.getAppDescription = exports.getDisplayName = exports.getAppName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.isEnvShareableToClient = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachComponentV2Sync = exports.forEachComponentV2 = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
|
|
7
|
+
exports.hasResourceType = exports.hasStartEngine = void 0;
|
|
8
8
|
exports.getAppUrl = getAppUrl;
|
|
9
9
|
/* eslint-disable no-await-in-loop */
|
|
10
10
|
const get_1 = __importDefault(require("lodash/get"));
|
|
@@ -529,6 +529,19 @@ const findWebInterface = (blocklet) => {
|
|
|
529
529
|
return interfaces.find((x) => x.type === constant_2.BLOCKLET_INTERFACE_TYPE_WEB);
|
|
530
530
|
};
|
|
531
531
|
exports.findWebInterface = findWebInterface;
|
|
532
|
+
const findDockerInterface = (blocklet) => {
|
|
533
|
+
if (!blocklet) {
|
|
534
|
+
return null;
|
|
535
|
+
}
|
|
536
|
+
// @ts-ignore
|
|
537
|
+
const meta = blocklet.meta || blocklet || {};
|
|
538
|
+
const { interfaces = [] } = meta;
|
|
539
|
+
if (!Array.isArray(interfaces)) {
|
|
540
|
+
return null;
|
|
541
|
+
}
|
|
542
|
+
return interfaces.find((x) => x.type === constant_2.BLOCKLET_INTERFACE_TYPE_DOCKER);
|
|
543
|
+
};
|
|
544
|
+
exports.findDockerInterface = findDockerInterface;
|
|
532
545
|
const findWebInterfacePort = (blocklet) => {
|
|
533
546
|
if (!blocklet) {
|
|
534
547
|
return null;
|
|
@@ -740,6 +753,7 @@ exports.default = {
|
|
|
740
753
|
fixBlockletStatus,
|
|
741
754
|
findWebInterface,
|
|
742
755
|
findWebInterfacePort,
|
|
756
|
+
findDockerInterface,
|
|
743
757
|
findServiceFromMeta,
|
|
744
758
|
getWhoCanAccess,
|
|
745
759
|
getComponentWhoCanAccess,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.
|
|
6
|
+
"version": "1.16.33-beta-20240929-110332-9d5dfdc4",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "./lib/index.js",
|
|
9
9
|
"typings": "./lib/index.d.ts",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@abtnode/constant": "1.16.
|
|
28
|
+
"@abtnode/constant": "1.16.33-beta-20240929-110332-9d5dfdc4",
|
|
29
29
|
"@arcblock/did": "1.18.135",
|
|
30
30
|
"@arcblock/did-ext": "1.18.135",
|
|
31
31
|
"@arcblock/did-util": "1.18.135",
|
|
32
32
|
"@arcblock/jwt": "1.18.135",
|
|
33
|
-
"@blocklet/constant": "1.16.
|
|
33
|
+
"@blocklet/constant": "1.16.33-beta-20240929-110332-9d5dfdc4",
|
|
34
34
|
"@ocap/asset": "1.18.135",
|
|
35
35
|
"@ocap/mcrypto": "1.18.135",
|
|
36
36
|
"@ocap/types": "1.18.135",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"ts-node": "^10.9.1",
|
|
80
80
|
"typescript": "^5.0.4"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "315517d60ab74ae086b6ff07e4871a3723c4dde4"
|
|
83
83
|
}
|