@ankhorage/infra 1.1.0 → 2.0.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/CHANGELOG.md +6 -0
- package/README.md +4 -1
- package/dist/adapters/minikube/index.d.ts.map +1 -1
- package/dist/adapters/minikube/index.js +13 -5
- package/dist/adapters/minikube/index.js.map +1 -1
- package/dist/generatedApiDatabase.d.ts +20 -0
- package/dist/generatedApiDatabase.d.ts.map +1 -0
- package/dist/generatedApiDatabase.js +343 -0
- package/dist/generatedApiDatabase.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/project.d.ts +1 -1
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +3 -0
- package/dist/project.js.map +1 -1
- package/dist/testSupport.d.ts.map +1 -1
- package/dist/testSupport.js +1 -0
- package/dist/testSupport.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/minikube/index.ts +18 -5
- package/src/generatedApiDatabase.test.ts +355 -0
- package/src/generatedApiDatabase.ts +558 -0
- package/src/index.ts +6 -2
- package/src/project.ts +3 -1
- package/src/testSupport.ts +1 -0
- package/src/types.ts +1 -1
- package/dist/apiArtifacts.d.ts +0 -8
- package/dist/apiArtifacts.d.ts.map +0 -1
- package/dist/apiArtifacts.js +0 -35
- package/dist/apiArtifacts.js.map +0 -1
- package/dist/apis.d.ts +0 -11
- package/dist/apis.d.ts.map +0 -1
- package/dist/apis.js +0 -354
- package/dist/apis.js.map +0 -1
- package/src/apiArtifacts.test.ts +0 -54
- package/src/apiArtifacts.ts +0 -107
- package/src/apis.test.ts +0 -212
- package/src/apis.ts +0 -534
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @ankhorage/infra
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- a4dda40: Consume the canonical generated API desired-state contract, generate deterministic Supabase/Postgres database artifacts, and remove the obsolete generated API handler/OpenAPI artifact surface.
|
|
8
|
+
|
|
3
9
|
## 1.1.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# INFRA
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Executable infra provider and standalone CLI for Ankhorage project workflows.
|
|
9
9
|
|
|
@@ -57,3 +57,6 @@ bunx @ankhorage/infra
|
|
|
57
57
|
- [Export graph](././paradox/diagrams/export-graph.mmd)
|
|
58
58
|
- [ankhorage-infra sequence](././paradox/diagrams/sequences/ankhorage-infra.mmd)
|
|
59
59
|
- [createInfraSecretStoreAdapter sequence](././paradox/diagrams/sequences/create-infra-secret-store-adapter.mmd)
|
|
60
|
+
- [getLocalAuthRedirectPatterns sequence](././paradox/diagrams/sequences/get-local-auth-redirect-patterns.mmd)
|
|
61
|
+
- [normalizeAuthCallbackRoute sequence](././paradox/diagrams/sequences/normalize-auth-callback-route.mmd)
|
|
62
|
+
- [resolveAuthRedirectConfiguration sequence](././paradox/diagrams/sequences/resolve-auth-redirect-configuration.mmd)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/minikube/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,kBAAkB,EAClB,+BAA+B,EAC/B,8BAA8B,EAC/B,MAAM,aAAa,CAAC;AAUrB,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,GAAE,+BAAoC,GAC5C,8BAA8B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/minikube/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,kBAAkB,EAClB,+BAA+B,EAC/B,8BAA8B,EAC/B,MAAM,aAAa,CAAC;AAUrB,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,GAAE,+BAAoC,GAC5C,8BAA8B,CAkGhC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generateGeneratedApiDatabaseArtifacts } from '../../generatedApiDatabase';
|
|
2
2
|
import { generateAuthProviderArtifacts } from './auth';
|
|
3
3
|
import { generateAuthorizationArtifacts } from './authz';
|
|
4
4
|
import { APP_NAMESPACE, generateMinikubeBaseArtifacts } from './base';
|
|
@@ -23,10 +23,16 @@ export function generateMinikubeInfra(manifest, options = {}) {
|
|
|
23
23
|
});
|
|
24
24
|
const storageArtifacts = generateStorageArtifacts({ manifest, namespace });
|
|
25
25
|
const secretStoreArtifacts = generateSecretStoreArtifacts({ manifest, namespace });
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const generatedApiDatabaseArtifacts = generateGeneratedApiDatabaseArtifacts({
|
|
27
|
+
generatedApis: options.appManifest?.generatedApis,
|
|
28
28
|
databaseProvider: manifest.database?.provider,
|
|
29
29
|
});
|
|
30
|
+
const generatedApiErrors = generatedApiDatabaseArtifacts.diagnostics.filter((diagnostic) => diagnostic.severity === 'error');
|
|
31
|
+
if (generatedApiErrors.length > 0) {
|
|
32
|
+
throw new Error(`Generated API database definition is invalid:\n${generatedApiErrors
|
|
33
|
+
.map((diagnostic) => `- ${diagnostic.path ?? diagnostic.apiId}: ${diagnostic.message}`)
|
|
34
|
+
.join('\n')}`);
|
|
35
|
+
}
|
|
30
36
|
const extraResources = unique([
|
|
31
37
|
...authArtifacts.resources,
|
|
32
38
|
...authzArtifacts.resources,
|
|
@@ -62,7 +68,9 @@ export function generateMinikubeInfra(manifest, options = {}) {
|
|
|
62
68
|
...authzArtifacts.warnings,
|
|
63
69
|
...storageArtifacts.warnings,
|
|
64
70
|
...secretStoreArtifacts.warnings,
|
|
65
|
-
...
|
|
71
|
+
...generatedApiDatabaseArtifacts.diagnostics
|
|
72
|
+
.filter((diagnostic) => diagnostic.severity === 'warning')
|
|
73
|
+
.map((diagnostic) => diagnostic.message),
|
|
66
74
|
]);
|
|
67
75
|
return {
|
|
68
76
|
files: [
|
|
@@ -71,7 +79,7 @@ export function generateMinikubeInfra(manifest, options = {}) {
|
|
|
71
79
|
...authzArtifacts.files,
|
|
72
80
|
...storageArtifacts.files,
|
|
73
81
|
...secretStoreArtifacts.files,
|
|
74
|
-
...
|
|
82
|
+
...generatedApiDatabaseArtifacts.files,
|
|
75
83
|
],
|
|
76
84
|
warnings,
|
|
77
85
|
meta: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/minikube/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,oBAAoB,CAAC;AAOxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,QAAQ,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD,MAAM,yBAAyB,GAAG,wCAAwC,CAAC;AAC3E,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC;AAEjE,MAAM,UAAU,qBAAqB,CACnC,QAA4B,EAC5B,UAA2C,EAAE;IAE7C,IAAI,QAAQ,CAAC,UAAU,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CACb,0EAA0E,QAAQ,CAAC,UAAU,EAAE,MAAM,IAAI,WAAW,KAAK,CAC1H,CAAC;IACJ,CAAC;IA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,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC;QACpC,QAAQ,CAAC,IAAI,CACX,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC;QAC7B,QAAQ,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAwB;IACxD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CACb,kMAAkM,CACnM,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,MAAM,CAAC,MAAgB;IAC9B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { generateApiInfrastructureArtifacts } from '../../apiArtifacts';\nimport type {\n GeneratedPackageDependency,\n InfraManifestInput,\n InfrastructureGenerationOptions,\n InfrastructureGenerationResult,\n} from '../../types';\nimport { generateAuthProviderArtifacts } from './auth';\nimport { generateAuthorizationArtifacts } from './authz';\nimport { APP_NAMESPACE, generateMinikubeBaseArtifacts } from './base';\nimport { generateSecretStoreArtifacts } from './secrets';\nimport { generateStorageArtifacts } from './storage';\n\nconst CANONICAL_PROJECT_SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/;\nconst BUILT_IN_NAMESPACES = new Set([APP_NAMESPACE, 'supabase']);\n\nexport function generateMinikubeInfra(\n manifest: InfraManifestInput,\n options: InfrastructureGenerationOptions = {},\n): InfrastructureGenerationResult {\n if (manifest.deployment?.target !== 'minikube') {\n throw new Error(\n `Minikube adapter only supports deployment target \"minikube\" (received \"${manifest.deployment?.target ?? 'undefined'}\").`,\n );\n }\n\n if (manifest.database?.provider && manifest.database.provider !== 'supabase') {\n throw new Error(\n `Unsupported database provider for minikube adapter: \"${manifest.database.provider}\". Only \"supabase\" is implemented.`,\n );\n }\n\n const appSlug = validateCanonicalAppSlug(options.appManifest?.metadata.slug);\n const namespace = APP_NAMESPACE;\n\n const authArtifacts = generateAuthProviderArtifacts({ manifest, namespace });\n const authzArtifacts = generateAuthorizationArtifacts({\n manifest,\n namespace,\n appManifest: options.appManifest,\n });\n const storageArtifacts = generateStorageArtifacts({ manifest, namespace });\n const secretStoreArtifacts = generateSecretStoreArtifacts({ manifest, namespace });\n const apiArtifacts = generateApiInfrastructureArtifacts({\n data: options.appManifest?.data,\n databaseProvider: manifest.database?.provider,\n });\n\n const extraResources = unique([\n ...authArtifacts.resources,\n ...authzArtifacts.resources,\n ...storageArtifacts.resources,\n ...secretStoreArtifacts.resources,\n ]);\n const providerLifecycle = [\n ...authArtifacts.providerLifecycle,\n ...authzArtifacts.providerLifecycle,\n ...storageArtifacts.providerLifecycle,\n ...secretStoreArtifacts.providerLifecycle,\n ];\n const providerNamespaces = unique([\n ...providerLifecycle.map((contribution) => contribution.namespace),\n ]).filter((providerNamespace) => !BUILT_IN_NAMESPACES.has(providerNamespace));\n const extraEnvEntries = unique([\n ...authArtifacts.envEntries,\n ...authzArtifacts.envEntries,\n ...storageArtifacts.envEntries,\n ...secretStoreArtifacts.envEntries,\n ]);\n\n const baseFiles = generateMinikubeBaseArtifacts({\n manifest,\n appSlug,\n extraResources,\n providerNamespaces,\n providerLifecycle,\n extraEnvEntries,\n });\n\n const warnings = unique([\n ...collectWarnings(manifest),\n ...authArtifacts.warnings,\n ...authzArtifacts.warnings,\n ...storageArtifacts.warnings,\n ...secretStoreArtifacts.warnings,\n ...apiArtifacts.warnings,\n ]);\n\n return {\n files: [\n ...baseFiles,\n ...authArtifacts.files,\n ...authzArtifacts.files,\n ...storageArtifacts.files,\n ...secretStoreArtifacts.files,\n ...apiArtifacts.files,\n ],\n warnings,\n meta: {\n target: 'minikube',\n providers: collectProviders(manifest),\n },\n dependencies: collectDependencies(manifest),\n };\n}\n\nfunction collectProviders(manifest: InfraManifestInput): string[] {\n const providers = new Set<string>();\n\n if (manifest.auth?.provider) providers.add(manifest.auth.provider);\n if (manifest.auth?.authorization?.engine) {\n providers.add(manifest.auth.authorization.engine);\n }\n if (manifest.database?.provider) providers.add(manifest.database.provider);\n if (manifest.storage?.provider) providers.add(manifest.storage.provider);\n if (manifest.secretStore?.provider) providers.add(manifest.secretStore.provider);\n if (manifest.state?.provider) providers.add(manifest.state.provider);\n\n return [...providers].sort();\n}\n\nfunction collectDependencies(manifest: InfraManifestInput): readonly GeneratedPackageDependency[] {\n if (manifest.state?.provider !== 'legend') {\n return [];\n }\n\n return [\n {\n name: '@ankhorage/state-legend',\n version: '^0.1.0',\n reason: 'Selected by infra.state.provider=legend.',\n },\n ];\n}\n\nfunction collectWarnings(manifest: InfraManifestInput): string[] {\n const warnings: string[] = [];\n\n if (manifest.deployment?.monitoring) {\n warnings.push(\n 'Monitoring is enabled in manifest, but monitoring stack resources are not generated yet.',\n );\n }\n\n if (manifest.networking?.cdn) {\n warnings.push('CDN is enabled in manifest, but CDN resources are not generated for minikube.');\n }\n\n return warnings;\n}\n\nfunction validateCanonicalAppSlug(slug: string | undefined): string {\n if (!slug) {\n throw new Error(\n 'Cannot generate Minikube infrastructure: appManifest.metadata.slug is required.',\n );\n }\n\n if (slug.trim() !== slug || !CANONICAL_PROJECT_SLUG_RE.test(slug)) {\n throw new Error(\n 'Cannot generate Minikube infrastructure: appManifest.metadata.slug must be a canonical lowercase slug up to 40 characters using only a-z, 0-9, and hyphens, without leading or trailing hyphens.',\n );\n }\n\n return slug;\n}\n\nfunction unique(values: string[]): string[] {\n return [...new Set(values)];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources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CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,QAA4B;IACnD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,IAAI,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC;QACpC,QAAQ,CAAC,IAAI,CACX,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC;QAC7B,QAAQ,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,wBAAwB,CAAC,IAAwB;IACxD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CACb,kMAAkM,CACnM,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,MAAM,CAAC,MAAgB;IAC9B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import { generateGeneratedApiDatabaseArtifacts } from '../../generatedApiDatabase';\nimport type {\n GeneratedPackageDependency,\n InfraManifestInput,\n InfrastructureGenerationOptions,\n InfrastructureGenerationResult,\n} from '../../types';\nimport { generateAuthProviderArtifacts } from './auth';\nimport { generateAuthorizationArtifacts } from './authz';\nimport { APP_NAMESPACE, generateMinikubeBaseArtifacts } from './base';\nimport { generateSecretStoreArtifacts } from './secrets';\nimport { generateStorageArtifacts } from './storage';\n\nconst CANONICAL_PROJECT_SLUG_RE = /^[a-z0-9](?:[a-z0-9-]{0,38}[a-z0-9])?$/;\nconst BUILT_IN_NAMESPACES = new Set([APP_NAMESPACE, 'supabase']);\n\nexport function generateMinikubeInfra(\n manifest: InfraManifestInput,\n options: InfrastructureGenerationOptions = {},\n): InfrastructureGenerationResult {\n if (manifest.deployment?.target !== 'minikube') {\n throw new Error(\n `Minikube adapter only supports deployment target \"minikube\" (received \"${manifest.deployment?.target ?? 'undefined'}\").`,\n );\n }\n\n if (manifest.database?.provider && manifest.database.provider !== 'supabase') {\n throw new Error(\n `Unsupported database provider for minikube adapter: \"${manifest.database.provider}\". Only \"supabase\" is implemented.`,\n );\n }\n\n const appSlug = validateCanonicalAppSlug(options.appManifest?.metadata.slug);\n const namespace = APP_NAMESPACE;\n\n const authArtifacts = generateAuthProviderArtifacts({ manifest, namespace });\n const authzArtifacts = generateAuthorizationArtifacts({\n manifest,\n namespace,\n appManifest: options.appManifest,\n });\n const storageArtifacts = generateStorageArtifacts({ manifest, namespace });\n const secretStoreArtifacts = generateSecretStoreArtifacts({ manifest, namespace });\n const generatedApiDatabaseArtifacts = generateGeneratedApiDatabaseArtifacts({\n generatedApis: options.appManifest?.generatedApis,\n databaseProvider: manifest.database?.provider,\n });\n const generatedApiErrors = generatedApiDatabaseArtifacts.diagnostics.filter(\n (diagnostic) => diagnostic.severity === 'error',\n );\n\n if (generatedApiErrors.length > 0) {\n throw new Error(\n `Generated API database definition is invalid:\\n${generatedApiErrors\n .map((diagnostic) => `- ${diagnostic.path ?? diagnostic.apiId}: ${diagnostic.message}`)\n .join('\\n')}`,\n );\n }\n\n const extraResources = unique([\n ...authArtifacts.resources,\n ...authzArtifacts.resources,\n ...storageArtifacts.resources,\n ...secretStoreArtifacts.resources,\n ]);\n const providerLifecycle = [\n ...authArtifacts.providerLifecycle,\n ...authzArtifacts.providerLifecycle,\n ...storageArtifacts.providerLifecycle,\n ...secretStoreArtifacts.providerLifecycle,\n ];\n const providerNamespaces = unique([\n ...providerLifecycle.map((contribution) => contribution.namespace),\n ]).filter((providerNamespace) => !BUILT_IN_NAMESPACES.has(providerNamespace));\n const extraEnvEntries = unique([\n ...authArtifacts.envEntries,\n ...authzArtifacts.envEntries,\n ...storageArtifacts.envEntries,\n ...secretStoreArtifacts.envEntries,\n ]);\n\n const baseFiles = generateMinikubeBaseArtifacts({\n manifest,\n appSlug,\n extraResources,\n providerNamespaces,\n providerLifecycle,\n extraEnvEntries,\n });\n\n const warnings = unique([\n ...collectWarnings(manifest),\n ...authArtifacts.warnings,\n ...authzArtifacts.warnings,\n ...storageArtifacts.warnings,\n ...secretStoreArtifacts.warnings,\n ...generatedApiDatabaseArtifacts.diagnostics\n .filter((diagnostic) => diagnostic.severity === 'warning')\n .map((diagnostic) => diagnostic.message),\n ]);\n\n return {\n files: [\n ...baseFiles,\n ...authArtifacts.files,\n ...authzArtifacts.files,\n ...storageArtifacts.files,\n ...secretStoreArtifacts.files,\n ...generatedApiDatabaseArtifacts.files,\n ],\n warnings,\n meta: {\n target: 'minikube',\n providers: collectProviders(manifest),\n },\n dependencies: collectDependencies(manifest),\n };\n}\n\nfunction collectProviders(manifest: InfraManifestInput): string[] {\n const providers = new Set<string>();\n\n if (manifest.auth?.provider) providers.add(manifest.auth.provider);\n if (manifest.auth?.authorization?.engine) {\n providers.add(manifest.auth.authorization.engine);\n }\n if (manifest.database?.provider) providers.add(manifest.database.provider);\n if (manifest.storage?.provider) providers.add(manifest.storage.provider);\n if (manifest.secretStore?.provider) providers.add(manifest.secretStore.provider);\n if (manifest.state?.provider) providers.add(manifest.state.provider);\n\n return [...providers].sort();\n}\n\nfunction collectDependencies(manifest: InfraManifestInput): readonly GeneratedPackageDependency[] {\n if (manifest.state?.provider !== 'legend') {\n return [];\n }\n\n return [\n {\n name: '@ankhorage/state-legend',\n version: '^0.1.0',\n reason: 'Selected by infra.state.provider=legend.',\n },\n ];\n}\n\nfunction collectWarnings(manifest: InfraManifestInput): string[] {\n const warnings: string[] = [];\n\n if (manifest.deployment?.monitoring) {\n warnings.push(\n 'Monitoring is enabled in manifest, but monitoring stack resources are not generated yet.',\n );\n }\n\n if (manifest.networking?.cdn) {\n warnings.push('CDN is enabled in manifest, but CDN resources are not generated for minikube.');\n }\n\n return warnings;\n}\n\nfunction validateCanonicalAppSlug(slug: string | undefined): string {\n if (!slug) {\n throw new Error(\n 'Cannot generate Minikube infrastructure: appManifest.metadata.slug is required.',\n );\n }\n\n if (slug.trim() !== slug || !CANONICAL_PROJECT_SLUG_RE.test(slug)) {\n throw new Error(\n 'Cannot generate Minikube infrastructure: appManifest.metadata.slug must be a canonical lowercase slug up to 40 characters using only a-z, 0-9, and hyphens, without leading or trailing hyphens.',\n );\n }\n\n return slug;\n}\n\nfunction unique(values: string[]): string[] {\n return [...new Set(values)];\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GeneratedApiRegistry } from '@ankhorage/contracts';
|
|
2
|
+
import type { GeneratedInfrastructureFile } from './types';
|
|
3
|
+
export type GeneratedApiDatabaseDiagnosticCode = 'duplicate-field' | 'duplicate-resource-id' | 'duplicate-target' | 'invalid-default' | 'invalid-identifier' | 'invalid-primary-key' | 'invalid-seed' | 'registry-id-mismatch' | 'unsupported-policy' | 'unsupported-provider';
|
|
4
|
+
export interface GeneratedApiDatabaseDiagnostic {
|
|
5
|
+
readonly code: GeneratedApiDatabaseDiagnosticCode;
|
|
6
|
+
readonly severity: 'error' | 'warning';
|
|
7
|
+
readonly apiId: string;
|
|
8
|
+
readonly resourceId?: string;
|
|
9
|
+
readonly path?: string;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
}
|
|
12
|
+
export interface GeneratedApiDatabaseArtifacts {
|
|
13
|
+
readonly files: readonly GeneratedInfrastructureFile[];
|
|
14
|
+
readonly diagnostics: readonly GeneratedApiDatabaseDiagnostic[];
|
|
15
|
+
}
|
|
16
|
+
export declare function generateGeneratedApiDatabaseArtifacts(args: {
|
|
17
|
+
readonly generatedApis: GeneratedApiRegistry | undefined;
|
|
18
|
+
readonly databaseProvider: string | undefined;
|
|
19
|
+
}): GeneratedApiDatabaseArtifacts;
|
|
20
|
+
//# sourceMappingURL=generatedApiDatabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatedApiDatabase.d.ts","sourceRoot":"","sources":["../src/generatedApiDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKV,oBAAoB,EAGrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,MAAM,kCAAkC,GAC1C,iBAAiB,GACjB,uBAAuB,GACvB,kBAAkB,GAClB,iBAAiB,GACjB,oBAAoB,GACpB,qBAAqB,GACrB,cAAc,GACd,sBAAsB,GACtB,oBAAoB,GACpB,sBAAsB,CAAC;AAE3B,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,IAAI,EAAE,kCAAkC,CAAC;IAClD,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,KAAK,EAAE,SAAS,2BAA2B,EAAE,CAAC;IACvD,QAAQ,CAAC,WAAW,EAAE,SAAS,8BAA8B,EAAE,CAAC;CACjE;AAmBD,wBAAgB,qCAAqC,CAAC,IAAI,EAAE;IAC1D,QAAQ,CAAC,aAAa,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACzD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/C,GAAG,6BAA6B,CA2ChC"}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
const DEFAULT_DATABASE_SCHEMA = 'public';
|
|
2
|
+
const SQL_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
3
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
4
|
+
export function generateGeneratedApiDatabaseArtifacts(args) {
|
|
5
|
+
const contexts = listGeneratedResources(args.generatedApis);
|
|
6
|
+
if (contexts.length === 0)
|
|
7
|
+
return { files: [], diagnostics: [] };
|
|
8
|
+
const diagnostics = validateGeneratedApiDatabaseState(args.generatedApis ?? {}, contexts, args.databaseProvider);
|
|
9
|
+
if (diagnostics.some((diagnostic) => diagnostic.severity === 'error')) {
|
|
10
|
+
return { files: [], diagnostics };
|
|
11
|
+
}
|
|
12
|
+
const seedEntries = contexts.map(createSeedEntry);
|
|
13
|
+
const metadata = contexts.map((context) => ({
|
|
14
|
+
apiId: context.api.id,
|
|
15
|
+
database: context.api.database,
|
|
16
|
+
auth: context.api.auth ?? null,
|
|
17
|
+
resourceId: context.resource.id,
|
|
18
|
+
operations: context.resource.operations,
|
|
19
|
+
collection: context.resource.collection,
|
|
20
|
+
policies: context.resource.policies ?? [],
|
|
21
|
+
}));
|
|
22
|
+
return {
|
|
23
|
+
files: [
|
|
24
|
+
jsonFile('infra/minikube/db/generated-api-resources.json', metadata),
|
|
25
|
+
jsonFile('infra/minikube/db/generated-api-seed.json', seedEntries),
|
|
26
|
+
{
|
|
27
|
+
path: 'infra/minikube/db/migrations/001_generated_api_resources.sql',
|
|
28
|
+
content: generateMigrationSql(contexts),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
path: 'infra/minikube/db/seeds/001_generated_api_seed.sql',
|
|
32
|
+
content: generateSeedSql(seedEntries),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
path: 'infra/minikube/db/README.md',
|
|
36
|
+
content: generateReadme(contexts),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
diagnostics,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function listGeneratedResources(registry) {
|
|
43
|
+
return Object.values(registry ?? {})
|
|
44
|
+
.sort((left, right) => left.id.localeCompare(right.id))
|
|
45
|
+
.flatMap((api) => [...api.resources]
|
|
46
|
+
.sort((left, right) => left.id.localeCompare(right.id))
|
|
47
|
+
.map((resource) => ({ api, resource, seed: resource.seed ?? [] })));
|
|
48
|
+
}
|
|
49
|
+
function validateGeneratedApiDatabaseState(registry, contexts, databaseProvider) {
|
|
50
|
+
const diagnostics = [];
|
|
51
|
+
const targets = new Map();
|
|
52
|
+
const resourceIdsByApi = new Map();
|
|
53
|
+
if (databaseProvider !== 'supabase') {
|
|
54
|
+
diagnostics.push({
|
|
55
|
+
code: 'unsupported-provider',
|
|
56
|
+
severity: 'error',
|
|
57
|
+
apiId: contexts[0]?.api.id ?? 'generated-api',
|
|
58
|
+
path: 'infra.database.provider',
|
|
59
|
+
message: 'Generated API database resources currently require the supabase provider.',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
for (const [registryId, api] of Object.entries(registry)) {
|
|
63
|
+
if (registryId !== api.id) {
|
|
64
|
+
diagnostics.push({
|
|
65
|
+
code: 'registry-id-mismatch',
|
|
66
|
+
severity: 'error',
|
|
67
|
+
apiId: api.id,
|
|
68
|
+
path: `generatedApis.${registryId}.id`,
|
|
69
|
+
message: `Generated API registry key '${registryId}' does not match definition id '${api.id}'.`,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for (const context of contexts) {
|
|
74
|
+
const { api, resource } = context;
|
|
75
|
+
const resourceIds = resourceIdsByApi.get(api.id) ?? new Set();
|
|
76
|
+
if (resourceIds.has(resource.id)) {
|
|
77
|
+
diagnostics.push(resourceDiagnostic(context, 'duplicate-resource-id', 'id', `Resource ID '${resource.id}' is duplicated.`));
|
|
78
|
+
}
|
|
79
|
+
resourceIds.add(resource.id);
|
|
80
|
+
resourceIdsByApi.set(api.id, resourceIds);
|
|
81
|
+
validateIdentifier(context, 'collection.name', resource.collection.name, diagnostics);
|
|
82
|
+
validateIdentifier(context, 'collection.schema', resource.collection.schema ?? DEFAULT_DATABASE_SCHEMA, diagnostics);
|
|
83
|
+
validateFields(context, diagnostics);
|
|
84
|
+
validatePrimaryKey(context, diagnostics);
|
|
85
|
+
validateSeeds(context, diagnostics);
|
|
86
|
+
const target = `${resource.collection.schema ?? DEFAULT_DATABASE_SCHEMA}.${resource.collection.name}`;
|
|
87
|
+
const previous = targets.get(target);
|
|
88
|
+
if (previous !== undefined) {
|
|
89
|
+
diagnostics.push(resourceDiagnostic(context, 'duplicate-target', 'collection', `Database target '${target}' is already owned by ${previous.api.id}/${previous.resource.id}.`));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
targets.set(target, context);
|
|
93
|
+
}
|
|
94
|
+
if ((resource.policies?.length ?? 0) > 0) {
|
|
95
|
+
diagnostics.push(resourceDiagnostic(context, 'unsupported-policy', 'policies', 'Policy references enable RLS, but the canonical contract does not yet contain provider-owned SQL policy expressions; no CREATE POLICY statement is emitted.', 'warning'));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return diagnostics;
|
|
99
|
+
}
|
|
100
|
+
function validateFields(context, diagnostics) {
|
|
101
|
+
const fieldNames = new Set();
|
|
102
|
+
for (const field of context.resource.collection.fields) {
|
|
103
|
+
validateIdentifier(context, `collection.fields.${field.name}.name`, field.name, diagnostics);
|
|
104
|
+
if (fieldNames.has(field.name)) {
|
|
105
|
+
diagnostics.push(resourceDiagnostic(context, 'duplicate-field', `collection.fields.${field.name}`, `Field '${field.name}' is duplicated.`));
|
|
106
|
+
}
|
|
107
|
+
fieldNames.add(field.name);
|
|
108
|
+
if (!isCompatibleDefault(field)) {
|
|
109
|
+
diagnostics.push(resourceDiagnostic(context, 'invalid-default', `collection.fields.${field.name}.defaultValue`, `Default value for '${field.name}' is incompatible with field type '${field.type}'.`));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function validatePrimaryKey(context, diagnostics) {
|
|
114
|
+
const { primaryKey } = context.resource.collection;
|
|
115
|
+
if (primaryKey === undefined)
|
|
116
|
+
return;
|
|
117
|
+
validateIdentifier(context, 'collection.primaryKey', primaryKey, diagnostics);
|
|
118
|
+
if (!context.resource.collection.fields.some((field) => field.name === primaryKey)) {
|
|
119
|
+
diagnostics.push(resourceDiagnostic(context, 'invalid-primary-key', 'collection.primaryKey', `Primary key '${primaryKey}' must reference a declared field.`));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function validateSeeds(context, diagnostics) {
|
|
123
|
+
const fields = new Map(context.resource.collection.fields.map((field) => [field.name, field]));
|
|
124
|
+
const { primaryKey } = context.resource.collection;
|
|
125
|
+
context.seed.forEach((record, index) => {
|
|
126
|
+
for (const key of Object.keys(record)) {
|
|
127
|
+
if (!fields.has(key)) {
|
|
128
|
+
diagnostics.push(resourceDiagnostic(context, 'invalid-seed', `seed.${index}.${key}`, `Seed field '${key}' is not declared by the collection.`));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
for (const field of fields.values()) {
|
|
132
|
+
const value = record[field.name];
|
|
133
|
+
const generatedUuidPrimaryKey = field.name === primaryKey && field.type === 'uuid' && value === undefined;
|
|
134
|
+
const requiresNonNullValue = field.required === true || field.name === primaryKey;
|
|
135
|
+
if (value === undefined) {
|
|
136
|
+
if (requiresNonNullValue && field.defaultValue === undefined && !generatedUuidPrimaryKey) {
|
|
137
|
+
diagnostics.push(resourceDiagnostic(context, 'invalid-seed', `seed.${index}.${field.name}`, `Seed record is missing required field '${field.name}'.`));
|
|
138
|
+
}
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (value === null) {
|
|
142
|
+
if (requiresNonNullValue) {
|
|
143
|
+
diagnostics.push(resourceDiagnostic(context, 'invalid-seed', `seed.${index}.${field.name}`, `Seed field '${field.name}' cannot be null.`));
|
|
144
|
+
}
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (!isCompatibleFieldValue(field, value)) {
|
|
148
|
+
diagnostics.push(resourceDiagnostic(context, 'invalid-seed', `seed.${index}.${field.name}`, `Seed value for '${field.name}' is incompatible with field type '${field.type}'.`));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function validateIdentifier(context, path, value, diagnostics) {
|
|
154
|
+
if (SQL_IDENTIFIER_RE.test(value))
|
|
155
|
+
return;
|
|
156
|
+
diagnostics.push(resourceDiagnostic(context, 'invalid-identifier', path, `Database identifier '${value}' must match ${SQL_IDENTIFIER_RE.source}.`));
|
|
157
|
+
}
|
|
158
|
+
function resourceDiagnostic(context, code, path, message, severity = 'error') {
|
|
159
|
+
return {
|
|
160
|
+
code,
|
|
161
|
+
severity,
|
|
162
|
+
apiId: context.api.id,
|
|
163
|
+
resourceId: context.resource.id,
|
|
164
|
+
path: `generatedApis.${context.api.id}.resources.${context.resource.id}.${path}`,
|
|
165
|
+
message,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function isCompatibleDefault(field) {
|
|
169
|
+
const value = field.defaultValue;
|
|
170
|
+
if (value === undefined || value === null)
|
|
171
|
+
return true;
|
|
172
|
+
return isCompatibleFieldValue(field, value);
|
|
173
|
+
}
|
|
174
|
+
function isCompatibleFieldValue(field, value) {
|
|
175
|
+
switch (field.type) {
|
|
176
|
+
case 'boolean':
|
|
177
|
+
return typeof value === 'boolean';
|
|
178
|
+
case 'number':
|
|
179
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
180
|
+
case 'text':
|
|
181
|
+
return typeof value === 'string';
|
|
182
|
+
case 'datetime':
|
|
183
|
+
return typeof value === 'string' && Number.isFinite(Date.parse(value));
|
|
184
|
+
case 'uuid':
|
|
185
|
+
return typeof value === 'string' && UUID_RE.test(value);
|
|
186
|
+
case 'json':
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function createSeedEntry(context) {
|
|
191
|
+
return {
|
|
192
|
+
apiId: context.api.id,
|
|
193
|
+
resourceId: context.resource.id,
|
|
194
|
+
collection: context.resource.collection,
|
|
195
|
+
records: context.seed.map((record, index) => materializeSeedRecord(context, record, index)),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function materializeSeedRecord(context, record, index) {
|
|
199
|
+
const { primaryKey } = context.resource.collection;
|
|
200
|
+
if (primaryKey === undefined || record[primaryKey] !== undefined)
|
|
201
|
+
return record;
|
|
202
|
+
const primaryKeyField = context.resource.collection.fields.find((field) => field.name === primaryKey);
|
|
203
|
+
if (primaryKeyField?.type !== 'uuid')
|
|
204
|
+
return record;
|
|
205
|
+
return {
|
|
206
|
+
...record,
|
|
207
|
+
[primaryKey]: createDeterministicSeedUuid(context.api.id, context.resource.id, index),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function generateMigrationSql(contexts) {
|
|
211
|
+
const statements = contexts.flatMap((context) => {
|
|
212
|
+
const schema = quoteIdentifier(context.resource.collection.schema ?? DEFAULT_DATABASE_SCHEMA);
|
|
213
|
+
const table = quoteIdentifier(context.resource.collection.name);
|
|
214
|
+
const columns = context.resource.collection.fields.map((field) => formatColumn(field, field.name === context.resource.collection.primaryKey));
|
|
215
|
+
const rls = (context.resource.policies?.length ?? 0) > 0
|
|
216
|
+
? [`alter table ${schema}.${table} enable row level security;`]
|
|
217
|
+
: [];
|
|
218
|
+
return [
|
|
219
|
+
`create schema if not exists ${schema};`,
|
|
220
|
+
`create table if not exists ${schema}.${table} (\n ${columns.join(',\n ')}\n);`,
|
|
221
|
+
...rls,
|
|
222
|
+
];
|
|
223
|
+
});
|
|
224
|
+
return [
|
|
225
|
+
'-- Generated from canonical GeneratedApiDefinition resources.',
|
|
226
|
+
'-- No HTTP/GraphQL service or Kubernetes API workload is generated here.',
|
|
227
|
+
'create extension if not exists pgcrypto;',
|
|
228
|
+
'',
|
|
229
|
+
...statements,
|
|
230
|
+
'',
|
|
231
|
+
].join('\n');
|
|
232
|
+
}
|
|
233
|
+
function generateSeedSql(entries) {
|
|
234
|
+
const statements = entries.flatMap((entry) => createSeedStatements(entry));
|
|
235
|
+
return [
|
|
236
|
+
'-- Generated from canonical generated API seed records.',
|
|
237
|
+
...(statements.length === 0 ? ['-- No generated API seed records configured.'] : statements),
|
|
238
|
+
'',
|
|
239
|
+
].join('\n');
|
|
240
|
+
}
|
|
241
|
+
function createSeedStatements(entry) {
|
|
242
|
+
if (entry.records.length === 0)
|
|
243
|
+
return [];
|
|
244
|
+
const fields = entry.collection.fields.filter((field) => entry.records.some((record) => record[field.name] !== undefined));
|
|
245
|
+
if (fields.length === 0)
|
|
246
|
+
return [];
|
|
247
|
+
const schema = quoteIdentifier(entry.collection.schema ?? DEFAULT_DATABASE_SCHEMA);
|
|
248
|
+
const table = quoteIdentifier(entry.collection.name);
|
|
249
|
+
const values = entry.records
|
|
250
|
+
.map((record) => `(${fields.map((field) => formatSeedValue(field, record[field.name])).join(', ')})`)
|
|
251
|
+
.join(',\n ');
|
|
252
|
+
const conflict = entry.collection.primaryKey === undefined
|
|
253
|
+
? 'on conflict do nothing'
|
|
254
|
+
: `on conflict (${quoteIdentifier(entry.collection.primaryKey)}) do nothing`;
|
|
255
|
+
return [
|
|
256
|
+
`insert into ${schema}.${table} (${fields.map((field) => quoteIdentifier(field.name)).join(', ')}) values\n ${values}\n${conflict};`,
|
|
257
|
+
];
|
|
258
|
+
}
|
|
259
|
+
function formatSeedValue(field, value) {
|
|
260
|
+
if (value === undefined)
|
|
261
|
+
return 'default';
|
|
262
|
+
return formatFieldValue(field, value);
|
|
263
|
+
}
|
|
264
|
+
function formatColumn(field, primaryKey) {
|
|
265
|
+
const defaultValue = formatDefault(field, primaryKey);
|
|
266
|
+
const primaryKeyClause = primaryKey ? ' primary key' : '';
|
|
267
|
+
const required = field.required === true && !primaryKey ? ' not null' : '';
|
|
268
|
+
const unique = field.unique === true && !primaryKey ? ' unique' : '';
|
|
269
|
+
return `${quoteIdentifier(field.name)} ${mapFieldType(field.type)}${defaultValue}${primaryKeyClause}${required}${unique}`;
|
|
270
|
+
}
|
|
271
|
+
function mapFieldType(type) {
|
|
272
|
+
if (type === 'uuid')
|
|
273
|
+
return 'uuid';
|
|
274
|
+
if (type === 'text')
|
|
275
|
+
return 'text';
|
|
276
|
+
if (type === 'number')
|
|
277
|
+
return 'numeric';
|
|
278
|
+
if (type === 'boolean')
|
|
279
|
+
return 'boolean';
|
|
280
|
+
if (type === 'datetime')
|
|
281
|
+
return 'timestamptz';
|
|
282
|
+
return 'jsonb';
|
|
283
|
+
}
|
|
284
|
+
function formatDefault(field, primaryKey) {
|
|
285
|
+
if (primaryKey && field.type === 'uuid' && field.defaultValue === undefined) {
|
|
286
|
+
return ' default gen_random_uuid()';
|
|
287
|
+
}
|
|
288
|
+
if (field.defaultValue === undefined)
|
|
289
|
+
return '';
|
|
290
|
+
return ` default ${formatFieldValue(field, field.defaultValue)}`;
|
|
291
|
+
}
|
|
292
|
+
function formatFieldValue(field, value) {
|
|
293
|
+
if (value === null)
|
|
294
|
+
return 'null';
|
|
295
|
+
if (field.type === 'json') {
|
|
296
|
+
return `'${escapeString(JSON.stringify(value))}'::jsonb`;
|
|
297
|
+
}
|
|
298
|
+
return formatValue(value);
|
|
299
|
+
}
|
|
300
|
+
function formatValue(value) {
|
|
301
|
+
if (value === null)
|
|
302
|
+
return 'null';
|
|
303
|
+
if (typeof value === 'string')
|
|
304
|
+
return `'${escapeString(value)}'`;
|
|
305
|
+
if (typeof value === 'number')
|
|
306
|
+
return Number.isFinite(value) ? String(value) : 'null';
|
|
307
|
+
if (typeof value === 'boolean')
|
|
308
|
+
return value ? 'true' : 'false';
|
|
309
|
+
return `'${escapeString(JSON.stringify(value))}'::jsonb`;
|
|
310
|
+
}
|
|
311
|
+
function generateReadme(contexts) {
|
|
312
|
+
const resources = contexts
|
|
313
|
+
.map((context) => {
|
|
314
|
+
const { collection } = context.resource;
|
|
315
|
+
return `- \`${context.api.id}/${context.resource.id}\` -> \`${collection.schema ?? DEFAULT_DATABASE_SCHEMA}.${collection.name}\``;
|
|
316
|
+
})
|
|
317
|
+
.join('\n');
|
|
318
|
+
return `# Generated API Database Artifacts\n\nThese files materialize canonical generated API resources into Supabase/Postgres database infrastructure.\n\n${resources}\n\nNo HTTP/GraphQL server, Docker image, application handler, OpenAPI document, Kubernetes Deployment or Service is generated by this bridge.\n`;
|
|
319
|
+
}
|
|
320
|
+
function jsonFile(path, value) {
|
|
321
|
+
return { path, content: `${JSON.stringify(value, null, 2)}\n` };
|
|
322
|
+
}
|
|
323
|
+
function quoteIdentifier(identifier) {
|
|
324
|
+
return `"${identifier.replaceAll('"', '""')}"`;
|
|
325
|
+
}
|
|
326
|
+
function escapeString(value) {
|
|
327
|
+
return value.replaceAll("'", "''");
|
|
328
|
+
}
|
|
329
|
+
function createDeterministicSeedUuid(apiId, resourceId, index) {
|
|
330
|
+
const input = `${apiId}:${resourceId}:${index}`;
|
|
331
|
+
const hex = `${hashHex(input, 0)}${hashHex(input, 1)}${hashHex(input, 2)}${hashHex(input, 3)}`;
|
|
332
|
+
const variant = ((Number.parseInt(hex.charAt(16), 16) & 0x3) | 0x8).toString(16);
|
|
333
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-${variant}${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
|
334
|
+
}
|
|
335
|
+
function hashHex(input, salt) {
|
|
336
|
+
let hash = 2166136261 ^ salt;
|
|
337
|
+
for (const char of input) {
|
|
338
|
+
hash ^= char.charCodeAt(0);
|
|
339
|
+
hash = Math.imul(hash, 16777619);
|
|
340
|
+
}
|
|
341
|
+
return (hash >>> 0).toString(16).padStart(8, '0');
|
|
342
|
+
}
|
|
343
|
+
//# sourceMappingURL=generatedApiDatabase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatedApiDatabase.js","sourceRoot":"","sources":["../src/generatedApiDatabase.ts"],"names":[],"mappings":"AAmDA,MAAM,uBAAuB,GAAG,QAAQ,CAAC;AACzC,MAAM,iBAAi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AAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;AAC5H,CAAC;AAED,SAAS,OAAO,CAAC,KAAa,EAAE,IAAY;IAC1C,IAAI,IAAI,GAAG,UAAU,GAAG,IAAI,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import type {\n DataContractValue,\n DbCollectionDefinition,\n DbFieldDefinition,\n GeneratedApiDefinition,\n GeneratedApiRegistry,\n GeneratedApiResourceDefinition,\n GeneratedApiSeedRecord,\n} from '@ankhorage/contracts';\n\nimport type { GeneratedInfrastructureFile } from './types';\n\nexport type GeneratedApiDatabaseDiagnosticCode =\n | 'duplicate-field'\n | 'duplicate-resource-id'\n | 'duplicate-target'\n | 'invalid-default'\n | 'invalid-identifier'\n | 'invalid-primary-key'\n | 'invalid-seed'\n | 'registry-id-mismatch'\n | 'unsupported-policy'\n | 'unsupported-provider';\n\nexport interface GeneratedApiDatabaseDiagnostic {\n readonly code: GeneratedApiDatabaseDiagnosticCode;\n readonly severity: 'error' | 'warning';\n readonly apiId: string;\n readonly resourceId?: string;\n readonly path?: string;\n readonly message: string;\n}\n\nexport interface GeneratedApiDatabaseArtifacts {\n readonly files: readonly GeneratedInfrastructureFile[];\n readonly diagnostics: readonly GeneratedApiDatabaseDiagnostic[];\n}\n\ninterface GeneratedResourceContext {\n readonly api: GeneratedApiDefinition;\n readonly resource: GeneratedApiResourceDefinition;\n readonly seed: readonly GeneratedApiSeedRecord[];\n}\n\ninterface GeneratedSeedEntry {\n readonly apiId: string;\n readonly resourceId: string;\n readonly collection: DbCollectionDefinition;\n readonly records: readonly GeneratedApiSeedRecord[];\n}\n\nconst DEFAULT_DATABASE_SCHEMA = 'public';\nconst SQL_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nexport function generateGeneratedApiDatabaseArtifacts(args: {\n readonly generatedApis: GeneratedApiRegistry | undefined;\n readonly databaseProvider: string | undefined;\n}): GeneratedApiDatabaseArtifacts {\n const contexts = listGeneratedResources(args.generatedApis);\n if (contexts.length === 0) return { files: [], diagnostics: [] };\n\n const diagnostics = validateGeneratedApiDatabaseState(\n args.generatedApis ?? {},\n contexts,\n args.databaseProvider,\n );\n if (diagnostics.some((diagnostic) => diagnostic.severity === 'error')) {\n return { files: [], diagnostics };\n }\n\n const seedEntries = contexts.map(createSeedEntry);\n const metadata = contexts.map((context) => ({\n apiId: context.api.id,\n database: context.api.database,\n auth: context.api.auth ?? null,\n resourceId: context.resource.id,\n operations: context.resource.operations,\n collection: context.resource.collection,\n policies: context.resource.policies ?? [],\n }));\n\n return {\n files: [\n jsonFile('infra/minikube/db/generated-api-resources.json', metadata),\n jsonFile('infra/minikube/db/generated-api-seed.json', seedEntries),\n {\n path: 'infra/minikube/db/migrations/001_generated_api_resources.sql',\n content: generateMigrationSql(contexts),\n },\n {\n path: 'infra/minikube/db/seeds/001_generated_api_seed.sql',\n content: generateSeedSql(seedEntries),\n },\n {\n path: 'infra/minikube/db/README.md',\n content: generateReadme(contexts),\n },\n ],\n diagnostics,\n };\n}\n\nfunction listGeneratedResources(\n registry: GeneratedApiRegistry | undefined,\n): readonly GeneratedResourceContext[] {\n return Object.values(registry ?? {})\n .sort((left, right) => left.id.localeCompare(right.id))\n .flatMap((api) =>\n [...api.resources]\n .sort((left, right) => left.id.localeCompare(right.id))\n .map((resource) => ({ api, resource, seed: resource.seed ?? [] })),\n );\n}\n\nfunction validateGeneratedApiDatabaseState(\n registry: GeneratedApiRegistry,\n contexts: readonly GeneratedResourceContext[],\n databaseProvider: string | undefined,\n): readonly GeneratedApiDatabaseDiagnostic[] {\n const diagnostics: GeneratedApiDatabaseDiagnostic[] = [];\n const targets = new Map<string, GeneratedResourceContext>();\n const resourceIdsByApi = new Map<string, Set<string>>();\n\n if (databaseProvider !== 'supabase') {\n diagnostics.push({\n code: 'unsupported-provider',\n severity: 'error',\n apiId: contexts[0]?.api.id ?? 'generated-api',\n path: 'infra.database.provider',\n message: 'Generated API database resources currently require the supabase provider.',\n });\n }\n\n for (const [registryId, api] of Object.entries(registry)) {\n if (registryId !== api.id) {\n diagnostics.push({\n code: 'registry-id-mismatch',\n severity: 'error',\n apiId: api.id,\n path: `generatedApis.${registryId}.id`,\n message: `Generated API registry key '${registryId}' does not match definition id '${api.id}'.`,\n });\n }\n }\n\n for (const context of contexts) {\n const { api, resource } = context;\n const resourceIds = resourceIdsByApi.get(api.id) ?? new Set<string>();\n if (resourceIds.has(resource.id)) {\n diagnostics.push(\n resourceDiagnostic(\n context,\n 'duplicate-resource-id',\n 'id',\n `Resource ID '${resource.id}' is duplicated.`,\n ),\n );\n }\n resourceIds.add(resource.id);\n resourceIdsByApi.set(api.id, resourceIds);\n\n validateIdentifier(context, 'collection.name', resource.collection.name, diagnostics);\n validateIdentifier(\n context,\n 'collection.schema',\n resource.collection.schema ?? DEFAULT_DATABASE_SCHEMA,\n diagnostics,\n );\n validateFields(context, diagnostics);\n validatePrimaryKey(context, diagnostics);\n validateSeeds(context, diagnostics);\n\n const target = `${resource.collection.schema ?? DEFAULT_DATABASE_SCHEMA}.${resource.collection.name}`;\n const previous = targets.get(target);\n if (previous !== undefined) {\n diagnostics.push(\n resourceDiagnostic(\n context,\n 'duplicate-target',\n 'collection',\n `Database target '${target}' is already owned by ${previous.api.id}/${previous.resource.id}.`,\n ),\n );\n } else {\n targets.set(target, context);\n }\n\n if ((resource.policies?.length ?? 0) > 0) {\n diagnostics.push(\n resourceDiagnostic(\n context,\n 'unsupported-policy',\n 'policies',\n 'Policy references enable RLS, but the canonical contract does not yet contain provider-owned SQL policy expressions; no CREATE POLICY statement is emitted.',\n 'warning',\n ),\n );\n }\n }\n\n return diagnostics;\n}\n\nfunction validateFields(\n context: GeneratedResourceContext,\n diagnostics: GeneratedApiDatabaseDiagnostic[],\n): void {\n const fieldNames = new Set<string>();\n for (const field of context.resource.collection.fields) {\n validateIdentifier(context, `collection.fields.${field.name}.name`, field.name, diagnostics);\n if (fieldNames.has(field.name)) {\n diagnostics.push(\n resourceDiagnostic(\n context,\n 'duplicate-field',\n `collection.fields.${field.name}`,\n `Field '${field.name}' is duplicated.`,\n ),\n );\n }\n fieldNames.add(field.name);\n\n if (!isCompatibleDefault(field)) {\n diagnostics.push(\n resourceDiagnostic(\n context,\n 'invalid-default',\n `collection.fields.${field.name}.defaultValue`,\n `Default value for '${field.name}' is incompatible with field type '${field.type}'.`,\n ),\n );\n }\n }\n}\n\nfunction validatePrimaryKey(\n context: GeneratedResourceContext,\n diagnostics: GeneratedApiDatabaseDiagnostic[],\n): void {\n const { primaryKey } = context.resource.collection;\n if (primaryKey === undefined) return;\n\n validateIdentifier(context, 'collection.primaryKey', primaryKey, diagnostics);\n if (!context.resource.collection.fields.some((field) => field.name === primaryKey)) {\n diagnostics.push(\n resourceDiagnostic(\n context,\n 'invalid-primary-key',\n 'collection.primaryKey',\n `Primary key '${primaryKey}' must reference a declared field.`,\n ),\n );\n }\n}\n\nfunction validateSeeds(\n context: GeneratedResourceContext,\n diagnostics: GeneratedApiDatabaseDiagnostic[],\n): void {\n const fields = new Map(context.resource.collection.fields.map((field) => [field.name, field]));\n const { primaryKey } = context.resource.collection;\n\n context.seed.forEach((record, index) => {\n for (const key of Object.keys(record)) {\n if (!fields.has(key)) {\n diagnostics.push(\n resourceDiagnostic(\n context,\n 'invalid-seed',\n `seed.${index}.${key}`,\n `Seed field '${key}' is not declared by the collection.`,\n ),\n );\n }\n }\n\n for (const field of fields.values()) {\n const value = record[field.name];\n const generatedUuidPrimaryKey =\n field.name === primaryKey && field.type === 'uuid' && value === undefined;\n const requiresNonNullValue = field.required === true || field.name === primaryKey;\n\n if (value === undefined) {\n if (requiresNonNullValue && field.defaultValue === undefined && !generatedUuidPrimaryKey) {\n diagnostics.push(\n resourceDiagnostic(\n context,\n 'invalid-seed',\n `seed.${index}.${field.name}`,\n `Seed record is missing required field '${field.name}'.`,\n ),\n );\n }\n continue;\n }\n\n if (value === null) {\n if (requiresNonNullValue) {\n diagnostics.push(\n resourceDiagnostic(\n context,\n 'invalid-seed',\n `seed.${index}.${field.name}`,\n `Seed field '${field.name}' cannot be null.`,\n ),\n );\n }\n continue;\n }\n\n if (!isCompatibleFieldValue(field, value)) {\n diagnostics.push(\n resourceDiagnostic(\n context,\n 'invalid-seed',\n `seed.${index}.${field.name}`,\n `Seed value for '${field.name}' is incompatible with field type '${field.type}'.`,\n ),\n );\n }\n }\n });\n}\n\nfunction validateIdentifier(\n context: GeneratedResourceContext,\n path: string,\n value: string,\n diagnostics: GeneratedApiDatabaseDiagnostic[],\n): void {\n if (SQL_IDENTIFIER_RE.test(value)) return;\n diagnostics.push(\n resourceDiagnostic(\n context,\n 'invalid-identifier',\n path,\n `Database identifier '${value}' must match ${SQL_IDENTIFIER_RE.source}.`,\n ),\n );\n}\n\nfunction resourceDiagnostic(\n context: GeneratedResourceContext,\n code: GeneratedApiDatabaseDiagnosticCode,\n path: string,\n message: string,\n severity: GeneratedApiDatabaseDiagnostic['severity'] = 'error',\n): GeneratedApiDatabaseDiagnostic {\n return {\n code,\n severity,\n apiId: context.api.id,\n resourceId: context.resource.id,\n path: `generatedApis.${context.api.id}.resources.${context.resource.id}.${path}`,\n message,\n };\n}\n\nfunction isCompatibleDefault(field: DbFieldDefinition): boolean {\n const value = field.defaultValue;\n if (value === undefined || value === null) return true;\n return isCompatibleFieldValue(field, value);\n}\n\nfunction isCompatibleFieldValue(field: DbFieldDefinition, value: DataContractValue): boolean {\n switch (field.type) {\n case 'boolean':\n return typeof value === 'boolean';\n case 'number':\n return typeof value === 'number' && Number.isFinite(value);\n case 'text':\n return typeof value === 'string';\n case 'datetime':\n return typeof value === 'string' && Number.isFinite(Date.parse(value));\n case 'uuid':\n return typeof value === 'string' && UUID_RE.test(value);\n case 'json':\n return true;\n }\n}\n\nfunction createSeedEntry(context: GeneratedResourceContext): GeneratedSeedEntry {\n return {\n apiId: context.api.id,\n resourceId: context.resource.id,\n collection: context.resource.collection,\n records: context.seed.map((record, index) => materializeSeedRecord(context, record, index)),\n };\n}\n\nfunction materializeSeedRecord(\n context: GeneratedResourceContext,\n record: GeneratedApiSeedRecord,\n index: number,\n): GeneratedApiSeedRecord {\n const { primaryKey } = context.resource.collection;\n if (primaryKey === undefined || record[primaryKey] !== undefined) return record;\n\n const primaryKeyField = context.resource.collection.fields.find(\n (field) => field.name === primaryKey,\n );\n if (primaryKeyField?.type !== 'uuid') return record;\n\n return {\n ...record,\n [primaryKey]: createDeterministicSeedUuid(context.api.id, context.resource.id, index),\n };\n}\n\nfunction generateMigrationSql(contexts: readonly GeneratedResourceContext[]): string {\n const statements = contexts.flatMap((context) => {\n const schema = quoteIdentifier(context.resource.collection.schema ?? DEFAULT_DATABASE_SCHEMA);\n const table = quoteIdentifier(context.resource.collection.name);\n const columns = context.resource.collection.fields.map((field) =>\n formatColumn(field, field.name === context.resource.collection.primaryKey),\n );\n const rls =\n (context.resource.policies?.length ?? 0) > 0\n ? [`alter table ${schema}.${table} enable row level security;`]\n : [];\n\n return [\n `create schema if not exists ${schema};`,\n `create table if not exists ${schema}.${table} (\\n ${columns.join(',\\n ')}\\n);`,\n ...rls,\n ];\n });\n\n return [\n '-- Generated from canonical GeneratedApiDefinition resources.',\n '-- No HTTP/GraphQL service or Kubernetes API workload is generated here.',\n 'create extension if not exists pgcrypto;',\n '',\n ...statements,\n '',\n ].join('\\n');\n}\n\nfunction generateSeedSql(entries: readonly GeneratedSeedEntry[]): string {\n const statements = entries.flatMap((entry) => createSeedStatements(entry));\n return [\n '-- Generated from canonical generated API seed records.',\n ...(statements.length === 0 ? ['-- No generated API seed records configured.'] : statements),\n '',\n ].join('\\n');\n}\n\nfunction createSeedStatements(entry: GeneratedSeedEntry): readonly string[] {\n if (entry.records.length === 0) return [];\n\n const fields = entry.collection.fields.filter((field) =>\n entry.records.some((record) => record[field.name] !== undefined),\n );\n if (fields.length === 0) return [];\n\n const schema = quoteIdentifier(entry.collection.schema ?? DEFAULT_DATABASE_SCHEMA);\n const table = quoteIdentifier(entry.collection.name);\n const values = entry.records\n .map(\n (record) =>\n `(${fields.map((field) => formatSeedValue(field, record[field.name])).join(', ')})`,\n )\n .join(',\\n ');\n const conflict =\n entry.collection.primaryKey === undefined\n ? 'on conflict do nothing'\n : `on conflict (${quoteIdentifier(entry.collection.primaryKey)}) do nothing`;\n\n return [\n `insert into ${schema}.${table} (${fields.map((field) => quoteIdentifier(field.name)).join(', ')}) values\\n ${values}\\n${conflict};`,\n ];\n}\n\nfunction formatSeedValue(field: DbFieldDefinition, value: DataContractValue | undefined): string {\n if (value === undefined) return 'default';\n return formatFieldValue(field, value);\n}\n\nfunction formatColumn(field: DbFieldDefinition, primaryKey: boolean): string {\n const defaultValue = formatDefault(field, primaryKey);\n const primaryKeyClause = primaryKey ? ' primary key' : '';\n const required = field.required === true && !primaryKey ? ' not null' : '';\n const unique = field.unique === true && !primaryKey ? ' unique' : '';\n return `${quoteIdentifier(field.name)} ${mapFieldType(field.type)}${defaultValue}${primaryKeyClause}${required}${unique}`;\n}\n\nfunction mapFieldType(type: DbFieldDefinition['type']): string {\n if (type === 'uuid') return 'uuid';\n if (type === 'text') return 'text';\n if (type === 'number') return 'numeric';\n if (type === 'boolean') return 'boolean';\n if (type === 'datetime') return 'timestamptz';\n return 'jsonb';\n}\n\nfunction formatDefault(field: DbFieldDefinition, primaryKey: boolean): string {\n if (primaryKey && field.type === 'uuid' && field.defaultValue === undefined) {\n return ' default gen_random_uuid()';\n }\n if (field.defaultValue === undefined) return '';\n return ` default ${formatFieldValue(field, field.defaultValue)}`;\n}\n\nfunction formatFieldValue(field: DbFieldDefinition, value: DataContractValue): string {\n if (value === null) return 'null';\n if (field.type === 'json') {\n return `'${escapeString(JSON.stringify(value))}'::jsonb`;\n }\n return formatValue(value);\n}\n\nfunction formatValue(value: DataContractValue): string {\n if (value === null) return 'null';\n if (typeof value === 'string') return `'${escapeString(value)}'`;\n if (typeof value === 'number') return Number.isFinite(value) ? String(value) : 'null';\n if (typeof value === 'boolean') return value ? 'true' : 'false';\n return `'${escapeString(JSON.stringify(value))}'::jsonb`;\n}\n\nfunction generateReadme(contexts: readonly GeneratedResourceContext[]): string {\n const resources = contexts\n .map((context) => {\n const { collection } = context.resource;\n return `- \\`${context.api.id}/${context.resource.id}\\` -> \\`${collection.schema ?? DEFAULT_DATABASE_SCHEMA}.${collection.name}\\``;\n })\n .join('\\n');\n\n return `# Generated API Database Artifacts\\n\\nThese files materialize canonical generated API resources into Supabase/Postgres database infrastructure.\\n\\n${resources}\\n\\nNo HTTP/GraphQL server, Docker image, application handler, OpenAPI document, Kubernetes Deployment or Service is generated by this bridge.\\n`;\n}\n\nfunction jsonFile(path: string, value: unknown): GeneratedInfrastructureFile {\n return { path, content: `${JSON.stringify(value, null, 2)}\\n` };\n}\n\nfunction quoteIdentifier(identifier: string): string {\n return `\"${identifier.replaceAll('\"', '\"\"')}\"`;\n}\n\nfunction escapeString(value: string): string {\n return value.replaceAll(\"'\", \"''\");\n}\n\nfunction createDeterministicSeedUuid(apiId: string, resourceId: string, index: number): string {\n const input = `${apiId}:${resourceId}:${index}`;\n const hex = `${hashHex(input, 0)}${hashHex(input, 1)}${hashHex(input, 2)}${hashHex(input, 3)}`;\n const variant = ((Number.parseInt(hex.charAt(16), 16) & 0x3) | 0x8).toString(16);\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-${variant}${hex.slice(17, 20)}-${hex.slice(20, 32)}`;\n}\n\nfunction hashHex(input: string, salt: number): string {\n let hash = 2166136261 ^ salt;\n for (const char of input) {\n hash ^= char.charCodeAt(0);\n hash = Math.imul(hash, 16777619);\n }\n return (hash >>> 0).toString(16).padStart(8, '0');\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { InfraGenerationInput, InfraManifestInput, InfrastructureGenerationOptions, InfrastructureGenerationResult } from './types';
|
|
2
|
-
export type { ApiInfrastructureArtifacts } from './apiArtifacts';
|
|
3
|
-
export { generateApiInfrastructureArtifacts } from './apiArtifacts';
|
|
4
2
|
export { type AuthRedirectConfiguration, type AuthRedirectEnvironment, getLocalAuthRedirectPatterns, normalizeAuthCallbackRoute, resolveAuthRedirectConfiguration, type ResolveAuthRedirectConfigurationInput, } from './authRedirects';
|
|
3
|
+
export { type GeneratedApiDatabaseArtifacts, type GeneratedApiDatabaseDiagnostic, type GeneratedApiDatabaseDiagnosticCode, generateGeneratedApiDatabaseArtifacts, } from './generatedApiDatabase';
|
|
5
4
|
export { createInfraSecretStoreAdapter, type CreateInfraSecretStoreAdapterInput, type InfraSecretStoreProviders, } from './secretStore';
|
|
6
5
|
export type { GeneratedFile, GeneratedInfrastructureFile, GeneratedPackageDependency, InfraDiagnostic, InfraGenerationInput, InfraGenerationOptions, InfraGenerationResult, InfraManifestInput, InfrastructureGenerationMeta, InfrastructureGenerationOptions, InfrastructureGenerationResult, PackageDependency, } from './types';
|
|
7
6
|
export declare function generateInfra(input: InfraGenerationInput): InfrastructureGenerationResult;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,+BAA+B,EAC/B,8BAA8B,EAC/B,MAAM,SAAS,CAAC;AAEjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,+BAA+B,EAC/B,8BAA8B,EAC/B,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,gCAAgC,EAChC,KAAK,qCAAqC,GAC3C,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,KAAK,kCAAkC,EACvC,qCAAqC,GACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,6BAA6B,EAC7B,KAAK,kCAAkC,EACvC,KAAK,yBAAyB,GAC/B,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,aAAa,EACb,2BAA2B,EAC3B,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,4BAA4B,EAC5B,+BAA+B,EAC/B,8BAA8B,EAC9B,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,8BAA8B,CAEzF;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,GAAE,+BAAoC,GAC5C,8BAA8B,CAUhC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { generateMinikubeInfra } from './adapters/minikube';
|
|
2
|
-
export { generateApiInfrastructureArtifacts } from './apiArtifacts';
|
|
3
2
|
export { getLocalAuthRedirectPatterns, normalizeAuthCallbackRoute, resolveAuthRedirectConfiguration, } from './authRedirects';
|
|
3
|
+
export { generateGeneratedApiDatabaseArtifacts, } from './generatedApiDatabase';
|
|
4
4
|
export { createInfraSecretStoreAdapter, } from './secretStore';
|
|
5
5
|
export function generateInfra(input) {
|
|
6
6
|
return generateInfrastructure(input.manifest, input.options ?? {});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAQ5D,OAAO,EAGL,4BAA4B,EAC5B,0BAA0B,EAC1B,gCAAgC,GAEjC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAIL,qCAAqC,GACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,6BAA6B,GAG9B,MAAM,eAAe,CAAC;AAgBvB,MAAM,UAAU,aAAa,CAAC,KAA2B;IACvD,OAAO,sBAAsB,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,QAA4B,EAC5B,UAA2C,EAAE;IAE7C,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC","sourcesContent":["import { generateMinikubeInfra } from './adapters/minikube';\nimport type {\n InfraGenerationInput,\n InfraManifestInput,\n InfrastructureGenerationOptions,\n InfrastructureGenerationResult,\n} from './types';\n\nexport {\n type AuthRedirectConfiguration,\n type AuthRedirectEnvironment,\n getLocalAuthRedirectPatterns,\n normalizeAuthCallbackRoute,\n resolveAuthRedirectConfiguration,\n type ResolveAuthRedirectConfigurationInput,\n} from './authRedirects';\nexport {\n type GeneratedApiDatabaseArtifacts,\n type GeneratedApiDatabaseDiagnostic,\n type GeneratedApiDatabaseDiagnosticCode,\n generateGeneratedApiDatabaseArtifacts,\n} from './generatedApiDatabase';\nexport {\n createInfraSecretStoreAdapter,\n type CreateInfraSecretStoreAdapterInput,\n type InfraSecretStoreProviders,\n} from './secretStore';\nexport type {\n GeneratedFile,\n GeneratedInfrastructureFile,\n GeneratedPackageDependency,\n InfraDiagnostic,\n InfraGenerationInput,\n InfraGenerationOptions,\n InfraGenerationResult,\n InfraManifestInput,\n InfrastructureGenerationMeta,\n InfrastructureGenerationOptions,\n InfrastructureGenerationResult,\n PackageDependency,\n} from './types';\n\nexport function generateInfra(input: InfraGenerationInput): InfrastructureGenerationResult {\n return generateInfrastructure(input.manifest, input.options ?? {});\n}\n\nexport function generateInfrastructure(\n manifest: InfraManifestInput,\n options: InfrastructureGenerationOptions = {},\n): InfrastructureGenerationResult {\n if (!manifest.deployment) {\n throw new Error('Deployment configuration is missing.');\n }\n\n if (manifest.deployment.target !== 'minikube') {\n throw new Error(`Unsupported deployment target: ${manifest.deployment.target}`);\n }\n\n return generateMinikubeInfra(manifest, options);\n}\n"]}
|
package/dist/project.d.ts
CHANGED