@workos/oagen 0.24.5 → 0.25.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/cli/index.mjs +43 -17
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{diff-DPnw1wPB.mjs → diff-BQn8Nv2c.mjs} +44 -18
- package/dist/diff-BQn8Nv2c.mjs.map +1 -0
- package/dist/index.d.mts +6 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/verify/index.mjs +1 -1
- package/docs/architecture/ir-types.md +12 -0
- package/docs/cli.md +13 -13
- package/package.json +1 -1
- package/dist/diff-DPnw1wPB.mjs.map +0 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -5780,11 +5780,44 @@ function deriveMethodName(op, _service) {
|
|
|
5780
5780
|
return `${verb}_${verb === "list" ? resource : noun}`;
|
|
5781
5781
|
}
|
|
5782
5782
|
/**
|
|
5783
|
+
* Resolve a service name to its mount target.
|
|
5784
|
+
*
|
|
5785
|
+
* Rule keys are either exact service names or trailing-`*` prefix patterns
|
|
5786
|
+
* (e.g. `UserManagement*`). Precedence:
|
|
5787
|
+
*
|
|
5788
|
+
* 1. An exact key always wins.
|
|
5789
|
+
* 2. Otherwise the wildcard with the longest prefix wins, so
|
|
5790
|
+
* `UserManagementOrganizationMembership*` beats `UserManagement*`.
|
|
5791
|
+
*
|
|
5792
|
+
* Matching is plain string comparison (`startsWith`) — `*` is only recognised
|
|
5793
|
+
* as the final character and no regex is ever built from rule keys.
|
|
5794
|
+
*
|
|
5795
|
+
* @param name - The IR service name to resolve.
|
|
5796
|
+
* @param mounts - Exact-name or trailing-`*` pattern → target service mappings.
|
|
5797
|
+
* @returns The mount target, or `name` unchanged when no rule matches.
|
|
5798
|
+
*/
|
|
5799
|
+
function resolveMountTarget(name, mounts) {
|
|
5800
|
+
const exact = mounts[name];
|
|
5801
|
+
if (exact !== void 0) return exact;
|
|
5802
|
+
let best;
|
|
5803
|
+
let bestLen = -1;
|
|
5804
|
+
for (const [pattern, target] of Object.entries(mounts)) {
|
|
5805
|
+
if (!pattern.endsWith("*")) continue;
|
|
5806
|
+
const prefix = pattern.slice(0, -1);
|
|
5807
|
+
if (name.startsWith(prefix) && prefix.length > bestLen) {
|
|
5808
|
+
best = target;
|
|
5809
|
+
bestLen = prefix.length;
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5812
|
+
return best ?? name;
|
|
5813
|
+
}
|
|
5814
|
+
/**
|
|
5783
5815
|
* Resolve all operations in the spec, applying hints and mount rules.
|
|
5784
5816
|
*
|
|
5785
5817
|
* @param spec - The parsed API spec
|
|
5786
5818
|
* @param hints - Per-operation overrides keyed by "METHOD /path"
|
|
5787
|
-
* @param mountRules - Service name → target service mappings
|
|
5819
|
+
* @param mountRules - Service name → target service mappings; keys may be
|
|
5820
|
+
* exact names or trailing-`*` prefix patterns (see {@link resolveMountTarget})
|
|
5788
5821
|
* @returns Resolved operations ready for emitter consumption
|
|
5789
5822
|
*/
|
|
5790
5823
|
function resolveOperations(spec, hints, mountRules) {
|
|
@@ -5794,7 +5827,7 @@ function resolveOperations(spec, hints, mountRules) {
|
|
|
5794
5827
|
for (const service of spec.services) for (const op of service.operations) {
|
|
5795
5828
|
const hint = hintMap[`${op.httpMethod.toUpperCase()} ${op.path}`];
|
|
5796
5829
|
const methodName = hint?.name ?? deriveMethodName(op, service);
|
|
5797
|
-
const mountOn = hint?.mountOn ??
|
|
5830
|
+
const mountOn = hint?.mountOn ?? resolveMountTarget(service.name, mounts);
|
|
5798
5831
|
let wrappers;
|
|
5799
5832
|
if (hint?.split) wrappers = hint.split.map((sh) => ({
|
|
5800
5833
|
name: sh.name,
|
|
@@ -5840,16 +5873,18 @@ function resolveResponseModelName(op) {
|
|
|
5840
5873
|
*
|
|
5841
5874
|
* Matching is on the POST-MOUNT name. Mount resolution never mutates
|
|
5842
5875
|
* `spec.services` — the post-mount target lives on `ResolvedOperation.mountOn`
|
|
5843
|
-
* (`mountOn = hint?.mountOn ??
|
|
5844
|
-
* post-mount name of a source service is derived here
|
|
5845
|
-
* `
|
|
5876
|
+
* (`mountOn = hint?.mountOn ?? resolveMountTarget(service.name, mountRules)`) — so
|
|
5877
|
+
* the post-mount name of a source service is derived here with the same
|
|
5878
|
+
* `resolveMountTarget` (exact rules and trailing-`*` prefix rules, longest
|
|
5879
|
+
* prefix wins). Selecting a target (e.g.
|
|
5846
5880
|
* `DirectorySync`) is valid because every source tag that mounts into it
|
|
5847
5881
|
* (`DirectoryUsers`, `DirectoryGroups`, …) shares that post-mount name, and the
|
|
5848
5882
|
* emitters group resources by mount, so all siblings emit together.
|
|
5849
5883
|
*
|
|
5850
5884
|
* @param spec - The parsed API spec (never mutated; never filtered).
|
|
5851
5885
|
* @param selected - Post-mount service names from `--services` (normalized/trimmed).
|
|
5852
|
-
* @param mountRules - Source-service-name
|
|
5886
|
+
* @param mountRules - Source-service-name (exact or trailing-`*` prefix pattern)
|
|
5887
|
+
* → post-mount-target mappings.
|
|
5853
5888
|
* @returns The validated selection as a `Set` of post-mount names.
|
|
5854
5889
|
* @throws A `ConfigError` listing valid post-mount names when a selection is
|
|
5855
5890
|
* unknown — scoped generation never silently emits the wrong set.
|
|
@@ -5867,8 +5902,7 @@ function canonicalServiceKey(name) {
|
|
|
5867
5902
|
}
|
|
5868
5903
|
function resolveScopedServices(spec, selected, mountRules) {
|
|
5869
5904
|
const mounts = mountRules ?? {};
|
|
5870
|
-
const
|
|
5871
|
-
const validPostMount = new Set(spec.services.map((s) => postMountName(s.name)));
|
|
5905
|
+
const validPostMount = new Set(spec.services.map((s) => resolveMountTarget(s.name, mounts)));
|
|
5872
5906
|
const selectedSet = new Set(selected);
|
|
5873
5907
|
const unknown = [...selectedSet].filter((s) => !validPostMount.has(s));
|
|
5874
5908
|
if (unknown.length > 0) {
|
|
@@ -6304,7 +6338,7 @@ async function readManifest(dir) {
|
|
|
6304
6338
|
}
|
|
6305
6339
|
try {
|
|
6306
6340
|
const parsed = JSON.parse(raw);
|
|
6307
|
-
if (typeof parsed.version !== "number" || typeof parsed.language !== "string" ||
|
|
6341
|
+
if (typeof parsed.version !== "number" || typeof parsed.language !== "string" || !Array.isArray(parsed.files) || !parsed.files.every((p) => typeof p === "string")) return null;
|
|
6308
6342
|
if (parsed.version > MANIFEST_VERSION) {
|
|
6309
6343
|
console.warn(`[oagen] ${MANIFEST_FILENAME} schema version ${parsed.version} is newer than supported (${MANIFEST_VERSION}); ignoring for pruning.`);
|
|
6310
6344
|
return null;
|
|
@@ -6321,7 +6355,6 @@ async function writeManifest(dir, opts) {
|
|
|
6321
6355
|
version: MANIFEST_VERSION,
|
|
6322
6356
|
language: opts.language,
|
|
6323
6357
|
...opts.sdkName !== void 0 ? { sdkName: opts.sdkName } : {},
|
|
6324
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6325
6358
|
...opts.specSha !== void 0 ? { specSha: opts.specSha } : {},
|
|
6326
6359
|
...opts.specPath !== void 0 ? { specPath: opts.specPath } : {},
|
|
6327
6360
|
...opts.emitterSha !== void 0 ? { emitterSha: opts.emitterSha } : {},
|
|
@@ -6331,16 +6364,9 @@ async function writeManifest(dir, opts) {
|
|
|
6331
6364
|
files: [...new Set(opts.files)].sort(),
|
|
6332
6365
|
...opts.operations !== void 0 ? { operations: opts.operations } : {}
|
|
6333
6366
|
};
|
|
6334
|
-
const previous = await readManifest(dir);
|
|
6335
|
-
if (previous && sameManifestExceptGeneratedAt(previous, manifest)) manifest.generatedAt = previous.generatedAt;
|
|
6336
6367
|
await fs.mkdir(dir, { recursive: true });
|
|
6337
6368
|
await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
|
|
6338
6369
|
}
|
|
6339
|
-
function sameManifestExceptGeneratedAt(a, b) {
|
|
6340
|
-
const { generatedAt: _aGeneratedAt, ...aComparable } = a;
|
|
6341
|
-
const { generatedAt: _bGeneratedAt, ...bComparable } = b;
|
|
6342
|
-
return JSON.stringify(aComparable) === JSON.stringify(bComparable);
|
|
6343
|
-
}
|
|
6344
6370
|
/** Return the set of previous paths no longer present in the current emission. */
|
|
6345
6371
|
function computeStalePaths(prev, currentPaths) {
|
|
6346
6372
|
const current = new Set(currentPaths);
|