@credal/sdk 0.0.14 → 0.0.16
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/Client.d.ts +3 -0
- package/api/resources/copilots/client/Client.d.ts +13 -10
- package/api/resources/copilots/client/Client.js +52 -40
- package/api/resources/copilots/client/requests/CreateCopilotRequest.d.ts +1 -1
- package/api/resources/copilots/client/requests/ProvideMessageFeedbackRequest.d.ts +1 -1
- package/api/resources/copilots/types/DataFilter.d.ts +1 -1
- package/api/resources/copilots/types/FinalChunk.d.ts +1 -1
- package/api/resources/copilots/types/StreamingChunk.d.ts +15 -1
- package/api/resources/documentCatalog/client/Client.d.ts +7 -4
- package/api/resources/documentCatalog/client/Client.js +13 -13
- package/api/resources/documentCollections/client/Client.d.ts +14 -11
- package/api/resources/documentCollections/client/Client.js +39 -29
- package/api/resources/documentCollections/client/requests/AddDocumentsToCollectionRequest.d.ts +2 -2
- package/api/resources/documentCollections/client/requests/CreateCollectionRequest.d.ts +1 -1
- package/api/resources/documentCollections/client/requests/RemoveDocumentsFromCollectionRequest.d.ts +2 -2
- package/api/resources/permissionsService/client/Client.d.ts +8 -5
- package/api/resources/permissionsService/client/Client.js +20 -14
- package/api/resources/permissionsService/client/requests/CheckBulkResourcesAuthorizationForUserRequest.d.ts +1 -1
- package/api/resources/permissionsService/client/requests/CheckResourceAuthorizationForUserRequest.d.ts +1 -1
- package/api/resources/search/client/Client.d.ts +5 -2
- package/api/resources/search/client/Client.js +7 -7
- package/api/resources/search/client/requests/SearchDocumentCollectionRequest.d.ts +1 -1
- package/api/resources/users/client/Client.d.ts +4 -1
- package/api/resources/users/client/Client.js +5 -3
- package/core/fetcher/Fetcher.d.ts +4 -1
- package/core/fetcher/Fetcher.js +19 -176
- package/core/fetcher/createRequestUrl.d.ts +1 -0
- package/core/fetcher/createRequestUrl.js +13 -0
- package/core/fetcher/getFetchFn.d.ts +4 -0
- package/core/fetcher/getFetchFn.js +59 -0
- package/core/fetcher/getRequestBody.d.ts +7 -0
- package/core/fetcher/getRequestBody.js +23 -0
- package/core/fetcher/getResponseBody.d.ts +1 -0
- package/core/fetcher/getResponseBody.js +55 -0
- package/core/fetcher/makeRequest.d.ts +1 -0
- package/core/fetcher/makeRequest.js +42 -0
- package/core/fetcher/requestWithRetries.d.ts +1 -0
- package/core/fetcher/requestWithRetries.js +41 -0
- package/core/fetcher/signals.d.ts +12 -0
- package/core/fetcher/signals.js +37 -0
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +22 -0
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +124 -0
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +50 -0
- package/core/runtime/runtime.d.ts +2 -1
- package/core/runtime/runtime.js +12 -1
- package/core/schemas/Schema.d.ts +8 -4
- package/core/schemas/Schema.js +1 -0
- package/core/schemas/builders/bigint/bigint.d.ts +2 -0
- package/core/schemas/builders/bigint/bigint.js +50 -0
- package/core/schemas/builders/bigint/index.d.ts +1 -0
- package/core/schemas/builders/bigint/index.js +5 -0
- package/core/schemas/builders/index.d.ts +1 -0
- package/core/schemas/builders/index.js +1 -0
- package/core/schemas/builders/lazy/lazy.d.ts +2 -2
- package/core/schemas/builders/lazy/lazy.js +8 -19
- package/core/schemas/builders/lazy/lazyObject.js +1 -10
- package/core/schemas/builders/list/list.js +31 -44
- package/core/schemas/builders/object/object.js +90 -111
- package/core/schemas/builders/object/types.d.ts +2 -2
- package/core/schemas/builders/object-like/getObjectLikeUtils.js +3 -12
- package/core/schemas/builders/record/record.js +49 -60
- package/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +2 -2
- package/core/schemas/builders/schema-utils/getSchemaUtils.js +18 -21
- package/core/schemas/builders/set/set.js +6 -15
- package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +21 -32
- package/core/schemas/builders/union/union.js +51 -62
- package/core/schemas/utils/getErrorMessageForIncorrectType.js +4 -0
- package/core/schemas/utils/maybeSkipValidation.js +3 -12
- package/core/streaming-fetcher/Stream.js +6 -6
- package/dist/Client.d.ts +3 -0
- package/dist/api/resources/copilots/client/Client.d.ts +13 -10
- package/dist/api/resources/copilots/client/Client.js +52 -40
- package/dist/api/resources/copilots/client/requests/CreateCopilotRequest.d.ts +1 -1
- package/dist/api/resources/copilots/client/requests/ProvideMessageFeedbackRequest.d.ts +1 -1
- package/dist/api/resources/copilots/types/DataFilter.d.ts +1 -1
- package/dist/api/resources/copilots/types/FinalChunk.d.ts +1 -1
- package/dist/api/resources/copilots/types/StreamingChunk.d.ts +15 -1
- package/dist/api/resources/documentCatalog/client/Client.d.ts +7 -4
- package/dist/api/resources/documentCatalog/client/Client.js +13 -13
- package/dist/api/resources/documentCollections/client/Client.d.ts +14 -11
- package/dist/api/resources/documentCollections/client/Client.js +39 -29
- package/dist/api/resources/documentCollections/client/requests/AddDocumentsToCollectionRequest.d.ts +2 -2
- package/dist/api/resources/documentCollections/client/requests/CreateCollectionRequest.d.ts +1 -1
- package/dist/api/resources/documentCollections/client/requests/RemoveDocumentsFromCollectionRequest.d.ts +2 -2
- package/dist/api/resources/permissionsService/client/Client.d.ts +8 -5
- package/dist/api/resources/permissionsService/client/Client.js +20 -14
- package/dist/api/resources/permissionsService/client/requests/CheckBulkResourcesAuthorizationForUserRequest.d.ts +1 -1
- package/dist/api/resources/permissionsService/client/requests/CheckResourceAuthorizationForUserRequest.d.ts +1 -1
- package/dist/api/resources/search/client/Client.d.ts +5 -2
- package/dist/api/resources/search/client/Client.js +7 -7
- package/dist/api/resources/search/client/requests/SearchDocumentCollectionRequest.d.ts +1 -1
- package/dist/api/resources/users/client/Client.d.ts +4 -1
- package/dist/api/resources/users/client/Client.js +5 -3
- package/dist/core/fetcher/Fetcher.d.ts +4 -1
- package/dist/core/fetcher/Fetcher.js +19 -176
- package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/core/fetcher/createRequestUrl.js +13 -0
- package/dist/core/fetcher/getFetchFn.d.ts +4 -0
- package/dist/core/fetcher/getFetchFn.js +59 -0
- package/dist/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/core/fetcher/getRequestBody.js +23 -0
- package/dist/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getResponseBody.js +55 -0
- package/dist/core/fetcher/makeRequest.d.ts +1 -0
- package/dist/core/fetcher/makeRequest.js +42 -0
- package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/core/fetcher/requestWithRetries.js +41 -0
- package/dist/core/fetcher/signals.d.ts +12 -0
- package/dist/core/fetcher/signals.js +37 -0
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.d.ts +30 -0
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +247 -0
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +22 -0
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +124 -0
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +31 -0
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +229 -0
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +18 -0
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +50 -0
- package/dist/core/runtime/runtime.d.ts +2 -1
- package/dist/core/runtime/runtime.js +12 -1
- package/dist/core/schemas/Schema.d.ts +8 -4
- package/dist/core/schemas/Schema.js +1 -0
- package/dist/core/schemas/builders/bigint/bigint.d.ts +2 -0
- package/dist/core/schemas/builders/bigint/bigint.js +50 -0
- package/dist/core/schemas/builders/bigint/index.d.ts +1 -0
- package/dist/core/schemas/builders/bigint/index.js +5 -0
- package/dist/core/schemas/builders/index.d.ts +1 -0
- package/dist/core/schemas/builders/index.js +1 -0
- package/dist/core/schemas/builders/lazy/lazy.d.ts +2 -2
- package/dist/core/schemas/builders/lazy/lazy.js +8 -19
- package/dist/core/schemas/builders/lazy/lazyObject.js +1 -10
- package/dist/core/schemas/builders/list/list.js +31 -44
- package/dist/core/schemas/builders/object/object.js +90 -111
- package/dist/core/schemas/builders/object/types.d.ts +2 -2
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +3 -12
- package/dist/core/schemas/builders/record/record.js +49 -60
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +2 -2
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +18 -21
- package/dist/core/schemas/builders/set/set.js +6 -15
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +21 -32
- package/dist/core/schemas/builders/union/union.js +51 -62
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +4 -0
- package/dist/core/schemas/utils/maybeSkipValidation.js +3 -12
- package/dist/core/streaming-fetcher/Stream.js +6 -6
- package/dist/serialization/resources/copilots/types/DataFilter.d.ts +1 -1
- package/dist/serialization/resources/copilots/types/DataFilter.js +1 -1
- package/dist/serialization/resources/copilots/types/FinalChunk.d.ts +1 -1
- package/dist/serialization/resources/copilots/types/FinalChunk.js +1 -1
- package/dist/serialization/resources/copilots/types/StreamingChunk.d.ts +13 -1
- package/dist/serialization/resources/copilots/types/StreamingChunk.js +11 -1
- package/dist/version.d.ts +1 -0
- package/dist/version.js +4 -0
- package/package.json +12 -2
- package/reference.md +155 -534
- package/serialization/resources/copilots/types/DataFilter.d.ts +1 -1
- package/serialization/resources/copilots/types/DataFilter.js +1 -1
- package/serialization/resources/copilots/types/FinalChunk.d.ts +1 -1
- package/serialization/resources/copilots/types/FinalChunk.js +1 -1
- package/serialization/resources/copilots/types/StreamingChunk.d.ts +13 -1
- package/serialization/resources/copilots/types/StreamingChunk.js +11 -1
- package/version.d.ts +1 -0
- package/version.js +4 -0
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.undiscriminatedUnion = void 0;
|
|
13
4
|
const Schema_1 = require("../../Schema");
|
|
@@ -15,37 +6,35 @@ const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
|
15
6
|
const schema_utils_1 = require("../schema-utils");
|
|
16
7
|
function undiscriminatedUnion(schemas) {
|
|
17
8
|
const baseSchema = {
|
|
18
|
-
parse: (raw, opts) =>
|
|
9
|
+
parse: (raw, opts) => {
|
|
19
10
|
return validateAndTransformUndiscriminatedUnion((schema, opts) => schema.parse(raw, opts), schemas, opts);
|
|
20
|
-
}
|
|
21
|
-
json: (parsed, opts) =>
|
|
11
|
+
},
|
|
12
|
+
json: (parsed, opts) => {
|
|
22
13
|
return validateAndTransformUndiscriminatedUnion((schema, opts) => schema.json(parsed, opts), schemas, opts);
|
|
23
|
-
}
|
|
14
|
+
},
|
|
24
15
|
getType: () => Schema_1.SchemaType.UNDISCRIMINATED_UNION,
|
|
25
16
|
};
|
|
26
17
|
return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
|
|
27
18
|
}
|
|
28
19
|
exports.undiscriminatedUnion = undiscriminatedUnion;
|
|
29
20
|
function validateAndTransformUndiscriminatedUnion(transform, schemas, opts) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
}
|
|
21
|
+
const errors = [];
|
|
22
|
+
for (const [index, schema] of schemas.entries()) {
|
|
23
|
+
const transformed = transform(schema, Object.assign(Object.assign({}, opts), { skipValidation: false }));
|
|
24
|
+
if (transformed.ok) {
|
|
25
|
+
return transformed;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
for (const error of transformed.errors) {
|
|
29
|
+
errors.push({
|
|
30
|
+
path: error.path,
|
|
31
|
+
message: `[Variant ${index}] ${error.message}`,
|
|
32
|
+
});
|
|
44
33
|
}
|
|
45
34
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
ok: false,
|
|
38
|
+
errors,
|
|
39
|
+
};
|
|
51
40
|
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
3
|
var t = {};
|
|
13
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -36,7 +27,7 @@ function union(discriminant, union) {
|
|
|
36
27
|
: discriminant.parsedDiscriminant;
|
|
37
28
|
const discriminantValueSchema = (0, enum_1.enum_)((0, keys_1.keys)(union));
|
|
38
29
|
const baseSchema = {
|
|
39
|
-
parse: (raw, opts) =>
|
|
30
|
+
parse: (raw, opts) => {
|
|
40
31
|
return transformAndValidateUnion({
|
|
41
32
|
value: raw,
|
|
42
33
|
discriminant: rawDiscriminant,
|
|
@@ -53,8 +44,8 @@ function union(discriminant, union) {
|
|
|
53
44
|
transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => additionalPropertiesSchema.parse(additionalProperties, opts),
|
|
54
45
|
breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
|
|
55
46
|
});
|
|
56
|
-
}
|
|
57
|
-
json: (parsed, opts) =>
|
|
47
|
+
},
|
|
48
|
+
json: (parsed, opts) => {
|
|
58
49
|
return transformAndValidateUnion({
|
|
59
50
|
value: parsed,
|
|
60
51
|
discriminant: parsedDiscriminant,
|
|
@@ -71,71 +62,69 @@ function union(discriminant, union) {
|
|
|
71
62
|
transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => additionalPropertiesSchema.json(additionalProperties, opts),
|
|
72
63
|
breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
|
|
73
64
|
});
|
|
74
|
-
}
|
|
65
|
+
},
|
|
75
66
|
getType: () => Schema_1.SchemaType.UNION,
|
|
76
67
|
};
|
|
77
68
|
return Object.assign(Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema));
|
|
78
69
|
}
|
|
79
70
|
exports.union = union;
|
|
80
71
|
function transformAndValidateUnion({ value, discriminant, transformedDiscriminant, transformDiscriminantValue, getAdditionalPropertiesSchema, allowUnrecognizedUnionMembers = false, transformAdditionalProperties, breadcrumbsPrefix = [], }) {
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
if (!(0, isPlainObject_1.isPlainObject)(value)) {
|
|
73
|
+
return {
|
|
74
|
+
ok: false,
|
|
75
|
+
errors: [
|
|
76
|
+
{
|
|
77
|
+
path: breadcrumbsPrefix,
|
|
78
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "object"),
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const _a = value, _b = discriminant, discriminantValue = _a[_b], additionalProperties = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
84
|
+
if (discriminantValue == null) {
|
|
85
|
+
return {
|
|
86
|
+
ok: false,
|
|
87
|
+
errors: [
|
|
88
|
+
{
|
|
89
|
+
path: breadcrumbsPrefix,
|
|
90
|
+
message: `Missing discriminant ("${discriminant}")`,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const transformedDiscriminantValue = transformDiscriminantValue(discriminantValue);
|
|
96
|
+
if (!transformedDiscriminantValue.ok) {
|
|
97
|
+
return {
|
|
98
|
+
ok: false,
|
|
99
|
+
errors: transformedDiscriminantValue.errors,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const additionalPropertiesSchema = getAdditionalPropertiesSchema(transformedDiscriminantValue.value);
|
|
103
|
+
if (additionalPropertiesSchema == null) {
|
|
104
|
+
if (allowUnrecognizedUnionMembers) {
|
|
83
105
|
return {
|
|
84
|
-
ok:
|
|
85
|
-
|
|
86
|
-
{
|
|
87
|
-
path: breadcrumbsPrefix,
|
|
88
|
-
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "object"),
|
|
89
|
-
},
|
|
90
|
-
],
|
|
106
|
+
ok: true,
|
|
107
|
+
value: Object.assign({ [transformedDiscriminant]: transformedDiscriminantValue.value }, additionalProperties),
|
|
91
108
|
};
|
|
92
109
|
}
|
|
93
|
-
|
|
94
|
-
if (discriminantValue == null) {
|
|
110
|
+
else {
|
|
95
111
|
return {
|
|
96
112
|
ok: false,
|
|
97
113
|
errors: [
|
|
98
114
|
{
|
|
99
|
-
path: breadcrumbsPrefix,
|
|
100
|
-
message:
|
|
115
|
+
path: [...breadcrumbsPrefix, discriminant],
|
|
116
|
+
message: "Unexpected discriminant value",
|
|
101
117
|
},
|
|
102
118
|
],
|
|
103
119
|
};
|
|
104
120
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (allowUnrecognizedUnionMembers) {
|
|
115
|
-
return {
|
|
116
|
-
ok: true,
|
|
117
|
-
value: Object.assign({ [transformedDiscriminant]: transformedDiscriminantValue.value }, additionalProperties),
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
return {
|
|
122
|
-
ok: false,
|
|
123
|
-
errors: [
|
|
124
|
-
{
|
|
125
|
-
path: [...breadcrumbsPrefix, discriminant],
|
|
126
|
-
message: "Unexpected discriminant value",
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
const transformedAdditionalProperties = yield transformAdditionalProperties(additionalProperties, additionalPropertiesSchema);
|
|
133
|
-
if (!transformedAdditionalProperties.ok) {
|
|
134
|
-
return transformedAdditionalProperties;
|
|
135
|
-
}
|
|
136
|
-
return {
|
|
137
|
-
ok: true,
|
|
138
|
-
value: Object.assign({ [transformedDiscriminant]: discriminantValue }, transformedAdditionalProperties.value),
|
|
139
|
-
};
|
|
140
|
-
});
|
|
121
|
+
}
|
|
122
|
+
const transformedAdditionalProperties = transformAdditionalProperties(additionalProperties, additionalPropertiesSchema);
|
|
123
|
+
if (!transformedAdditionalProperties.ok) {
|
|
124
|
+
return transformedAdditionalProperties;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
ok: true,
|
|
128
|
+
value: Object.assign({ [transformedDiscriminant]: discriminantValue }, transformedAdditionalProperties.value),
|
|
129
|
+
};
|
|
141
130
|
}
|
|
@@ -12,9 +12,13 @@ function getTypeAsString(value) {
|
|
|
12
12
|
if (value === null) {
|
|
13
13
|
return "null";
|
|
14
14
|
}
|
|
15
|
+
if (value instanceof BigInt) {
|
|
16
|
+
return "BigInt";
|
|
17
|
+
}
|
|
15
18
|
switch (typeof value) {
|
|
16
19
|
case "string":
|
|
17
20
|
return `"${value}"`;
|
|
21
|
+
case "bigint":
|
|
18
22
|
case "number":
|
|
19
23
|
case "boolean":
|
|
20
24
|
case "undefined":
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.maybeSkipValidation = void 0;
|
|
13
4
|
function maybeSkipValidation(schema) {
|
|
@@ -15,8 +6,8 @@ function maybeSkipValidation(schema) {
|
|
|
15
6
|
}
|
|
16
7
|
exports.maybeSkipValidation = maybeSkipValidation;
|
|
17
8
|
function transformAndMaybeSkipValidation(transform) {
|
|
18
|
-
return (value, opts) =>
|
|
19
|
-
const transformed =
|
|
9
|
+
return (value, opts) => {
|
|
10
|
+
const transformed = transform(value, opts);
|
|
20
11
|
const { skipValidation = false } = opts !== null && opts !== void 0 ? opts : {};
|
|
21
12
|
if (!transformed.ok && skipValidation) {
|
|
22
13
|
// eslint-disable-next-line no-console
|
|
@@ -33,5 +24,5 @@ function transformAndMaybeSkipValidation(transform) {
|
|
|
33
24
|
else {
|
|
34
25
|
return transformed;
|
|
35
26
|
}
|
|
36
|
-
}
|
|
27
|
+
};
|
|
37
28
|
}
|
|
@@ -116,15 +116,15 @@ class Stream {
|
|
|
116
116
|
}
|
|
117
117
|
decodeChunk(chunk) {
|
|
118
118
|
let decoded = "";
|
|
119
|
-
//
|
|
120
|
-
if (
|
|
121
|
-
decoded += Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
122
|
-
}
|
|
123
|
-
// TextDecoder is present in Browser environment
|
|
124
|
-
else if (runtime_1.RUNTIME.type === "browser" && typeof TextDecoder !== "undefined") {
|
|
119
|
+
// If TextDecoder is present, use it
|
|
120
|
+
if (typeof TextDecoder !== "undefined") {
|
|
125
121
|
const decoder = new TextDecoder("utf8");
|
|
126
122
|
decoded += decoder.decode(chunk);
|
|
127
123
|
}
|
|
124
|
+
// Buffer is present in Node.js environment
|
|
125
|
+
else if (runtime_1.RUNTIME.type === "node" && typeof chunk != "undefined") {
|
|
126
|
+
decoded += Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
127
|
+
}
|
|
128
128
|
return decoded;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -9,7 +9,7 @@ export declare const DataFilter: core.serialization.ObjectSchema<serializers.Dat
|
|
|
9
9
|
export declare namespace DataFilter {
|
|
10
10
|
interface Raw {
|
|
11
11
|
semanticSearchTerms: string[];
|
|
12
|
-
|
|
12
|
+
webSearchTerm: string[];
|
|
13
13
|
filteredDataSourcesPerCollection: CollectionFilteredData.Raw[];
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -31,6 +31,6 @@ const core = __importStar(require("../../../../core"));
|
|
|
31
31
|
const CollectionFilteredData_1 = require("./CollectionFilteredData");
|
|
32
32
|
exports.DataFilter = core.serialization.object({
|
|
33
33
|
semanticSearchTerms: core.serialization.list(core.serialization.string()),
|
|
34
|
-
|
|
34
|
+
webSearchTerm: core.serialization.list(core.serialization.string()),
|
|
35
35
|
filteredDataSourcesPerCollection: core.serialization.list(CollectionFilteredData_1.CollectionFilteredData),
|
|
36
36
|
});
|
|
@@ -8,6 +8,6 @@ import { ReferencedSource } from "./ReferencedSource";
|
|
|
8
8
|
export declare const FinalChunk: core.serialization.ObjectSchema<serializers.FinalChunk.Raw, Credal.FinalChunk>;
|
|
9
9
|
export declare namespace FinalChunk {
|
|
10
10
|
interface Raw {
|
|
11
|
-
|
|
11
|
+
sources: ReferencedSource.Raw[];
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -30,5 +30,5 @@ exports.FinalChunk = void 0;
|
|
|
30
30
|
const core = __importStar(require("../../../../core"));
|
|
31
31
|
const ReferencedSource_1 = require("./ReferencedSource");
|
|
32
32
|
exports.FinalChunk = core.serialization.object({
|
|
33
|
-
|
|
33
|
+
sources: core.serialization.list(ReferencedSource_1.ReferencedSource),
|
|
34
34
|
});
|
|
@@ -10,5 +10,17 @@ import { FinalChunk } from "./FinalChunk";
|
|
|
10
10
|
import { BlockedChunk } from "./BlockedChunk";
|
|
11
11
|
export declare const StreamingChunk: core.serialization.Schema<serializers.StreamingChunk.Raw, Credal.StreamingChunk>;
|
|
12
12
|
export declare namespace StreamingChunk {
|
|
13
|
-
type Raw =
|
|
13
|
+
type Raw = StreamingChunk.Initial | StreamingChunk.DataChunk | StreamingChunk.FinalChunk | StreamingChunk.Blocked;
|
|
14
|
+
interface Initial extends InitialChunk.Raw {
|
|
15
|
+
event: "initial";
|
|
16
|
+
}
|
|
17
|
+
interface DataChunk extends DataChunk.Raw {
|
|
18
|
+
event: "data_chunk";
|
|
19
|
+
}
|
|
20
|
+
interface FinalChunk extends FinalChunk.Raw {
|
|
21
|
+
event: "final_chunk";
|
|
22
|
+
}
|
|
23
|
+
interface Blocked extends BlockedChunk.Raw {
|
|
24
|
+
event: "blocked";
|
|
25
|
+
}
|
|
14
26
|
}
|
|
@@ -32,4 +32,14 @@ const InitialChunk_1 = require("./InitialChunk");
|
|
|
32
32
|
const DataChunk_1 = require("./DataChunk");
|
|
33
33
|
const FinalChunk_1 = require("./FinalChunk");
|
|
34
34
|
const BlockedChunk_1 = require("./BlockedChunk");
|
|
35
|
-
exports.StreamingChunk = core.serialization
|
|
35
|
+
exports.StreamingChunk = core.serialization
|
|
36
|
+
.union("event", {
|
|
37
|
+
initial: InitialChunk_1.InitialChunk,
|
|
38
|
+
data_chunk: DataChunk_1.DataChunk,
|
|
39
|
+
final_chunk: FinalChunk_1.FinalChunk,
|
|
40
|
+
blocked: BlockedChunk_1.BlockedChunk,
|
|
41
|
+
})
|
|
42
|
+
.transform({
|
|
43
|
+
transform: (value) => value,
|
|
44
|
+
untransform: (value) => value,
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION = "0.0.16";
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@credal/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": "https://github.com/credal-ai/credal-typescript-sdk",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -13,16 +13,21 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"url-join": "4.0.1",
|
|
16
|
-
"form-data": "4.0.0",
|
|
16
|
+
"form-data": "^4.0.0",
|
|
17
17
|
"formdata-node": "^6.0.3",
|
|
18
18
|
"node-fetch": "2.7.0",
|
|
19
19
|
"qs": "6.11.2",
|
|
20
|
+
"readable-stream": "^4.5.2",
|
|
20
21
|
"js-base64": "3.7.2"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@types/url-join": "4.0.1",
|
|
24
25
|
"@types/qs": "6.9.8",
|
|
25
26
|
"@types/node-fetch": "2.6.9",
|
|
27
|
+
"@types/readable-stream": "^4.0.15",
|
|
28
|
+
"fetch-mock-jest": "^1.5.1",
|
|
29
|
+
"webpack": "^5.94.0",
|
|
30
|
+
"ts-loader": "^9.3.1",
|
|
26
31
|
"jest": "29.7.0",
|
|
27
32
|
"@types/jest": "29.5.5",
|
|
28
33
|
"ts-jest": "29.1.1",
|
|
@@ -30,5 +35,10 @@
|
|
|
30
35
|
"@types/node": "17.0.33",
|
|
31
36
|
"prettier": "2.7.1",
|
|
32
37
|
"typescript": "4.6.4"
|
|
38
|
+
},
|
|
39
|
+
"browser": {
|
|
40
|
+
"fs": false,
|
|
41
|
+
"os": false,
|
|
42
|
+
"path": false
|
|
33
43
|
}
|
|
34
44
|
}
|