@mfeflow/contracts 0.6.0 → 0.7.0

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/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export { judgeRemoteInitial, primaryExpose, type RemoteInitialVerdict } from './
7
7
  export { injectIntoHead, registryInjection, type InjectionOptions, type RouteNeed, } from './html-injection.js';
8
8
  export { isRegistryEntry, isRegistryIndex, isRegistryIndexRemote, registryRemoteIssues, ROUTE_OVERLAP, validateRegistryEntry, validateRegistryIndex, type RegistryEntry, type RegistryIndex, type RegistryIndexRemote, } from './registry.js';
9
9
  export { isFeatureRegistryIndex, isLoopbackHttp, isPrivateHost, isRegistryProtocol, redactUrl, redactUrlsIn, registryIndexUrl, registryTemplateProblem, validateFeatureRegistryIndex, MAX_DESCRIPTION, MAX_INDEX_ITEMS, REGISTRY_ITEM_NAME, type FeatureRegistryIndex, type FeatureRegistryItem, } from './feature-registry.js';
10
- export { FILE_HASH, PROJECT_REPOS, REGISTRY_HOST, REGISTRY_NAMESPACE, isMfeflowProject, validateMfeflowProject, type MfeflowProject, type ProjectBudget, type ProjectRegistry, } from './project.js';
10
+ export { ENV_KEY_NAME, FILE_HASH, PROJECT_REPOS, REGISTRY_HOST, REGISTRY_NAMESPACE, isMfeflowProject, validateMfeflowProject, type MfeflowProject, type ProjectBudget, type ProjectRegistry, } from './project.js';
11
11
  export { COST_MODEL, judgeCost, round1, splitScripts, type CostLine, type CostModel, type CostSample, type CostVerdict, } from './cost-model.js';
12
12
  export { FEATURE_CONDITION, FEATURE_NAME, isFeatureManifest, TRANSFORM_OPS, validateFeatureManifest, type AddBootStepOp, type AddEnvKeyOp, type AddImportOp, type AddRouteOp, type AddSharedOp, type AddWorkflowStepOp, type EnvValidator, type FeatureCondition, type FeatureDependency, type FeatureFile, type FeatureManifest, type FeatureMigration, type FeaturePrompt, type FeatureScript, type FeatureTarget, type Literal, type PromptValue, type TransformOp, type TransformOpName, type WorkflowStep, type WrapProviderOp, } from './feature.js';
13
13
  export { DOCS_URL, SCHEMA_ALIASES, SCHEMA_URLS, errorDocsUrl, type SchemaName } from './docs.js';
package/dist/index.js CHANGED
@@ -715,6 +715,7 @@ function redactUrlsIn(text) {
715
715
  }
716
716
  const project_SEGMENT = String.raw`(?!\.\.?(?:/|$))[^/\\\u0000]+`;
717
717
  const CHECKOUT_PATH = new RegExp(`^(?:(?![A-Za-z]:)(?:\\.\\.(?:/\\.\\.)*(?:/${project_SEGMENT})*|${project_SEGMENT}(?:/${project_SEGMENT})*)|(?:/|[A-Za-z]:/)${project_SEGMENT}(?:/${project_SEGMENT})*)$`);
718
+ const ENV_KEY_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
718
719
  const FILE_HASH = /^sha256-[0-9a-f]{64}$/;
719
720
  const REGISTRY_NAMESPACE = /^@[a-z0-9][a-z0-9-]*$/;
720
721
  function isCheckoutPath(value) {
@@ -821,6 +822,12 @@ function validateMfeflowProject(value) {
821
822
  if (!isSafeRelativePath(file)) c.add(at, 'must be a relative path with forward slashes');
822
823
  if ('string' != typeof hash || !FILE_HASH.test(hash)) c.add(at, 'must be a hash like "sha256-<64 hex characters>"');
823
824
  }
825
+ const envKeys = c.object(value, 'envKeys', '', false);
826
+ if (envKeys) for (const [file, keys] of Object.entries(envKeys)){
827
+ const at = `envKeys.${file}`;
828
+ if (!isSafeRelativePath(file)) c.add(at, 'must be a relative path with forward slashes');
829
+ if (!Array.isArray(keys) || keys.some((key)=>'string' != typeof key || !ENV_KEY_NAME.test(key))) c.add(at, 'must be a list of key names like "API_ORIGIN"');
830
+ }
824
831
  const registries = c.object(value, 'registries', '', false);
825
832
  if (registries) for (const [ns, url] of Object.entries(registries)){
826
833
  const at = `registries.${ns}`;
@@ -1524,6 +1531,11 @@ const JSON_SCHEMAS = {
1524
1531
  propertyNames: relativePath,
1525
1532
  additionalProperties: str(FILE_HASH)
1526
1533
  },
1534
+ envKeys: {
1535
+ type: 'object',
1536
+ propertyNames: relativePath,
1537
+ additionalProperties: json_schema_strings(ENV_KEY_NAME)
1538
+ },
1527
1539
  registries: {
1528
1540
  type: 'object',
1529
1541
  propertyNames: {
@@ -1773,4 +1785,4 @@ const JSON_SCHEMAS = {
1773
1785
  })
1774
1786
  };
1775
1787
  export { EXPOSE, ROUTE, isRegistryIndexRemote, registryRemoteIssues } from "./entry.js";
1776
- export { ANALYTICS_EVENT, COST_MODEL, DOCS_URL, EVENT_NAME, FEATURE_CONDITION, FEATURE_NAME, FILE_HASH, JSON_SCHEMAS, MAX_DESCRIPTION, MAX_INDEX_ITEMS, MFE_NAME, PROJECT_REPOS, REGISTRY_HOST, REGISTRY_ITEM_NAME, REGISTRY_NAMESPACE, ROUTE_OVERLAP, SCHEMA_ALIASES, SCHEMA_URLS, TRANSFORM_OPS, assetsFromManifest, errorDocsUrl, injectIntoHead, isFeatureManifest, isFeatureRegistryIndex, isLoopbackHttp, isMfeManifest, isMfeflowProject, isPortableRelativePath, isPrivateHost, isRegistryEntry, isRegistryIndex, isRegistryProtocol, isSafeRelativePath, judgeCost, judgeRemoteInitial, primaryExpose, redactUrl, redactUrlsIn, registryIndexUrl, registryInjection, registryTemplateProblem, remoteDistFiles, round1, routesOverlap, splitScripts, validateFeatureManifest, validateFeatureRegistryIndex, validateMfeManifest, validateMfeflowProject, validateRegistryEntry, validateRegistryIndex };
1788
+ export { ANALYTICS_EVENT, COST_MODEL, DOCS_URL, ENV_KEY_NAME, EVENT_NAME, FEATURE_CONDITION, FEATURE_NAME, FILE_HASH, JSON_SCHEMAS, MAX_DESCRIPTION, MAX_INDEX_ITEMS, MFE_NAME, PROJECT_REPOS, REGISTRY_HOST, REGISTRY_ITEM_NAME, REGISTRY_NAMESPACE, ROUTE_OVERLAP, SCHEMA_ALIASES, SCHEMA_URLS, TRANSFORM_OPS, assetsFromManifest, errorDocsUrl, injectIntoHead, isFeatureManifest, isFeatureRegistryIndex, isLoopbackHttp, isMfeManifest, isMfeflowProject, isPortableRelativePath, isPrivateHost, isRegistryEntry, isRegistryIndex, isRegistryProtocol, isSafeRelativePath, judgeCost, judgeRemoteInitial, primaryExpose, redactUrl, redactUrlsIn, registryIndexUrl, registryInjection, registryTemplateProblem, remoteDistFiles, round1, routesOverlap, splitScripts, validateFeatureManifest, validateFeatureRegistryIndex, validateMfeManifest, validateMfeflowProject, validateRegistryEntry, validateRegistryIndex };
package/dist/project.d.ts CHANGED
@@ -29,6 +29,11 @@ export interface MfeflowProject {
29
29
  * While the new version is that one, the file stays quiet; when it changes, the file is raised again.
30
30
  */
31
31
  kept?: Record<string, string>;
32
+ /**
33
+ * Keys `mfeflow add env-key` wrote, by the file it wrote them in. `upgrade` asks before a new
34
+ * template changes the value of one of them. Absent in projects made before this was recorded.
35
+ */
36
+ envKeys?: Record<string, string[]>;
32
37
  /** Third-party feature registries: `{ "@someone": "https://…/{name}.json" }`, https only (plain http for loopback hosts). `@mfeflow` is reserved. */
33
38
  registries?: Record<string, string>;
34
39
  /** Built mfeflow checkout, relative to the project root, that `@mfeflow/*` dependencies link to. Set by `--local` only. */
@@ -56,6 +61,8 @@ export interface ProjectBudget {
56
61
  }
57
62
  /** The regex form of `isCheckoutPath`, for JSON Schema. */
58
63
  export declare const CHECKOUT_PATH: RegExp;
64
+ /** An env key name, as `mfeflow add env-key` accepts it. */
65
+ export declare const ENV_KEY_NAME: RegExp;
59
66
  export declare const FILE_HASH: RegExp;
60
67
  export declare const REGISTRY_NAMESPACE: RegExp;
61
68
  /** A relative path with forward slashes whose only `..` segments come first, so it may leave the project. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mfeflow/contracts",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Types, validators and JSON Schemas for mfeflow: mfeflow.app.json ownership manifests, mfeflow.json project state, and the remote registry (entries and index).",
5
5
  "keywords": [
6
6
  "micro-frontend",