@pattern-stack/codegen 0.6.5 → 0.6.7
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/CHANGELOG.md +26 -1
- package/dist/runtime/subsystems/auth/auth.module.js +1 -1
- package/dist/runtime/subsystems/auth/auth.module.js.map +1 -1
- package/dist/runtime/subsystems/auth/auth.tokens.d.ts +1 -1
- package/dist/runtime/subsystems/auth/auth.tokens.js.map +1 -1
- package/dist/runtime/subsystems/auth/backends/encryption-key/env.d.ts +1 -1
- package/dist/runtime/subsystems/auth/backends/encryption-key/env.js +1 -1
- package/dist/runtime/subsystems/auth/backends/encryption-key/env.js.map +1 -1
- package/dist/runtime/subsystems/auth/controllers/auth.controller.js.map +1 -1
- package/dist/runtime/subsystems/auth/index.d.ts +1 -1
- package/dist/runtime/subsystems/auth/index.js +1 -1
- package/dist/runtime/subsystems/auth/index.js.map +1 -1
- package/dist/runtime/subsystems/auth/protocols/auth-strategy.d.ts +1 -1
- package/dist/runtime/subsystems/auth/protocols/integration-store.d.ts +2 -2
- package/dist/runtime/subsystems/auth/protocols/provider-strategy.d.ts +13 -6
- package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.d.ts +2 -2
- package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js.map +1 -1
- package/dist/runtime/subsystems/auth/runtime/session-expired.error.d.ts +2 -2
- package/dist/runtime/subsystems/auth/runtime/session-expired.error.js.map +1 -1
- package/dist/runtime/subsystems/auth/runtime/with-auth-retry.d.ts +1 -1
- package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js.map +1 -1
- package/dist/runtime/subsystems/index.d.ts +1 -1
- package/dist/runtime/subsystems/index.js +1 -1
- package/dist/runtime/subsystems/index.js.map +1 -1
- package/dist/runtime/subsystems/sync/deep-equal.differ.js.map +1 -1
- package/dist/runtime/subsystems/sync/execute-sync.use-case.js.map +1 -1
- package/dist/runtime/subsystems/sync/index.js.map +1 -1
- package/dist/runtime/subsystems/sync/sync-change-source.protocol.d.ts +1 -1
- package/dist/runtime/subsystems/sync/sync-cursor-store.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/sync/sync-loopback.protocol.d.ts +3 -4
- package/dist/runtime/subsystems/sync/sync-run-recorder.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/sync/sync.module.js.map +1 -1
- package/dist/src/cli/index.js +55 -19
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/examples/auth-integrations/README.md +125 -0
- package/examples/auth-integrations/definitions/entities/integration.yaml +98 -0
- package/examples/auth-integrations/runtime/integrations/adapters/integration-grant-sink.adapter.ts +29 -0
- package/examples/auth-integrations/runtime/integrations/adapters/integration-reader.adapter.ts +52 -0
- package/examples/auth-integrations/runtime/integrations/adapters/integration-token-writer.adapter.ts +43 -0
- package/examples/auth-integrations/runtime/integrations/facade/integrations.service.ts +150 -0
- package/examples/auth-integrations/runtime/integrations/integrations-auth.module.ts +81 -0
- package/examples/auth-integrations/runtime/integrations/oauth/use-cases/create-or-update-from-oauth-grant.use-case.ts +75 -0
- package/examples/auth-integrations/runtime/integrations/oauth/use-cases/disconnect-integration.use-case.ts +29 -0
- package/examples/auth-integrations/runtime/integrations/oauth/use-cases/list-user-integrations.use-case.ts +21 -0
- package/examples/auth-integrations/runtime/integrations/oauth/use-cases/mark-integration-requires-reauth.use-case.ts +21 -0
- package/package.json +2 -1
- package/runtime/subsystems/auth/auth.tokens.ts +1 -1
- package/runtime/subsystems/auth/backends/encryption-key/env.ts +3 -3
- package/runtime/subsystems/auth/controllers/auth.controller.ts +3 -3
- package/runtime/subsystems/auth/index.ts +2 -2
- package/runtime/subsystems/auth/protocols/auth-strategy.ts +1 -1
- package/runtime/subsystems/auth/protocols/integration-store.ts +2 -2
- package/runtime/subsystems/auth/protocols/provider-strategy.ts +12 -5
- package/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.ts +2 -2
- package/runtime/subsystems/auth/runtime/session-expired.error.ts +2 -2
- package/runtime/subsystems/auth/runtime/with-auth-retry.ts +1 -1
- package/runtime/subsystems/index.ts +1 -1
- package/runtime/subsystems/sync/deep-equal.differ.ts +1 -1
- package/runtime/subsystems/sync/execute-sync.use-case.ts +1 -1
- package/runtime/subsystems/sync/sync-change-source.protocol.ts +1 -1
- package/runtime/subsystems/sync/sync-cursor-store.memory-backend.ts +1 -1
- package/runtime/subsystems/sync/sync-loopback.protocol.ts +3 -4
- package/runtime/subsystems/sync/sync-run-recorder.drizzle-backend.ts +1 -1
- package/templates/subsystem/auth/app-module-hook.ejs.t +1 -1
- package/templates/subsystem/auth/env-config.ejs.t +5 -5
- package/templates/subsystem/auth/prompt.js +3 -3
- package/templates/subsystem/auth-config/codegen-config-auth-block.ejs.t +1 -1
package/dist/src/cli/index.js
CHANGED
|
@@ -8196,14 +8196,18 @@ function localsToHygenArgs6(locals) {
|
|
|
8196
8196
|
import path18 from "path";
|
|
8197
8197
|
var FALLBACK_BACKEND_SRC4 = "src";
|
|
8198
8198
|
var SHARED_DIR_NAME = "shared";
|
|
8199
|
+
var DEFAULT_MODULES_DIR = "modules";
|
|
8199
8200
|
var DEFAULT_DEFINITIONS_DIR = "definitions/entities";
|
|
8200
8201
|
function resolveAuthIntegrationsScaffoldLocals(input) {
|
|
8201
8202
|
const { cwd, config } = input;
|
|
8202
8203
|
const backendSrc = typeof config?.paths?.backend_src === "string" && config.paths.backend_src.length > 0 ? config.paths.backend_src : FALLBACK_BACKEND_SRC4;
|
|
8203
|
-
const
|
|
8204
|
+
const pathsAny = config?.paths;
|
|
8205
|
+
const sharedConfigured = pathsAny?.shared;
|
|
8204
8206
|
const sharedRoot = typeof sharedConfigured === "string" && sharedConfigured.length > 0 ? path18.resolve(cwd, sharedConfigured) : path18.resolve(cwd, backendSrc, SHARED_DIR_NAME);
|
|
8205
|
-
const
|
|
8206
|
-
const
|
|
8207
|
+
const modulesConfigured = pathsAny?.modules_dir;
|
|
8208
|
+
const vendorRoot = typeof modulesConfigured === "string" && modulesConfigured.length > 0 ? path18.resolve(cwd, modulesConfigured) : path18.resolve(cwd, backendSrc, DEFAULT_MODULES_DIR);
|
|
8209
|
+
const entitiesConfigured = typeof pathsAny?.entities === "string" && pathsAny.entities.length > 0 ? pathsAny.entities : typeof pathsAny?.entities_dir === "string" && pathsAny.entities_dir.length > 0 ? pathsAny.entities_dir : null;
|
|
8210
|
+
const definitionsPath = entitiesConfigured !== null ? path18.resolve(cwd, entitiesConfigured, "integration.yaml") : path18.resolve(cwd, DEFAULT_DEFINITIONS_DIR, "integration.yaml");
|
|
8207
8211
|
const appModulePath = path18.resolve(cwd, backendSrc, "app.module.ts");
|
|
8208
8212
|
let authModuleRegistered = false;
|
|
8209
8213
|
const appModuleSource = input.readFile(appModulePath);
|
|
@@ -8214,6 +8218,7 @@ function resolveAuthIntegrationsScaffoldLocals(input) {
|
|
|
8214
8218
|
appName: path18.basename(cwd),
|
|
8215
8219
|
appModulePath,
|
|
8216
8220
|
sharedRoot,
|
|
8221
|
+
vendorRoot,
|
|
8217
8222
|
definitionsPath,
|
|
8218
8223
|
authModuleRegistered
|
|
8219
8224
|
};
|
|
@@ -8481,19 +8486,24 @@ async function detectInstalledSubsystems(ctx) {
|
|
|
8481
8486
|
}
|
|
8482
8487
|
if (!seen.has("auth-integrations")) {
|
|
8483
8488
|
const backendSrc = ctx.config?.paths?.backend_src ?? "src";
|
|
8484
|
-
const
|
|
8489
|
+
const pathsAny = ctx.config?.paths;
|
|
8490
|
+
const modulesConfigured = pathsAny?.modules_dir;
|
|
8491
|
+
const vendorRoot = typeof modulesConfigured === "string" && modulesConfigured.length > 0 ? path20.resolve(ctx.cwd, modulesConfigured) : path20.resolve(ctx.cwd, backendSrc, "modules");
|
|
8492
|
+
const sharedConfigured = pathsAny?.shared;
|
|
8485
8493
|
const sharedRoot = typeof sharedConfigured === "string" && sharedConfigured.length > 0 ? path20.resolve(ctx.cwd, sharedConfigured) : path20.resolve(ctx.cwd, backendSrc, "shared");
|
|
8486
|
-
const
|
|
8487
|
-
|
|
8488
|
-
"integrations",
|
|
8489
|
-
|
|
8490
|
-
)
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8494
|
+
const candidates = [
|
|
8495
|
+
path20.join(vendorRoot, "integrations", "integrations-auth.module.ts"),
|
|
8496
|
+
path20.join(sharedRoot, "integrations", "integrations-auth.module.ts")
|
|
8497
|
+
];
|
|
8498
|
+
for (const moduleFile of candidates) {
|
|
8499
|
+
if (fs9.existsSync(moduleFile)) {
|
|
8500
|
+
found.push({
|
|
8501
|
+
name: "auth-integrations",
|
|
8502
|
+
path: path20.dirname(moduleFile),
|
|
8503
|
+
backend: "drizzle"
|
|
8504
|
+
});
|
|
8505
|
+
break;
|
|
8506
|
+
}
|
|
8497
8507
|
}
|
|
8498
8508
|
}
|
|
8499
8509
|
return found;
|
|
@@ -9491,7 +9501,7 @@ function authIntegrationsExamplesRoot() {
|
|
|
9491
9501
|
if (fs10.existsSync(topLevel)) return topLevel;
|
|
9492
9502
|
return path21.join(pkgRoot, "dist", "examples", "auth-integrations");
|
|
9493
9503
|
}
|
|
9494
|
-
function copyTreeIdempotent(srcDir, destDir, force) {
|
|
9504
|
+
function copyTreeIdempotent(srcDir, destDir, force, transform) {
|
|
9495
9505
|
const written = [];
|
|
9496
9506
|
const skipped = [];
|
|
9497
9507
|
const walk = (src, dest) => {
|
|
@@ -9510,7 +9520,13 @@ function copyTreeIdempotent(srcDir, destDir, force) {
|
|
|
9510
9520
|
continue;
|
|
9511
9521
|
}
|
|
9512
9522
|
fs10.mkdirSync(path21.dirname(destPath), { recursive: true });
|
|
9513
|
-
|
|
9523
|
+
const isTextSource = transform && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx"));
|
|
9524
|
+
if (isTextSource && transform) {
|
|
9525
|
+
const raw = fs10.readFileSync(srcPath, "utf-8");
|
|
9526
|
+
fs10.writeFileSync(destPath, transform(raw, destPath), "utf-8");
|
|
9527
|
+
} else {
|
|
9528
|
+
fs10.copyFileSync(srcPath, destPath);
|
|
9529
|
+
}
|
|
9514
9530
|
written.push(destPath);
|
|
9515
9531
|
}
|
|
9516
9532
|
};
|
|
@@ -9519,6 +9535,24 @@ function copyTreeIdempotent(srcDir, destDir, force) {
|
|
|
9519
9535
|
walk(srcDir, destDir);
|
|
9520
9536
|
return { written, skipped };
|
|
9521
9537
|
}
|
|
9538
|
+
var AUTH_BARE_IMPORT_RE = /(['"])@pattern-stack\/codegen\/runtime\/subsystems\/auth\1/g;
|
|
9539
|
+
function buildAuthImportRewriter(subsystemsRoot) {
|
|
9540
|
+
const authRoot = path21.join(subsystemsRoot, "auth");
|
|
9541
|
+
return (content, destPath) => {
|
|
9542
|
+
if (!AUTH_BARE_IMPORT_RE.test(content)) {
|
|
9543
|
+
AUTH_BARE_IMPORT_RE.lastIndex = 0;
|
|
9544
|
+
return content;
|
|
9545
|
+
}
|
|
9546
|
+
AUTH_BARE_IMPORT_RE.lastIndex = 0;
|
|
9547
|
+
let rel = path21.relative(path21.dirname(destPath), authRoot);
|
|
9548
|
+
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
9549
|
+
const relPosix = rel.split(path21.sep).join("/");
|
|
9550
|
+
return content.replace(
|
|
9551
|
+
AUTH_BARE_IMPORT_RE,
|
|
9552
|
+
(_match, quote) => `${quote}${relPosix}${quote}`
|
|
9553
|
+
);
|
|
9554
|
+
};
|
|
9555
|
+
}
|
|
9522
9556
|
function runAuthIntegrationsScaffold(cwd, config, opts) {
|
|
9523
9557
|
const locals = resolveAuthIntegrationsScaffoldLocals({
|
|
9524
9558
|
cwd,
|
|
@@ -9535,7 +9569,7 @@ function runAuthIntegrationsScaffold(cwd, config, opts) {
|
|
|
9535
9569
|
};
|
|
9536
9570
|
}
|
|
9537
9571
|
const adaptersSrc = path21.join(examplesRoot, "runtime", "integrations");
|
|
9538
|
-
const adaptersDest = path21.join(locals.
|
|
9572
|
+
const adaptersDest = path21.join(locals.vendorRoot, "integrations");
|
|
9539
9573
|
const integrationYamlSrc = path21.join(
|
|
9540
9574
|
examplesRoot,
|
|
9541
9575
|
"definitions",
|
|
@@ -9555,10 +9589,12 @@ function runAuthIntegrationsScaffold(cwd, config, opts) {
|
|
|
9555
9589
|
authModuleRegistered: locals.authModuleRegistered
|
|
9556
9590
|
};
|
|
9557
9591
|
}
|
|
9592
|
+
const subsystemsRoot = resolveSubsystemsRootFromConfig(cwd, config);
|
|
9558
9593
|
const adapterCopy = copyTreeIdempotent(
|
|
9559
9594
|
adaptersSrc,
|
|
9560
9595
|
adaptersDest,
|
|
9561
|
-
opts.force
|
|
9596
|
+
opts.force,
|
|
9597
|
+
buildAuthImportRewriter(subsystemsRoot)
|
|
9562
9598
|
);
|
|
9563
9599
|
let yamlWritten = false;
|
|
9564
9600
|
let yamlSkipped = false;
|