@squidcloud/client 1.0.387 → 1.0.389
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/cjs/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/internal-common/src/metric-name.d.ts +9 -0
- package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +10 -5
- package/dist/internal-common/src/public-types/backend.public-types.d.ts +4 -4
- package/dist/internal-common/src/public-types/context.public-types.d.ts +20 -0
- package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +30 -0
- package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +148 -0
- package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +60 -0
- package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +166 -0
- package/dist/internal-common/src/types/ai-agent.types.d.ts +145 -0
- package/dist/internal-common/src/types/ai-assistant.types.d.ts +1 -0
- package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +59 -0
- package/dist/internal-common/src/types/backend-function.types.d.ts +1 -0
- package/dist/internal-common/src/types/communication.types.d.ts +1 -0
- package/dist/internal-common/src/types/document.types.d.ts +1 -0
- package/dist/internal-common/src/types/file.types.d.ts +6 -0
- package/dist/internal-common/src/types/headers.types.d.ts +17 -0
- package/dist/internal-common/src/types/mutation.types.d.ts +1 -0
- package/dist/internal-common/src/types/notification.types.d.ts +5 -0
- package/dist/internal-common/src/types/observability.types.d.ts +72 -0
- package/dist/internal-common/src/types/query.types.d.ts +13 -0
- package/dist/internal-common/src/types/secret.types.d.ts +2 -0
- package/dist/internal-common/src/types/socket.types.d.ts +1 -0
- package/dist/internal-common/src/types/stage.d.ts +9 -0
- package/dist/internal-common/src/types/time-units.d.ts +1 -0
- package/dist/internal-common/src/types/url-shortener.types.d.ts +41 -0
- package/dist/internal-common/src/utils/array.d.ts +7 -0
- package/dist/internal-common/src/utils/e2e-test-utils.d.ts +2 -0
- package/dist/internal-common/src/utils/global.utils.d.ts +1 -0
- package/dist/internal-common/src/utils/http.d.ts +5 -0
- package/dist/internal-common/src/utils/lock.manager.d.ts +14 -0
- package/dist/internal-common/src/utils/metric-utils.d.ts +4 -0
- package/dist/internal-common/src/utils/metrics.types.d.ts +7 -0
- package/dist/internal-common/src/utils/object.d.ts +57 -0
- package/dist/internal-common/src/utils/serialization.d.ts +11 -0
- package/dist/internal-common/src/utils/squid.constants.d.ts +1 -0
- package/dist/internal-common/src/utils/trace-id-generator.d.ts +1 -0
- package/dist/internal-common/src/utils/validation.d.ts +19 -0
- package/dist/internal-common/src/websocket.impl.d.ts +26 -0
- package/dist/typescript-client/src/index.d.ts +1 -0
- package/dist/typescript-client/src/notification-client.d.ts +20 -0
- package/dist/typescript-client/src/squid.d.ts +26 -20
- package/dist/typescript-client/src/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { MmEntity, MmEntityMatch, MmFindMatchesOptions, MmListEntitiesOptions, MmMatchMaker } from '../public-types/ai-matchmaking.public-types';
|
|
2
|
+
export interface MmCreateMatchMakerRequest {
|
|
3
|
+
matchMaker: MmMatchMaker;
|
|
4
|
+
}
|
|
5
|
+
export interface MmDeleteMatchMakerRequest {
|
|
6
|
+
matchMakerId: string;
|
|
7
|
+
}
|
|
8
|
+
export interface MmGetMatchMakerRequest {
|
|
9
|
+
matchMakerId: string;
|
|
10
|
+
}
|
|
11
|
+
export interface MmGetMatchMakerResponse {
|
|
12
|
+
matchMaker: MmMatchMaker | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface MmDeleteEntityRequest {
|
|
15
|
+
matchMakerId: string;
|
|
16
|
+
entityId: string;
|
|
17
|
+
}
|
|
18
|
+
export interface MmInsertEntityRequest {
|
|
19
|
+
matchMakerId: string;
|
|
20
|
+
entity: MmEntity;
|
|
21
|
+
}
|
|
22
|
+
export interface MmInsertEntitiesRequest {
|
|
23
|
+
matchMakerId: string;
|
|
24
|
+
entities: Array<MmEntity>;
|
|
25
|
+
}
|
|
26
|
+
export interface MmFindMatchesRequest {
|
|
27
|
+
matchMakerId: string;
|
|
28
|
+
entityId: string;
|
|
29
|
+
options: MmFindMatchesOptions;
|
|
30
|
+
}
|
|
31
|
+
export interface MmFindMatchesResponse {
|
|
32
|
+
matches: Array<MmEntityMatch>;
|
|
33
|
+
}
|
|
34
|
+
export interface MmFindMatchesForEntityRequest {
|
|
35
|
+
matchMakerId: string;
|
|
36
|
+
entity: Omit<MmEntity, 'metadata' | 'id'>;
|
|
37
|
+
options: MmFindMatchesOptions;
|
|
38
|
+
}
|
|
39
|
+
export interface MmFindMatchesForEntityResponse {
|
|
40
|
+
matches: Array<MmEntityMatch>;
|
|
41
|
+
}
|
|
42
|
+
export interface MmListMatchMakersResponse {
|
|
43
|
+
matchMakers: Array<MmMatchMaker>;
|
|
44
|
+
}
|
|
45
|
+
export interface MmListEntitiesRequest {
|
|
46
|
+
matchMakerId: string;
|
|
47
|
+
categoryId: string;
|
|
48
|
+
options: MmListEntitiesOptions;
|
|
49
|
+
}
|
|
50
|
+
export interface MmListEntitiesResponse {
|
|
51
|
+
entities: Array<MmEntity>;
|
|
52
|
+
}
|
|
53
|
+
export interface MmGetEntityRequest {
|
|
54
|
+
matchMakerId: string;
|
|
55
|
+
entityId: string;
|
|
56
|
+
}
|
|
57
|
+
export interface MmGetEntityResponse {
|
|
58
|
+
entity: MmEntity | undefined;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ChatId = string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** HTTP header names used by Squid for request metadata. */
|
|
2
|
+
export declare const SquidHeaders: {
|
|
3
|
+
/** Correlates logs and spans across distributed calls. */
|
|
4
|
+
readonly TRACE_ID: "x-squid-traceid";
|
|
5
|
+
/** Shared secret header for internal authentication. */
|
|
6
|
+
readonly SECRET: "x-squid-secret";
|
|
7
|
+
/** API key provided by the calling application. */
|
|
8
|
+
readonly APP_API_KEY: "x-app-api-key";
|
|
9
|
+
/** Unique identifier of the client application. */
|
|
10
|
+
readonly APP_ID: "x-squid-appid";
|
|
11
|
+
/** Unique identifier of the end user or service client. */
|
|
12
|
+
readonly CLIENT_ID: "x-squid-clientid";
|
|
13
|
+
/** Version string of the Squid client library. */
|
|
14
|
+
readonly CLIENT_VERSION: "x-squid-client-version";
|
|
15
|
+
/** Originating IP address of the request. */
|
|
16
|
+
readonly SOURCE_IP: "x-squid-source-ip";
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { MetricName } from '../metric-name';
|
|
2
|
+
import { AppId } from '../public-types/communication.public-types';
|
|
3
|
+
export interface ObservableNameMetrics {
|
|
4
|
+
count: MetricName;
|
|
5
|
+
time: MetricName;
|
|
6
|
+
}
|
|
7
|
+
export declare const ObservableNames: {
|
|
8
|
+
readonly functionExecution: ObservableNameMetrics;
|
|
9
|
+
readonly codeInitialization: ObservableNameMetrics;
|
|
10
|
+
readonly getAiChatbotProfiles: ObservableNameMetrics;
|
|
11
|
+
readonly aiImageGeneration: ObservableNameMetrics;
|
|
12
|
+
readonly aiRemoveBackground: ObservableNameMetrics;
|
|
13
|
+
readonly aiAudioTranscribe: ObservableNameMetrics;
|
|
14
|
+
readonly aiAudioCreateSpeech: ObservableNameMetrics;
|
|
15
|
+
readonly discoverGraphQLConnectionSchema: ObservableNameMetrics;
|
|
16
|
+
readonly discoverOpenApiSchema: ObservableNameMetrics;
|
|
17
|
+
readonly discoverOpenApiSchemaFromFile: ObservableNameMetrics;
|
|
18
|
+
readonly graphqlQuery: ObservableNameMetrics;
|
|
19
|
+
readonly testGraphQLConnection: ObservableNameMetrics;
|
|
20
|
+
readonly testAgentProtocolConnection: ObservableNameMetrics;
|
|
21
|
+
readonly graphql: ObservableNameMetrics;
|
|
22
|
+
};
|
|
23
|
+
export type ObservableName = keyof typeof ObservableNames;
|
|
24
|
+
export interface MetricEvent {
|
|
25
|
+
appId: AppId;
|
|
26
|
+
name: MetricName;
|
|
27
|
+
tags: Record<string, string>;
|
|
28
|
+
timestamp: Date;
|
|
29
|
+
value: number;
|
|
30
|
+
isExposedToUser: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface LogEvent {
|
|
33
|
+
message: string;
|
|
34
|
+
level: string;
|
|
35
|
+
tags: Record<string, string>;
|
|
36
|
+
timestamp: Date;
|
|
37
|
+
isExposedToUser: boolean;
|
|
38
|
+
host: string;
|
|
39
|
+
source?: string;
|
|
40
|
+
service?: string;
|
|
41
|
+
}
|
|
42
|
+
export declare const AUDIT_LOG_EVENT_NAMES: readonly ["ai_agent"];
|
|
43
|
+
export type AuditLogEventName = (typeof AUDIT_LOG_EVENT_NAMES)[number];
|
|
44
|
+
export interface AuditLogEvent {
|
|
45
|
+
appId: AppId;
|
|
46
|
+
name: AuditLogEventName;
|
|
47
|
+
timestamp: Date;
|
|
48
|
+
context: {
|
|
49
|
+
clientId?: string;
|
|
50
|
+
userId: string;
|
|
51
|
+
};
|
|
52
|
+
tags: Record<string, string>;
|
|
53
|
+
}
|
|
54
|
+
/** Tag for metric events. Value: '0' - not an error, '1' - is an error. */
|
|
55
|
+
export declare const O11Y_TAG_IS_ERROR = "isError";
|
|
56
|
+
/** Tag for log events. Metrics have an explicit appId field. */
|
|
57
|
+
export declare const O11Y_TAG_APP_ID = "appId";
|
|
58
|
+
/** Tag for metric and log events. */
|
|
59
|
+
export declare const O11Y_TAG_INTEGRATION_ID = "integrationId";
|
|
60
|
+
/** Tag for AI events. */
|
|
61
|
+
export declare const O11Y_TAG_AI_MODEL = "aiModel";
|
|
62
|
+
export declare const O11Y_TAG_AI_PROFILE = "aiProfile";
|
|
63
|
+
export declare const O11Y_TAG_API_KEY_SOURCE = "apiKeySource";
|
|
64
|
+
/** Tag for metric and log events. Value: '0' - not a tenant originated, '1' - is a tenant originated. */
|
|
65
|
+
export declare const O11Y_TAG_IS_TENANT_ORIGINATED = "isTenantOriginated";
|
|
66
|
+
/** Contains a full (with a service name) function name for backend functions. */
|
|
67
|
+
export declare const O11Y_TAG_FUNCTION_NAME = "functionName";
|
|
68
|
+
/** Contains a type of the function name for backend functions (See ExecuteFunctionAnnotationType.). */
|
|
69
|
+
export declare const O11Y_TAG_FUNCTION_TYPE = "functionType";
|
|
70
|
+
export declare function getBooleanMetricTagValue(value: boolean): string;
|
|
71
|
+
export declare const COUNT_METRIC_SUFFIXES: string[];
|
|
72
|
+
export declare const GAUGE_METRIC_SUFFIXES: string[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Condition, SimpleCondition } from '../public-types/query.public-types';
|
|
2
|
+
/**
|
|
3
|
+
* Generates the regex pattern, handling special characters as follows:
|
|
4
|
+
* - `_` is replaced with a `.`
|
|
5
|
+
* - `%` is replaced with `[\s\S]*`.
|
|
6
|
+
* - The above characters can be escaped with \, eg. `\_` is replaced with `_` and `\%` with `%`.
|
|
7
|
+
* - All special characters in regex (-, /, \, ^, $, *, +, ?, ., (, ), |, [, ], {, }) get escaped with \
|
|
8
|
+
*
|
|
9
|
+
* Exported for testing purposes.
|
|
10
|
+
* */
|
|
11
|
+
export declare function replaceSpecialCharacters(input: string): string;
|
|
12
|
+
/** Returns true if the condition is a 'SimpleCondition' or false otherwise. */
|
|
13
|
+
export declare function isSimpleCondition(condition: Condition): condition is SimpleCondition;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SOCKET_RECONNECT_TIMEOUT: number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage of the Squid deployment:
|
|
3
|
+
* - 'local' - Squid is run locally.
|
|
4
|
+
* - 'prod' - Production environment (https://console.getsquid.ai).
|
|
5
|
+
* - 'sandbox' - One of the sandbox environments (https://console.sandbox.squid.cloud).
|
|
6
|
+
* - 'staging' - One of the staging environments (https://console.staging.squid.cloud).
|
|
7
|
+
*/
|
|
8
|
+
export declare const STAGES: readonly ["local", "prod", "sandbox", "staging"];
|
|
9
|
+
export type Stage = (typeof STAGES)[number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AppId } from '../public-types/communication.public-types';
|
|
2
|
+
/**
|
|
3
|
+
* Request to create a shortened URL.
|
|
4
|
+
*/
|
|
5
|
+
export interface ShortUrlRequest {
|
|
6
|
+
/** The URL to shorten. It must be a valid URL and should include the protocol (start with http:// or https://). */
|
|
7
|
+
url: string;
|
|
8
|
+
/** The application ID that will own this shortened URL. */
|
|
9
|
+
appId: AppId;
|
|
10
|
+
/** Seconds to live for the shortened URL. If set to 0, the URL will never expire. Defaults to 1 day. */
|
|
11
|
+
secondsToLive?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Request to create shortened URLs.
|
|
15
|
+
*/
|
|
16
|
+
export interface ShortUrlBulkRequest {
|
|
17
|
+
/** The URLs to shorten. They must be valid URLs and should include the protocol (start with http:// or https://). */
|
|
18
|
+
urls: string[];
|
|
19
|
+
/** The application ID that will own these shortened URLs. */
|
|
20
|
+
appId: AppId;
|
|
21
|
+
/** Seconds to live for all shortened URLs. If set to 0, the URLs will never expire. Defaults to 1 day. */
|
|
22
|
+
secondsToLive?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Request to delete a shortened URL.
|
|
26
|
+
*/
|
|
27
|
+
export interface ShortUrlDeleteRequest {
|
|
28
|
+
/** The ID of the shortened URL to delete. */
|
|
29
|
+
id: string;
|
|
30
|
+
/** The application ID that owns the shortened URL. */
|
|
31
|
+
appId: AppId;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Request to delete a shortened URL.
|
|
35
|
+
*/
|
|
36
|
+
export interface ShortUrlBulkDeleteRequest {
|
|
37
|
+
/** The IDs of the shortened URLs to delete. */
|
|
38
|
+
ids: string[];
|
|
39
|
+
/** The application ID that owns the shortened URLs. */
|
|
40
|
+
appId: AppId;
|
|
41
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function truncateOrPadArray(arr: number[], length: number): number[];
|
|
2
|
+
/**
|
|
3
|
+
* Computes a single “recommended” chunk size so that if you loop
|
|
4
|
+
* `for (let i = 0; i < length; i += chunkSize)`,
|
|
5
|
+
* no slice will exceed `maxChunkSize` and all chunk sizes are 'almost' equal.
|
|
6
|
+
*/
|
|
7
|
+
export declare function computeRecommendedChunkSize(length: number, maxChunkSize: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isTimestampEnabled(): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AppId } from '../public-types/communication.public-types';
|
|
2
|
+
import { Stage } from '../types/stage';
|
|
3
|
+
export declare const KOTLIN_CONTROLLERS: string[];
|
|
4
|
+
export declare function getEnvironmentPrefix(shard: string | undefined, region: string, cloudId: string, stage: Stage): string;
|
|
5
|
+
export declare function getApplicationUrl(environmentPrefix: string, appId: string, path: string, appIdPlaceholder?: AppId, environmentPrefixPlaceholder?: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type LockMutex = string;
|
|
2
|
+
/**
|
|
3
|
+
* A simple lock manager that locks a list of mutexes.
|
|
4
|
+
* When locking a list of mutexes, the lock will start only when all the mutexes are available - preventing partial lock
|
|
5
|
+
* and potential deadlocks.
|
|
6
|
+
*/
|
|
7
|
+
export declare class LockManager {
|
|
8
|
+
private readonly locks;
|
|
9
|
+
lock(...mutexes: LockMutex[]): Promise<void>;
|
|
10
|
+
release(...mutexes: LockMutex[]): void;
|
|
11
|
+
canGetLock(...mutexes: LockMutex[]): boolean;
|
|
12
|
+
lockSync(...mutexes: LockMutex[]): void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { QueryMetricsRequestCommon, QueryMetricsResultGroup } from '../public-types/metric.public-types';
|
|
2
|
+
export type QueryMetricsRequestIntervals = Required<Pick<QueryMetricsRequestCommon, 'fillValue' | 'fn' | 'groupByTags' | 'periodEndSeconds' | 'periodStartSeconds' | 'pointIntervalAlignment' | 'pointIntervalSeconds' | 'tagDomains' | 'noDataBehavior'>>;
|
|
3
|
+
/** Adds missed known tag domain groups and fills all missed points with a request.fillValue. */
|
|
4
|
+
export declare function fillMissedPoints(request: QueryMetricsRequestIntervals, resultGroups: Array<QueryMetricsResultGroup>): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type suffixes defines the type of the metric and can be used for
|
|
3
|
+
* metric value validation for incoming metrics.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SQUID_METRIC_TYPE_SUFFIXES: readonly ["_count", "_time", "_size", "_entries", "_value"];
|
|
6
|
+
/** Returns true if the given metric has a valid metric type. */
|
|
7
|
+
export declare function hasValidMetricTypeSuffix(metricName: string): boolean;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** Returns a value by the `path`. Works with array indexes, like a.b[0]. */
|
|
2
|
+
export declare function getInPath(obj: unknown, path: string): any;
|
|
3
|
+
export declare function isDateObject(value: unknown): value is Date;
|
|
4
|
+
/** Sets a value by path . Does not support array indexes. */
|
|
5
|
+
export declare function setInPath(obj: object, path: string, value: unknown, delimiter?: string): void;
|
|
6
|
+
export declare function deleteInPath(obj: object, path: string, delimiter?: string): void;
|
|
7
|
+
export declare function replaceKeyInMap<K, T>(map: Map<K, T | undefined>, a: K, b: K): void;
|
|
8
|
+
export declare function replaceKeyInRecord<K extends keyof any, T>(record: Record<K, T>, a: K, b: K): void;
|
|
9
|
+
export declare function isNil(obj: unknown): obj is null | undefined;
|
|
10
|
+
export declare function isEqual(a: unknown, b: unknown): boolean;
|
|
11
|
+
export declare function isEmpty(a: unknown): boolean;
|
|
12
|
+
export declare function omit<T extends object, K extends PropertyKey[]>(object: T | null | undefined, ...fieldsToRemove: K): Pick<T, Exclude<keyof T, K[number]>>;
|
|
13
|
+
export type CloneCustomizer = (value: unknown) => unknown | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a deep copy of the specified object, including all nested objects and specifically handling Date, Map, and
|
|
16
|
+
* Set fields.
|
|
17
|
+
*
|
|
18
|
+
* The customizer function can modify the cloning process for the object and its fields. If the customizer
|
|
19
|
+
* returns 'undefined' for any input, the function falls back to the standard cloning logic.
|
|
20
|
+
*
|
|
21
|
+
* The cloning process is recursive, ensuring deep cloning of all objects.
|
|
22
|
+
*
|
|
23
|
+
* Note: This function does not support cloning objects with circular dependencies and will throw a system stack
|
|
24
|
+
* overflow error if encountered.
|
|
25
|
+
*/
|
|
26
|
+
export declare function cloneDeep<R = unknown>(value: R, customizer?: CloneCustomizer): R;
|
|
27
|
+
/** Creates a shallow clone of the object. */
|
|
28
|
+
export declare function cloneShallow<T>(value: T): T;
|
|
29
|
+
export declare function deepMerge<T extends object, U extends object>(target: T, source: U): T & U;
|
|
30
|
+
/** Returns true if the `value` is a defined object and is not an array. */
|
|
31
|
+
export declare function isPlainObject(value: unknown): value is object;
|
|
32
|
+
/** Compares 2 values. 'null' and 'undefined' values are considered equal and are less than any other values. */
|
|
33
|
+
export declare function compareValues(v1: unknown, v2: unknown): number;
|
|
34
|
+
/** Returns a new object with all top-level object fields re-mapped using `valueMapperFn`. */
|
|
35
|
+
export declare function mapValues<ResultType extends object = Record<string, unknown>, InputType extends Record<string, unknown> = Record<string, unknown>>(obj: InputType, valueMapperFn: (value: any, key: keyof InputType, obj: InputType) => unknown): ResultType;
|
|
36
|
+
/** Groups elements of the array by key. See _.groupBy for details. */
|
|
37
|
+
export declare function groupBy<T, K extends PropertyKey>(array: T[], getKey: (item: T) => K): Record<K, T[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Picks selected fields from the object and returns a new object with the fields selected.
|
|
40
|
+
* The selected fields are assigned by reference (there is no cloning).
|
|
41
|
+
*/
|
|
42
|
+
export declare function pick<T extends object, K extends keyof T>(obj: T, keys: ReadonlyArray<K>): Pick<T, K>;
|
|
43
|
+
/** Inverts the record: swaps keys and values. */
|
|
44
|
+
export declare function invert<K extends string | number, V extends string | number>(record: Record<K, V>): Record<V, K>;
|
|
45
|
+
/**
|
|
46
|
+
* Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end.
|
|
47
|
+
* If end is less than start a zero-length range is created unless a negative step is specified.
|
|
48
|
+
*
|
|
49
|
+
* Same as lodash range but with an additional parameter: `maximumNumberOfItems`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function range(start: number, end: number, step: number, maximumNumberOfItems?: number): number[];
|
|
52
|
+
/** Returns count of top level properties in object. */
|
|
53
|
+
export declare function countObjectKeys(obj: object | undefined): number;
|
|
54
|
+
/** Returns object entries sorted by name. */
|
|
55
|
+
export declare function getSortedEntries<T>(record: Record<string, T>): Array<[string, T]>;
|
|
56
|
+
/** Removes top level fields which are empty objects. May be used for value formatting. */
|
|
57
|
+
export declare function removeEmptyTopLevelRecords<T extends object>(record: T): Partial<T>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function normalizeJsonAsString(json: unknown): string;
|
|
2
|
+
export declare function serializeObj(obj: unknown): string;
|
|
3
|
+
export declare function deserializeObj<T = any>(str: string): T;
|
|
4
|
+
export declare function encodeValueForMapping(value: unknown): string;
|
|
5
|
+
export declare function decodeValueForMapping(encodedString: string): any;
|
|
6
|
+
/**
|
|
7
|
+
* Compares 2 objects by their normalized JSON value.
|
|
8
|
+
* This function should not be used with objects with circular references.
|
|
9
|
+
* Returns true if the object are equal.
|
|
10
|
+
*/
|
|
11
|
+
export declare function compareByNormalizedJsonValue<T>(v1: T, v2: T): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SQUID_SUPPORT_EMAIL = "support@getsquid.ai";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateTraceId(prefix?: string): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HttpStatusCode } from '../public-types/http-status.public-types';
|
|
2
|
+
export declare class ValidationError extends Error {
|
|
3
|
+
readonly statusCode: HttpStatusCode;
|
|
4
|
+
readonly details?: any;
|
|
5
|
+
constructor(error: string, statusCode: HttpStatusCode, details?: Record<string, unknown>);
|
|
6
|
+
}
|
|
7
|
+
export declare function isValidId(id: unknown, maxLength?: number): boolean;
|
|
8
|
+
export declare function validateFieldSort(fieldSort: unknown): void;
|
|
9
|
+
export declare function validateQueryLimit(limit: unknown): void;
|
|
10
|
+
/**
|
|
11
|
+
* All type names returned by 'typeof' supported by JavaScript:
|
|
12
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof}.
|
|
13
|
+
* and a few other supported types.
|
|
14
|
+
*/
|
|
15
|
+
export type JavascriptTypeName = 'undefined' | 'object' | 'boolean' | 'number' | 'bigint' | 'string' | 'symbol' | 'function';
|
|
16
|
+
/** Returns true if 'typeof' of the 'value' is 'type' or 'type[]'. */
|
|
17
|
+
export declare function isRightType(value: unknown, type: JavascriptTypeName): boolean;
|
|
18
|
+
/** Returns true if 'obj' has only keys listed in the 'keys'. Object can't be an array. */
|
|
19
|
+
export declare function hasOnlyKeys(obj: object, keys: string[]): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
maxAttempts?: number;
|
|
3
|
+
protocols?: string[];
|
|
4
|
+
onmessage?: (event: any) => void;
|
|
5
|
+
onopen?: (event: any) => void;
|
|
6
|
+
onclose?: (event: any) => void;
|
|
7
|
+
onerror?: (event: any) => void;
|
|
8
|
+
onreconnect?: (event: any) => void;
|
|
9
|
+
onmaximum?: (event: any) => void;
|
|
10
|
+
timeoutMillis?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface WebSocketWrapper {
|
|
13
|
+
open: () => void;
|
|
14
|
+
reconnect: (e: any) => void;
|
|
15
|
+
json: (x: any) => void;
|
|
16
|
+
send: (x: string) => void;
|
|
17
|
+
close: (x?: number, y?: string) => void;
|
|
18
|
+
connected: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Websocket is explicitly closed by calling socket.close().
|
|
21
|
+
* Used to ignore errors after socket.closed() is called.
|
|
22
|
+
*/
|
|
23
|
+
closeCalled: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function createWebSocketWrapper(url: string, opts?: Options): WebSocketWrapper;
|
|
26
|
+
export {};
|
|
@@ -30,6 +30,7 @@ export * from './integration-client';
|
|
|
30
30
|
export * from './job-client';
|
|
31
31
|
export * from './mutation/mutation-sender';
|
|
32
32
|
export * from './native-query-manager';
|
|
33
|
+
export * from './notification-client';
|
|
33
34
|
export * from './observability-client';
|
|
34
35
|
export * from './personal-storage-client';
|
|
35
36
|
export * from './public-types';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { ClientId } from '../../internal-common/src/public-types/communication.public-types';
|
|
3
|
+
/**
|
|
4
|
+
* NotificationClient is a client for handling user-defined notifications.
|
|
5
|
+
* Using this class you can receive messages that are sent from the server to this client or
|
|
6
|
+
* publish messages to other clients. In order to publish a message you have to initialize the squid sdk with a valid
|
|
7
|
+
* api key.
|
|
8
|
+
*/
|
|
9
|
+
export declare class NotificationClient {
|
|
10
|
+
private readonly socketManager;
|
|
11
|
+
private readonly rpcManager;
|
|
12
|
+
/**
|
|
13
|
+
* Observes user-defined notifications.
|
|
14
|
+
*/
|
|
15
|
+
observeNotifications(): Observable<unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Publishes a notification to clients.
|
|
18
|
+
*/
|
|
19
|
+
publishNotification(payload: unknown, clientIds: Array<ClientId>): Promise<void>;
|
|
20
|
+
}
|
|
@@ -7,6 +7,7 @@ import { DistributedLock } from './distributed-lock.manager';
|
|
|
7
7
|
import { ExecuteFunctionOptions } from './execute-function-options';
|
|
8
8
|
import { ExtractionClient } from './extraction-client';
|
|
9
9
|
import { JobClient } from './job-client';
|
|
10
|
+
import { NotificationClient } from './notification-client';
|
|
10
11
|
import { ObservabilityClient } from './observability-client';
|
|
11
12
|
import { PersonalStorageClient } from './personal-storage-client';
|
|
12
13
|
import { ApiKey, AppId, CollectionName, DocumentData, EnvironmentId, IntegrationId, SquidDeveloperId, SquidRegion } from './public-types';
|
|
@@ -65,16 +66,16 @@ export interface SquidOptions {
|
|
|
65
66
|
* @category Authentication
|
|
66
67
|
*/
|
|
67
68
|
export interface SquidAuthProvider {
|
|
68
|
-
/**
|
|
69
|
-
* Returns a valid AccessToken or undefined if there is no active authorized session.
|
|
70
|
-
* Called by Squid every time a Squid client makes requests to the Squid backend.
|
|
71
|
-
*/
|
|
72
|
-
getToken(): Promise<string | undefined> | string | undefined;
|
|
73
69
|
/**
|
|
74
70
|
* Optional Auth integration id.
|
|
75
71
|
* Sent as a part of all Squid requests to the backend.
|
|
76
72
|
*/
|
|
77
73
|
integrationId: string;
|
|
74
|
+
/**
|
|
75
|
+
* Returns a valid AccessToken or undefined if there is no active authorized session.
|
|
76
|
+
* Called by Squid every time a Squid client makes requests to the Squid backend.
|
|
77
|
+
*/
|
|
78
|
+
getToken(): Promise<string | undefined> | string | undefined;
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
80
81
|
* The main entry point to the Squid Client SDK.
|
|
@@ -89,6 +90,7 @@ export interface SquidAuthProvider {
|
|
|
89
90
|
*/
|
|
90
91
|
export declare class Squid {
|
|
91
92
|
readonly options: SquidOptions;
|
|
93
|
+
private static readonly squidInstancesMap;
|
|
92
94
|
private readonly socketManager;
|
|
93
95
|
private readonly dataManager;
|
|
94
96
|
private readonly documentReferenceFactory;
|
|
@@ -107,7 +109,6 @@ export declare class Squid {
|
|
|
107
109
|
private readonly clientIdService;
|
|
108
110
|
private readonly _connectionDetails;
|
|
109
111
|
private readonly querySender;
|
|
110
|
-
private static readonly squidInstancesMap;
|
|
111
112
|
private readonly aiClient;
|
|
112
113
|
private readonly jobClient;
|
|
113
114
|
private readonly apiClient;
|
|
@@ -116,6 +117,7 @@ export declare class Squid {
|
|
|
116
117
|
private readonly observabilityClient;
|
|
117
118
|
private readonly queueManagerFactory;
|
|
118
119
|
private readonly schedulerClient;
|
|
120
|
+
private readonly notificationClient;
|
|
119
121
|
private readonly _appId;
|
|
120
122
|
/**
|
|
121
123
|
* Creates a new instance of Squid with the given options.
|
|
@@ -123,6 +125,18 @@ export declare class Squid {
|
|
|
123
125
|
* @param options The options for initializing the Squid instance.
|
|
124
126
|
*/
|
|
125
127
|
constructor(options: SquidOptions);
|
|
128
|
+
/**
|
|
129
|
+
* Returns the observability client for metrics.
|
|
130
|
+
*/
|
|
131
|
+
get observability(): ObservabilityClient;
|
|
132
|
+
/**
|
|
133
|
+
* Returns the scheduler client for managing scheduled jobs and tasks.
|
|
134
|
+
*/
|
|
135
|
+
get schedulers(): SchedulerClient;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the application ID of the current Squid instance.
|
|
138
|
+
*/
|
|
139
|
+
get appId(): AppId;
|
|
126
140
|
/**
|
|
127
141
|
* Returns the global Squid instance with the given options, creating a new instance if one with the same options
|
|
128
142
|
* does not exist.
|
|
@@ -199,8 +213,10 @@ export declare class Squid {
|
|
|
199
213
|
* See https://docs.getsquid.ai/docs/sdk/client-sdk/database/native-queries.
|
|
200
214
|
*
|
|
201
215
|
* @param integrationId The id of the integration that the query is associated with.
|
|
202
|
-
* @param query The raw SQL or database-specific query string to execute. Use named bind variables enclosed in ${},
|
|
203
|
-
*
|
|
216
|
+
* @param query The raw SQL or database-specific query string to execute. Use named bind variables enclosed in ${},
|
|
217
|
+
* e.g., ${firstName}.
|
|
218
|
+
* @param params (Optional) An object containing key-value pairs to bind to the query variables. Defaults to an empty
|
|
219
|
+
* object.
|
|
204
220
|
* @returns A promise that resolves with the result of the query.
|
|
205
221
|
*/
|
|
206
222
|
executeNativeRelationalQuery<T = any>(integrationId: IntegrationId, query: string, params?: Record<string, any>): Promise<Array<T>>;
|
|
@@ -263,18 +279,6 @@ export declare class Squid {
|
|
|
263
279
|
* Returns a client for working with structured data extraction tools.
|
|
264
280
|
*/
|
|
265
281
|
extraction(): ExtractionClient;
|
|
266
|
-
/**
|
|
267
|
-
* Returns the observability client for metrics.
|
|
268
|
-
*/
|
|
269
|
-
get observability(): ObservabilityClient;
|
|
270
|
-
/**
|
|
271
|
-
* Returns the scheduler client for managing scheduled jobs and tasks.
|
|
272
|
-
*/
|
|
273
|
-
get schedulers(): SchedulerClient;
|
|
274
|
-
/**
|
|
275
|
-
* Returns the application ID of the current Squid instance.
|
|
276
|
-
*/
|
|
277
|
-
get appId(): AppId;
|
|
278
282
|
/**
|
|
279
283
|
* Returns a distributed lock for the given mutex. The lock can be used to synchronize access to a shared resource.
|
|
280
284
|
* The lock will be released when the release method on the returned object is invoked or whenever the connection
|
|
@@ -306,5 +310,7 @@ export declare class Squid {
|
|
|
306
310
|
destruct(): Promise<void>;
|
|
307
311
|
/** Provides information about the connection to the Squid Server. */
|
|
308
312
|
connectionDetails(): ConnectionDetails;
|
|
313
|
+
/** Returns the notification client for handling (publishing and receiving) custom messages. */
|
|
314
|
+
getNotificationClient(): NotificationClient;
|
|
309
315
|
private _validateNotDestructed;
|
|
310
316
|
}
|