@blocklet/meta 1.16.16 → 1.16.17-beta-7ec31a60

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/axios.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import axios from 'axios';
2
+ export default axios;
package/lib/axios.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const axios_1 = __importDefault(require("axios"));
7
+ const hpagent_1 = require("hpagent");
8
+ function proxyInterceptor(config) {
9
+ /* istanbul ignore if */
10
+ if (config.socketPath != null)
11
+ return config;
12
+ const { proxy } = config;
13
+ /* istanbul ignore if */
14
+ if (proxy === false)
15
+ return config;
16
+ const httpProxyUrl = process.env.HTTP_PROXY || process.env.http_proxy;
17
+ const httpsProxyUrl = process.env.HTTPS_PROXY || process.env.https_proxy;
18
+ const proxyOptions = Object.assign({ keepAlive: true, keepAliveMsecs: 1000, maxSockets: 256, maxFreeSockets: 256 }, config.proxyOptions || {});
19
+ if (httpProxyUrl) {
20
+ config.proxy = false;
21
+ config.httpAgent = new hpagent_1.HttpProxyAgent({ proxy: httpProxyUrl, ...proxyOptions });
22
+ }
23
+ if (httpsProxyUrl) {
24
+ config.proxy = false;
25
+ config.httpsAgent = new hpagent_1.HttpsProxyAgent({ proxy: httpsProxyUrl, ...proxyOptions });
26
+ }
27
+ return config;
28
+ }
29
+ axios_1.default.interceptors.request.use(proxyInterceptor);
30
+ exports.default = axios_1.default;
@@ -0,0 +1,6 @@
1
+ declare const normalizePathPrefix: (prefix: any) => string;
2
+ export { normalizePathPrefix };
3
+ declare const _default: {
4
+ normalizePathPrefix: (prefix: any) => string;
5
+ };
6
+ export default _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizePathPrefix = void 0;
4
+ const normalizePathPrefix = (prefix) => {
5
+ if (typeof prefix === 'string') {
6
+ if (!prefix || prefix === '/') {
7
+ return '/';
8
+ }
9
+ return `/${prefix}/`.replace(/\/+/g, '/');
10
+ }
11
+ return '/';
12
+ };
13
+ exports.normalizePathPrefix = normalizePathPrefix;
14
+ exports.default = { normalizePathPrefix };
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  const get_1 = __importDefault(require("lodash/get"));
6
6
  const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
7
7
  const isEqual_1 = __importDefault(require("lodash/isEqual"));
8
- const normalize_path_prefix_1 = __importDefault(require("@abtnode/util/lib/normalize-path-prefix"));
9
- const parseLinkString = (link, prefix = '') => link.startsWith('/') ? (0, normalize_path_prefix_1.default)(`${prefix}${link || '/'}`) : link;
8
+ const normalize_path_prefix_1 = require("./normalize-path-prefix");
9
+ const parseLinkString = (link, prefix = '') => link.startsWith('/') ? (0, normalize_path_prefix_1.normalizePathPrefix)(`${prefix}${link || '/'}`) : link;
10
10
  const parseLink = (input, prefix) => {
11
11
  if (Object.prototype.toString.call(input) === '[object Object]') {
12
12
  return Object.entries(input).reduce((o, [key, value]) => {
@@ -119,9 +119,9 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
119
119
  if (childNav.section) {
120
120
  item.section = item.section || childNav.section;
121
121
  }
122
- item.link = parseLink(childNavigation[0].link || '/', (0, normalize_path_prefix_1.default)(`${prefix}${child.mountPoint}`));
122
+ item.link = parseLink(childNavigation[0].link || '/', (0, normalize_path_prefix_1.normalizePathPrefix)(`${prefix}${child.mountPoint}`));
123
123
  // doParseNavigation because child nav depth may be > 1
124
- const list = doParseNavigation(childNavigation, child, (0, normalize_path_prefix_1.default)(`${prefix}${child.mountPoint}`), _level + 1);
124
+ const list = doParseNavigation(childNavigation, child, (0, normalize_path_prefix_1.normalizePathPrefix)(`${prefix}${child.mountPoint}`), _level + 1);
125
125
  if (list.length > 1) {
126
126
  // more than 1 child nav
127
127
  delete item.link;
@@ -139,7 +139,7 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
139
139
  else {
140
140
  // child declares multiple menus
141
141
  const groupSection = childNavigation[0].section || [];
142
- const list = doParseNavigation(childNavigation, child, (0, normalize_path_prefix_1.default)(`${prefix}${child.mountPoint}`), _level + 1);
142
+ const list = doParseNavigation(childNavigation, child, (0, normalize_path_prefix_1.normalizePathPrefix)(`${prefix}${child.mountPoint}`), _level + 1);
143
143
  if (_level === 1) {
144
144
  // primary menu
145
145
  const item = (0, cloneDeep_1.default)(itemProto);
package/lib/payment/v2.js CHANGED
@@ -35,7 +35,6 @@ const json_stable_stringify_1 = __importDefault(require("json-stable-stringify")
35
35
  const get_1 = __importDefault(require("lodash/get"));
36
36
  const pick_1 = __importDefault(require("lodash/pick"));
37
37
  const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
38
- const axios_1 = __importDefault(require("@abtnode/util/lib/axios"));
39
38
  const util_1 = require("@ocap/util");
40
39
  const asset_1 = require("@ocap/asset");
41
40
  const wallet_1 = require("@ocap/wallet");
@@ -46,6 +45,7 @@ const nft_templates_1 = require("../nft-templates");
46
45
  const validate_1 = require("../validate");
47
46
  const util_2 = require("../util");
48
47
  const util_meta_1 = require("../util-meta");
48
+ const axios_1 = __importDefault(require("../axios"));
49
49
  const debug = (0, debug_1.default)('@blocklet/meta:payment');
50
50
  const { toTypeInfo } = did;
51
51
  const { BLOCKLET_STORE_META_PATH } = constant_1.default;
package/lib/schema.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- import JOI from 'joi';
1
+ import JOI, { Root } from 'joi';
2
+ declare const Joi: Root & {
3
+ [key: string]: Function;
4
+ };
2
5
  declare const titleSchema: JOI.StringSchema<string>;
3
6
  declare const descriptionSchema: JOI.StringSchema<string>;
4
7
  declare const logoSchema: JOI.StringSchema<string>;
@@ -30,7 +33,7 @@ declare const createBlockletSchema: (baseDir: string, { ensureFiles, ensureDist,
30
33
  ensureName?: boolean;
31
34
  skipValidateDidName?: boolean;
32
35
  }) => JOI.ObjectSchema;
33
- export { blockletMetaSchema, blockletNameSchema, componentSchema, createBlockletSchema, descriptionSchema, distSchema, endpointSchema, engineSchema, environmentSchema, environmentNameSchema, interfaceSchema, logoSchema, mountPointSchema, updateMountPointSchema, navigationItemSchema, navigationSchema, personSchema, scriptsSchema, serviceSchema, signatureSchema, themeSchema, titleSchema, statsSchema, cacheableSchema, authConfigSchema, };
36
+ export { blockletMetaSchema, blockletNameSchema, componentSchema, createBlockletSchema, descriptionSchema, distSchema, endpointSchema, engineSchema, environmentSchema, environmentNameSchema, interfaceSchema, logoSchema, mountPointSchema, updateMountPointSchema, navigationItemSchema, navigationSchema, personSchema, scriptsSchema, serviceSchema, signatureSchema, themeSchema, titleSchema, statsSchema, cacheableSchema, authConfigSchema, Joi, };
34
37
  declare const _default: {
35
38
  blockletNameSchema: JOI.StringSchema<string>;
36
39
  componentSchema: JOI.ObjectSchema<any>;
@@ -57,5 +60,8 @@ declare const _default: {
57
60
  mountPointSchema: JOI.StringSchema<string>;
58
61
  updateMountPointSchema: JOI.StringSchema<string>;
59
62
  authConfigSchema: JOI.ObjectSchema<any>;
63
+ Joi: JOI.Root & {
64
+ [key: string]: Function;
65
+ };
60
66
  };
61
67
  export default _default;
package/lib/schema.js CHANGED
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.authConfigSchema = exports.cacheableSchema = exports.statsSchema = exports.titleSchema = exports.themeSchema = exports.signatureSchema = exports.serviceSchema = exports.scriptsSchema = exports.personSchema = exports.navigationSchema = exports.navigationItemSchema = exports.updateMountPointSchema = exports.mountPointSchema = exports.logoSchema = exports.interfaceSchema = exports.environmentNameSchema = exports.environmentSchema = exports.engineSchema = exports.endpointSchema = exports.distSchema = exports.descriptionSchema = exports.createBlockletSchema = exports.componentSchema = exports.blockletNameSchema = exports.blockletMetaSchema = void 0;
29
+ exports.Joi = exports.authConfigSchema = exports.cacheableSchema = exports.statsSchema = exports.titleSchema = exports.themeSchema = exports.signatureSchema = exports.serviceSchema = exports.scriptsSchema = exports.personSchema = exports.navigationSchema = exports.navigationItemSchema = exports.updateMountPointSchema = exports.mountPointSchema = exports.logoSchema = exports.interfaceSchema = exports.environmentNameSchema = exports.environmentSchema = exports.engineSchema = exports.endpointSchema = exports.distSchema = exports.descriptionSchema = exports.createBlockletSchema = exports.componentSchema = exports.blockletNameSchema = exports.blockletMetaSchema = void 0;
30
30
  const fs_1 = __importDefault(require("fs"));
31
31
  const joi_1 = __importDefault(require("joi"));
32
32
  const cjk_length_1 = __importDefault(require("cjk-length"));
@@ -48,6 +48,7 @@ const Joi = joi_1.default.extend(joi_extension_semver_1.semver)
48
48
  .extend(joi_extension_semver_1.semverRange)
49
49
  .extend(extension_1.fileExtension)
50
50
  .extend(extension_1.didExtension);
51
+ exports.Joi = Joi;
51
52
  const checkLinkHelper = (value, helper) => {
52
53
  if ((0, parse_navigation_from_blocklet_1.checkLink)(value)) {
53
54
  return value;
@@ -623,20 +624,19 @@ const blockletMetaProps = {
623
624
  scripts: scriptsSchema,
624
625
  // capabilities
625
626
  capabilities: Joi.object({
626
- clusterMode: Joi.boolean().default(false),
627
- // added in 1.2.2
628
- component: Joi.boolean().default(true),
627
+ clusterMode: Joi.boolean(),
629
628
  didSpace: Joi.string()
630
629
  .valid(...Object.values(constant_2.BLOCKLET_APP_SPACE_ENDPOINTS))
631
630
  .optional(),
632
631
  navigation: Joi.boolean().default(true),
633
- serverless: Joi.boolean().optional(), // Can the blocklet be installed on serverless
634
- }).default({
635
- clusterMode: false,
636
- component: true,
637
- }),
632
+ serverless: Joi.boolean().optional(),
633
+ // @deprecated
634
+ component: Joi.boolean().default(true),
635
+ resourceExportPage: Joi.string().trim(),
636
+ }).default({}),
638
637
  // Other contents to be included in the bundle
639
638
  files: Joi.array().items(Joi.string().trim()).optional(),
639
+ resources: Joi.array().items(Joi.string().trim().required()),
640
640
  // TODO: this field should be refactored in future version
641
641
  engine: Joi.alternatives().try(engineSchema, Joi.array().items(engineSchema)).optional(),
642
642
  // NOTE: following fields are appended by registry or bundling process
@@ -688,7 +688,6 @@ const createBlockletSchema = (baseDir, { ensureFiles = false, ensureDist = false
688
688
  components: componentsSchema({ checkStore: ensureComponentStore }),
689
689
  staticComponents: componentsSchema({ isStatic: true, checkStore: ensureComponentStore }),
690
690
  name: ensureName ? Joi.string().optional() : Joi.string().required(),
691
- resources: Joi.array().items(Joi.string().trim().required()),
692
691
  })
693
692
  .options({ stripUnknown: true, noDefaults: false, ...schemaOptions })
694
693
  .rename('children', 'components')
@@ -743,4 +742,5 @@ exports.default = {
743
742
  mountPointSchema,
744
743
  updateMountPointSchema,
745
744
  authConfigSchema,
745
+ Joi,
746
746
  };
@@ -15,6 +15,7 @@ export interface TBlockletMeta {
15
15
  component?: boolean;
16
16
  didSpace?: 'required' | 'optional';
17
17
  navigation?: boolean;
18
+ resourceExportPage?: string;
18
19
  serverless?: boolean;
19
20
  };
20
21
  community?: string;
@@ -95,6 +96,7 @@ export interface TBlockletMeta {
95
96
  os?: '*' | 'aix' | 'darwin' | 'freebsd' | 'linux' | 'openbsd' | 'sunos' | 'win32' | ('aix' | 'darwin' | 'freebsd' | 'linux' | 'openbsd' | 'sunos' | 'win32')[];
96
97
  server?: string;
97
98
  };
99
+ resources?: string[];
98
100
  screenshots?: string[];
99
101
  scripts?: TScripts;
100
102
  signatures?: TSignature[];
@@ -1,3 +1,6 @@
1
- import { urlPathFriendly, isValidUrlPath } from '@abtnode/util/lib/url-path-friendly';
1
+ declare const isValidUrlPath: (name: any) => boolean;
2
+ declare const urlPathFriendly: (name: any, { keepSlash }?: {
3
+ keepSlash?: boolean;
4
+ }) => any;
2
5
  export { isValidUrlPath };
3
6
  export default urlPathFriendly;
@@ -1,6 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isValidUrlPath = void 0;
4
- const url_path_friendly_1 = require("@abtnode/util/lib/url-path-friendly");
5
- Object.defineProperty(exports, "isValidUrlPath", { enumerable: true, get: function () { return url_path_friendly_1.isValidUrlPath; } });
6
- exports.default = url_path_friendly_1.urlPathFriendly;
4
+ const isValidUrlPath = (name) => {
5
+ // Check if the path contains any uppercase letters
6
+ if (/[A-Z]/.test(name)) {
7
+ return false;
8
+ }
9
+ // Check if the path contains any non-ASCII characters
10
+ if (/[^\x20-\x7F]/.test(name)) {
11
+ return false;
12
+ }
13
+ // Check if the resulting string matches the pattern of a valid URL path
14
+ const regex = /^[a-z0-9/\-._]*$/i;
15
+ return regex.test(name) && !name.includes('//');
16
+ };
17
+ exports.isValidUrlPath = isValidUrlPath;
18
+ const urlPathFriendly = (name, { keepSlash = true } = {}) => {
19
+ // Replace non-URL path friendly characters with hyphens
20
+ const pathFriendlyStr = name
21
+ .trim()
22
+ .replace(/[^\x20-\x7F]/g, '')
23
+ .replace(/[^a-z0-9_.\-/]/gi, '-')
24
+ .toLowerCase();
25
+ // Remove consecutive hyphens
26
+ const noConsecutiveHyphens = pathFriendlyStr.replace(/-+/g, '-');
27
+ // Replace consecutive periods with a single period
28
+ const result = noConsecutiveHyphens.replace(/\.+/g, '.');
29
+ // Remove consecutive slashes if keepSlash is true
30
+ const noConsecutiveSlashes = result.replace(/\/+/g, '/');
31
+ // Remove leading/trailing slashes if keepSlash is false
32
+ if (!keepSlash) {
33
+ return noConsecutiveSlashes.replace(/^\/|\/$/g, '');
34
+ }
35
+ return noConsecutiveSlashes;
36
+ };
37
+ exports.default = urlPathFriendly;
package/lib/util-meta.js CHANGED
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getSourceUrlsFromConfig = exports.getBlockletMetaFromUrls = exports.getBlockletMetaFromUrl = exports.getBlockletMetaByUrl = exports.validateUrl = void 0;
7
7
  const url_1 = require("url");
8
8
  const fs_1 = __importDefault(require("fs"));
9
- const axios_1 = __importDefault(require("@abtnode/util/lib/axios"));
10
9
  const promise_any_1 = __importDefault(require("promise.any"));
11
10
  const url_join_1 = __importDefault(require("url-join"));
12
11
  const constant_1 = __importDefault(require("@abtnode/constant"));
12
+ const axios_1 = __importDefault(require("./axios"));
13
13
  const did_1 = __importDefault(require("./did"));
14
14
  const validate_1 = require("./validate");
15
15
  // @ts-ignore
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.16",
6
+ "version": "1.16.17-beta-7ec31a60",
7
7
  "description": "Library to parse/validate/fix blocklet meta",
8
8
  "main": "./lib/index.js",
9
9
  "typings": "./lib/index.d.ts",
@@ -24,24 +24,24 @@
24
24
  "author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
- "@abtnode/constant": "1.16.16",
28
- "@abtnode/util": "1.16.16",
29
- "@arcblock/did": "1.18.90",
30
- "@arcblock/did-ext": "1.18.90",
31
- "@arcblock/did-util": "1.18.90",
32
- "@arcblock/jwt": "1.18.90",
33
- "@blocklet/constant": "1.16.16",
34
- "@ocap/asset": "1.18.90",
35
- "@ocap/mcrypto": "1.18.90",
36
- "@ocap/types": "1.18.90",
37
- "@ocap/util": "1.18.90",
38
- "@ocap/wallet": "1.18.90",
27
+ "@abtnode/constant": "1.16.17-beta-7ec31a60",
28
+ "@arcblock/did": "1.18.91",
29
+ "@arcblock/did-ext": "1.18.91",
30
+ "@arcblock/did-util": "1.18.91",
31
+ "@arcblock/jwt": "1.18.91",
32
+ "@blocklet/constant": "1.16.17-beta-7ec31a60",
33
+ "@ocap/asset": "1.18.91",
34
+ "@ocap/mcrypto": "1.18.91",
35
+ "@ocap/types": "1.18.91",
36
+ "@ocap/util": "1.18.91",
37
+ "@ocap/wallet": "1.18.91",
39
38
  "ajv": "^8.11.0",
40
39
  "axios": "^0.27.2",
41
40
  "cjk-length": "^1.0.0",
42
41
  "debug": "^4.3.4",
43
42
  "fs-extra": "^10.1.0",
44
43
  "hosted-git-info": "3.0.8",
44
+ "hpagent": "^1.1.0",
45
45
  "is-absolute-url": "^3.0.3",
46
46
  "is-glob": "^4.0.3",
47
47
  "is-var-name": "^2.0.0",
@@ -78,5 +78,5 @@
78
78
  "ts-node": "^10.9.1",
79
79
  "typescript": "^5.0.4"
80
80
  },
81
- "gitHead": "2de4f6dbad086bd861273a4fc9ca8a87ddda4778"
81
+ "gitHead": "622bb131130d28c3fc554dcb5dc9d72b7da3fba2"
82
82
  }