@executor-js/plugin-openapi 1.4.28 → 1.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AddOpenApiSource-FLMNI742.js → AddOpenApiSource-KSOMPQ2R.js} +4 -4
- package/dist/{EditOpenApiSource-I4NIGIIJ.js → EditOpenApiSource-AOA7APR2.js} +301 -192
- package/dist/EditOpenApiSource-AOA7APR2.js.map +1 -0
- package/dist/{OpenApiSourceSummary-CM46DB4L.js → OpenApiSourceSummary-Y3S6ZBOZ.js} +4 -4
- package/dist/OpenApiSourceSummary-Y3S6ZBOZ.js.map +1 -0
- package/dist/api/group.d.ts +124 -118
- package/dist/api/index.d.ts +148 -369
- package/dist/chunk-BB5IAKRG.js +136 -0
- package/dist/chunk-BB5IAKRG.js.map +1 -0
- package/dist/{chunk-E7PZ2QGD.js → chunk-EOXXE5DG.js} +17 -455
- package/dist/chunk-EOXXE5DG.js.map +1 -0
- package/dist/{chunk-OZ67JNID.js → chunk-NIKLYJ3X.js} +830 -319
- package/dist/chunk-NIKLYJ3X.js.map +1 -0
- package/dist/{chunk-TGDT6QCH.js → chunk-YJMXYKYX.js} +178 -117
- package/dist/chunk-YJMXYKYX.js.map +1 -0
- package/dist/{chunk-GFQUEZUW.js → chunk-ZZBTLFTA.js} +78 -93
- package/dist/chunk-ZZBTLFTA.js.map +1 -0
- package/dist/client.js +7 -137
- package/dist/client.js.map +1 -1
- package/dist/core.js +5 -10
- package/dist/index.js +3 -2
- package/dist/react/atoms.d.ts +83 -223
- package/dist/react/client.d.ts +123 -117
- package/dist/sdk/credential-status.d.ts +3 -3
- package/dist/sdk/extract.d.ts +19 -19
- package/dist/sdk/index.d.ts +2 -2
- package/dist/sdk/invoke.d.ts +7 -7
- package/dist/sdk/parse.d.ts +2 -3
- package/dist/sdk/plugin.d.ts +181 -275
- package/dist/sdk/preview.d.ts +12 -12
- package/dist/sdk/source-contracts.d.ts +55 -0
- package/dist/sdk/store.d.ts +6 -269
- package/dist/sdk/types.d.ts +16 -65
- package/dist/testing/index.d.ts +149 -11
- package/dist/testing.js +419 -33
- package/dist/testing.js.map +1 -1
- package/dist/testing.test.d.ts +1 -0
- package/package.json +3 -4
- package/dist/EditOpenApiSource-I4NIGIIJ.js.map +0 -1
- package/dist/OpenApiSourceSummary-CM46DB4L.js.map +0 -1
- package/dist/chunk-E7PZ2QGD.js.map +0 -1
- package/dist/chunk-GFQUEZUW.js.map +0 -1
- package/dist/chunk-OZ67JNID.js.map +0 -1
- package/dist/chunk-TGDT6QCH.js.map +0 -1
- /package/dist/{AddOpenApiSource-FLMNI742.js.map → AddOpenApiSource-KSOMPQ2R.js.map} +0 -0
|
@@ -187,13 +187,12 @@ var preferredResponseContent = (content) => {
|
|
|
187
187
|
|
|
188
188
|
// src/sdk/types.ts
|
|
189
189
|
import { Schema as Schema3 } from "effect";
|
|
190
|
+
import { ScopedSecretCredentialInput, SecretBackedValue } from "@executor-js/sdk/shared";
|
|
190
191
|
import {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
SecretId
|
|
196
|
-
} from "@executor-js/sdk/core";
|
|
192
|
+
OAuth2Flow as HttpOAuth2Flow,
|
|
193
|
+
OAuth2SourceConfig as SharedOAuth2SourceConfig
|
|
194
|
+
} from "@executor-js/sdk/http-source";
|
|
195
|
+
var OAuth2SourceConfig = SharedOAuth2SourceConfig;
|
|
197
196
|
var OperationId = Schema3.String.pipe(Schema3.brand("OperationId"));
|
|
198
197
|
var HttpMethod = Schema3.Literals([
|
|
199
198
|
"get",
|
|
@@ -287,50 +286,6 @@ var OpenApiCredentialInput = Schema3.Union([
|
|
|
287
286
|
HeaderValue,
|
|
288
287
|
ConfiguredHeaderValue
|
|
289
288
|
]);
|
|
290
|
-
var OpenApiSourceBindingValue = Schema3.Union([
|
|
291
|
-
Schema3.Struct({
|
|
292
|
-
kind: Schema3.Literal("secret"),
|
|
293
|
-
secretId: SecretId,
|
|
294
|
-
secretScopeId: Schema3.optional(ScopeId)
|
|
295
|
-
}),
|
|
296
|
-
Schema3.Struct({
|
|
297
|
-
kind: Schema3.Literal("connection"),
|
|
298
|
-
connectionId: ConnectionId
|
|
299
|
-
}),
|
|
300
|
-
Schema3.Struct({
|
|
301
|
-
kind: Schema3.Literal("text"),
|
|
302
|
-
text: Schema3.String
|
|
303
|
-
})
|
|
304
|
-
]);
|
|
305
|
-
var OpenApiSourceBindingInput = Schema3.Struct({
|
|
306
|
-
sourceId: Schema3.String,
|
|
307
|
-
sourceScope: ScopeId,
|
|
308
|
-
scope: ScopeId,
|
|
309
|
-
slot: Schema3.String,
|
|
310
|
-
value: OpenApiSourceBindingValue
|
|
311
|
-
});
|
|
312
|
-
var OpenApiSourceBindingRef = Schema3.Struct({
|
|
313
|
-
sourceId: Schema3.String,
|
|
314
|
-
sourceScopeId: ScopeId,
|
|
315
|
-
scopeId: ScopeId,
|
|
316
|
-
slot: Schema3.String,
|
|
317
|
-
value: OpenApiSourceBindingValue,
|
|
318
|
-
createdAt: Schema3.Date,
|
|
319
|
-
updatedAt: Schema3.Date
|
|
320
|
-
});
|
|
321
|
-
var OAuth2Flow = Schema3.Literals(["authorizationCode", "clientCredentials"]);
|
|
322
|
-
var OAuth2SourceConfig = Schema3.Struct({
|
|
323
|
-
kind: Schema3.Literal("oauth2"),
|
|
324
|
-
securitySchemeName: Schema3.String,
|
|
325
|
-
flow: OAuth2Flow,
|
|
326
|
-
tokenUrl: Schema3.String,
|
|
327
|
-
authorizationUrl: Schema3.NullOr(Schema3.String),
|
|
328
|
-
issuerUrl: Schema3.optional(Schema3.NullOr(Schema3.String)),
|
|
329
|
-
clientIdSlot: Schema3.String,
|
|
330
|
-
clientSecretSlot: Schema3.NullOr(Schema3.String),
|
|
331
|
-
connectionSlot: Schema3.String,
|
|
332
|
-
scopes: Schema3.Array(Schema3.String)
|
|
333
|
-
}).annotate({ identifier: "OpenApiOAuth2SourceConfig" });
|
|
334
289
|
var InvocationResult = Schema3.Struct({
|
|
335
290
|
status: Schema3.Number,
|
|
336
291
|
headers: Schema3.Record(Schema3.String, Schema3.String),
|
|
@@ -530,7 +485,7 @@ var extract = Effect2.fn("OpenApi.extract")(function* (doc) {
|
|
|
530
485
|
});
|
|
531
486
|
|
|
532
487
|
// src/sdk/preview.ts
|
|
533
|
-
import { Effect as Effect3, Option as Option3 } from "effect";
|
|
488
|
+
import { Effect as Effect3, Option as Option3, Predicate } from "effect";
|
|
534
489
|
import { Schema as Schema4 } from "effect";
|
|
535
490
|
var OAuth2Scopes = Schema4.Record(Schema4.String, Schema4.String);
|
|
536
491
|
var SecuritySchemeType = Schema4.Literals(["http", "apiKey", "oauth2", "openIdConnect"]);
|
|
@@ -702,7 +657,7 @@ var extractSecuritySchemes = (rawSchemes, resolver) => Object.entries(rawSchemes
|
|
|
702
657
|
var buildHeaderPresets = (schemes, strategies) => {
|
|
703
658
|
const schemeMap = new Map(schemes.map((s) => [s.name, s]));
|
|
704
659
|
return strategies.flatMap((strategy) => {
|
|
705
|
-
const resolved = strategy.schemes.map((name) => schemeMap.get(name)).filter(
|
|
660
|
+
const resolved = strategy.schemes.map((name) => schemeMap.get(name)).filter(Predicate.isNotUndefined);
|
|
706
661
|
if (resolved.length === 0) return [];
|
|
707
662
|
const headers = {};
|
|
708
663
|
const secretHeaders = [];
|
|
@@ -825,90 +780,14 @@ var previewSpec = Effect3.fn("OpenApi.previewSpec")(function* (input) {
|
|
|
825
780
|
});
|
|
826
781
|
});
|
|
827
782
|
|
|
828
|
-
// src/sdk/
|
|
829
|
-
import {
|
|
830
|
-
import { defineSchema } from "@executor-js/sdk/core";
|
|
831
|
-
var openapiSchema = defineSchema({
|
|
832
|
-
openapi_source: {
|
|
833
|
-
fields: {
|
|
834
|
-
id: { type: "string", required: true },
|
|
835
|
-
scope_id: { type: "string", required: true, index: true },
|
|
836
|
-
name: { type: "string", required: true },
|
|
837
|
-
spec: { type: "string", required: true },
|
|
838
|
-
// Origin URL the spec was fetched from. Set when `addSpec` was
|
|
839
|
-
// invoked with an http(s) URL; null when the caller passed raw
|
|
840
|
-
// spec text. Drives `canRefresh` on the core source row and
|
|
841
|
-
// is the address re-fetched on `refreshSource`.
|
|
842
|
-
source_url: { type: "string", required: false },
|
|
843
|
-
base_url: { type: "string", required: false },
|
|
844
|
-
// OAuth2 stays JSON because it is one typed source-owned config object
|
|
845
|
-
// carrying slot names, not concrete secret/connection ids.
|
|
846
|
-
oauth2: { type: "json", required: false }
|
|
847
|
-
}
|
|
848
|
-
},
|
|
849
|
-
openapi_operation: {
|
|
850
|
-
fields: {
|
|
851
|
-
id: { type: "string", required: true },
|
|
852
|
-
scope_id: { type: "string", required: true, index: true },
|
|
853
|
-
source_id: { type: "string", required: true, index: true },
|
|
854
|
-
binding: { type: "json", required: true }
|
|
855
|
-
}
|
|
856
|
-
},
|
|
857
|
-
openapi_source_header: {
|
|
858
|
-
fields: {
|
|
859
|
-
id: { type: "string", required: true },
|
|
860
|
-
scope_id: { type: "string", required: true, index: true },
|
|
861
|
-
source_id: { type: "string", required: true, index: true },
|
|
862
|
-
name: { type: "string", required: true },
|
|
863
|
-
kind: { type: ["text", "binding"], required: true },
|
|
864
|
-
text_value: { type: "string", required: false },
|
|
865
|
-
slot_key: { type: "string", required: false },
|
|
866
|
-
prefix: { type: "string", required: false }
|
|
867
|
-
}
|
|
868
|
-
},
|
|
869
|
-
openapi_source_query_param: {
|
|
870
|
-
fields: {
|
|
871
|
-
id: { type: "string", required: true },
|
|
872
|
-
scope_id: { type: "string", required: true, index: true },
|
|
873
|
-
source_id: { type: "string", required: true, index: true },
|
|
874
|
-
name: { type: "string", required: true },
|
|
875
|
-
kind: { type: ["text", "binding"], required: true },
|
|
876
|
-
text_value: { type: "string", required: false },
|
|
877
|
-
slot_key: { type: "string", required: false },
|
|
878
|
-
prefix: { type: "string", required: false }
|
|
879
|
-
}
|
|
880
|
-
},
|
|
881
|
-
openapi_source_spec_fetch_header: {
|
|
882
|
-
fields: {
|
|
883
|
-
id: { type: "string", required: true },
|
|
884
|
-
scope_id: { type: "string", required: true, index: true },
|
|
885
|
-
source_id: { type: "string", required: true, index: true },
|
|
886
|
-
name: { type: "string", required: true },
|
|
887
|
-
kind: { type: ["text", "binding"], required: true },
|
|
888
|
-
text_value: { type: "string", required: false },
|
|
889
|
-
slot_key: { type: "string", required: false },
|
|
890
|
-
prefix: { type: "string", required: false }
|
|
891
|
-
}
|
|
892
|
-
},
|
|
893
|
-
openapi_source_spec_fetch_query_param: {
|
|
894
|
-
fields: {
|
|
895
|
-
id: { type: "string", required: true },
|
|
896
|
-
scope_id: { type: "string", required: true, index: true },
|
|
897
|
-
source_id: { type: "string", required: true, index: true },
|
|
898
|
-
name: { type: "string", required: true },
|
|
899
|
-
kind: { type: ["text", "binding"], required: true },
|
|
900
|
-
text_value: { type: "string", required: false },
|
|
901
|
-
slot_key: { type: "string", required: false },
|
|
902
|
-
prefix: { type: "string", required: false }
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
});
|
|
783
|
+
// src/sdk/source-contracts.ts
|
|
784
|
+
import { Schema as Schema5 } from "effect";
|
|
906
785
|
var StoredSourceSchema = Schema5.Struct({
|
|
907
786
|
namespace: Schema5.String,
|
|
908
787
|
scope: Schema5.String,
|
|
909
788
|
name: Schema5.String,
|
|
910
789
|
config: Schema5.Struct({
|
|
911
|
-
spec: Schema5.String,
|
|
790
|
+
spec: Schema5.optional(Schema5.String),
|
|
912
791
|
sourceUrl: Schema5.optional(Schema5.String),
|
|
913
792
|
baseUrl: Schema5.optional(Schema5.String),
|
|
914
793
|
namespace: Schema5.optional(Schema5.String),
|
|
@@ -925,326 +804,14 @@ var StoredSourceSchema = Schema5.Struct({
|
|
|
925
804
|
oauth2: Schema5.optional(OAuth2SourceConfig)
|
|
926
805
|
})
|
|
927
806
|
}).annotate({ identifier: "OpenApiStoredSource" });
|
|
928
|
-
var encodeBinding = Schema5.encodeSync(OperationBinding);
|
|
929
|
-
var decodeBinding = Schema5.decodeUnknownSync(OperationBinding);
|
|
930
|
-
var decodeBindingJson = Schema5.decodeUnknownSync(Schema5.fromJsonString(OperationBinding));
|
|
931
|
-
var decodeOAuth2SourceConfigOption = Schema5.decodeUnknownOption(OAuth2SourceConfig);
|
|
932
|
-
var decodeOAuth2SourceConfigJsonOption = Schema5.decodeUnknownOption(
|
|
933
|
-
Schema5.fromJsonString(OAuth2SourceConfig)
|
|
934
|
-
);
|
|
935
|
-
var encodeOAuth2SourceConfig = Schema5.encodeSync(OAuth2SourceConfig);
|
|
936
|
-
var NullableString = Schema5.NullOr(Schema5.String);
|
|
937
|
-
var OptionalNullableString = Schema5.optional(NullableString);
|
|
938
|
-
var ChildStorageRow = Schema5.Struct({
|
|
939
|
-
name: Schema5.String,
|
|
940
|
-
kind: Schema5.Literals(["text", "binding"]),
|
|
941
|
-
text_value: OptionalNullableString,
|
|
942
|
-
slot_key: OptionalNullableString,
|
|
943
|
-
prefix: OptionalNullableString
|
|
944
|
-
});
|
|
945
|
-
var decodeChildStorageRowOption = Schema5.decodeUnknownOption(ChildStorageRow);
|
|
946
|
-
var SourceStorageRow = Schema5.Struct({
|
|
947
|
-
id: Schema5.String,
|
|
948
|
-
scope_id: Schema5.String,
|
|
949
|
-
name: Schema5.String,
|
|
950
|
-
spec: Schema5.String,
|
|
951
|
-
source_url: OptionalNullableString,
|
|
952
|
-
base_url: OptionalNullableString,
|
|
953
|
-
oauth2: Schema5.optional(Schema5.Unknown)
|
|
954
|
-
});
|
|
955
|
-
var decodeSourceStorageRow = Schema5.decodeUnknownSync(SourceStorageRow);
|
|
956
|
-
var OperationStorageRow = Schema5.Struct({
|
|
957
|
-
id: Schema5.String,
|
|
958
|
-
source_id: Schema5.String,
|
|
959
|
-
binding: Schema5.Unknown
|
|
960
|
-
});
|
|
961
|
-
var decodeOperationStorageRow = Schema5.decodeUnknownSync(OperationStorageRow);
|
|
962
|
-
var valueMapToChildRows = (sourceId, scope, values) => {
|
|
963
|
-
if (!values) return [];
|
|
964
|
-
return Object.entries(values).map(([name, value]) => {
|
|
965
|
-
const id = JSON.stringify([sourceId, name]);
|
|
966
|
-
if (typeof value === "string") {
|
|
967
|
-
return {
|
|
968
|
-
id,
|
|
969
|
-
scope_id: scope,
|
|
970
|
-
source_id: sourceId,
|
|
971
|
-
name,
|
|
972
|
-
kind: "text",
|
|
973
|
-
text_value: value
|
|
974
|
-
};
|
|
975
|
-
}
|
|
976
|
-
return {
|
|
977
|
-
id,
|
|
978
|
-
scope_id: scope,
|
|
979
|
-
source_id: sourceId,
|
|
980
|
-
name,
|
|
981
|
-
kind: "binding",
|
|
982
|
-
slot_key: value.slot,
|
|
983
|
-
prefix: value.prefix
|
|
984
|
-
};
|
|
985
|
-
});
|
|
986
|
-
};
|
|
987
|
-
var childRowsToValueMap = (rows) => {
|
|
988
|
-
const out = {};
|
|
989
|
-
for (const row of rows) {
|
|
990
|
-
const decoded = decodeChildStorageRowOption(row);
|
|
991
|
-
if (Option4.isSome(decoded)) {
|
|
992
|
-
const child = decoded.value;
|
|
993
|
-
if (child.kind === "binding" && child.slot_key != null) {
|
|
994
|
-
out[child.name] = child.prefix != null ? ConfiguredHeaderBinding.make({
|
|
995
|
-
kind: "binding",
|
|
996
|
-
slot: child.slot_key,
|
|
997
|
-
prefix: child.prefix
|
|
998
|
-
}) : ConfiguredHeaderBinding.make({
|
|
999
|
-
kind: "binding",
|
|
1000
|
-
slot: child.slot_key
|
|
1001
|
-
});
|
|
1002
|
-
} else if (child.kind === "text" && child.text_value != null) {
|
|
1003
|
-
out[child.name] = child.text_value;
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
return out;
|
|
1008
|
-
};
|
|
1009
|
-
var toJsonRecord = (value) => value;
|
|
1010
807
|
var slugifySlotPart = (value) => value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "default";
|
|
1011
808
|
var headerBindingSlot = (headerName) => `header:${slugifySlotPart(headerName)}`;
|
|
1012
809
|
var queryParamBindingSlot = (name) => `query_param:${slugifySlotPart(name)}`;
|
|
810
|
+
var specFetchHeaderBindingSlot = (headerName) => `spec_fetch_header:${slugifySlotPart(headerName)}`;
|
|
811
|
+
var specFetchQueryParamBindingSlot = (name) => `spec_fetch_query_param:${slugifySlotPart(name)}`;
|
|
1013
812
|
var oauth2ClientIdSlot = (securitySchemeName) => `oauth2:${slugifySlotPart(securitySchemeName)}:client-id`;
|
|
1014
813
|
var oauth2ClientSecretSlot = (securitySchemeName) => `oauth2:${slugifySlotPart(securitySchemeName)}:client-secret`;
|
|
1015
814
|
var oauth2ConnectionSlot = (securitySchemeName) => `oauth2:${slugifySlotPart(securitySchemeName)}:connection`;
|
|
1016
|
-
var normalizeStoredOAuth2 = (value) => {
|
|
1017
|
-
if (value == null) return void 0;
|
|
1018
|
-
const sourceConfig = typeof value === "string" ? decodeOAuth2SourceConfigJsonOption(value) : decodeOAuth2SourceConfigOption(value);
|
|
1019
|
-
if (Option4.isSome(sourceConfig)) {
|
|
1020
|
-
return sourceConfig.value;
|
|
1021
|
-
}
|
|
1022
|
-
return void 0;
|
|
1023
|
-
};
|
|
1024
|
-
var makeDefaultOpenapiStore = ({ adapter }) => {
|
|
1025
|
-
const loadChildValueMap = (model, sourceId, scope) => adapter.findMany({
|
|
1026
|
-
model,
|
|
1027
|
-
where: [
|
|
1028
|
-
{ field: "source_id", value: sourceId },
|
|
1029
|
-
{ field: "scope_id", value: scope }
|
|
1030
|
-
]
|
|
1031
|
-
}).pipe(Effect4.map(childRowsToValueMap));
|
|
1032
|
-
const rowToSource = (row) => Effect4.gen(function* () {
|
|
1033
|
-
const sourceRow = decodeSourceStorageRow(row);
|
|
1034
|
-
const sourceId = sourceRow.id;
|
|
1035
|
-
const scope = sourceRow.scope_id;
|
|
1036
|
-
const oauth2 = normalizeStoredOAuth2(sourceRow.oauth2);
|
|
1037
|
-
const headers = yield* loadChildValueMap("openapi_source_header", sourceId, scope);
|
|
1038
|
-
const queryParams = yield* loadChildValueMap("openapi_source_query_param", sourceId, scope);
|
|
1039
|
-
const specFetchHeaders = yield* loadChildValueMap(
|
|
1040
|
-
"openapi_source_spec_fetch_header",
|
|
1041
|
-
sourceId,
|
|
1042
|
-
scope
|
|
1043
|
-
);
|
|
1044
|
-
const specFetchQueryParams = yield* loadChildValueMap(
|
|
1045
|
-
"openapi_source_spec_fetch_query_param",
|
|
1046
|
-
sourceId,
|
|
1047
|
-
scope
|
|
1048
|
-
);
|
|
1049
|
-
const specFetchCredentials = Object.keys(specFetchHeaders).length === 0 && Object.keys(specFetchQueryParams).length === 0 ? void 0 : {
|
|
1050
|
-
...Object.keys(specFetchHeaders).length > 0 ? { headers: specFetchHeaders } : {},
|
|
1051
|
-
...Object.keys(specFetchQueryParams).length > 0 ? { queryParams: specFetchQueryParams } : {}
|
|
1052
|
-
};
|
|
1053
|
-
return {
|
|
1054
|
-
namespace: sourceId,
|
|
1055
|
-
scope,
|
|
1056
|
-
name: sourceRow.name,
|
|
1057
|
-
config: {
|
|
1058
|
-
spec: sourceRow.spec,
|
|
1059
|
-
sourceUrl: sourceRow.source_url ?? void 0,
|
|
1060
|
-
baseUrl: sourceRow.base_url ?? void 0,
|
|
1061
|
-
headers,
|
|
1062
|
-
queryParams,
|
|
1063
|
-
specFetchCredentials,
|
|
1064
|
-
oauth2
|
|
1065
|
-
}
|
|
1066
|
-
};
|
|
1067
|
-
});
|
|
1068
|
-
const rowToOperation = (row) => {
|
|
1069
|
-
const operationRow = decodeOperationStorageRow(row);
|
|
1070
|
-
return {
|
|
1071
|
-
toolId: operationRow.id,
|
|
1072
|
-
sourceId: operationRow.source_id,
|
|
1073
|
-
binding: decodeBinding(
|
|
1074
|
-
typeof operationRow.binding === "string" ? decodeBindingJson(operationRow.binding) : operationRow.binding
|
|
1075
|
-
)
|
|
1076
|
-
};
|
|
1077
|
-
};
|
|
1078
|
-
const replaceChildRows = (model, sourceId, scope, values) => Effect4.gen(function* () {
|
|
1079
|
-
yield* adapter.deleteMany({
|
|
1080
|
-
model,
|
|
1081
|
-
where: [
|
|
1082
|
-
{ field: "source_id", value: sourceId },
|
|
1083
|
-
{ field: "scope_id", value: scope }
|
|
1084
|
-
]
|
|
1085
|
-
});
|
|
1086
|
-
const rows = valueMapToChildRows(sourceId, scope, values);
|
|
1087
|
-
if (rows.length === 0) return;
|
|
1088
|
-
yield* adapter.createMany({
|
|
1089
|
-
model,
|
|
1090
|
-
data: rows,
|
|
1091
|
-
forceAllowId: true
|
|
1092
|
-
});
|
|
1093
|
-
});
|
|
1094
|
-
const deleteSource = (namespace, scope) => Effect4.gen(function* () {
|
|
1095
|
-
yield* adapter.deleteMany({
|
|
1096
|
-
model: "openapi_operation",
|
|
1097
|
-
where: [
|
|
1098
|
-
{ field: "source_id", value: namespace },
|
|
1099
|
-
{ field: "scope_id", value: scope }
|
|
1100
|
-
]
|
|
1101
|
-
});
|
|
1102
|
-
for (const model of [
|
|
1103
|
-
"openapi_source_header",
|
|
1104
|
-
"openapi_source_query_param",
|
|
1105
|
-
"openapi_source_spec_fetch_header",
|
|
1106
|
-
"openapi_source_spec_fetch_query_param"
|
|
1107
|
-
]) {
|
|
1108
|
-
yield* adapter.deleteMany({
|
|
1109
|
-
model,
|
|
1110
|
-
where: [
|
|
1111
|
-
{ field: "source_id", value: namespace },
|
|
1112
|
-
{ field: "scope_id", value: scope }
|
|
1113
|
-
]
|
|
1114
|
-
});
|
|
1115
|
-
}
|
|
1116
|
-
yield* adapter.delete({
|
|
1117
|
-
model: "openapi_source",
|
|
1118
|
-
where: [
|
|
1119
|
-
{ field: "id", value: namespace },
|
|
1120
|
-
{ field: "scope_id", value: scope }
|
|
1121
|
-
]
|
|
1122
|
-
});
|
|
1123
|
-
});
|
|
1124
|
-
return {
|
|
1125
|
-
upsertSource: (input, operations) => Effect4.gen(function* () {
|
|
1126
|
-
yield* deleteSource(input.namespace, input.scope);
|
|
1127
|
-
yield* adapter.create({
|
|
1128
|
-
model: "openapi_source",
|
|
1129
|
-
data: {
|
|
1130
|
-
id: input.namespace,
|
|
1131
|
-
scope_id: input.scope,
|
|
1132
|
-
name: input.name,
|
|
1133
|
-
spec: input.config.spec,
|
|
1134
|
-
source_url: input.config.sourceUrl ?? void 0,
|
|
1135
|
-
base_url: input.config.baseUrl ?? void 0,
|
|
1136
|
-
oauth2: input.config.oauth2 ? toJsonRecord(encodeOAuth2SourceConfig(input.config.oauth2)) : void 0
|
|
1137
|
-
},
|
|
1138
|
-
forceAllowId: true
|
|
1139
|
-
});
|
|
1140
|
-
yield* replaceChildRows(
|
|
1141
|
-
"openapi_source_header",
|
|
1142
|
-
input.namespace,
|
|
1143
|
-
input.scope,
|
|
1144
|
-
input.config.headers
|
|
1145
|
-
);
|
|
1146
|
-
yield* replaceChildRows(
|
|
1147
|
-
"openapi_source_query_param",
|
|
1148
|
-
input.namespace,
|
|
1149
|
-
input.scope,
|
|
1150
|
-
input.config.queryParams
|
|
1151
|
-
);
|
|
1152
|
-
yield* replaceChildRows(
|
|
1153
|
-
"openapi_source_spec_fetch_header",
|
|
1154
|
-
input.namespace,
|
|
1155
|
-
input.scope,
|
|
1156
|
-
input.config.specFetchCredentials?.headers
|
|
1157
|
-
);
|
|
1158
|
-
yield* replaceChildRows(
|
|
1159
|
-
"openapi_source_spec_fetch_query_param",
|
|
1160
|
-
input.namespace,
|
|
1161
|
-
input.scope,
|
|
1162
|
-
input.config.specFetchCredentials?.queryParams
|
|
1163
|
-
);
|
|
1164
|
-
if (operations.length > 0) {
|
|
1165
|
-
yield* adapter.createMany({
|
|
1166
|
-
model: "openapi_operation",
|
|
1167
|
-
data: operations.map((op) => ({
|
|
1168
|
-
id: op.toolId,
|
|
1169
|
-
scope_id: input.scope,
|
|
1170
|
-
source_id: op.sourceId,
|
|
1171
|
-
binding: toJsonRecord(encodeBinding(op.binding))
|
|
1172
|
-
})),
|
|
1173
|
-
forceAllowId: true
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
}),
|
|
1177
|
-
updateSourceMeta: (namespace, scope, patch) => Effect4.gen(function* () {
|
|
1178
|
-
const existingRow = yield* adapter.findOne({
|
|
1179
|
-
model: "openapi_source",
|
|
1180
|
-
where: [
|
|
1181
|
-
{ field: "id", value: namespace },
|
|
1182
|
-
{ field: "scope_id", value: scope }
|
|
1183
|
-
]
|
|
1184
|
-
});
|
|
1185
|
-
if (!existingRow) return;
|
|
1186
|
-
const existing = yield* rowToSource(existingRow);
|
|
1187
|
-
const nextName = patch.name?.trim() || existing.name;
|
|
1188
|
-
const nextBaseUrl = patch.baseUrl !== void 0 ? patch.baseUrl : existing.config.baseUrl;
|
|
1189
|
-
const nextOAuth2 = patch.oauth2 !== void 0 ? patch.oauth2 : existing.config.oauth2;
|
|
1190
|
-
yield* adapter.update({
|
|
1191
|
-
model: "openapi_source",
|
|
1192
|
-
where: [
|
|
1193
|
-
{ field: "id", value: namespace },
|
|
1194
|
-
{ field: "scope_id", value: scope }
|
|
1195
|
-
],
|
|
1196
|
-
update: {
|
|
1197
|
-
name: nextName,
|
|
1198
|
-
base_url: nextBaseUrl ?? void 0,
|
|
1199
|
-
oauth2: nextOAuth2 ? toJsonRecord(encodeOAuth2SourceConfig(nextOAuth2)) : void 0
|
|
1200
|
-
}
|
|
1201
|
-
});
|
|
1202
|
-
if (patch.headers !== void 0) {
|
|
1203
|
-
yield* replaceChildRows("openapi_source_header", namespace, scope, patch.headers);
|
|
1204
|
-
}
|
|
1205
|
-
if (patch.queryParams !== void 0) {
|
|
1206
|
-
yield* replaceChildRows(
|
|
1207
|
-
"openapi_source_query_param",
|
|
1208
|
-
namespace,
|
|
1209
|
-
scope,
|
|
1210
|
-
patch.queryParams
|
|
1211
|
-
);
|
|
1212
|
-
}
|
|
1213
|
-
}),
|
|
1214
|
-
getSource: (namespace, scope) => Effect4.gen(function* () {
|
|
1215
|
-
const row = yield* adapter.findOne({
|
|
1216
|
-
model: "openapi_source",
|
|
1217
|
-
where: [
|
|
1218
|
-
{ field: "id", value: namespace },
|
|
1219
|
-
{ field: "scope_id", value: scope }
|
|
1220
|
-
]
|
|
1221
|
-
});
|
|
1222
|
-
if (!row) return null;
|
|
1223
|
-
return yield* rowToSource(row);
|
|
1224
|
-
}),
|
|
1225
|
-
listSources: () => Effect4.gen(function* () {
|
|
1226
|
-
const rows = yield* adapter.findMany({ model: "openapi_source" });
|
|
1227
|
-
return yield* Effect4.forEach(rows, rowToSource, {
|
|
1228
|
-
concurrency: "unbounded"
|
|
1229
|
-
});
|
|
1230
|
-
}),
|
|
1231
|
-
getOperationByToolId: (toolId, scope) => adapter.findOne({
|
|
1232
|
-
model: "openapi_operation",
|
|
1233
|
-
where: [
|
|
1234
|
-
{ field: "id", value: toolId },
|
|
1235
|
-
{ field: "scope_id", value: scope }
|
|
1236
|
-
]
|
|
1237
|
-
}).pipe(Effect4.map((row) => row ? rowToOperation(row) : null)),
|
|
1238
|
-
listOperationsBySource: (sourceId, scope) => adapter.findMany({
|
|
1239
|
-
model: "openapi_operation",
|
|
1240
|
-
where: [
|
|
1241
|
-
{ field: "source_id", value: sourceId },
|
|
1242
|
-
{ field: "scope_id", value: scope }
|
|
1243
|
-
]
|
|
1244
|
-
}).pipe(Effect4.map((rows) => rows.map(rowToOperation))),
|
|
1245
|
-
removeSource: (namespace, scope) => deleteSource(namespace, scope)
|
|
1246
|
-
};
|
|
1247
|
-
};
|
|
1248
815
|
|
|
1249
816
|
export {
|
|
1250
817
|
OpenApiParseError,
|
|
@@ -1259,6 +826,7 @@ export {
|
|
|
1259
826
|
expandServerUrlOptions,
|
|
1260
827
|
resolveBaseUrl,
|
|
1261
828
|
preferredContent,
|
|
829
|
+
OAuth2SourceConfig,
|
|
1262
830
|
OperationId,
|
|
1263
831
|
HttpMethod,
|
|
1264
832
|
ParameterLocation,
|
|
@@ -1273,12 +841,6 @@ export {
|
|
|
1273
841
|
OperationBinding,
|
|
1274
842
|
HeaderValue,
|
|
1275
843
|
ConfiguredHeaderBinding,
|
|
1276
|
-
ConfiguredHeaderValue,
|
|
1277
|
-
OpenApiCredentialInput,
|
|
1278
|
-
OpenApiSourceBindingValue,
|
|
1279
|
-
OpenApiSourceBindingInput,
|
|
1280
|
-
OpenApiSourceBindingRef,
|
|
1281
|
-
OAuth2SourceConfig,
|
|
1282
844
|
InvocationResult,
|
|
1283
845
|
extract,
|
|
1284
846
|
OAuth2AuthorizationCodeFlow,
|
|
@@ -1291,13 +853,13 @@ export {
|
|
|
1291
853
|
PreviewOperation,
|
|
1292
854
|
SpecPreview,
|
|
1293
855
|
previewSpec,
|
|
1294
|
-
openapiSchema,
|
|
1295
856
|
StoredSourceSchema,
|
|
1296
857
|
headerBindingSlot,
|
|
1297
858
|
queryParamBindingSlot,
|
|
859
|
+
specFetchHeaderBindingSlot,
|
|
860
|
+
specFetchQueryParamBindingSlot,
|
|
1298
861
|
oauth2ClientIdSlot,
|
|
1299
862
|
oauth2ClientSecretSlot,
|
|
1300
|
-
oauth2ConnectionSlot
|
|
1301
|
-
makeDefaultOpenapiStore
|
|
863
|
+
oauth2ConnectionSlot
|
|
1302
864
|
};
|
|
1303
|
-
//# sourceMappingURL=chunk-
|
|
865
|
+
//# sourceMappingURL=chunk-EOXXE5DG.js.map
|