@veryfront/ext-content-mdx 0.1.1226 → 0.1.1228

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.
Files changed (107) hide show
  1. package/esm/_dnt.polyfills.d.ts +105 -6
  2. package/esm/_dnt.polyfills.d.ts.map +1 -1
  3. package/esm/_dnt.polyfills.js +127 -1
  4. package/esm/deno.d.ts +17 -2
  5. package/esm/deno.js +24 -9
  6. package/esm/src/extensions/contract-registry-internal.d.ts +144 -0
  7. package/esm/src/extensions/contract-registry-internal.d.ts.map +1 -0
  8. package/esm/src/extensions/contract-registry-internal.js +642 -0
  9. package/esm/src/extensions/contracts.d.ts +16 -0
  10. package/esm/src/extensions/contracts.d.ts.map +1 -0
  11. package/esm/src/extensions/contracts.js +46 -0
  12. package/esm/src/extensions/errors.d.ts +16 -0
  13. package/esm/src/extensions/errors.d.ts.map +1 -0
  14. package/esm/src/extensions/errors.js +46 -0
  15. package/esm/src/extensions/first-party-import.d.ts +43 -0
  16. package/esm/src/extensions/first-party-import.d.ts.map +1 -0
  17. package/esm/src/extensions/first-party-import.js +377 -0
  18. package/esm/src/extensions/parser/yaml-defaults.d.ts +22 -0
  19. package/esm/src/extensions/parser/yaml-defaults.d.ts.map +1 -0
  20. package/esm/src/extensions/parser/yaml-defaults.js +57 -0
  21. package/esm/src/extensions/parser/yaml-parser.d.ts +59 -0
  22. package/esm/src/extensions/parser/yaml-parser.d.ts.map +1 -0
  23. package/esm/src/extensions/parser/yaml-parser.js +62 -0
  24. package/esm/src/extensions/recommendations.d.ts +8 -0
  25. package/esm/src/extensions/recommendations.d.ts.map +1 -0
  26. package/esm/src/extensions/recommendations.js +38 -0
  27. package/esm/src/extensions/runtime-validation.d.ts +21 -0
  28. package/esm/src/extensions/runtime-validation.d.ts.map +1 -0
  29. package/esm/src/extensions/runtime-validation.js +95 -0
  30. package/esm/src/observability/telemetry-error.d.ts.map +1 -1
  31. package/esm/src/observability/telemetry-error.js +15 -3
  32. package/esm/src/platform/compat/async-context.d.ts +8 -0
  33. package/esm/src/platform/compat/async-context.d.ts.map +1 -0
  34. package/esm/src/platform/compat/async-context.js +7 -0
  35. package/esm/src/platform/compat/std/front-matter-yaml.js +1 -1
  36. package/esm/src/platform/compat/std/yaml.d.ts +17 -0
  37. package/esm/src/platform/compat/std/yaml.d.ts.map +1 -0
  38. package/esm/src/platform/compat/std/yaml.js +39 -0
  39. package/esm/src/utils/constants/http.d.ts +8 -2
  40. package/esm/src/utils/constants/http.d.ts.map +1 -1
  41. package/esm/src/utils/constants/http.js +10 -2
  42. package/esm/src/utils/version-constant.d.ts +1 -1
  43. package/esm/src/utils/version-constant.js +1 -1
  44. package/package.json +2 -2
  45. package/esm/deps/jsr.io/@std/yaml/1.1.0/_chars.d.ts +0 -33
  46. package/esm/deps/jsr.io/@std/yaml/1.1.0/_chars.d.ts.map +0 -1
  47. package/esm/deps/jsr.io/@std/yaml/1.1.0/_chars.js +0 -48
  48. package/esm/deps/jsr.io/@std/yaml/1.1.0/_loader_state.d.ts +0 -64
  49. package/esm/deps/jsr.io/@std/yaml/1.1.0/_loader_state.d.ts.map +0 -1
  50. package/esm/deps/jsr.io/@std/yaml/1.1.0/_loader_state.js +0 -1371
  51. package/esm/deps/jsr.io/@std/yaml/1.1.0/_schema.d.ts +0 -44
  52. package/esm/deps/jsr.io/@std/yaml/1.1.0/_schema.d.ts.map +0 -1
  53. package/esm/deps/jsr.io/@std/yaml/1.1.0/_schema.js +0 -117
  54. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/binary.d.ts +0 -3
  55. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/binary.d.ts.map +0 -1
  56. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/binary.js +0 -103
  57. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/bool.d.ts +0 -3
  58. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/bool.d.ts.map +0 -1
  59. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/bool.js +0 -32
  60. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/float.d.ts +0 -3
  61. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/float.d.ts.map +0 -1
  62. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/float.js +0 -96
  63. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/int.d.ts +0 -3
  64. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/int.d.ts.map +0 -1
  65. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/int.js +0 -159
  66. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/map.d.ts +0 -3
  67. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/map.d.ts.map +0 -1
  68. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/map.js +0 -14
  69. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/merge.d.ts +0 -3
  70. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/merge.d.ts.map +0 -1
  71. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/merge.js +0 -10
  72. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/nil.d.ts +0 -3
  73. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/nil.d.ts.map +0 -1
  74. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/nil.js +0 -22
  75. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/omap.d.ts +0 -3
  76. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/omap.d.ts.map +0 -1
  77. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/omap.js +0 -29
  78. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/pairs.d.ts +0 -3
  79. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/pairs.d.ts.map +0 -1
  80. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/pairs.js +0 -19
  81. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/regexp.d.ts +0 -3
  82. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/regexp.d.ts.map +0 -1
  83. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/regexp.js +0 -30
  84. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/seq.d.ts +0 -3
  85. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/seq.d.ts.map +0 -1
  86. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/seq.js +0 -10
  87. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/set.d.ts +0 -3
  88. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/set.d.ts.map +0 -1
  89. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/set.js +0 -14
  90. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/str.d.ts +0 -3
  91. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/str.d.ts.map +0 -1
  92. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/str.js +0 -9
  93. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/timestamp.d.ts +0 -3
  94. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/timestamp.d.ts.map +0 -1
  95. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/timestamp.js +0 -81
  96. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/undefined.d.ts +0 -3
  97. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/undefined.d.ts.map +0 -1
  98. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type/undefined.js +0 -20
  99. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type.d.ts +0 -32
  100. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type.d.ts.map +0 -1
  101. package/esm/deps/jsr.io/@std/yaml/1.1.0/_type.js +0 -6
  102. package/esm/deps/jsr.io/@std/yaml/1.1.0/_utils.d.ts +0 -4
  103. package/esm/deps/jsr.io/@std/yaml/1.1.0/_utils.d.ts.map +0 -1
  104. package/esm/deps/jsr.io/@std/yaml/1.1.0/_utils.js +0 -13
  105. package/esm/deps/jsr.io/@std/yaml/1.1.0/parse.d.ts +0 -76
  106. package/esm/deps/jsr.io/@std/yaml/1.1.0/parse.d.ts.map +0 -1
  107. package/esm/deps/jsr.io/@std/yaml/1.1.0/parse.js +0 -91
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Contract registry — runtime resolution of extension-provided implementations.
3
+ *
4
+ * @module extensions/contracts
5
+ */
6
+ import { MISSING_EXTENSION_ERROR } from "./errors.js";
7
+ import { getRecommendation } from "./recommendations.js";
8
+ import { assertCanonicalNonEmptyString } from "./runtime-validation.js";
9
+ import { registerUnmanagedContract, resetContractRegistry, tryResolveRegisteredContract, unregisterContract, } from "./contract-registry-internal.js";
10
+ /** Resolve path segments to an absolute path. */
11
+ export function resolve(name) {
12
+ assertCanonicalNonEmptyString(name, "Contract name");
13
+ const impl = tryResolveRegisteredContract(name);
14
+ if (impl === undefined) {
15
+ const recommendation = getRecommendation(name);
16
+ throw MISSING_EXTENSION_ERROR.create({
17
+ message: recommendation
18
+ ? `Missing extension for contract "${name}". Install it with: deno add ${recommendation}`
19
+ : `Missing extension for contract "${name}"`,
20
+ detail: recommendation ? `Install it with: deno add ${recommendation}` : undefined,
21
+ });
22
+ }
23
+ return impl;
24
+ }
25
+ /** Try to resolve. */
26
+ export function tryResolve(name) {
27
+ assertCanonicalNonEmptyString(name, "Contract name");
28
+ return tryResolveRegisteredContract(name);
29
+ }
30
+ /** Register. */
31
+ export function register(name, impl) {
32
+ assertCanonicalNonEmptyString(name, "Contract name");
33
+ if (impl === undefined) {
34
+ throw new TypeError(`Contract "${name}" implementation must not be undefined`);
35
+ }
36
+ registerUnmanagedContract(name, impl);
37
+ }
38
+ /** Unregister. */
39
+ export function unregister(name) {
40
+ assertCanonicalNonEmptyString(name, "Contract name");
41
+ unregisterContract(name);
42
+ }
43
+ /** Reset. */
44
+ export function reset() {
45
+ resetContractRegistry();
46
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Extension system error definitions.
3
+ *
4
+ * @module extensions/errors
5
+ */
6
+ /** Shared missing extension error value. */
7
+ export declare const MISSING_EXTENSION_ERROR: import("../errors/types.js").RegisteredError;
8
+ /** Shared extension validation error value. */
9
+ export declare const EXTENSION_VALIDATION_ERROR: import("../errors/types.js").RegisteredError;
10
+ /** Shared circular dependency error value. */
11
+ export declare const CIRCULAR_DEPENDENCY_ERROR: import("../errors/types.js").RegisteredError;
12
+ /** Shared extension conflict error value. */
13
+ export declare const EXTENSION_CONFLICT_ERROR: import("../errors/types.js").RegisteredError;
14
+ /** Shared extension setup timeout error value. */
15
+ export declare const EXTENSION_SETUP_TIMEOUT_ERROR: import("../errors/types.js").RegisteredError;
16
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/src/extensions/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,4CAA4C;AAC5C,eAAO,MAAM,uBAAuB,8CAMlC,CAAC;AAEH,+CAA+C;AAC/C,eAAO,MAAM,0BAA0B,8CAMrC,CAAC;AAEH,8CAA8C;AAC9C,eAAO,MAAM,yBAAyB,8CAMpC,CAAC;AAEH,6CAA6C;AAC7C,eAAO,MAAM,wBAAwB,8CAMnC,CAAC;AAEH,kDAAkD;AAClD,eAAO,MAAM,6BAA6B,8CAOxC,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Extension system error definitions.
3
+ *
4
+ * @module extensions/errors
5
+ */
6
+ import { defineError } from "../errors/types.js";
7
+ /** Shared missing extension error value. */
8
+ export const MISSING_EXTENSION_ERROR = defineError({
9
+ slug: "missing-extension",
10
+ category: "RUNTIME",
11
+ status: 500,
12
+ title: "Required extension not found",
13
+ suggestion: "Install the missing extension package and add it to your configuration",
14
+ });
15
+ /** Shared extension validation error value. */
16
+ export const EXTENSION_VALIDATION_ERROR = defineError({
17
+ slug: "extension-validation",
18
+ category: "CONFIG",
19
+ status: 422,
20
+ title: "Extension validation failed",
21
+ suggestion: "Check that the extension exports a valid name, version, and capabilities array",
22
+ });
23
+ /** Shared circular dependency error value. */
24
+ export const CIRCULAR_DEPENDENCY_ERROR = defineError({
25
+ slug: "extension-circular-dependency",
26
+ category: "CONFIG",
27
+ status: 422,
28
+ title: "Circular dependency detected between extensions",
29
+ suggestion: "Review the 'extends' fields in your extensions to break the cycle",
30
+ });
31
+ /** Shared extension conflict error value. */
32
+ export const EXTENSION_CONFLICT_ERROR = defineError({
33
+ slug: "extension-conflict",
34
+ category: "CONFIG",
35
+ status: 409,
36
+ title: "Conflicting extensions detected",
37
+ suggestion: "Remove or disable one of the conflicting extensions in your configuration",
38
+ });
39
+ /** Shared extension setup timeout error value. */
40
+ export const EXTENSION_SETUP_TIMEOUT_ERROR = defineError({
41
+ slug: "extension-setup-timeout",
42
+ category: "RUNTIME",
43
+ status: 500,
44
+ title: "Extension setup timed out",
45
+ suggestion: "Check the extension's setup() for blocking operations, or increase VF_EXTENSION_SETUP_TIMEOUT_MS",
46
+ });
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Resolve first-party extension implementations without making the root npm
3
+ * package statically depend on every extension dependency.
4
+ *
5
+ * Source and compiled-binary builds can load the workspace extension sources.
6
+ * npm builds should load the separate @veryfront/ext-* packages installed by
7
+ * the consuming service or app.
8
+ */
9
+ /** Optional non-root entry point for a first-party extension import. */
10
+ export interface FirstPartyExtensionImportOptions {
11
+ /**
12
+ * Workspace source entry below the extension's `src/` directory, without
13
+ * an extension. Supply it together with `packageSubpath`; both values must
14
+ * name the same relative entry. When both are omitted, the workspace
15
+ * `index` entry and npm package root are used.
16
+ */
17
+ readonly sourceEntry?: string;
18
+ /**
19
+ * Published npm package subpath, without a leading `./` or `/`.
20
+ * Supply it together with `sourceEntry` using the same value. When both are
21
+ * omitted, the package root is used.
22
+ */
23
+ readonly packageSubpath?: string;
24
+ }
25
+ export declare function firstPartyExtensionSourceSpecifiers(sourceDirectory: string, sourceEntry?: string): string[];
26
+ export declare function importFirstPartyExtensionModule<TModule>(sourceDirectory: string, packageName: string, options?: FirstPartyExtensionImportOptions): Promise<TModule>;
27
+ /**
28
+ * Classify a dynamic-import failure as "the extension module itself is not
29
+ * installed" as opposed to a real load failure inside an installed extension.
30
+ *
31
+ * Checks the stable `error.code` first and falls back to message patterns,
32
+ * walking the `cause` chain so wrapped errors classify like their root cause.
33
+ *
34
+ * When `expectedSpecifierFragments` is provided, package specifiers and
35
+ * absolute/file paths match exactly. Safe relative multi-segment path
36
+ * fragments match only as complete path suffixes, with an optional emitted
37
+ * `.ts` or `.js` extension. Every recognized missing-module error in the
38
+ * cause chain must agree. This keeps a broken transitive dependency (e.g.
39
+ * `Cannot find package 'jose'` thrown while loading an installed
40
+ * @veryfront/ext-auth-jwt) from being misread as "extension not installed".
41
+ */
42
+ export declare function isMissingFirstPartyExtensionModule(error: unknown, expectedSpecifierFragments?: string[]): boolean;
43
+ //# sourceMappingURL=first-party-import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"first-party-import.d.ts","sourceRoot":"","sources":["../../../src/src/extensions/first-party-import.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,wEAAwE;AACxE,MAAM,WAAW,gCAAgC;IAC/C;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AASD,wBAAgB,mCAAmC,CACjD,eAAe,EAAE,MAAM,EACvB,WAAW,SAAU,GACpB,MAAM,EAAE,CAKV;AAED,wBAAsB,+BAA+B,CAAC,OAAO,EAC3D,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,gCAAqC,GAC7C,OAAO,CAAC,OAAO,CAAC,CAqElB;AA8FD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,EACd,0BAA0B,CAAC,EAAE,MAAM,EAAE,GACpC,OAAO,CAuBT"}
@@ -0,0 +1,377 @@
1
+ /**
2
+ * Resolve first-party extension implementations without making the root npm
3
+ * package statically depend on every extension dependency.
4
+ *
5
+ * Source and compiled-binary builds can load the workspace extension sources.
6
+ * npm builds should load the separate @veryfront/ext-* packages installed by
7
+ * the consuming service or app.
8
+ */
9
+ const SOURCE_EXTENSION_ROOT = "../../extensions";
10
+ const FIRST_PARTY_ENTRY_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*(?:\/[A-Za-z0-9][A-Za-z0-9._-]*)*$/;
11
+ const FIRST_PARTY_SOURCE_DIRECTORY_PATTERN = /^ext-[a-z0-9]+(?:-[a-z0-9]+)*$/;
12
+ const FIRST_PARTY_PACKAGE_PATTERN = /^@veryfront\/ext-[a-z0-9]+(?:-[a-z0-9]+)*$/;
13
+ const FIRST_PARTY_PACKAGE_SPECIFIER_PATTERN = /^@veryfront\/ext-[a-z0-9]+(?:-[a-z0-9]+)*(?:\/[A-Za-z0-9][A-Za-z0-9._-]*(?:\/[A-Za-z0-9][A-Za-z0-9._-]*)*)?$/;
14
+ const SAFE_RELATIVE_PATH_FRAGMENT_PATTERN = /^[A-Za-z0-9_-][A-Za-z0-9._-]*(?:\/[A-Za-z0-9_-][A-Za-z0-9._-]*)+$/;
15
+ export function firstPartyExtensionSourceSpecifiers(sourceDirectory, sourceEntry = "index") {
16
+ assertValidSourceDirectory(sourceDirectory);
17
+ assertValidEntry("source entry", sourceEntry);
18
+ const sourceRoot = `${SOURCE_EXTENSION_ROOT}/${sourceDirectory}/src/${sourceEntry}`;
19
+ return [`${sourceRoot}.ts`, `${sourceRoot}.js`];
20
+ }
21
+ export async function importFirstPartyExtensionModule(sourceDirectory, packageName, options = {}) {
22
+ assertValidSourceDirectory(sourceDirectory);
23
+ assertValidPackageName(packageName);
24
+ if (packageName !== `@veryfront/${sourceDirectory}`) {
25
+ throw new TypeError("First-party extension source directory and package name must identify the same extension");
26
+ }
27
+ const capturedOptions = captureImportOptions(options);
28
+ if (capturedOptions.hasSourceEntry !== capturedOptions.hasPackageSubpath ||
29
+ (capturedOptions.hasSourceEntry &&
30
+ capturedOptions.sourceEntry !== capturedOptions.packageSubpath)) {
31
+ throw new TypeError("First-party extension source entry and package subpath must be supplied together and match");
32
+ }
33
+ const sourceEntry = capturedOptions.hasSourceEntry ? capturedOptions.sourceEntry : "index";
34
+ const packageSubpath = capturedOptions.hasPackageSubpath
35
+ ? capturedOptions.packageSubpath
36
+ : undefined;
37
+ assertValidEntry("source entry", sourceEntry);
38
+ if (packageSubpath !== undefined) {
39
+ assertValidEntry("package subpath", packageSubpath);
40
+ }
41
+ const packageSpecifier = packageSubpath === undefined
42
+ ? packageName
43
+ : `${packageName}/${packageSubpath}`;
44
+ let sourceError;
45
+ for (const sourceSpecifier of firstPartyExtensionSourceSpecifiers(sourceDirectory, sourceEntry)) {
46
+ try {
47
+ return await import(sourceSpecifier);
48
+ }
49
+ catch (error) {
50
+ const expectedSourceSpecifier = new URL(sourceSpecifier, globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url).href;
51
+ if (!isMissingFirstPartyExtensionModule(error, [expectedSourceSpecifier])) {
52
+ throw error;
53
+ }
54
+ sourceError ??= error;
55
+ }
56
+ }
57
+ try {
58
+ return await import(packageSpecifier);
59
+ }
60
+ catch (error) {
61
+ const expectedPackageSpecifiers = packageSubpath === undefined
62
+ ? [packageName]
63
+ : [packageSpecifier, packageName];
64
+ if (!isMissingFirstPartyExtensionModule(error, expectedPackageSpecifiers)) {
65
+ throw error;
66
+ }
67
+ throw withMissingExtensionInstallHint(error, sourceDirectory, packageName, packageSpecifier, sourceError);
68
+ }
69
+ }
70
+ function captureImportOptions(options) {
71
+ if (typeof options !== "object" || options === null || Array.isArray(options)) {
72
+ return throwInvalidImportOptions();
73
+ }
74
+ let prototype;
75
+ let keys;
76
+ try {
77
+ prototype = Object.getPrototypeOf(options);
78
+ keys = Reflect.ownKeys(options);
79
+ }
80
+ catch {
81
+ return throwInvalidImportOptions();
82
+ }
83
+ if (prototype !== Object.prototype && prototype !== null) {
84
+ return throwInvalidImportOptions();
85
+ }
86
+ let sourceEntryDescriptor;
87
+ let packageSubpathDescriptor;
88
+ try {
89
+ for (const key of keys) {
90
+ if (key !== "sourceEntry" && key !== "packageSubpath") {
91
+ return throwInvalidImportOptions();
92
+ }
93
+ const descriptor = Object.getOwnPropertyDescriptor(options, key);
94
+ if (descriptor === undefined ||
95
+ descriptor.enumerable !== true ||
96
+ !Object.prototype.hasOwnProperty.call(descriptor, "value")) {
97
+ return throwInvalidImportOptions();
98
+ }
99
+ if (key === "sourceEntry") {
100
+ sourceEntryDescriptor = descriptor;
101
+ }
102
+ else {
103
+ packageSubpathDescriptor = descriptor;
104
+ }
105
+ }
106
+ }
107
+ catch {
108
+ return throwInvalidImportOptions();
109
+ }
110
+ return Object.freeze({
111
+ hasSourceEntry: sourceEntryDescriptor?.value !== undefined,
112
+ hasPackageSubpath: packageSubpathDescriptor?.value !== undefined,
113
+ sourceEntry: sourceEntryDescriptor?.value,
114
+ packageSubpath: packageSubpathDescriptor?.value,
115
+ });
116
+ }
117
+ function throwInvalidImportOptions() {
118
+ throw new TypeError("Invalid first-party extension import options");
119
+ }
120
+ function assertValidSourceDirectory(sourceDirectory) {
121
+ if (typeof sourceDirectory !== "string" ||
122
+ !FIRST_PARTY_SOURCE_DIRECTORY_PATTERN.test(sourceDirectory)) {
123
+ throw new TypeError("Invalid first-party extension source directory");
124
+ }
125
+ }
126
+ function assertValidPackageName(packageName) {
127
+ if (typeof packageName !== "string" ||
128
+ !FIRST_PARTY_PACKAGE_PATTERN.test(packageName)) {
129
+ throw new TypeError("Invalid first-party extension package name");
130
+ }
131
+ }
132
+ function assertValidEntry(label, entry) {
133
+ if (typeof entry !== "string" || !FIRST_PARTY_ENTRY_PATTERN.test(entry)) {
134
+ throw new TypeError(`Invalid first-party extension ${label}`);
135
+ }
136
+ }
137
+ // Stable runtime error codes for unresolvable modules (preferred over message
138
+ // text, which runtimes reword between releases).
139
+ const MISSING_MODULE_ERROR_CODES = new Set([
140
+ "ERR_MODULE_NOT_FOUND", // Node ESM
141
+ "MODULE_NOT_FOUND", // Node CJS interop
142
+ "ERR_PACKAGE_PATH_NOT_EXPORTED", // Node package exports
143
+ ]);
144
+ /**
145
+ * Classify a dynamic-import failure as "the extension module itself is not
146
+ * installed" as opposed to a real load failure inside an installed extension.
147
+ *
148
+ * Checks the stable `error.code` first and falls back to message patterns,
149
+ * walking the `cause` chain so wrapped errors classify like their root cause.
150
+ *
151
+ * When `expectedSpecifierFragments` is provided, package specifiers and
152
+ * absolute/file paths match exactly. Safe relative multi-segment path
153
+ * fragments match only as complete path suffixes, with an optional emitted
154
+ * `.ts` or `.js` extension. Every recognized missing-module error in the
155
+ * cause chain must agree. This keeps a broken transitive dependency (e.g.
156
+ * `Cannot find package 'jose'` thrown while loading an installed
157
+ * @veryfront/ext-auth-jwt) from being misread as "extension not installed".
158
+ */
159
+ export function isMissingFirstPartyExtensionModule(error, expectedSpecifierFragments) {
160
+ const chain = errorChain(error);
161
+ const missing = chain.filter(isMissingModuleError);
162
+ if (missing.length === 0)
163
+ return false;
164
+ if (!expectedSpecifierFragments || expectedSpecifierFragments.length === 0) {
165
+ return true;
166
+ }
167
+ let matched = false;
168
+ for (const entry of missing) {
169
+ const message = errorMessage(entry);
170
+ const missingSpecifier = message === undefined ? undefined : reportedMissingSpecifier(message);
171
+ if (missingSpecifier === undefined)
172
+ return false;
173
+ if (!expectedSpecifierFragments.some((expected) => matchesExpectedSpecifier(missingSpecifier, expected))) {
174
+ return false;
175
+ }
176
+ matched = true;
177
+ }
178
+ return matched;
179
+ }
180
+ function reportedMissingSpecifier(message) {
181
+ for (const prefix of [
182
+ "[ERR_PACKAGE_PATH_NOT_EXPORTED] ",
183
+ "[ERR_MODULE_NOT_FOUND] ",
184
+ ]) {
185
+ if (message.startsWith(prefix)) {
186
+ message = message.slice(prefix.length);
187
+ break;
188
+ }
189
+ }
190
+ const unknownExport = message.match(/^Unknown export\s+["'](\.\/[^"']+)["']\s+for\s+["']([^"']+)["']$/) ?? message.match(/^Unknown export\s+["'](\.\/[^"']+)["']\s+for\s+["']([^"']+)["']\.\n {2}Package exports:(?:\n \* [^\r\n]+)+(?:\n {4}at [^\r\n]+\n?)?$/);
191
+ if (unknownExport) {
192
+ return `${unknownExport[2]}/${unknownExport[1].slice(2)}`;
193
+ }
194
+ const packageSubpath = message.match(/^Package subpath\s+["'](\.\/[^"']+)["']\s+is not defined by\s+["']exports["']\s+in\s+(?:["']([^"']+[/\\]package\.json)["']|(.+?[/\\]package\.json))(?:\s+imported from\s+.+)?$/);
195
+ if (packageSubpath) {
196
+ const packageName = packageNameFromManifestPath(packageSubpath[2] ?? packageSubpath[3]);
197
+ if (packageName)
198
+ return `${packageName}/${packageSubpath[1].slice(2)}`;
199
+ }
200
+ const bunResolveMessage = message.match(/^(?:ResolveMessage:\s+)?Cannot find module\s+["']([^"']+)["']\s+from\s+["']([^"']+)["']$/);
201
+ if (bunResolveMessage) {
202
+ const specifier = bunResolveMessage[1];
203
+ const importer = bunResolveMessage[2];
204
+ if ((specifier.startsWith("./") || specifier.startsWith("../")) &&
205
+ importer.startsWith("/")) {
206
+ try {
207
+ return canonicalFilePath(new URL(specifier, new URL(".", `file://${importer}`)).href);
208
+ }
209
+ catch {
210
+ return undefined;
211
+ }
212
+ }
213
+ return specifier;
214
+ }
215
+ for (const pattern of [
216
+ /^Cannot find module\s+["']([^"']+)["']\nRequire stack:(?:\n- [^\r\n]+)+$/,
217
+ /^(?:Cannot find package|Cannot find module|Module not found)\s+["']([^"']+)["'](?:(?:\s+imported from\s+.+)|\.)?$/,
218
+ /^Import\s+["']([^"']+)["']\s+not a dependency(?: and not in import map)?(?:\s+from\s+.+)?$/,
219
+ /^Unable to resolve\s+["']([^"']+)["'](?:\s+from\s+.+)?$/,
220
+ ]) {
221
+ const match = message.match(pattern);
222
+ if (match)
223
+ return match[1];
224
+ }
225
+ return undefined;
226
+ }
227
+ function packageNameFromManifestPath(path) {
228
+ const normalized = path.replaceAll("\\", "/");
229
+ const marker = "/node_modules/";
230
+ const markerIndex = normalized.lastIndexOf(marker);
231
+ if (markerIndex < 0)
232
+ return undefined;
233
+ const segments = normalized.slice(markerIndex + marker.length).split("/");
234
+ if (segments[0]?.startsWith("@")) {
235
+ return segments[0] && segments[1] ? `${segments[0]}/${segments[1]}` : undefined;
236
+ }
237
+ return segments[0] || undefined;
238
+ }
239
+ function matchesExpectedSpecifier(reportedSpecifier, expectedSpecifier) {
240
+ if (typeof expectedSpecifier !== "string")
241
+ return false;
242
+ const expectedFilePath = canonicalFilePath(expectedSpecifier);
243
+ const reportedFilePath = canonicalFilePath(reportedSpecifier);
244
+ if (expectedFilePath !== undefined) {
245
+ return reportedFilePath === expectedFilePath;
246
+ }
247
+ if (FIRST_PARTY_PACKAGE_SPECIFIER_PATTERN.test(expectedSpecifier)) {
248
+ return FIRST_PARTY_PACKAGE_SPECIFIER_PATTERN.test(reportedSpecifier) &&
249
+ reportedSpecifier === expectedSpecifier;
250
+ }
251
+ const relativeFragment = expectedSpecifier.replaceAll("\\", "/");
252
+ if (!SAFE_RELATIVE_PATH_FRAGMENT_PATTERN.test(relativeFragment))
253
+ return false;
254
+ const normalizedReportedSpecifier = reportedSpecifier.replaceAll("\\", "/");
255
+ if (reportedFilePath === undefined &&
256
+ !normalizedReportedSpecifier.startsWith("./") &&
257
+ !normalizedReportedSpecifier.startsWith("../")) {
258
+ return false;
259
+ }
260
+ const reportedPath = reportedFilePath ?? normalizedReportedSpecifier;
261
+ const suffixes = relativeFragment.endsWith(".ts") ||
262
+ relativeFragment.endsWith(".js")
263
+ ? [relativeFragment]
264
+ : [
265
+ relativeFragment,
266
+ `${relativeFragment}.ts`,
267
+ `${relativeFragment}.js`,
268
+ ];
269
+ for (const suffix of suffixes) {
270
+ if (reportedPath === suffix || reportedPath.endsWith(`/${suffix}`)) {
271
+ return true;
272
+ }
273
+ }
274
+ return false;
275
+ }
276
+ function canonicalFilePath(specifier) {
277
+ if (/^file:/i.test(specifier)) {
278
+ try {
279
+ const url = new URL(specifier);
280
+ if (url.protocol !== "file:" ||
281
+ url.username !== "" ||
282
+ url.password !== "" ||
283
+ url.port !== "" ||
284
+ url.search !== "" ||
285
+ url.hash !== "" ||
286
+ /%2f|%5c/i.test(url.pathname)) {
287
+ return undefined;
288
+ }
289
+ const host = url.hostname === "localhost" ? "" : url.hostname;
290
+ let path = decodeURIComponent(url.pathname).replaceAll("\\", "/");
291
+ if (/^\/[A-Za-z]:\//.test(path))
292
+ path = path.slice(1);
293
+ return host ? `//${host.toLowerCase()}${path}` : normalizeAbsoluteFilePath(path);
294
+ }
295
+ catch {
296
+ return undefined;
297
+ }
298
+ }
299
+ const normalized = specifier.replaceAll("\\", "/");
300
+ if (!normalized.startsWith("/") &&
301
+ !normalized.startsWith("//") &&
302
+ !/^[A-Za-z]:\//.test(normalized)) {
303
+ return undefined;
304
+ }
305
+ return normalizeAbsoluteFilePath(normalized);
306
+ }
307
+ function normalizeAbsoluteFilePath(path) {
308
+ if (/^[A-Za-z]:\//.test(path)) {
309
+ return `${path[0].toLowerCase()}${path.slice(1)}`;
310
+ }
311
+ const uncPath = path.match(/^\/\/([^/]+)(\/.*)$/);
312
+ return uncPath ? `//${uncPath[1].toLowerCase()}${uncPath[2]}` : path;
313
+ }
314
+ function isMissingModuleError(error) {
315
+ let code;
316
+ try {
317
+ code = error?.code;
318
+ }
319
+ catch {
320
+ return false;
321
+ }
322
+ const message = errorMessage(error);
323
+ if (message === undefined)
324
+ return false;
325
+ if (typeof code === "string" && MISSING_MODULE_ERROR_CODES.has(code))
326
+ return true;
327
+ return reportedMissingSpecifier(message) !== undefined;
328
+ }
329
+ function errorChain(error) {
330
+ const chain = [];
331
+ let current = error;
332
+ while (current !== undefined && current !== null && chain.length < 8) {
333
+ if (chain.includes(current))
334
+ break;
335
+ chain.push(current);
336
+ try {
337
+ current = current instanceof Error ? current.cause : undefined;
338
+ }
339
+ catch {
340
+ break;
341
+ }
342
+ }
343
+ return chain;
344
+ }
345
+ function errorMessage(error) {
346
+ try {
347
+ if (error instanceof Error) {
348
+ return typeof error.message === "string" ? error.message : undefined;
349
+ }
350
+ if (typeof error === "object" && error !== null) {
351
+ const message = error.message;
352
+ return typeof message === "string" ? message : undefined;
353
+ }
354
+ return typeof error === "string" ? error : undefined;
355
+ }
356
+ catch {
357
+ return undefined;
358
+ }
359
+ }
360
+ /**
361
+ * Both the workspace source and the npm package are missing. Surface the
362
+ * package-resolution error (its message names the installable @veryfront/ext-*
363
+ * package) instead of the internal workspace source path, and append an
364
+ * explicit install hint for npm consumers.
365
+ */
366
+ function withMissingExtensionInstallHint(error, sourceDirectory, packageName, packageSpecifier, sourceError) {
367
+ const message = errorMessage(error);
368
+ if (message === undefined)
369
+ return error;
370
+ const hint = packageSpecifier === packageName
371
+ ? ` First-party extension "${sourceDirectory}" is not installed; install ${packageName} alongside veryfront to enable it.`
372
+ : ` First-party extension entry "${packageSpecifier}" is unavailable; install or update ${packageName} alongside veryfront to enable it.`;
373
+ const cause = sourceError !== undefined && sourceError !== error
374
+ ? new AggregateError([error, sourceError], message)
375
+ : error;
376
+ return new Error(`${message}${hint}`, { cause });
377
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Product-distribution default for the general YAML parser contract.
3
+ *
4
+ * Mirrors `skill-defaults.ts`: the first-party `ext-yaml` extension owns the
5
+ * third-party parser, and core reaches it through a dynamic import so the root
6
+ * package never statically depends on it. An installation without the
7
+ * extension simply has no default, and the call site raises the registry's
8
+ * missing-extension error.
9
+ *
10
+ * @module extensions/parser/yaml-defaults
11
+ */
12
+ import { type YamlParserProvider } from "./yaml-parser.js";
13
+ /**
14
+ * Load the product distribution's extension-owned default YAML parser.
15
+ *
16
+ * Returns undefined when the extension is not installed. A load failure
17
+ * *inside* an installed extension is rethrown: that is a broken installation,
18
+ * not an absent one, and hiding it would surface later as a confusing
19
+ * "install @veryfront/ext-yaml" message for an extension that is present.
20
+ */
21
+ export declare function loadDefaultYamlParserProvider(): Promise<Readonly<YamlParserProvider> | undefined>;
22
+ //# sourceMappingURL=yaml-defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml-defaults.d.ts","sourceRoot":"","sources":["../../../../src/src/extensions/parser/yaml-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,EAA8B,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAqCvF;;;;;;;GAOG;AACH,wBAAsB,6BAA6B,IAAI,OAAO,CAC5D,QAAQ,CAAC,kBAAkB,CAAC,GAAG,SAAS,CACzC,CAoBA"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Product-distribution default for the general YAML parser contract.
3
+ *
4
+ * Mirrors `skill-defaults.ts`: the first-party `ext-yaml` extension owns the
5
+ * third-party parser, and core reaches it through a dynamic import so the root
6
+ * package never statically depends on it. An installation without the
7
+ * extension simply has no default, and the call site raises the registry's
8
+ * missing-extension error.
9
+ *
10
+ * @module extensions/parser/yaml-defaults
11
+ */
12
+ import { importFirstPartyExtensionModule, isMissingFirstPartyExtensionModule, } from "../first-party-import.js";
13
+ import { snapshotYamlParserProvider } from "./yaml-parser.js";
14
+ const DEFAULT_YAML_SOURCE_DIRECTORY = "ext-yaml";
15
+ const DEFAULT_YAML_EXTENSION_PACKAGE = "@veryfront/ext-yaml";
16
+ const DEFAULT_YAML_FACTORY_EXPORT = "createYamlParser";
17
+ function readProviderFactory(extensionModule) {
18
+ if (extensionModule === null ||
19
+ (typeof extensionModule !== "object" && typeof extensionModule !== "function")) {
20
+ throw new TypeError(`Invalid ${DEFAULT_YAML_EXTENSION_PACKAGE} module: expected a module namespace`);
21
+ }
22
+ let factory;
23
+ try {
24
+ factory = extensionModule.createYamlParser;
25
+ }
26
+ catch (cause) {
27
+ throw new TypeError(`Invalid ${DEFAULT_YAML_EXTENSION_PACKAGE} module: could not read export "${DEFAULT_YAML_FACTORY_EXPORT}"`, { cause });
28
+ }
29
+ if (typeof factory !== "function") {
30
+ throw new TypeError(`Invalid ${DEFAULT_YAML_EXTENSION_PACKAGE} module: export "${DEFAULT_YAML_FACTORY_EXPORT}" must be callable`);
31
+ }
32
+ return factory;
33
+ }
34
+ /**
35
+ * Load the product distribution's extension-owned default YAML parser.
36
+ *
37
+ * Returns undefined when the extension is not installed. A load failure
38
+ * *inside* an installed extension is rethrown: that is a broken installation,
39
+ * not an absent one, and hiding it would surface later as a confusing
40
+ * "install @veryfront/ext-yaml" message for an extension that is present.
41
+ */
42
+ export async function loadDefaultYamlParserProvider() {
43
+ let extensionModule;
44
+ try {
45
+ extensionModule = await importFirstPartyExtensionModule(DEFAULT_YAML_SOURCE_DIRECTORY, DEFAULT_YAML_EXTENSION_PACKAGE);
46
+ }
47
+ catch (error) {
48
+ if (!isMissingFirstPartyExtensionModule(error, [
49
+ "extensions/ext-yaml/src/index",
50
+ DEFAULT_YAML_EXTENSION_PACKAGE,
51
+ ])) {
52
+ throw error;
53
+ }
54
+ return undefined;
55
+ }
56
+ return snapshotYamlParserProvider(readProviderFactory(extensionModule)());
57
+ }