@geekapps/auth-nextjs 0.22.0 → 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/typegen.js CHANGED
@@ -3,24 +3,113 @@ import { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync, existsSync
3
3
  import { join, resolve } from "path";
4
4
  var DEFAULT_ISSUER = "https://accounts-api.geekapps.com.br";
5
5
  var DEFAULT_OUT_DIR = "geekapps-connections";
6
- async function fetchCatalog({ issuer, clientId, clientSecret }) {
7
- const response = await fetch(`${issuer.replace(/\/$/, "")}/connections/catalog`, {
8
- headers: { authorization: `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString("base64")}` },
6
+ var DEFAULT_AUGMENT = "@geekapps/auth-nextjs/connections";
7
+ async function fetchCatalog(credentials) {
8
+ const issuer = credentials.issuer.replace(/\/$/, "");
9
+ const asUser = "accessToken" in credentials;
10
+ const response = await fetch(`${issuer}${asUser ? "/me/connections/catalog" : "/connections/catalog"}`, {
11
+ headers: {
12
+ authorization: asUser ? `Bearer ${credentials.accessToken}` : `Basic ${Buffer.from(`${credentials.clientId}:${credentials.clientSecret}`).toString("base64")}`
13
+ },
9
14
  cache: "no-store"
10
15
  });
11
16
  if (!response.ok) {
12
- throw new Error(`cat\xE1logo indispon\xEDvel (${response.status}) \u2014 confira GEEKAPPS_AUTH_CLIENT_ID e GEEKAPPS_AUTH_CLIENT_SECRET`);
17
+ throw new Error(
18
+ asUser ? `cat\xE1logo indispon\xEDvel (${response.status}) \u2014 rode \`geekapps login\` de novo` : `cat\xE1logo indispon\xEDvel (${response.status}) \u2014 confira GEEKAPPS_AUTH_CLIENT_ID e GEEKAPPS_AUTH_CLIENT_SECRET`
19
+ );
13
20
  }
14
21
  return await response.json();
15
22
  }
23
+ async function fetchManifest(manifestUrl) {
24
+ const response = await fetch(manifestUrl, { headers: { accept: "application/json" }, cache: "no-store" });
25
+ if (!response.ok) throw new Error(`manifesto indispon\xEDvel (${response.status})`);
26
+ const manifest = await response.json();
27
+ if (manifest?.version !== 1 || !manifest.scopes || !Array.isArray(manifest.routes)) {
28
+ throw new Error("manifesto em formato inv\xE1lido");
29
+ }
30
+ return manifest;
31
+ }
16
32
  var HEADER = "// Gerado pelo SDK do Geekapps Auth. N\xE3o edite \xE0 m\xE3o.\n\n";
33
+ function pascal(name) {
34
+ return name.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((part) => part[0].toUpperCase() + part.slice(1)).join("");
35
+ }
36
+ function properties(schema) {
37
+ return schema?.properties ?? {};
38
+ }
39
+ function required(schema) {
40
+ return Array.isArray(schema?.required) ? schema.required : [];
41
+ }
42
+ function mergeInputSchema(route) {
43
+ const parts = [route.params, route.query, route.body];
44
+ const pathParams = [...route.path.matchAll(/:([A-Za-z0-9_]+)/g)].map((m) => m[1]);
45
+ return {
46
+ type: "object",
47
+ properties: Object.assign({}, ...parts.map(properties)),
48
+ required: [.../* @__PURE__ */ new Set([...pathParams, ...parts.flatMap(required)])],
49
+ additionalProperties: false
50
+ };
51
+ }
52
+ async function generateManifestTypes(app, manifest) {
53
+ const { compile } = await import("json-schema-to-typescript");
54
+ const options = { bannerComment: "", additionalProperties: false, format: false, declareExternallyReferenced: true };
55
+ const blocks = [];
56
+ const routeEntries = [];
57
+ for (const route of manifest.routes) {
58
+ const base = pascal(route.route);
59
+ const input = `${base}Input`;
60
+ const output = `${base}Output`;
61
+ blocks.push(await compile(mergeInputSchema(route), input, options));
62
+ blocks.push(
63
+ route.response ? await compile({ ...route.response, title: void 0 }, output, options) : `export type ${output} = unknown;
64
+ `
65
+ );
66
+ routeEntries.push(
67
+ ` ${JSON.stringify(route.route)}: {
68
+ scope: ${JSON.stringify(route.scope)};
69
+ method: ${JSON.stringify(route.method)};
70
+ path: ${JSON.stringify(route.path)};
71
+ input: ${input};
72
+ output: ${output};
73
+ };`
74
+ );
75
+ }
76
+ const scopeIds = Object.keys(manifest.scopes);
77
+ const scopeDocs = scopeIds.map((id) => ` ${JSON.stringify(id)}: ${JSON.stringify(manifest.scopes[id].description)};`).join("\n");
78
+ return `${HEADER}/** Escopos que esta app aceita em conex\xF5es. */
79
+ export type Scope = ${scopeIds.length ? scopeIds.map((id) => JSON.stringify(id)).join(" | ") : "never"};
80
+
81
+ /** Descri\xE7\xE3o de cada escopo, como aparece no consent. */
82
+ export interface ScopeDescriptions {
83
+ ${scopeDocs}
84
+ }
85
+
86
+ /** Rotas liberadas por escopo, pelo nome usado no cliente (\`post.messages.send(...)\`). */
87
+ export interface Routes {
88
+ ${routeEntries.join("\n")}
89
+ }
90
+
91
+ export interface App {
92
+ slug: ${JSON.stringify(app.slug)};
93
+ targetAppId: ${JSON.stringify(app.targetAppId)};
94
+ scopes: Scope;
95
+ routes: Routes;
96
+ }
97
+
98
+ ${blocks.join("\n")}`;
99
+ }
17
100
  async function generateOpenApiTypes(openApiUrl) {
18
101
  const { default: openapiTS, astToString } = await import("openapi-typescript");
19
102
  return HEADER + astToString(await openapiTS(new URL(openApiUrl)));
20
103
  }
21
104
  function renderIndex(apps, augment) {
22
- const imports = apps.map((app, i) => `import type { paths as paths${i} } from "./${app.slug}";`).join("\n");
23
- const members = apps.map((app, i) => ` ${JSON.stringify(app.slug)}: paths${i};`).join("\n");
105
+ const imports = apps.flatMap(({ app, manifest, openApi }, i) => [
106
+ manifest ? `import type { App as App${i} } from "./${app.slug}";` : null,
107
+ openApi ? `import type { paths as paths${i} } from "./${app.slug}.openapi";` : null
108
+ ]).filter(Boolean).join("\n");
109
+ const members = apps.map(({ app, manifest, openApi }, i) => {
110
+ const fields = [manifest ? `app: App${i};` : null, openApi ? `paths: paths${i};` : null].filter(Boolean).join(" ");
111
+ return ` ${JSON.stringify(app.slug)}: { ${fields} };`;
112
+ }).join("\n");
24
113
  return `${HEADER}${imports}
25
114
 
26
115
  declare module ${JSON.stringify(augment)} {
@@ -38,22 +127,38 @@ async function generateConnectionTypes(params) {
38
127
  const files = /* @__PURE__ */ new Map();
39
128
  const result = { apps: [], failed: [], stale: [] };
40
129
  const generated = [];
130
+ const keepExisting = (file) => {
131
+ const existing = join(outDir, file);
132
+ if (!existsSync(existing)) return false;
133
+ files.set(file, readFileSync(existing, "utf-8"));
134
+ return true;
135
+ };
41
136
  for (const app of catalog) {
42
- const file = `${app.slug}.d.ts`;
43
- try {
44
- files.set(file, await generateOpenApiTypes(app.openApiUrl));
45
- generated.push(app);
46
- } catch (error) {
47
- result.failed.push({ name: app.name, reason: error.message });
48
- const existing = join(outDir, file);
49
- if (existsSync(existing)) {
50
- files.set(file, readFileSync(existing, "utf-8"));
51
- generated.push(app);
137
+ const entry = { app, manifest: false, openApi: false };
138
+ if (app.manifestUrl) {
139
+ const file = `${app.slug}.d.ts`;
140
+ try {
141
+ files.set(file, await generateManifestTypes(app, await fetchManifest(app.manifestUrl)));
142
+ entry.manifest = true;
143
+ } catch (error) {
144
+ result.failed.push({ name: app.name, reason: `manifesto: ${error.message}` });
145
+ entry.manifest = keepExisting(file);
146
+ }
147
+ }
148
+ if (app.openApiUrl) {
149
+ const file = `${app.slug}.openapi.d.ts`;
150
+ try {
151
+ files.set(file, await generateOpenApiTypes(app.openApiUrl));
152
+ entry.openApi = true;
153
+ } catch (error) {
154
+ result.failed.push({ name: app.name, reason: `openapi: ${error.message}` });
155
+ entry.openApi = keepExisting(file);
52
156
  }
53
157
  }
158
+ if (entry.manifest || entry.openApi) generated.push(entry);
54
159
  }
55
- result.apps = generated.map((app) => app.name);
56
- files.set("index.d.ts", renderIndex(generated, params.augment ?? "@geekapps/auth-nextjs/connections"));
160
+ result.apps = generated.map(({ app }) => app.name);
161
+ files.set("index.d.ts", renderIndex(generated, params.augment ?? DEFAULT_AUGMENT));
57
162
  const current = existsSync(outDir) ? new Set(readdirSync(outDir).filter((f) => f.endsWith(".d.ts"))) : /* @__PURE__ */ new Set();
58
163
  if (params.check) {
59
164
  for (const [file, content] of files) {
@@ -75,6 +180,8 @@ export {
75
180
  DEFAULT_ISSUER,
76
181
  DEFAULT_OUT_DIR,
77
182
  fetchCatalog,
78
- generateConnectionTypes
183
+ fetchManifest,
184
+ generateConnectionTypes,
185
+ generateManifestTypes
79
186
  };
80
187
  //# sourceMappingURL=typegen.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/typegen.ts"],"sourcesContent":["// Gerador de tipos das App Connections (OpenAPI → TypeScript).\r\nimport { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync, existsSync } from \"node:fs\";\r\nimport { join, resolve } from \"node:path\";\r\n\r\nexport const DEFAULT_ISSUER = \"https://accounts-api.geekapps.com.br\";\r\nexport const DEFAULT_OUT_DIR = \"geekapps-connections\";\r\n\r\n/** Uma app conectável que declarou um OpenAPI — o que o catálogo do auth-server devolve. */\r\nexport type CatalogApp = {\r\n targetAppId: string;\r\n name: string;\r\n /** Chave estável no tipo `GeekappsConnections` (ex: \"billing\"). */\r\n slug: string;\r\n apiBaseUrl: string | null;\r\n openApiUrl: string;\r\n};\r\n\r\nexport type Credentials = { issuer: string; clientId: string; clientSecret: string };\r\n\r\n/** Apps conectáveis com OpenAPI declarado, vistas por esta app (credenciais dela). */\r\nexport async function fetchCatalog({ issuer, clientId, clientSecret }: Credentials): Promise<CatalogApp[]> {\r\n const response = await fetch(`${issuer.replace(/\\/$/, \"\")}/connections/catalog`, {\r\n headers: { authorization: `Basic ${Buffer.from(`${clientId}:${clientSecret}`).toString(\"base64\")}` },\r\n cache: \"no-store\",\r\n });\r\n if (!response.ok) {\r\n throw new Error(`catálogo indisponível (${response.status}) — confira GEEKAPPS_AUTH_CLIENT_ID e GEEKAPPS_AUTH_CLIENT_SECRET`);\r\n }\r\n return (await response.json()) as CatalogApp[];\r\n}\r\n\r\nconst HEADER = \"// Gerado pelo SDK do Geekapps Auth. Não edite à mão.\\n\\n\";\r\n\r\n/**\r\n * Tipos de um OpenAPI, no formato do openapi-typescript. Import dinâmico: é\r\n * dependência opcional (só desenvolvimento) — sem ela, a geração só não roda.\r\n */\r\nasync function generateOpenApiTypes(openApiUrl: string) {\r\n const { default: openapiTS, astToString } = await import(\"openapi-typescript\");\r\n return HEADER + astToString(await openapiTS(new URL(openApiUrl)));\r\n}\r\n\r\n/** `index.d.ts`: liga cada app ao `GeekappsConnections` do módulo do SDK. */\r\nfunction renderIndex(apps: CatalogApp[], augment: string) {\r\n const imports = apps.map((app, i) => `import type { paths as paths${i} } from \"./${app.slug}\";`).join(\"\\n\");\r\n const members = apps.map((app, i) => ` ${JSON.stringify(app.slug)}: paths${i};`).join(\"\\n\");\r\n return `${HEADER}${imports}\r\n\r\ndeclare module ${JSON.stringify(augment)} {\r\n interface GeekappsConnections {\r\n${members}\r\n }\r\n}\r\n\r\nexport {};\r\n`;\r\n}\r\n\r\nexport type GenerateResult = {\r\n apps: string[];\r\n /** Apps do catálogo cujo OpenAPI não pôde ser baixado/convertido. */\r\n failed: Array<{ name: string; reason: string }>;\r\n /** Com `check`: arquivos que estariam diferentes. */\r\n stale: string[];\r\n};\r\n\r\n/**\r\n * Gerador de tipos das App Connections, embutido no SDK (sem pacote à parte).\r\n * Roda sozinho em desenvolvimento; para o CI, chame com `check: true`.\r\n *\r\n * Baixa o OpenAPI de cada app conectável e escreve os tipos em `outDir`\r\n * (`<slug>.d.ts` por app + `index.d.ts`, que estende `GeekappsConnections` do\r\n * módulo `augment`). Com `check`, não escreve nada: só diz o que estaria\r\n * diferente. Uma app cujo OpenAPI falha mantém o arquivo anterior.\r\n */\r\nexport async function generateConnectionTypes(params: {\r\n credentials: Credentials;\r\n outDir?: string;\r\n /** Módulo que recebe o `GeekappsConnections`. Padrão: \"@geekapps/auth-nextjs/connections\". */\r\n augment?: string;\r\n check?: boolean;\r\n}): Promise<GenerateResult> {\r\n const outDir = resolve(process.cwd(), params.outDir ?? DEFAULT_OUT_DIR);\r\n const catalog = (await fetchCatalog(params.credentials)).sort((a, b) => a.slug.localeCompare(b.slug));\r\n\r\n const files = new Map<string, string>();\r\n const result: GenerateResult = { apps: [], failed: [], stale: [] };\r\n const generated: CatalogApp[] = [];\r\n\r\n for (const app of catalog) {\r\n const file = `${app.slug}.d.ts`;\r\n try {\r\n files.set(file, await generateOpenApiTypes(app.openApiUrl));\r\n generated.push(app);\r\n } catch (error) {\r\n result.failed.push({ name: app.name, reason: (error as Error).message });\r\n // Mantém o que já existia, para a app não perder os tipos por uma falha de rede.\r\n const existing = join(outDir, file);\r\n if (existsSync(existing)) {\r\n files.set(file, readFileSync(existing, \"utf-8\"));\r\n generated.push(app);\r\n }\r\n }\r\n }\r\n result.apps = generated.map((app) => app.name);\r\n files.set(\"index.d.ts\", renderIndex(generated, params.augment ?? \"@geekapps/auth-nextjs/connections\"));\r\n\r\n const current = existsSync(outDir) ? new Set(readdirSync(outDir).filter((f) => f.endsWith(\".d.ts\"))) : new Set<string>();\r\n\r\n if (params.check) {\r\n for (const [file, content] of files) {\r\n const path = join(outDir, file);\r\n if (!existsSync(path) || readFileSync(path, \"utf-8\") !== content) result.stale.push(file);\r\n }\r\n for (const file of current) if (!files.has(file)) result.stale.push(file);\r\n return result;\r\n }\r\n\r\n mkdirSync(outDir, { recursive: true });\r\n for (const [file, content] of files) {\r\n const path = join(outDir, file);\r\n if (!existsSync(path) || readFileSync(path, \"utf-8\") !== content) writeFileSync(path, content, \"utf-8\");\r\n }\r\n // Apps que deixaram o catálogo não devem deixar tipos órfãos.\r\n for (const file of current) if (!files.has(file)) rmSync(join(outDir, file));\r\n\r\n return result;\r\n}\r\n"],"mappings":";AACA,SAAS,WAAW,aAAa,cAAc,QAAQ,eAAe,kBAAkB;AACxF,SAAS,MAAM,eAAe;AAEvB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAe/B,eAAsB,aAAa,EAAE,QAAQ,UAAU,aAAa,GAAuC;AACzG,QAAM,WAAW,MAAM,MAAM,GAAG,OAAO,QAAQ,OAAO,EAAE,CAAC,wBAAwB;AAAA,IAC/E,SAAS,EAAE,eAAe,SAAS,OAAO,KAAK,GAAG,QAAQ,IAAI,YAAY,EAAE,E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}
1
+ {"version":3,"sources":["../src/typegen.ts"],"sourcesContent":["// Gerador de tipos das App Connections: manifesto da app alvo\n// (/.well-known/geekapps-app.json) → TypeScript. O OpenAPI, quando a app\n// declara um, ainda gera os `paths` do cliente antigo (createConnectionClient).\nimport { mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync, existsSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\n\nexport const DEFAULT_ISSUER = \"https://accounts-api.geekapps.com.br\";\nexport const DEFAULT_OUT_DIR = \"geekapps-connections\";\nconst DEFAULT_AUGMENT = \"@geekapps/auth-nextjs/connections\";\n\n/** Uma app conectável — o que o catálogo do auth-server devolve. */\nexport type CatalogApp = {\n targetAppId: string;\n name: string;\n /** Chave estável no tipo `GeekappsConnections` (ex: \"post\"). */\n slug: string;\n apiBaseUrl: string | null;\n /** `${apiBaseUrl}/.well-known/geekapps-app.json`, quando a app publica um manifesto. */\n manifestUrl?: string | null;\n /** OpenAPI declarado (opcional) — só para o cliente antigo. */\n openApiUrl?: string | null;\n};\n\n/**\n * Quem pede o catálogo: a app consumidora (client id + secret) ou o usuário\n * logado pelo CLI (`geekapps login`), que vê as apps das suas organizações.\n */\nexport type Credentials =\n | { issuer: string; clientId: string; clientSecret: string }\n | { issuer: string; accessToken: string };\n\ntype JsonSchema = Record<string, unknown>;\n\n/** O manifesto publicado pelo plugin do @geekapps/auth-fastify. */\nexport type ConnectionManifest = {\n version: 1;\n appId: string | null;\n scopes: Record<string, { description: string }>;\n routes: Array<{\n method: string;\n path: string;\n scope: string;\n route: string;\n params: JsonSchema | null;\n query: JsonSchema | null;\n body: JsonSchema | null;\n response: JsonSchema | null;\n }>;\n};\n\n/** Apps conectáveis vistas por esta app (credenciais dela). */\nexport async function fetchCatalog(credentials: Credentials): Promise<CatalogApp[]> {\n const issuer = credentials.issuer.replace(/\\/$/, \"\");\n const asUser = \"accessToken\" in credentials;\n const response = await fetch(`${issuer}${asUser ? \"/me/connections/catalog\" : \"/connections/catalog\"}`, {\n headers: {\n authorization: asUser\n ? `Bearer ${credentials.accessToken}`\n : `Basic ${Buffer.from(`${credentials.clientId}:${credentials.clientSecret}`).toString(\"base64\")}`,\n },\n cache: \"no-store\",\n });\n if (!response.ok) {\n throw new Error(\n asUser\n ? `catálogo indisponível (${response.status}) — rode \\`geekapps login\\` de novo`\n : `catálogo indisponível (${response.status}) — confira GEEKAPPS_AUTH_CLIENT_ID e GEEKAPPS_AUTH_CLIENT_SECRET`,\n );\n }\n return (await response.json()) as CatalogApp[];\n}\n\nexport async function fetchManifest(manifestUrl: string): Promise<ConnectionManifest> {\n const response = await fetch(manifestUrl, { headers: { accept: \"application/json\" }, cache: \"no-store\" });\n if (!response.ok) throw new Error(`manifesto indisponível (${response.status})`);\n const manifest = (await response.json()) as ConnectionManifest;\n if (manifest?.version !== 1 || !manifest.scopes || !Array.isArray(manifest.routes)) {\n throw new Error(\"manifesto em formato inválido\");\n }\n return manifest;\n}\n\nconst HEADER = \"// Gerado pelo SDK do Geekapps Auth. Não edite à mão.\\n\\n\";\n\n/** \"messages.send\" → \"MessagesSend\". */\nfunction pascal(name: string) {\n return name\n .split(/[^a-zA-Z0-9]+/)\n .filter(Boolean)\n .map((part) => part[0]!.toUpperCase() + part.slice(1))\n .join(\"\");\n}\n\nfunction properties(schema: JsonSchema | null) {\n return (schema?.properties as Record<string, JsonSchema> | undefined) ?? {};\n}\n\nfunction required(schema: JsonSchema | null) {\n return Array.isArray(schema?.required) ? (schema!.required as string[]) : [];\n}\n\n/**\n * O cliente recebe params, query e body num objeto só (o manifesto garante\n * que não há campo repetido): junta os três num schema de objeto.\n */\nfunction mergeInputSchema(route: ConnectionManifest[\"routes\"][number]): JsonSchema {\n const parts = [route.params, route.query, route.body];\n // Path params são sempre obrigatórios, mesmo sem `required` no schema.\n const pathParams = [...route.path.matchAll(/:([A-Za-z0-9_]+)/g)].map((m) => m[1]!);\n return {\n type: \"object\",\n properties: Object.assign({}, ...parts.map(properties)),\n required: [...new Set([...pathParams, ...parts.flatMap(required)])],\n additionalProperties: false,\n };\n}\n\n/**\n * Tipos de um manifesto. Usa `json-schema-to-typescript` (import dinâmico:\n * dependência opcional, só de desenvolvimento — sem ela, a geração não roda).\n */\nexport async function generateManifestTypes(app: Pick<CatalogApp, \"slug\" | \"targetAppId\">, manifest: ConnectionManifest) {\n const { compile } = await import(\"json-schema-to-typescript\");\n const options = { bannerComment: \"\", additionalProperties: false, format: false, declareExternallyReferenced: true } as const;\n\n const blocks: string[] = [];\n const routeEntries: string[] = [];\n for (const route of manifest.routes) {\n const base = pascal(route.route);\n const input = `${base}Input`;\n const output = `${base}Output`;\n blocks.push(await compile(mergeInputSchema(route) as never, input, options));\n blocks.push(\n route.response\n ? await compile({ ...route.response, title: undefined } as never, output, options)\n : `export type ${output} = unknown;\\n`,\n );\n routeEntries.push(\n ` ${JSON.stringify(route.route)}: {\\n` +\n ` scope: ${JSON.stringify(route.scope)};\\n` +\n ` method: ${JSON.stringify(route.method)};\\n` +\n ` path: ${JSON.stringify(route.path)};\\n` +\n ` input: ${input};\\n` +\n ` output: ${output};\\n` +\n ` };`,\n );\n }\n\n const scopeIds = Object.keys(manifest.scopes);\n const scopeDocs = scopeIds\n .map((id) => ` ${JSON.stringify(id)}: ${JSON.stringify(manifest.scopes[id]!.description)};`)\n .join(\"\\n\");\n\n return `${HEADER}/** Escopos que esta app aceita em conexões. */\nexport type Scope = ${scopeIds.length ? scopeIds.map((id) => JSON.stringify(id)).join(\" | \") : \"never\"};\n\n/** Descrição de cada escopo, como aparece no consent. */\nexport interface ScopeDescriptions {\n${scopeDocs}\n}\n\n/** Rotas liberadas por escopo, pelo nome usado no cliente (\\`post.messages.send(...)\\`). */\nexport interface Routes {\n${routeEntries.join(\"\\n\")}\n}\n\nexport interface App {\n slug: ${JSON.stringify(app.slug)};\n targetAppId: ${JSON.stringify(app.targetAppId)};\n scopes: Scope;\n routes: Routes;\n}\n\n${blocks.join(\"\\n\")}`;\n}\n\n/** Tipos de um OpenAPI, no formato do openapi-typescript (cliente antigo). */\nasync function generateOpenApiTypes(openApiUrl: string) {\n const { default: openapiTS, astToString } = await import(\"openapi-typescript\");\n return HEADER + astToString(await openapiTS(new URL(openApiUrl)));\n}\n\ntype Generated = { app: CatalogApp; manifest: boolean; openApi: boolean };\n\n/** `index.d.ts`: liga cada app ao `GeekappsConnections` do módulo do SDK. */\nfunction renderIndex(apps: Generated[], augment: string) {\n const imports = apps\n .flatMap(({ app, manifest, openApi }, i) => [\n manifest ? `import type { App as App${i} } from \"./${app.slug}\";` : null,\n openApi ? `import type { paths as paths${i} } from \"./${app.slug}.openapi\";` : null,\n ])\n .filter(Boolean)\n .join(\"\\n\");\n const members = apps\n .map(({ app, manifest, openApi }, i) => {\n const fields = [manifest ? `app: App${i};` : null, openApi ? `paths: paths${i};` : null].filter(Boolean).join(\" \");\n return ` ${JSON.stringify(app.slug)}: { ${fields} };`;\n })\n .join(\"\\n\");\n return `${HEADER}${imports}\n\ndeclare module ${JSON.stringify(augment)} {\n interface GeekappsConnections {\n${members}\n }\n}\n\nexport {};\n`;\n}\n\nexport type GenerateResult = {\n apps: string[];\n /** Apps do catálogo cujo manifesto/OpenAPI não pôde ser baixado/convertido. */\n failed: Array<{ name: string; reason: string }>;\n /** Com `check`: arquivos que estariam diferentes. */\n stale: string[];\n};\n\n/**\n * Gerador de tipos das App Connections, embutido no SDK (sem pacote à parte).\n * Roda sozinho em desenvolvimento; para o CI, chame com `check: true`.\n *\n * Para cada app conectável escreve em `outDir`:\n * • `<slug>.d.ts` — a partir do manifesto (escopos, rotas e tipos de\n * entrada/saída de cada rota), requer `json-schema-to-typescript`;\n * • `<slug>.openapi.d.ts` — a partir do OpenAPI, se a app declarar um\n * (só para o `createConnectionClient` antigo), requer `openapi-typescript`;\n * • `index.d.ts`, que estende `GeekappsConnections` do módulo `augment`.\n * Com `check`, não escreve nada: só diz o que estaria diferente. Uma app cuja\n * busca falha mantém os arquivos anteriores.\n */\nexport async function generateConnectionTypes(params: {\n credentials: Credentials;\n outDir?: string;\n /** Módulo que recebe o `GeekappsConnections`. Padrão: \"@geekapps/auth-nextjs/connections\". */\n augment?: string;\n check?: boolean;\n}): Promise<GenerateResult> {\n const outDir = resolve(process.cwd(), params.outDir ?? DEFAULT_OUT_DIR);\n const catalog = (await fetchCatalog(params.credentials)).sort((a, b) => a.slug.localeCompare(b.slug));\n\n const files = new Map<string, string>();\n const result: GenerateResult = { apps: [], failed: [], stale: [] };\n const generated: Generated[] = [];\n\n // Mantém o que já existia, para a app não perder os tipos por uma falha de rede.\n const keepExisting = (file: string) => {\n const existing = join(outDir, file);\n if (!existsSync(existing)) return false;\n files.set(file, readFileSync(existing, \"utf-8\"));\n return true;\n };\n\n for (const app of catalog) {\n const entry: Generated = { app, manifest: false, openApi: false };\n\n if (app.manifestUrl) {\n const file = `${app.slug}.d.ts`;\n try {\n files.set(file, await generateManifestTypes(app, await fetchManifest(app.manifestUrl)));\n entry.manifest = true;\n } catch (error) {\n result.failed.push({ name: app.name, reason: `manifesto: ${(error as Error).message}` });\n entry.manifest = keepExisting(file);\n }\n }\n\n if (app.openApiUrl) {\n const file = `${app.slug}.openapi.d.ts`;\n try {\n files.set(file, await generateOpenApiTypes(app.openApiUrl));\n entry.openApi = true;\n } catch (error) {\n result.failed.push({ name: app.name, reason: `openapi: ${(error as Error).message}` });\n entry.openApi = keepExisting(file);\n }\n }\n\n if (entry.manifest || entry.openApi) generated.push(entry);\n }\n result.apps = generated.map(({ app }) => app.name);\n files.set(\"index.d.ts\", renderIndex(generated, params.augment ?? DEFAULT_AUGMENT));\n\n const current = existsSync(outDir) ? new Set(readdirSync(outDir).filter((f) => f.endsWith(\".d.ts\"))) : new Set<string>();\n\n if (params.check) {\n for (const [file, content] of files) {\n const path = join(outDir, file);\n if (!existsSync(path) || readFileSync(path, \"utf-8\") !== content) result.stale.push(file);\n }\n for (const file of current) if (!files.has(file)) result.stale.push(file);\n return result;\n }\n\n mkdirSync(outDir, { recursive: true });\n for (const [file, content] of files) {\n const path = join(outDir, file);\n if (!existsSync(path) || readFileSync(path, \"utf-8\") !== content) writeFileSync(path, content, \"utf-8\");\n }\n // Apps que deixaram o catálogo não devem deixar tipos órfãos.\n for (const file of current) if (!files.has(file)) rmSync(join(outDir, file));\n\n return result;\n}\n"],"mappings":";AAGA,SAAS,WAAW,aAAa,cAAc,QAAQ,eAAe,kBAAkB;AACxF,SAAS,MAAM,eAAe;AAEvB,IAAM,iBAAiB;AACvB,IAAM,kBAAkB;AAC/B,IAAM,kBAAkB;AA2CxB,eAAsB,aAAa,aAAiD;AAClF,QAAM,SAAS,YAAY,OAAO,QAAQ,OAAO,EAAE;AACnD,QAAM,SAAS,iBAAiB;AAChC,QAAM,WAAW,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,4BAA4B,sBAAsB,IAAI;AAAA,IACtG,SAAS;AAAA,MACP,eAAe,SACX,UAAU,YAAY,WAAW,KACjC,SAAS,OAAO,KAAK,GAAG,YAAY,QAAQ,IAAI,YAAY,YAAY,EAAE,EAAE,SAAS,QAAQ,CAAC;AAAA,IACpG;AAAA,IACA,OAAO;AAAA,EACT,CAAC;AACD,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,IAAI;AAAA,MACR,SACI,gCAA0B,SAAS,MAAM,6CACzC,gCAA0B,SAAS,MAAM;AAAA,IAC/C;AAAA,EACF;AACA,SAAQ,MAAM,SAAS,KAAK;AAC9B;AAEA,eAAsB,cAAc,aAAkD;AACpF,QAAM,WAAW,MAAM,MAAM,aAAa,EAAE,SAAS,EAAE,QAAQ,mBAAmB,GAAG,OAAO,WAAW,CAAC;AACxG,MAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,8BAA2B,SAAS,MAAM,GAAG;AAC/E,QAAM,WAAY,MAAM,SAAS,KAAK;AACtC,MAAI,UAAU,YAAY,KAAK,CAAC,SAAS,UAAU,CAAC,MAAM,QAAQ,SAAS,MAAM,GAAG;AAClF,UAAM,IAAI,MAAM,kCAA+B;AAAA,EACj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AAG,QAAO,MAAM,KAAK,IAAI;AACxE,WAAO;AAAA,EACT;AAEA,YAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;AACrC,aAAW,CAAC,MAAM,OAAO,KAAK,OAAO;AACnC,UAAM,OAAO,KAAK,QAAQ,IAAI;AAC9B,QAAI,CAAC,WAAW,IAAI,KAAK,aAAa,MAAM,OAAO,MAAM,QAAS,eAAc,MAAM,SAAS,OAAO;AAAA,EACxG;AAEA,aAAW,QAAQ,QAAS,KAAI,CAAC,MAAM,IAAI,IAAI,EAAG,QAAO,KAAK,QAAQ,IAAI,CAAC;AAE3E,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,68 +1,69 @@
1
- {
2
- "name": "@geekapps/auth-nextjs",
3
- "version": "0.22.0",
4
- "type": "module",
5
- "sideEffects": false,
6
- "types": "/dist",
7
- "exports": {
8
- "./server": {
9
- "types": "./dist/server.d.ts",
10
- "import": "./dist/server.js"
11
- },
12
- "./client": {
13
- "types": "./dist/client.d.ts",
14
- "import": "./dist/client.js"
15
- },
16
- "./middleware": {
17
- "types": "./dist/middleware.d.ts",
18
- "import": "./dist/middleware.js"
19
- },
20
- "./actions": {
21
- "types": "./dist/actions.d.ts",
22
- "import": "./dist/actions.js"
23
- },
24
- "./connections": {
25
- "types": "./dist/connections.d.ts",
26
- "import": "./dist/connections.js"
27
- },
28
- "./typegen": {
29
- "types": "./dist/typegen.d.ts",
30
- "import": "./dist/typegen.js"
31
- }
32
- },
33
- "files": [
34
- "dist",
35
- "README.md"
36
- ],
37
- "scripts": {
38
- "build": "tsup",
39
- "prepublishOnly": "npm run build && node -e \"const fs=require('fs');const p=require('./package.json');const miss=Object.values(p.exports||{}).map(e=>e.types).filter(t=>t&&!fs.existsSync(t));if(miss.length){console.error('Faltam declaracoes:',miss.join(', '));process.exit(1)}\""
40
- },
41
- "dependencies": {
42
- "jose": "^6.2.3"
43
- },
44
- "peerDependencies": {
45
- "next": ">=16",
46
- "openapi-fetch": ">=0.13",
47
- "react": ">=18",
48
- "typescript": ">=5",
49
- "openapi-typescript": ">=7"
50
- },
51
- "peerDependenciesMeta": {
52
- "openapi-fetch": {
53
- "optional": true
54
- },
55
- "openapi-typescript": {
56
- "optional": true
57
- }
58
- },
59
- "devDependencies": {
60
- "@types/node": "^25.0.0",
61
- "@types/react": "^19.0.0",
62
- "next": "16.2.4",
63
- "openapi-fetch": "^0.17.0",
64
- "tsup": "^8.5.1",
65
- "typescript": "^5.0.0",
66
- "openapi-typescript": "^7.13.0"
67
- }
68
- }
1
+ {
2
+ "name": "@geekapps/auth-nextjs",
3
+ "version": "0.25.0",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "types": "/dist",
7
+ "exports": {
8
+ "./server": {
9
+ "types": "./dist/server.d.ts",
10
+ "import": "./dist/server.js"
11
+ },
12
+ "./client": {
13
+ "types": "./dist/client.d.ts",
14
+ "import": "./dist/client.js"
15
+ },
16
+ "./middleware": {
17
+ "types": "./dist/middleware.d.ts",
18
+ "import": "./dist/middleware.js"
19
+ },
20
+ "./actions": {
21
+ "types": "./dist/actions.d.ts",
22
+ "import": "./dist/actions.js"
23
+ },
24
+ "./connections": {
25
+ "types": "./dist/connections.d.ts",
26
+ "import": "./dist/connections.js"
27
+ },
28
+ "./typegen": {
29
+ "types": "./dist/typegen.d.ts",
30
+ "import": "./dist/typegen.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist",
35
+ "README.md"
36
+ ],
37
+ "scripts": {
38
+ "build": "tsup",
39
+ "prepublishOnly": "npm run build && node -e \"const fs=require('fs');const p=require('./package.json');const miss=Object.values(p.exports||{}).map(e=>e.types).filter(t=>t&&!fs.existsSync(t));if(miss.length){console.error('Faltam declaracoes:',miss.join(', '));process.exit(1)}\""
40
+ },
41
+ "dependencies": {
42
+ "jose": "^6.2.3",
43
+ "json-schema-to-typescript": "^15.0.4"
44
+ },
45
+ "peerDependencies": {
46
+ "next": ">=16",
47
+ "openapi-fetch": ">=0.13",
48
+ "react": ">=18",
49
+ "typescript": ">=5",
50
+ "openapi-typescript": ">=7"
51
+ },
52
+ "peerDependenciesMeta": {
53
+ "openapi-fetch": {
54
+ "optional": true
55
+ },
56
+ "openapi-typescript": {
57
+ "optional": true
58
+ }
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "^25.0.0",
62
+ "@types/react": "^19.0.0",
63
+ "next": "16.2.4",
64
+ "openapi-fetch": "^0.17.0",
65
+ "tsup": "^8.5.1",
66
+ "typescript": "^5.0.0",
67
+ "openapi-typescript": "^7.13.0"
68
+ }
69
+ }