@ankhorage/studio 0.11.12 → 0.13.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/README.md +1 -1
- package/dist/contractGuards.d.ts.map +1 -1
- package/dist/contractGuards.js +78 -89
- package/dist/contractGuards.js.map +1 -1
- package/dist/core/StudioProvider.d.ts.map +1 -1
- package/dist/core/StudioProvider.js +18 -2
- package/dist/core/StudioProvider.js.map +1 -1
- package/dist/core/studioManifestDraftModel.d.ts +1 -2
- package/dist/core/studioManifestDraftModel.d.ts.map +1 -1
- package/dist/core/studioManifestDraftModel.js +1 -4
- package/dist/core/studioManifestDraftModel.js.map +1 -1
- package/dist/externalApiApi.d.ts +5 -0
- package/dist/externalApiApi.d.ts.map +1 -0
- package/dist/externalApiApi.js +166 -0
- package/dist/externalApiApi.js.map +1 -0
- package/dist/externalApiAuthoring.d.ts +4 -0
- package/dist/externalApiAuthoring.d.ts.map +1 -0
- package/dist/externalApiAuthoring.js +3 -0
- package/dist/externalApiAuthoring.js.map +1 -0
- package/dist/externalApiAuthoringContracts.d.ts +70 -0
- package/dist/externalApiAuthoringContracts.d.ts.map +1 -0
- package/dist/externalApiAuthoringContracts.js +2 -0
- package/dist/externalApiAuthoringContracts.js.map +1 -0
- package/dist/generatedApiAuthoring.d.ts +14 -0
- package/dist/generatedApiAuthoring.d.ts.map +1 -0
- package/dist/generatedApiAuthoring.js +64 -0
- package/dist/generatedApiAuthoring.js.map +1 -0
- package/dist/host/dataSources/createProjectEndpointCredentialResolver.d.ts +8 -0
- package/dist/host/dataSources/createProjectEndpointCredentialResolver.d.ts.map +1 -0
- package/dist/host/dataSources/createProjectEndpointCredentialResolver.js +43 -0
- package/dist/host/dataSources/createProjectEndpointCredentialResolver.js.map +1 -0
- package/dist/host/dataSources/createTrustedEndpointTestFetch.d.ts +3 -0
- package/dist/host/dataSources/createTrustedEndpointTestFetch.d.ts.map +1 -0
- package/dist/host/dataSources/createTrustedEndpointTestFetch.js +5 -0
- package/dist/host/dataSources/createTrustedEndpointTestFetch.js.map +1 -0
- package/dist/host/dataSources/createTrustedExternalApiFetch.d.ts +3 -0
- package/dist/host/dataSources/createTrustedExternalApiFetch.d.ts.map +1 -0
- package/dist/host/dataSources/createTrustedExternalApiFetch.js +5 -0
- package/dist/host/dataSources/createTrustedExternalApiFetch.js.map +1 -0
- package/dist/host/dataSources/requestTrustedExternalApi.d.ts +12 -0
- package/dist/host/dataSources/requestTrustedExternalApi.d.ts.map +1 -0
- package/dist/host/dataSources/requestTrustedExternalApi.js +44 -0
- package/dist/host/dataSources/requestTrustedExternalApi.js.map +1 -0
- package/dist/host/dataSources/sanitizeExternalApiOperationTestResult.d.ts +4 -0
- package/dist/host/dataSources/sanitizeExternalApiOperationTestResult.d.ts.map +1 -0
- package/dist/host/dataSources/sanitizeExternalApiOperationTestResult.js +34 -0
- package/dist/host/dataSources/sanitizeExternalApiOperationTestResult.js.map +1 -0
- package/dist/host/dataSources/studioExternalApiService.d.ts +24 -0
- package/dist/host/dataSources/studioExternalApiService.d.ts.map +1 -0
- package/dist/host/dataSources/studioExternalApiService.js +179 -0
- package/dist/host/dataSources/studioExternalApiService.js.map +1 -0
- package/dist/host/generatedDatabaseRuntime.d.ts +9 -0
- package/dist/host/generatedDatabaseRuntime.d.ts.map +1 -0
- package/dist/host/generatedDatabaseRuntime.js +12 -0
- package/dist/host/generatedDatabaseRuntime.js.map +1 -0
- package/dist/host/http/dataSourceRoutes.d.ts +9 -0
- package/dist/host/http/dataSourceRoutes.d.ts.map +1 -0
- package/dist/host/http/dataSourceRoutes.js +147 -0
- package/dist/host/http/dataSourceRoutes.js.map +1 -0
- package/dist/host/http/serverWithSecrets.d.ts +1 -1
- package/dist/host/http/serverWithSecrets.d.ts.map +1 -1
- package/dist/host/http/serverWithSecrets.js +4 -5
- package/dist/host/http/serverWithSecrets.js.map +1 -1
- package/dist/host/index.d.ts +4 -0
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +4 -0
- package/dist/host/index.js.map +1 -1
- package/dist/host/layout/generatedDatabaseRuntimeSource.d.ts +5 -0
- package/dist/host/layout/generatedDatabaseRuntimeSource.d.ts.map +1 -0
- package/dist/host/layout/generatedDatabaseRuntimeSource.js +40 -0
- package/dist/host/layout/generatedDatabaseRuntimeSource.js.map +1 -0
- package/dist/host/layout/layoutGenerator.d.ts.map +1 -1
- package/dist/host/layout/layoutGenerator.js +10 -2
- package/dist/host/layout/layoutGenerator.js.map +1 -1
- package/dist/host/layout/templates/rootLayout.d.ts +1 -0
- package/dist/host/layout/templates/rootLayout.d.ts.map +1 -1
- package/dist/host/layout/templates/rootLayout.js +2 -1
- package/dist/host/layout/templates/rootLayout.js.map +1 -1
- package/dist/host/orchestrator/projectManager.d.ts.map +1 -1
- package/dist/host/orchestrator/projectManager.js +3 -0
- package/dist/host/orchestrator/projectManager.js.map +1 -1
- package/dist/host/orchestrator/scaffolder.d.ts +2 -0
- package/dist/host/orchestrator/scaffolder.d.ts.map +1 -1
- package/dist/host/orchestrator/scaffolder.js +11 -4
- package/dist/host/orchestrator/scaffolder.js.map +1 -1
- package/dist/host/orchestrator/templates.d.ts +3 -0
- package/dist/host/orchestrator/templates.d.ts.map +1 -1
- package/dist/host/orchestrator/templates.js +9 -4
- package/dist/host/orchestrator/templates.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/manifestState.d.ts +1 -2
- package/dist/manifestState.d.ts.map +1 -1
- package/dist/manifestState.js +1 -4
- package/dist/manifestState.js.map +1 -1
- package/dist/manifestSync.js +1 -1
- package/dist/manifestSync.js.map +1 -1
- package/dist/normalizeExternalApiSourceId.d.ts +9 -0
- package/dist/normalizeExternalApiSourceId.d.ts.map +1 -0
- package/dist/normalizeExternalApiSourceId.js +12 -0
- package/dist/normalizeExternalApiSourceId.js.map +1 -0
- package/dist/ui/admin/pages/ApisAdminPage.d.ts.map +1 -1
- package/dist/ui/admin/pages/ApisAdminPage.js +9 -8
- package/dist/ui/admin/pages/ApisAdminPage.js.map +1 -1
- package/dist/ui/admin/pages/DataSourceCatalogCard.d.ts +5 -0
- package/dist/ui/admin/pages/DataSourceCatalogCard.d.ts.map +1 -0
- package/dist/ui/admin/pages/DataSourceCatalogCard.js +27 -0
- package/dist/ui/admin/pages/DataSourceCatalogCard.js.map +1 -0
- package/dist/ui/admin/pages/DataSourceOperationsCard.d.ts +5 -0
- package/dist/ui/admin/pages/DataSourceOperationsCard.d.ts.map +1 -0
- package/dist/ui/admin/pages/DataSourceOperationsCard.js +46 -0
- package/dist/ui/admin/pages/DataSourceOperationsCard.js.map +1 -0
- package/dist/ui/admin/pages/ExternalApiAdminPrimitives.d.ts +43 -0
- package/dist/ui/admin/pages/ExternalApiAdminPrimitives.d.ts.map +1 -0
- package/dist/ui/admin/pages/ExternalApiAdminPrimitives.js +43 -0
- package/dist/ui/admin/pages/ExternalApiAdminPrimitives.js.map +1 -0
- package/dist/ui/admin/pages/ExternalApiConnectCard.d.ts +2 -0
- package/dist/ui/admin/pages/ExternalApiConnectCard.d.ts.map +1 -0
- package/dist/ui/admin/pages/ExternalApiConnectCard.js +57 -0
- package/dist/ui/admin/pages/ExternalApiConnectCard.js.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiAuthoringCard.d.ts +2 -0
- package/dist/ui/admin/pages/GeneratedApiAuthoringCard.d.ts.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiAuthoringCard.js +36 -0
- package/dist/ui/admin/pages/GeneratedApiAuthoringCard.js.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiEditor.d.ts +9 -0
- package/dist/ui/admin/pages/GeneratedApiEditor.d.ts.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiEditor.js +31 -0
- package/dist/ui/admin/pages/GeneratedApiEditor.js.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiFieldEditor.d.ts +7 -0
- package/dist/ui/admin/pages/GeneratedApiFieldEditor.d.ts.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiFieldEditor.js +18 -0
- package/dist/ui/admin/pages/GeneratedApiFieldEditor.js.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiNormalizedOperations.d.ts +5 -0
- package/dist/ui/admin/pages/GeneratedApiNormalizedOperations.d.ts.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiNormalizedOperations.js +12 -0
- package/dist/ui/admin/pages/GeneratedApiNormalizedOperations.js.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiResourceEditor.d.ts +8 -0
- package/dist/ui/admin/pages/GeneratedApiResourceEditor.d.ts.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiResourceEditor.js +27 -0
- package/dist/ui/admin/pages/GeneratedApiResourceEditor.js.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiToggle.d.ts +6 -0
- package/dist/ui/admin/pages/GeneratedApiToggle.d.ts.map +1 -0
- package/dist/ui/admin/pages/GeneratedApiToggle.js +8 -0
- package/dist/ui/admin/pages/GeneratedApiToggle.js.map +1 -0
- package/dist/ui/admin/pages/ManualRestSourceCard.d.ts +2 -0
- package/dist/ui/admin/pages/ManualRestSourceCard.d.ts.map +1 -0
- package/dist/ui/admin/pages/ManualRestSourceCard.js +59 -0
- package/dist/ui/admin/pages/ManualRestSourceCard.js.map +1 -0
- package/dist/ui/admin/pages/adminDataSourceOperations.d.ts +7 -1
- package/dist/ui/admin/pages/adminDataSourceOperations.d.ts.map +1 -1
- package/dist/ui/admin/pages/adminDataSourceOperations.js +11 -4
- package/dist/ui/admin/pages/adminDataSourceOperations.js.map +1 -1
- package/dist/ui/admin/pages/generatedApiEditorModel.d.ts +39 -0
- package/dist/ui/admin/pages/generatedApiEditorModel.d.ts.map +1 -0
- package/dist/ui/admin/pages/generatedApiEditorModel.js +226 -0
- package/dist/ui/admin/pages/generatedApiEditorModel.js.map +1 -0
- package/dist/ui/admin/pages/generatedApiEditorStyles.d.ts +34 -0
- package/dist/ui/admin/pages/generatedApiEditorStyles.d.ts.map +1 -0
- package/dist/ui/admin/pages/generatedApiEditorStyles.js +35 -0
- package/dist/ui/admin/pages/generatedApiEditorStyles.js.map +1 -0
- package/dist/upsertExternalApiDataSource.d.ts +7 -0
- package/dist/upsertExternalApiDataSource.d.ts.map +1 -0
- package/dist/upsertExternalApiDataSource.js +7 -0
- package/dist/upsertExternalApiDataSource.js.map +1 -0
- package/package.json +16 -8
- package/dist/ui/admin/adminPageUtils.d.ts +0 -3
- package/dist/ui/admin/adminPageUtils.d.ts.map +0 -1
- package/dist/ui/admin/adminPageUtils.js +0 -7
- package/dist/ui/admin/adminPageUtils.js.map +0 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { createManualRestDataSource, discoverOpenApiDataSource, introspectGraphQlDataSource, testEndpoint, } from '@ankhorage/data-sources';
|
|
2
|
+
import { normalizeExternalApiSourceId } from '../../normalizeExternalApiSourceId';
|
|
3
|
+
import { upsertExternalApiDataSource } from '../../upsertExternalApiDataSource';
|
|
4
|
+
import { createProjectEndpointCredentialResolver } from './createProjectEndpointCredentialResolver';
|
|
5
|
+
import { createTrustedEndpointTestFetch } from './createTrustedEndpointTestFetch';
|
|
6
|
+
import { createTrustedExternalApiFetch } from './createTrustedExternalApiFetch';
|
|
7
|
+
import { sanitizeExternalApiOperationTestResult } from './sanitizeExternalApiOperationTestResult';
|
|
8
|
+
export class StudioExternalApiService {
|
|
9
|
+
projectManager;
|
|
10
|
+
discoveryFetch;
|
|
11
|
+
endpointFetch;
|
|
12
|
+
secretService;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.projectManager = options.projectManager;
|
|
15
|
+
this.discoveryFetch = options.discoveryFetch ?? createTrustedExternalApiFetch();
|
|
16
|
+
this.endpointFetch = options.endpointFetch ?? createTrustedEndpointTestFetch();
|
|
17
|
+
this.secretService = options.secretService;
|
|
18
|
+
}
|
|
19
|
+
async connect(projectId, request) {
|
|
20
|
+
const normalized = normalizeExternalApiSourceId(request.sourceId);
|
|
21
|
+
if (!normalized.ok)
|
|
22
|
+
return invalidResult(normalized.message);
|
|
23
|
+
const input = { ...request, sourceId: normalized.sourceId };
|
|
24
|
+
if (input.protocol === 'graphql')
|
|
25
|
+
return this.connectGraphQl(projectId, input, []);
|
|
26
|
+
const openApi = await this.discoverOpenApi(input);
|
|
27
|
+
if (openApi.ok)
|
|
28
|
+
return this.persist(projectId, openApi.data, openApi.attempts);
|
|
29
|
+
if (input.protocol === 'openapi')
|
|
30
|
+
return openApi;
|
|
31
|
+
return this.connectGraphQl(projectId, input, openApi.attempts, openApi.diagnostics);
|
|
32
|
+
}
|
|
33
|
+
async createManualRest(projectId, request) {
|
|
34
|
+
const normalized = normalizeExternalApiSourceId(request.sourceId);
|
|
35
|
+
if (!normalized.ok)
|
|
36
|
+
return invalidResult(normalized.message);
|
|
37
|
+
const result = createManualRestDataSource({
|
|
38
|
+
id: normalized.sourceId,
|
|
39
|
+
baseUrl: request.baseUrl,
|
|
40
|
+
name: clean(request.name),
|
|
41
|
+
description: clean(request.description),
|
|
42
|
+
credential: request.credential,
|
|
43
|
+
endpoints: [
|
|
44
|
+
{
|
|
45
|
+
id: request.endpointId,
|
|
46
|
+
path: request.path,
|
|
47
|
+
operations: [
|
|
48
|
+
{
|
|
49
|
+
id: request.operationId,
|
|
50
|
+
intent: request.intent,
|
|
51
|
+
method: request.method,
|
|
52
|
+
path: request.path,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
return result.ok
|
|
59
|
+
? this.persist(projectId, result.data, [], result.diagnostics ?? [])
|
|
60
|
+
: { ok: false, attempts: [], diagnostics: result.diagnostics };
|
|
61
|
+
}
|
|
62
|
+
async testOperation(projectId, request) {
|
|
63
|
+
const manifest = await this.readEditableManifest(projectId);
|
|
64
|
+
const source = manifest.dataSources?.[request.sourceId];
|
|
65
|
+
if (!source)
|
|
66
|
+
return missingSourceResult(request.sourceId);
|
|
67
|
+
if (source.kind !== 'api' || source.origin !== 'external') {
|
|
68
|
+
return unsupportedTestSourceResult(request.sourceId);
|
|
69
|
+
}
|
|
70
|
+
const credentialResolver = this.secretService
|
|
71
|
+
? createProjectEndpointCredentialResolver({
|
|
72
|
+
projectId,
|
|
73
|
+
service: this.secretService,
|
|
74
|
+
})
|
|
75
|
+
: undefined;
|
|
76
|
+
const result = await testEndpoint({
|
|
77
|
+
dataSource: source,
|
|
78
|
+
endpointId: request.endpointId,
|
|
79
|
+
operationId: request.operationId,
|
|
80
|
+
values: request.values,
|
|
81
|
+
dryRun: request.dryRun,
|
|
82
|
+
fetch: this.endpointFetch,
|
|
83
|
+
credentialResolver,
|
|
84
|
+
});
|
|
85
|
+
return sanitizeExternalApiOperationTestResult(result);
|
|
86
|
+
}
|
|
87
|
+
discoverOpenApi(request) {
|
|
88
|
+
return discoverOpenApiDataSource({
|
|
89
|
+
id: request.sourceId,
|
|
90
|
+
url: request.url,
|
|
91
|
+
fetch: this.discoveryFetch,
|
|
92
|
+
name: clean(request.name),
|
|
93
|
+
description: clean(request.description),
|
|
94
|
+
credential: request.credential,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async connectGraphQl(projectId, request, attempts, previousDiagnostics = []) {
|
|
98
|
+
const result = await introspectGraphQlDataSource({
|
|
99
|
+
id: request.sourceId,
|
|
100
|
+
endpointUrl: request.url,
|
|
101
|
+
fetch: this.discoveryFetch,
|
|
102
|
+
name: clean(request.name),
|
|
103
|
+
description: clean(request.description),
|
|
104
|
+
credential: request.credential,
|
|
105
|
+
});
|
|
106
|
+
return result.ok
|
|
107
|
+
? this.persist(projectId, result.data, attempts, result.diagnostics)
|
|
108
|
+
: {
|
|
109
|
+
ok: false,
|
|
110
|
+
attempts,
|
|
111
|
+
diagnostics: [...previousDiagnostics, ...result.diagnostics],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async persist(projectId, source, attempts, diagnostics = []) {
|
|
115
|
+
const manifest = await this.readEditableManifest(projectId);
|
|
116
|
+
const upsert = upsertExternalApiDataSource(manifest.dataSources ?? {}, source);
|
|
117
|
+
await this.projectManager.saveStudioManifest({
|
|
118
|
+
projectId,
|
|
119
|
+
manifest: { ...manifest, dataSources: upsert.registry },
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
ok: true,
|
|
123
|
+
sourceId: source.id,
|
|
124
|
+
kind: source.kind,
|
|
125
|
+
protocol: source.protocol,
|
|
126
|
+
created: upsert.created,
|
|
127
|
+
attempts,
|
|
128
|
+
diagnostics,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
async readEditableManifest(projectId) {
|
|
132
|
+
try {
|
|
133
|
+
return await this.projectManager.getStudioManifest(projectId);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return this.projectManager.getProjectManifest(projectId);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function invalidResult(message) {
|
|
141
|
+
return {
|
|
142
|
+
ok: false,
|
|
143
|
+
attempts: [],
|
|
144
|
+
diagnostics: [{ code: 'invalid-config', message, severity: 'error' }],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function unsupportedTestSourceResult(sourceId) {
|
|
148
|
+
return {
|
|
149
|
+
ok: false,
|
|
150
|
+
diagnostics: [
|
|
151
|
+
{
|
|
152
|
+
code: 'invalid-config',
|
|
153
|
+
dataSourceId: sourceId,
|
|
154
|
+
message: 'Studio HTTP operation testing supports external API sources only.',
|
|
155
|
+
severity: 'error',
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function missingSourceResult(sourceId) {
|
|
161
|
+
return {
|
|
162
|
+
ok: false,
|
|
163
|
+
diagnostics: [
|
|
164
|
+
{
|
|
165
|
+
code: 'missing-data-source',
|
|
166
|
+
dataSourceId: sourceId,
|
|
167
|
+
message: `Data source '${sourceId}' could not be found.`,
|
|
168
|
+
severity: 'error',
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function clean(value) {
|
|
174
|
+
const normalized = value?.trim();
|
|
175
|
+
if (!normalized)
|
|
176
|
+
return undefined;
|
|
177
|
+
return normalized;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=studioExternalApiService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studioExternalApiService.js","sourceRoot":"","sources":["../../../src/host/dataSources/studioExternalApiService.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EAGzB,2BAA2B,EAC3B,YAAY,GACb,MAAM,yBAAyB,CAAC;AASjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAGhF,OAAO,EAAE,uCAAuC,EAAE,MAAM,2CAA2C,CAAC;AACpG,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,sCAAsC,EAAE,MAAM,0CAA0C,CAAC;AAQlG,MAAM,OAAO,wBAAwB;IAClB,cAAc,CAA0B;IACxC,cAAc,CAAmB;IACjC,aAAa,CAAoB;IACjC,aAAa,CAAyC;IAEvE,YAAY,OAQX;QACC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,6BAA6B,EAAE,CAAC;QAChF,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,8BAA8B,EAAE,CAAC;QAC/E,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,OAAO,CACX,SAAiB,EACjB,OAAkC;QAElC,MAAM,UAAU,GAAG,4BAA4B,CAAC,OAAO,CAAC,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BAA2B,CAAC,QAAgB;IACnD,OAAO;QACL,EAAE,EAAE,KAAK;QACT,WAAW,EAAE;YACX;gBACE,IAAI,EAAE,gBAAgB;gBACtB,YAAY,EAAE,QAAQ;gBACtB,OAAO,EAAE,mEAAmE;gBAC5E,QAAQ,EAAE,OAAO;aAClB;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,OAAO;QACL,EAAE,EAAE,KAAK;QACT,WAAW,EAAE;YACX;gBACE,IAAI,EAAE,qBAAqB;gBAC3B,YAAY,EAAE,QAAQ;gBACtB,OAAO,EAAE,gBAAgB,QAAQ,uBAAuB;gBACxD,QAAQ,EAAE,OAAO;aAClB;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,KAAyB;IACtC,MAAM,UAAU,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IACjC,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAClC,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AppManifest } from '@ankhorage/contracts';
|
|
2
|
+
export type GeneratedDatabaseRuntimeManifest = Pick<AppManifest, 'generatedApis' | 'infra'>;
|
|
3
|
+
export type GeneratedDatabaseRuntimeProvider = 'supabase';
|
|
4
|
+
export interface GeneratedDatabaseRuntimeSelection {
|
|
5
|
+
readonly provider: GeneratedDatabaseRuntimeProvider;
|
|
6
|
+
readonly adapterIds: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveGeneratedDatabaseRuntime(manifest: GeneratedDatabaseRuntimeManifest): GeneratedDatabaseRuntimeSelection | null;
|
|
9
|
+
//# sourceMappingURL=generatedDatabaseRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatedDatabaseRuntime.d.ts","sourceRoot":"","sources":["../../src/host/generatedDatabaseRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,MAAM,gCAAgC,GAAG,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,OAAO,CAAC,CAAC;AAC5F,MAAM,MAAM,gCAAgC,GAAG,UAAU,CAAC;AAE1D,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,QAAQ,EAAE,gCAAgC,CAAC;IACpD,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,gCAAgC,GACzC,iCAAiC,GAAG,IAAI,CAc1C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function resolveGeneratedDatabaseRuntime(manifest) {
|
|
2
|
+
const adapterIds = [
|
|
3
|
+
...new Set(Object.values(manifest.generatedApis ?? {})
|
|
4
|
+
.map((definition) => definition.database.id.trim())
|
|
5
|
+
.filter(Boolean)),
|
|
6
|
+
].sort();
|
|
7
|
+
if (adapterIds.length === 0 || manifest.infra.database?.provider !== 'supabase') {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return { provider: 'supabase', adapterIds };
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=generatedDatabaseRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatedDatabaseRuntime.js","sourceRoot":"","sources":["../../src/host/generatedDatabaseRuntime.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,+BAA+B,CAC7C,QAA0C;IAE1C,MAAM,UAAU,GAAG;QACjB,GAAG,IAAI,GAAG,CACR,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,IAAI,EAAE,CAAC;aACxC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;aAClD,MAAM,CAAC,OAAO,CAAC,CACnB;KACF,CAAC,IAAI,EAAE,CAAC;IAET,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,KAAK,UAAU,EAAE,CAAC;QAChF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FastifyInstance } from 'fastify';
|
|
2
|
+
import { StudioExternalApiService } from '../dataSources/studioExternalApiService';
|
|
3
|
+
import type { ProjectManager } from '../orchestrator/projectManager';
|
|
4
|
+
export declare function registerProjectDataSourceRoutes(fastify: FastifyInstance, options: {
|
|
5
|
+
readonly projectManager: ProjectManager;
|
|
6
|
+
readonly workspaceRoot: string;
|
|
7
|
+
readonly service?: StudioExternalApiService;
|
|
8
|
+
}): void;
|
|
9
|
+
//# sourceMappingURL=dataSourceRoutes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataSourceRoutes.d.ts","sourceRoot":"","sources":["../../../src/host/http/dataSourceRoutes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;AAO7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGrE,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE;IACP,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,wBAAwB,CAAC;CAC7C,GACA,IAAI,CA4BN"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { StudioExternalApiService } from '../dataSources/studioExternalApiService';
|
|
2
|
+
import { ProjectSecretService } from '../secrets/projectSecretService';
|
|
3
|
+
export function registerProjectDataSourceRoutes(fastify, options) {
|
|
4
|
+
const service = options.service ??
|
|
5
|
+
new StudioExternalApiService({
|
|
6
|
+
projectManager: options.projectManager,
|
|
7
|
+
secretService: new ProjectSecretService({
|
|
8
|
+
projectManager: options.projectManager,
|
|
9
|
+
workspaceRoot: options.workspaceRoot,
|
|
10
|
+
}),
|
|
11
|
+
});
|
|
12
|
+
fastify.post('/api/projects/:id/data-sources/connect', async (request, reply) => {
|
|
13
|
+
const body = readConnectRequest(request.body);
|
|
14
|
+
if (!body)
|
|
15
|
+
return invalidPayload(reply, 'External API connection payload is invalid.');
|
|
16
|
+
return sendResult(reply, await service.connect(readProjectId(request), body));
|
|
17
|
+
});
|
|
18
|
+
fastify.post('/api/projects/:id/data-sources/manual-rest', async (request, reply) => {
|
|
19
|
+
const body = readManualRestRequest(request.body);
|
|
20
|
+
if (!body)
|
|
21
|
+
return invalidPayload(reply, 'Manual REST data-source payload is invalid.');
|
|
22
|
+
return sendResult(reply, await service.createManualRest(readProjectId(request), body));
|
|
23
|
+
});
|
|
24
|
+
fastify.post('/api/projects/:id/data-sources/test', async (request, reply) => {
|
|
25
|
+
const body = readOperationTestRequest(request.body);
|
|
26
|
+
if (!body)
|
|
27
|
+
return invalidPayload(reply, 'Data-source operation test payload is invalid.');
|
|
28
|
+
return sendResult(reply, await service.testOperation(readProjectId(request), body));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function readProjectId(request) {
|
|
32
|
+
return request.params.id;
|
|
33
|
+
}
|
|
34
|
+
function sendResult(reply, result) {
|
|
35
|
+
return result.ok ? result : reply.status(422).send(result);
|
|
36
|
+
}
|
|
37
|
+
function invalidPayload(reply, message) {
|
|
38
|
+
return reply.status(400).send({
|
|
39
|
+
ok: false,
|
|
40
|
+
diagnostics: [{ code: 'invalid-config', message, severity: 'error' }],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function readConnectRequest(value) {
|
|
44
|
+
const record = readRecord(value);
|
|
45
|
+
const protocol = record?.protocol;
|
|
46
|
+
if (!record ||
|
|
47
|
+
typeof record.sourceId !== 'string' ||
|
|
48
|
+
typeof record.url !== 'string' ||
|
|
49
|
+
(protocol !== 'auto' && protocol !== 'graphql' && protocol !== 'openapi')) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
sourceId: record.sourceId,
|
|
54
|
+
url: record.url,
|
|
55
|
+
protocol,
|
|
56
|
+
name: readString(record.name),
|
|
57
|
+
description: readString(record.description),
|
|
58
|
+
credential: readCredential(record.credential),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function readManualRestRequest(value) {
|
|
62
|
+
const record = readRecord(value);
|
|
63
|
+
if (!record ||
|
|
64
|
+
typeof record.sourceId !== 'string' ||
|
|
65
|
+
typeof record.baseUrl !== 'string' ||
|
|
66
|
+
typeof record.endpointId !== 'string' ||
|
|
67
|
+
typeof record.path !== 'string' ||
|
|
68
|
+
typeof record.operationId !== 'string' ||
|
|
69
|
+
typeof record.method !== 'string' ||
|
|
70
|
+
!isIntent(record.intent)) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
sourceId: record.sourceId,
|
|
75
|
+
baseUrl: record.baseUrl,
|
|
76
|
+
endpointId: record.endpointId,
|
|
77
|
+
path: record.path,
|
|
78
|
+
operationId: record.operationId,
|
|
79
|
+
method: record.method,
|
|
80
|
+
intent: record.intent,
|
|
81
|
+
name: readString(record.name),
|
|
82
|
+
description: readString(record.description),
|
|
83
|
+
credential: readCredential(record.credential),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function readOperationTestRequest(value) {
|
|
87
|
+
const record = readRecord(value);
|
|
88
|
+
if (!record ||
|
|
89
|
+
typeof record.sourceId !== 'string' ||
|
|
90
|
+
typeof record.endpointId !== 'string' ||
|
|
91
|
+
typeof record.operationId !== 'string') {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
const values = readDataValues(record.values);
|
|
95
|
+
if (record.values !== undefined && values === undefined)
|
|
96
|
+
return null;
|
|
97
|
+
return {
|
|
98
|
+
sourceId: record.sourceId,
|
|
99
|
+
endpointId: record.endpointId,
|
|
100
|
+
operationId: record.operationId,
|
|
101
|
+
values,
|
|
102
|
+
dryRun: record.dryRun === true,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function readCredential(value) {
|
|
106
|
+
const record = readRecord(value);
|
|
107
|
+
if (!record || typeof record.id !== 'string' || typeof record.kind !== 'string')
|
|
108
|
+
return undefined;
|
|
109
|
+
return {
|
|
110
|
+
id: record.id,
|
|
111
|
+
kind: record.kind,
|
|
112
|
+
label: readString(record.label),
|
|
113
|
+
scope: readString(record.scope),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function readDataValues(value) {
|
|
117
|
+
if (value === undefined)
|
|
118
|
+
return undefined;
|
|
119
|
+
const record = readRecord(value);
|
|
120
|
+
if (!record || !Object.values(record).every(isDataContractValue))
|
|
121
|
+
return undefined;
|
|
122
|
+
return record;
|
|
123
|
+
}
|
|
124
|
+
function isDataContractValue(value) {
|
|
125
|
+
if (value === null || ['boolean', 'number', 'string'].includes(typeof value))
|
|
126
|
+
return true;
|
|
127
|
+
if (Array.isArray(value))
|
|
128
|
+
return value.every(isDataContractValue);
|
|
129
|
+
const record = readRecord(value);
|
|
130
|
+
return record !== null && Object.values(record).every(isDataContractValue);
|
|
131
|
+
}
|
|
132
|
+
function isIntent(value) {
|
|
133
|
+
return (value === 'action' ||
|
|
134
|
+
value === 'create' ||
|
|
135
|
+
value === 'delete' ||
|
|
136
|
+
value === 'read' ||
|
|
137
|
+
value === 'update');
|
|
138
|
+
}
|
|
139
|
+
function readRecord(value) {
|
|
140
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
141
|
+
? value
|
|
142
|
+
: null;
|
|
143
|
+
}
|
|
144
|
+
function readString(value) {
|
|
145
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=dataSourceRoutes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataSourceRoutes.js","sourceRoot":"","sources":["../../../src/host/http/dataSourceRoutes.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAEnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,MAAM,UAAU,+BAA+B,CAC7C,OAAwB,EACxB,OAIC;IAED,MAAM,OAAO,GACX,OAAO,CAAC,OAAO;QACf,IAAI,wBAAwB,CAAC;YAC3B,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,aAAa,EAAE,IAAI,oBAAoB,CAAC;gBACtC,cAAc,EAAE,OAAO,CAAC,cAAc;gBACtC,aAAa,EAAE,OAAO,CAAC,aAAa;aACrC,CAAC;SACH,CAAC,CAAC;IAEL,OAAO,CAAC,IAAI,CAAC,wCAAwC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAC9E,MAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI;YAAE,OAAO,cAAc,CAAC,KAAK,EAAE,6CAA6C,CAAC,CAAC;QACvF,OAAO,UAAU,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,IAAI,CAAC,4CAA4C,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QAClF,MAAM,IAAI,GAAG,qBAAqB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI;YAAE,OAAO,cAAc,CAAC,KAAK,EAAE,6CAA6C,CAAC,CAAC;QACvF,OAAO,UAAU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AAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9E,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type StartStudioHostServerOptions } from './server';
|
|
2
2
|
/**
|
|
3
|
-
* Starts the Studio host with
|
|
3
|
+
* Starts the Studio host with trusted auth, secret, and data-source bridges registered.
|
|
4
4
|
*/
|
|
5
5
|
export declare function startStudioHostServerWithSecrets(options?: number | StartStudioHostServerOptions): Promise<import("fastify").FastifyInstance<import("fastify").RawServerDefault, import("node:http").IncomingMessage, import("node:http").ServerResponse<import("node:http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>>;
|
|
6
6
|
//# sourceMappingURL=serverWithSecrets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverWithSecrets.d.ts","sourceRoot":"","sources":["../../../src/host/http/serverWithSecrets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serverWithSecrets.d.ts","sourceRoot":"","sources":["../../../src/host/http/serverWithSecrets.ts"],"names":[],"mappings":"AAMA,OAAO,EAA0B,KAAK,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAErF;;GAEG;AACH,wBAAsB,gCAAgC,CACpD,OAAO,GAAE,MAAM,GAAG,4BAAiC,mRAiBpD"}
|
|
@@ -2,10 +2,11 @@ import { ModuleManager } from '../orchestrator/moduleManager';
|
|
|
2
2
|
import { ProjectManager } from '../orchestrator/projectManager';
|
|
3
3
|
import { resolveWorkspaceRoot } from '../utils/workspaceRoot';
|
|
4
4
|
import { registerProjectAuthRoutes } from './authRoutes';
|
|
5
|
+
import { registerProjectDataSourceRoutes } from './dataSourceRoutes';
|
|
5
6
|
import { registerProjectSecretRoutes } from './secretRoutes';
|
|
6
7
|
import { createStudioHostServer } from './server';
|
|
7
8
|
/**
|
|
8
|
-
* Starts the Studio host with
|
|
9
|
+
* Starts the Studio host with trusted auth, secret, and data-source bridges registered.
|
|
9
10
|
*/
|
|
10
11
|
export async function startStudioHostServerWithSecrets(options = {}) {
|
|
11
12
|
const resolvedOptions = typeof options === 'number' ? { port: options } : options;
|
|
@@ -14,10 +15,8 @@ export async function startStudioHostServerWithSecrets(options = {}) {
|
|
|
14
15
|
const projectManager = new ProjectManager(projectRoot);
|
|
15
16
|
const fastify = await createStudioHostServer({ projectManager, orchestrator, projectRoot });
|
|
16
17
|
registerProjectAuthRoutes(fastify, { projectManager, workspaceRoot: projectRoot });
|
|
17
|
-
registerProjectSecretRoutes(fastify, {
|
|
18
|
-
|
|
19
|
-
workspaceRoot: projectRoot,
|
|
20
|
-
});
|
|
18
|
+
registerProjectSecretRoutes(fastify, { projectManager, workspaceRoot: projectRoot });
|
|
19
|
+
registerProjectDataSourceRoutes(fastify, { projectManager, workspaceRoot: projectRoot });
|
|
21
20
|
const port = resolvedOptions.port ?? 3000;
|
|
22
21
|
const host = resolvedOptions.host ?? '127.0.0.1';
|
|
23
22
|
await fastify.listen({ port, host });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverWithSecrets.js","sourceRoot":"","sources":["../../../src/host/http/serverWithSecrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAqC,MAAM,UAAU,CAAC;AAErF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,UAAiD,EAAE;IAEnD,MAAM,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AW,GAAG,eAAe,CAAC,WAAW,IAAI,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7F,MAAM,YAAY,GAAG,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;IACpD,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,CAAC;IAE5F,yBAAyB,CAAC,OAAO,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC;IACnF,2BAA2B,CAAC,OAAO,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC;IACrF,+BAA+B,CAAC,OAAO,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC;IAEzF,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,IAAI,IAAI,CAAC;IAC1C,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,IAAI,WAAW,CAAC;IACjD,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,2CAA2C,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IACvE,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/host/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export { type ProjectAuthHealthResult, ProjectAuthHealthService, } from './auth/projectAuthHealthService';
|
|
2
2
|
export { createStudioHost, type CreateStudioHostOptions, type StudioHost, } from './createStudioHost';
|
|
3
|
+
export { createTrustedEndpointTestFetch } from './dataSources/createTrustedEndpointTestFetch';
|
|
4
|
+
export { createTrustedExternalApiFetch } from './dataSources/createTrustedExternalApiFetch';
|
|
5
|
+
export { StudioExternalApiService } from './dataSources/studioExternalApiService';
|
|
3
6
|
export { registerProjectAuthRoutes } from './http/authRoutes';
|
|
7
|
+
export { registerProjectDataSourceRoutes } from './http/dataSourceRoutes';
|
|
4
8
|
export { registerProjectSecretRoutes } from './http/secretRoutes';
|
|
5
9
|
export { isOriginAllowed } from './http/security';
|
|
6
10
|
export { createStudioHostServer, startStudioHostServer, type StartStudioHostServerOptions, } from './http/server';
|
package/dist/host/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,wBAAwB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,UAAU,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,4BAA4B,GAClC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EACL,KAAK,sBAAsB,EAC3B,4BAA4B,GAC7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,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AC3B,4BAA4B,GAC7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,oBAAoB,EACpB,KAAK,2BAA2B,GACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/host/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export { ProjectAuthHealthService, } from './auth/projectAuthHealthService';
|
|
2
2
|
export { createStudioHost, } from './createStudioHost';
|
|
3
|
+
export { createTrustedEndpointTestFetch } from './dataSources/createTrustedEndpointTestFetch';
|
|
4
|
+
export { createTrustedExternalApiFetch } from './dataSources/createTrustedExternalApiFetch';
|
|
5
|
+
export { StudioExternalApiService } from './dataSources/studioExternalApiService';
|
|
3
6
|
export { registerProjectAuthRoutes } from './http/authRoutes';
|
|
7
|
+
export { registerProjectDataSourceRoutes } from './http/dataSourceRoutes';
|
|
4
8
|
export { registerProjectSecretRoutes } from './http/secretRoutes';
|
|
5
9
|
export { isOriginAllowed } from './http/security';
|
|
6
10
|
export { createStudioHostServer, startStudioHostServer, } from './http/server';
|
package/dist/host/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,GACzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,gBAAgB,GAGjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;A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B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAuB,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAEL,4BAA4B,GAC7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAGL,oBAAoB,GAErB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { GeneratedDatabaseRuntimeSelection } from '../generatedDatabaseRuntime';
|
|
2
|
+
export declare const GENERATED_DATABASE_ADAPTERS_EXPRESSION = "GENERATED_DATABASE_ADAPTERS";
|
|
3
|
+
export declare function getGeneratedDatabaseRuntimeImports(selection: GeneratedDatabaseRuntimeSelection | null): readonly string[];
|
|
4
|
+
export declare function getGeneratedDatabaseRuntimeModuleDeclarations(selection: GeneratedDatabaseRuntimeSelection | null, useStoredAuthSession: boolean): string;
|
|
5
|
+
//# sourceMappingURL=generatedDatabaseRuntimeSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatedDatabaseRuntimeSource.d.ts","sourceRoot":"","sources":["../../../src/host/layout/generatedDatabaseRuntimeSource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAGrF,eAAO,MAAM,sCAAsC,gCAAgC,CAAC;AAEpF,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,iCAAiC,GAAG,IAAI,GAClD,SAAS,MAAM,EAAE,CAInB;AAED,wBAAgB,6CAA6C,CAC3D,SAAS,EAAE,iCAAiC,GAAG,IAAI,EACnD,oBAAoB,EAAE,OAAO,GAC5B,MAAM,CAgCR"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { escapeStringLiteral } from './utils/escapeStringLiteral';
|
|
2
|
+
export const GENERATED_DATABASE_ADAPTERS_EXPRESSION = 'GENERATED_DATABASE_ADAPTERS';
|
|
3
|
+
export function getGeneratedDatabaseRuntimeImports(selection) {
|
|
4
|
+
return selection?.provider === 'supabase'
|
|
5
|
+
? ["import { createSupabaseDbAdapter } from '@ankhorage/supabase-db';"]
|
|
6
|
+
: [];
|
|
7
|
+
}
|
|
8
|
+
export function getGeneratedDatabaseRuntimeModuleDeclarations(selection, useStoredAuthSession) {
|
|
9
|
+
if (selection?.provider !== 'supabase')
|
|
10
|
+
return '';
|
|
11
|
+
const adapterEntries = selection.adapterIds
|
|
12
|
+
.map((id) => ` '${escapeStringLiteral(id)}': generatedSupabaseDbAdapter,`)
|
|
13
|
+
.join('\n');
|
|
14
|
+
const fetchDeclaration = useStoredAuthSession
|
|
15
|
+
? `const generatedSupabaseDbFetch: typeof fetch = (input, init) => {
|
|
16
|
+
const session = getStoredAuthSession();
|
|
17
|
+
if (!session?.accessToken) return fetch(input, init);
|
|
18
|
+
const headers = new Headers(init?.headers);
|
|
19
|
+
headers.set('Authorization', \`Bearer \${session.accessToken}\`);
|
|
20
|
+
return fetch(input, { ...init, headers });
|
|
21
|
+
};\n`
|
|
22
|
+
: '';
|
|
23
|
+
const fetchOption = useStoredAuthSession ? ', fetch: generatedSupabaseDbFetch' : '';
|
|
24
|
+
return `${fetchDeclaration}const generatedSupabaseUrl = process.env.EXPO_PUBLIC_SUPABASE_URL?.trim() ?? '';
|
|
25
|
+
const generatedSupabaseAnonKey = process.env.EXPO_PUBLIC_SUPABASE_ANON_KEY?.trim() ?? '';
|
|
26
|
+
const generatedSupabaseDbAdapter =
|
|
27
|
+
generatedSupabaseUrl.length > 0 && generatedSupabaseAnonKey.length > 0
|
|
28
|
+
? createSupabaseDbAdapter({
|
|
29
|
+
url: generatedSupabaseUrl,
|
|
30
|
+
anonKey: generatedSupabaseAnonKey${fetchOption},
|
|
31
|
+
})
|
|
32
|
+
: null;
|
|
33
|
+
const GENERATED_DATABASE_ADAPTERS =
|
|
34
|
+
generatedSupabaseDbAdapter === null
|
|
35
|
+
? {}
|
|
36
|
+
: {
|
|
37
|
+
${adapterEntries}
|
|
38
|
+
};`;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=generatedDatabaseRuntimeSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatedDatabaseRuntimeSource.js","sourceRoot":"","sources":["../../../src/host/layout/generatedDatabaseRuntimeSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,MAAM,CAAC,MAAM,sCAAsC,GAAG,6BAA6B,CAAC;AAEpF,MAAM,UAAU,kCAAkC,CAChD,SAAmD;IAEnD,OAAO,SAAS,EAAE,QAAQ,KAAK,UAAU;QACvC,CAAC,CAAC,CAAC,mEAAmE,CAAC;QACvE,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,MAAM,UAAU,6CAA6C,CAC3D,SAAmD,EACnD,oBAA6B;IAE7B,IAAI,SAAS,EAAE,QAAQ,KAAK,UAAU;QAAE,OAAO,EAAE,CAAC;IAElD,MAAM,cAAc,GAAG,SAAS,CAAC,UAAU;SACxC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,UAAU,mBAAmB,CAAC,EAAE,CAAC,gCAAgC,CAAC;SAC9E,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,MAAM,gBAAgB,GAAG,oBAAoB;QAC3C,CAAC,CAAC;;;;;;KAMD;QACD,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,WAAW,GAAG,oBAAoB,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEpF,OAAO,GAAG,gBAAgB;;;;;;2CAMe,WAAW;;;;;;;EAOpD,cAAc;SACP,CAAC;AACV,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layoutGenerator.d.ts","sourceRoot":"","sources":["../../../src/host/layout/layoutGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,sBAAsB,CAAC;AACxF,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"layoutGenerator.d.ts","sourceRoot":"","sources":["../../../src/host/layout/layoutGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,sBAAsB,CAAC;AACxF,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,kCAAkC,CAAC;AAS1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA6BxD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iCAAiC;IAChD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAsCD,qBAAa,yBAAyB;IACpC,aAAa,CACX,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,WAAW,EACrB,SAAS,EAAE,cAAc,EAAE,EAC3B,OAAO,GAAE,iCAAsC,GAC9C,aAAa,EAAE;IAqIlB,OAAO,CAAC,yBAAyB;IAsGjC,OAAO,CAAC,oBAAoB;IA2F5B,OAAO,CAAC,2BAA2B;IA4BnC,OAAO,CAAC,iBAAiB;CAO1B"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { resolveExpoRuntimeLayoutIntegration, } from '@ankhorage/expo-runtime/planning';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { getStudioAdminRouteDefinition, STUDIO_ADMIN_ROUTE_REGISTRY, } from '../../studioAdminRouteModel';
|
|
4
|
+
import { resolveGeneratedDatabaseRuntime } from '../generatedDatabaseRuntime';
|
|
4
5
|
import { resolveAuthLayoutPlan, } from './auth/resolveAuthLayoutPlan';
|
|
6
|
+
import { GENERATED_DATABASE_ADAPTERS_EXPRESSION, getGeneratedDatabaseRuntimeImports, getGeneratedDatabaseRuntimeModuleDeclarations, } from './generatedDatabaseRuntimeSource';
|
|
5
7
|
import { composeGeneratedImports } from './generatedImportComposer';
|
|
6
8
|
import { buildNavigatorJsx, getAuthAdapterTs, getAuthOAuthCallbackTsx, getAuthOAuthRuntimeTs, getAuthScreenTsx, getAuthSessionTs, getIndexRedirectRouteTsx, getNestedLayoutTsx, getRootLayoutImportRequirements, getRootLayoutTsx, getScreenTsx, getSignOutScreenTsx, } from './templates';
|
|
7
9
|
import { routeNameToHref } from './templates/utils/routes';
|
|
@@ -171,6 +173,7 @@ export class GeneratedAppFileGenerator {
|
|
|
171
173
|
const pluginImports = mutations.flatMap((m) => m.imports);
|
|
172
174
|
const pluginHooks = mutations.flatMap((m) => m.hooks);
|
|
173
175
|
const runtimeLayoutIntegration = resolveExpoRuntimeLayoutIntegration(runtimePlan);
|
|
176
|
+
const databaseRuntime = resolveGeneratedDatabaseRuntime(manifest);
|
|
174
177
|
const allImports = composeGeneratedImports([
|
|
175
178
|
...getRootLayoutImportRequirements(includeStudio),
|
|
176
179
|
`import type { AppManifest${includeStudio ? ', NavigatorSpec, RouteDefinition' : ''} } from '@ankhorage/contracts';`,
|
|
@@ -200,6 +203,7 @@ export class GeneratedAppFileGenerator {
|
|
|
200
203
|
subscribeToAuthSessionChanges,
|
|
201
204
|
} from '@/auth/session';`,
|
|
202
205
|
getPackageOwnedRuntimeImports(),
|
|
206
|
+
...getGeneratedDatabaseRuntimeImports(databaseRuntime),
|
|
203
207
|
includeStudio
|
|
204
208
|
? `import { StudioProvider, AnkhStudio, useStudio, useStudioAppBarAugmentation } from '@ankhorage/studio';`
|
|
205
209
|
: '',
|
|
@@ -220,8 +224,9 @@ export class GeneratedAppFileGenerator {
|
|
|
220
224
|
innerNavigation,
|
|
221
225
|
includeStudio,
|
|
222
226
|
authRuntime: authLayoutPlan,
|
|
227
|
+
databaseAdaptersExpression: databaseRuntime === null ? undefined : GENERATED_DATABASE_ADAPTERS_EXPRESSION,
|
|
223
228
|
initialRouteNameOverride: '(app)',
|
|
224
|
-
runtimeModuleDeclarations: mergeRuntimeModuleDeclarations(getGeneratedRuntimeRegistryDeclarations(), ...runtimeLayoutIntegration.moduleDeclarations),
|
|
229
|
+
runtimeModuleDeclarations: mergeRuntimeModuleDeclarations(getGeneratedRuntimeRegistryDeclarations(), getGeneratedDatabaseRuntimeModuleDeclarations(databaseRuntime, true), ...runtimeLayoutIntegration.moduleDeclarations),
|
|
225
230
|
runtimeProviderEnd: [...runtimeLayoutIntegration.providerEnd],
|
|
226
231
|
runtimeProviderStart: [...runtimeLayoutIntegration.providerStart],
|
|
227
232
|
useStoredAuthSessionCredentialResolver: true,
|
|
@@ -239,6 +244,7 @@ export class GeneratedAppFileGenerator {
|
|
|
239
244
|
const needsZoraDrawerContent = innerNavigation.usesZoraDrawerContent;
|
|
240
245
|
const needsZoraNavigationRouteMap = innerNavigation.usesZoraNavigationRouteMap;
|
|
241
246
|
const runtimeLayoutIntegration = resolveExpoRuntimeLayoutIntegration(runtimePlan);
|
|
247
|
+
const databaseRuntime = resolveGeneratedDatabaseRuntime(manifest);
|
|
242
248
|
const coreImports = [
|
|
243
249
|
`import type { AppManifest${includeStudio ? ', NavigatorSpec, RouteDefinition' : ''} } from '@ankhorage/contracts';`,
|
|
244
250
|
...runtimeLayoutIntegration.imports,
|
|
@@ -268,6 +274,7 @@ export class GeneratedAppFileGenerator {
|
|
|
268
274
|
`import { GestureHandlerRootView } from 'react-native-gesture-handler';`,
|
|
269
275
|
`import { SafeAreaProvider } from 'react-native-safe-area-context';`,
|
|
270
276
|
getPackageOwnedRuntimeImports(),
|
|
277
|
+
...getGeneratedDatabaseRuntimeImports(databaseRuntime),
|
|
271
278
|
includeStudio
|
|
272
279
|
? `import { StudioProvider, AnkhStudio, useStudio, useStudioAppBarAugmentation } from '@ankhorage/studio';`
|
|
273
280
|
: '',
|
|
@@ -293,7 +300,8 @@ export class GeneratedAppFileGenerator {
|
|
|
293
300
|
allHooks,
|
|
294
301
|
innerNavigation,
|
|
295
302
|
includeStudio,
|
|
296
|
-
|
|
303
|
+
databaseAdaptersExpression: databaseRuntime === null ? undefined : GENERATED_DATABASE_ADAPTERS_EXPRESSION,
|
|
304
|
+
runtimeModuleDeclarations: mergeRuntimeModuleDeclarations(getGeneratedRuntimeRegistryDeclarations(), getGeneratedDatabaseRuntimeModuleDeclarations(databaseRuntime, false), ...runtimeLayoutIntegration.moduleDeclarations),
|
|
297
305
|
runtimeProviderEnd: [...runtimeLayoutIntegration.providerEnd],
|
|
298
306
|
runtimeProviderStart: [...runtimeLayoutIntegration.providerStart],
|
|
299
307
|
});
|