@squidcloud/client 1.0.10 → 1.0.11
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/common/src/api-call.context.d.ts +17 -0
- package/dist/common/src/backend-run.types.d.ts +60 -0
- package/dist/common/src/bundle-api.types.d.ts +21 -41
- package/dist/common/src/context.types.d.ts +0 -1
- package/dist/common/src/document.types.d.ts +8 -8
- package/dist/common/src/executable.context.d.ts +4 -0
- package/dist/common/src/graphql.context.d.ts +14 -0
- package/dist/common/src/index.d.ts +14 -7
- package/dist/common/src/metrics.types.d.ts +55 -42
- package/dist/common/src/mutation.context.d.ts +1 -4
- package/dist/common/src/mutation.types.d.ts +5 -5
- package/dist/common/src/named-query.context.d.ts +4 -0
- package/dist/common/src/query/query-context.d.ts +1 -4
- package/dist/common/src/query/simple-query-builder.d.ts +2 -2
- package/dist/common/src/query.types.d.ts +4 -4
- package/dist/common/src/regions.d.ts +4 -0
- package/dist/common/src/schema/schema.types.d.ts +10 -1
- package/dist/common/src/secret.types.d.ts +9 -1
- package/dist/common/src/socket.types.d.ts +4 -4
- package/dist/common/src/trigger.types.d.ts +4 -6
- package/dist/common/src/utils/assert.d.ts +2 -0
- package/dist/common/src/utils/object.d.ts +3 -3
- package/dist/common/src/utils/serialization.d.ts +1 -0
- package/dist/common/src/utils/transforms.d.ts +17 -0
- package/dist/common/src/utils/url.d.ts +2 -1
- package/dist/index.js +6 -6
- package/dist/package.json +1 -3
- package/dist/typescript-client/src/collection-reference.d.ts +2 -2
- package/dist/typescript-client/src/collection-reference.factory.d.ts +2 -2
- package/dist/typescript-client/src/data.manager.d.ts +33 -21
- package/dist/typescript-client/src/destruct.manager.d.ts +3 -1
- package/dist/typescript-client/src/document-identity.service.d.ts +3 -3
- package/dist/typescript-client/src/document-reference.d.ts +5 -5
- package/dist/typescript-client/src/document-reference.factory.d.ts +2 -2
- package/dist/typescript-client/src/document-store.d.ts +11 -0
- package/dist/typescript-client/src/query/query-builder.factory.d.ts +15 -15
- package/dist/typescript-client/src/query/query-subscription.manager.d.ts +11 -11
- package/dist/typescript-client/src/squid.d.ts +4 -4
- package/dist/typescript-client/src/testing/squid-env-setup.d.ts +8 -7
- package/package.json +2 -4
- package/dist/typescript-client/src/db.dao.d.ts +0 -22
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ApiEndpoint, ApiEndpointId, ApiIntegration } from './integration.types';
|
|
2
|
+
interface ApiRequest {
|
|
3
|
+
endpointId: ApiEndpointId;
|
|
4
|
+
endpoint: ApiEndpoint;
|
|
5
|
+
apiIntegration: ApiIntegration;
|
|
6
|
+
request: Record<string, any>;
|
|
7
|
+
serverUrlOverride: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare class ApiCallContext {
|
|
10
|
+
readonly endpointId: ApiEndpointId;
|
|
11
|
+
readonly endpoint: ApiEndpoint;
|
|
12
|
+
readonly apiIntegration: ApiIntegration;
|
|
13
|
+
readonly serverUrlOverride: string | undefined;
|
|
14
|
+
readonly request: Record<string, any>;
|
|
15
|
+
constructor(apiRequest: ApiRequest);
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Auth, RunContext } from './context.types';
|
|
2
|
+
import { ServiceFunctionName } from './bundle-data.types';
|
|
3
|
+
import { SecretKey, SecretValue } from './secret.types';
|
|
4
|
+
export interface RunPermissions {
|
|
5
|
+
hosts: Array<string>;
|
|
6
|
+
}
|
|
7
|
+
export interface ErrorResponse extends GeneralResponse {
|
|
8
|
+
ok: false;
|
|
9
|
+
error: string;
|
|
10
|
+
details?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface GeneralResponse {
|
|
13
|
+
ok: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface RunConfiguration {
|
|
16
|
+
codeUrl: string;
|
|
17
|
+
codeUrlId: string;
|
|
18
|
+
isSecurityRules: boolean;
|
|
19
|
+
permissions: RunPermissions;
|
|
20
|
+
}
|
|
21
|
+
export interface RunConfigurationRequest {
|
|
22
|
+
configuration: RunConfiguration;
|
|
23
|
+
context: RunContext;
|
|
24
|
+
auth: Auth | undefined;
|
|
25
|
+
functionToRun: string;
|
|
26
|
+
params: Array<unknown>;
|
|
27
|
+
secrets?: RunSecrets;
|
|
28
|
+
}
|
|
29
|
+
export type EvaluateRulesFunctionRequest = {
|
|
30
|
+
functionName: ServiceFunctionName;
|
|
31
|
+
params: Array<any>;
|
|
32
|
+
};
|
|
33
|
+
export interface LoadJsPayload {
|
|
34
|
+
codeUrl: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ExecuteFunctionPayload {
|
|
37
|
+
functionName: string;
|
|
38
|
+
params: Array<unknown>;
|
|
39
|
+
context: RunContext;
|
|
40
|
+
auth: Auth | undefined;
|
|
41
|
+
secrets?: Record<SecretKey, SecretValue>;
|
|
42
|
+
backendApiKey: string;
|
|
43
|
+
codeDir: string;
|
|
44
|
+
}
|
|
45
|
+
export type WorkerActionType = 'loadJs' | 'executeFunction' | 'ping' | 'terminate';
|
|
46
|
+
export interface ActionRequest {
|
|
47
|
+
action: WorkerActionType;
|
|
48
|
+
payload?: LoadJsPayload | ExecuteFunctionPayload;
|
|
49
|
+
traceContext?: any;
|
|
50
|
+
}
|
|
51
|
+
export type LoadJsResponse = GeneralResponse;
|
|
52
|
+
export type TerminateResponse = GeneralResponse;
|
|
53
|
+
export interface ExecuteFunctionResponse extends GeneralResponse {
|
|
54
|
+
ok: true;
|
|
55
|
+
functionResponse: unknown;
|
|
56
|
+
}
|
|
57
|
+
export interface RunSecrets {
|
|
58
|
+
custom: Record<SecretKey, SecretValue>;
|
|
59
|
+
backendApiKey: string;
|
|
60
|
+
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { ActionType } from './bundle-data.types';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Mutation, MutationType } from './mutation.types';
|
|
5
|
-
import { RunContext } from './context.types';
|
|
2
|
+
import { Auth, RunContext } from './context.types';
|
|
3
|
+
import { DocumentData, SquidDocId, SquidDocument } from './document.types';
|
|
6
4
|
import { Logger } from './logger.types';
|
|
7
|
-
import { SecretKey } from './secret.types';
|
|
8
|
-
import { QueryContext } from './query';
|
|
9
5
|
import { MutationContext } from './mutation.context';
|
|
6
|
+
import { Mutation, MutationType } from './mutation.types';
|
|
7
|
+
import { QueryContext } from './query';
|
|
8
|
+
import { SecretKey } from './secret.types';
|
|
9
|
+
import { ExecutableContext } from './executable.context';
|
|
10
|
+
import { ApiCallContext } from './api-call.context';
|
|
11
|
+
import { NamedQueryContext } from './named-query.context';
|
|
12
|
+
import { GraphqlContext } from './graphql.context';
|
|
10
13
|
export type DocHash = string;
|
|
11
14
|
export type SecurityResponse = {
|
|
12
|
-
docsToHash: Record<
|
|
15
|
+
docsToHash: Record<SquidDocId, DocHash | undefined>;
|
|
13
16
|
rulesPassed: true;
|
|
14
17
|
} | {
|
|
15
18
|
rulesPassed: false;
|
|
@@ -19,50 +22,27 @@ export interface ServiceConfig {
|
|
|
19
22
|
logger: Logger;
|
|
20
23
|
secrets: Record<SecretKey, any>;
|
|
21
24
|
backendApiKey: string;
|
|
25
|
+
codeDir: string;
|
|
26
|
+
auth: Auth | undefined;
|
|
22
27
|
}
|
|
23
|
-
export type SecureDatabaseAction<T extends ActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? (
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export
|
|
28
|
-
mutationContext: MutationContext<T>;
|
|
29
|
-
}
|
|
30
|
-
export type SecureApiAction = (request?: SecureApiRequest) => boolean | Promise<boolean>;
|
|
31
|
-
export interface SecureApiRequest {
|
|
32
|
-
endpointId: ApiEndpointId;
|
|
33
|
-
endpoint: ApiEndpoint;
|
|
34
|
-
apiIntegration: ApiIntegration;
|
|
35
|
-
request: Record<string, any>;
|
|
36
|
-
serverUrlOverride: string | undefined;
|
|
37
|
-
}
|
|
38
|
-
export type SecureExecutableAction = (request?: SecureExecutableRequest) => boolean | Promise<boolean>;
|
|
39
|
-
export interface SecureExecutableRequest {
|
|
40
|
-
params: any[];
|
|
41
|
-
}
|
|
42
|
-
export type SecureNamedQueryAction = (request?: SecureNamedQueryRequest) => boolean | Promise<boolean>;
|
|
43
|
-
export interface SecureNamedQueryRequest {
|
|
44
|
-
params: Record<string, any>;
|
|
45
|
-
}
|
|
46
|
-
export type SecureGraphQLAction = (request?: SecureGraphQLRequest) => boolean | Promise<boolean>;
|
|
47
|
-
export interface SecureGraphQLRequest {
|
|
48
|
-
isGraphiQL: boolean;
|
|
49
|
-
query?: string;
|
|
50
|
-
operationName?: string;
|
|
51
|
-
variables?: string | Record<string, any>;
|
|
52
|
-
}
|
|
28
|
+
export type SecureDatabaseAction<T extends ActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? (context?: QueryContext) => boolean | Promise<boolean> : (context?: MutationContext) => boolean | Promise<boolean>;
|
|
29
|
+
export type SecureApiAction = (context?: ApiCallContext) => boolean | Promise<boolean>;
|
|
30
|
+
export type SecureExecutableAction = (context?: ExecutableContext) => boolean | Promise<boolean>;
|
|
31
|
+
export type SecureNamedQueryAction = (context?: NamedQueryContext) => boolean | Promise<boolean>;
|
|
32
|
+
export type SecureGraphQLAction = (context?: GraphqlContext) => boolean | Promise<boolean>;
|
|
53
33
|
export type TransformDatabaseAction<T extends ActionType> = T extends 'read' ? (request?: TransformDatabaseReadRequest) => TransformDatabaseReadResponse | Promise<TransformDatabaseReadResponse> : (request?: TransformDatabaseWriteRequest) => TransformDatabaseWriteResponse | Promise<TransformDatabaseWriteResponse>;
|
|
54
34
|
export interface TransformDatabaseReadRequest {
|
|
55
|
-
documents: Array<
|
|
35
|
+
documents: Array<SquidDocument>;
|
|
56
36
|
}
|
|
57
37
|
export interface TransformDatabaseWriteRequest {
|
|
58
38
|
mutations: Array<Mutation>;
|
|
59
39
|
}
|
|
60
|
-
export type TransformDatabaseReadResponse = Array<
|
|
40
|
+
export type TransformDatabaseReadResponse = Array<SquidDocument>;
|
|
61
41
|
export type TransformDatabaseWriteResponse = Array<Mutation>;
|
|
62
42
|
export type ExecutableAction = (...args: any[]) => any;
|
|
63
43
|
export type TriggerAction = (request?: TriggerRequest) => void | Promise<void>;
|
|
64
|
-
export interface TriggerRequest<T extends
|
|
65
|
-
|
|
44
|
+
export interface TriggerRequest<T extends DocumentData = any> {
|
|
45
|
+
squidDocId: SquidDocId;
|
|
66
46
|
mutationType: MutationType;
|
|
67
47
|
docBefore?: T;
|
|
68
48
|
docAfter?: T;
|
|
@@ -8,22 +8,22 @@ export type DocId = string;
|
|
|
8
8
|
export type DocIdObj = Record<FieldName, any>;
|
|
9
9
|
export type CollectionName = string;
|
|
10
10
|
export type DocTimestamp = number;
|
|
11
|
-
export interface
|
|
11
|
+
export interface SquidDocIdObj {
|
|
12
12
|
collectionName: CollectionName;
|
|
13
13
|
docId: DocId;
|
|
14
14
|
integrationId: IntegrationId;
|
|
15
15
|
}
|
|
16
|
-
export interface BeforeAndAfterDocs<T =
|
|
16
|
+
export interface BeforeAndAfterDocs<T = SquidDocument> {
|
|
17
17
|
before: T | undefined;
|
|
18
18
|
after: T | undefined;
|
|
19
19
|
}
|
|
20
|
-
export type
|
|
21
|
-
export interface
|
|
20
|
+
export type SquidDocId = string;
|
|
21
|
+
export interface SquidDocument {
|
|
22
22
|
__docId__: DocId;
|
|
23
23
|
__ts__: DocTimestamp;
|
|
24
24
|
[fieldName: string]: FieldType | undefined;
|
|
25
25
|
}
|
|
26
|
-
export type
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
26
|
+
export type DocumentData = Record<FieldName, any | undefined>;
|
|
27
|
+
export declare function parseSquidDocId(squidDocId: SquidDocId): SquidDocIdObj;
|
|
28
|
+
export declare function getSquidDocId(squidDocIdObj: SquidDocIdObj): SquidDocId;
|
|
29
|
+
export declare function getSquidDocId(docId: DocId, collectionName: CollectionName, integrationId: IntegrationId): SquidDocId;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface GraphQlRequest {
|
|
2
|
+
isGraphiQL: boolean;
|
|
3
|
+
query?: string;
|
|
4
|
+
operationName?: string;
|
|
5
|
+
variables?: string | Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export declare class GraphqlContext {
|
|
8
|
+
readonly isGraphiQL: boolean;
|
|
9
|
+
readonly query: string | undefined;
|
|
10
|
+
readonly variables: string | Record<string, any> | undefined;
|
|
11
|
+
readonly operationName: string | undefined;
|
|
12
|
+
constructor(graphQlRequest: GraphQlRequest);
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -3,8 +3,6 @@ export * from './application.schemas';
|
|
|
3
3
|
export * from './application.types';
|
|
4
4
|
export * from './backend-function.schemas';
|
|
5
5
|
export * from './backend-function.types';
|
|
6
|
-
export * from './named-query.schemas';
|
|
7
|
-
export * from './named-query.types';
|
|
8
6
|
export * from './bundle-api.types';
|
|
9
7
|
export * from './bundle-data.types';
|
|
10
8
|
export * from './communication.types';
|
|
@@ -14,14 +12,21 @@ export * from './graphql.types';
|
|
|
14
12
|
export * from './http-status.enum';
|
|
15
13
|
export * from './integration.types';
|
|
16
14
|
export * from './logger.types';
|
|
15
|
+
export * from './metrics.schemas';
|
|
16
|
+
export * from './metrics.types';
|
|
17
|
+
export * from './mutation.context';
|
|
18
|
+
export * from './named-query.context';
|
|
19
|
+
export * from './graphql.context';
|
|
20
|
+
export * from './executable.context';
|
|
21
|
+
export * from './api-call.context';
|
|
17
22
|
export * from './mutation.schemas';
|
|
18
23
|
export * from './mutation.types';
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
21
|
-
export * from './metrics.schemas';
|
|
24
|
+
export * from './named-query.schemas';
|
|
25
|
+
export * from './named-query.types';
|
|
22
26
|
export * from './query';
|
|
23
27
|
export * from './query.schemas';
|
|
24
28
|
export * from './query.types';
|
|
29
|
+
export * from './regions';
|
|
25
30
|
export * from './schema/schema.types';
|
|
26
31
|
export * from './secret.schemas';
|
|
27
32
|
export * from './secret.types';
|
|
@@ -29,14 +34,16 @@ export * from './socket.schemas';
|
|
|
29
34
|
export * from './socket.types';
|
|
30
35
|
export * from './time-units';
|
|
31
36
|
export * from './trigger.types';
|
|
37
|
+
export * from './backend-run.types';
|
|
32
38
|
export * from './types';
|
|
33
39
|
export * from './utils/array';
|
|
34
40
|
export * from './utils/assert';
|
|
35
41
|
export * from './utils/error';
|
|
42
|
+
export * from './utils/id';
|
|
36
43
|
export * from './utils/isDefined';
|
|
37
44
|
export * from './utils/lock.manager';
|
|
38
45
|
export * from './utils/object';
|
|
39
46
|
export * from './utils/serialization';
|
|
40
|
-
export * from './utils/
|
|
47
|
+
export * from './utils/transforms';
|
|
41
48
|
export * from './utils/url';
|
|
42
|
-
export * from './utils/
|
|
49
|
+
export * from './utils/validation';
|
|
@@ -1,52 +1,65 @@
|
|
|
1
|
-
export type MetricRate =
|
|
2
|
-
export type
|
|
1
|
+
export type MetricRate = string;
|
|
2
|
+
export type MetricResolution = string;
|
|
3
3
|
export type MetricTimeWindow = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
export type MetricName = 'backendBootstrapLatency' | 'backendFailureCount' | 'backendFailureFunctionCallCount' | 'backendSuccessFunctionCallCount' | 'backendFunctionCallCount' | 'backendFunctionCallLatency' | 'integrationConnectAttemptLatency' | 'integrationConnectionErrorCount' | 'integrationReadOperationLatency' | 'integrationWriteOperationLatency' | 'integrationOperationErrorCount';
|
|
8
|
-
export type MetricAggregationFunction = 'sum' | 'avg';
|
|
9
|
-
export type MetricAggregation = 'none' | {
|
|
10
|
-
groupByFields: string[];
|
|
11
|
-
functionName: MetricAggregationFunction;
|
|
4
|
+
startTimeMs: number;
|
|
5
|
+
endTimeMs: number;
|
|
12
6
|
};
|
|
7
|
+
export type MetricType = 'latency' | 'successful' | 'failure' | 'total';
|
|
8
|
+
export type MetricUnit = 'millisecond' | 'count';
|
|
9
|
+
export type MetricGroupName = 'backendBootstrap' | 'backendFunctionCall' | 'integrationConnectAttempt' | 'integrationReadOperation' | 'integrationWriteOperation';
|
|
13
10
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* Filter key descriptions:
|
|
12
|
+
* - `functionName` - Only supported by 'backendFunctionCall' metric. The name of the function.
|
|
13
|
+
* - `integrationId` - Only supported by `integration*` metrics. The id of the integration.
|
|
14
|
+
* - `resultType` - Only supported by all metrics. The result of the operation being either 'success' or 'failure'.
|
|
17
15
|
*/
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export type
|
|
26
|
-
export type
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
export type MetricFilterKey = 'functionName' | 'integrationId' | 'resultType';
|
|
17
|
+
/**
|
|
18
|
+
* Internal filters are automatically assigned and are not configurable through the open API.
|
|
19
|
+
*/
|
|
20
|
+
export type MetricInternalFilterKey = MetricFilterKey | 'appId' | 'operationType';
|
|
21
|
+
export type MetricFilterValue = string | number | boolean;
|
|
22
|
+
export type MetricFilterOperationType = 'read' | 'write';
|
|
23
|
+
export type MetricFilterResultType = 'success' | 'failure';
|
|
24
|
+
export type MetricInternalFilters = MetricFilters<MetricInternalFilterKey> & {
|
|
25
|
+
operationType?: MetricFilterOperationType;
|
|
26
|
+
};
|
|
27
|
+
export type MetricFilters<T extends string> = {
|
|
28
|
+
[key in T]?: MetricFilterValue;
|
|
29
|
+
} & {
|
|
30
|
+
resultType?: MetricFilterResultType;
|
|
31
|
+
};
|
|
32
|
+
export interface MetricRequest {
|
|
33
|
+
summary?: boolean;
|
|
34
|
+
histogram?: {
|
|
35
|
+
rate: MetricRate;
|
|
36
|
+
resolution: MetricResolution;
|
|
32
37
|
};
|
|
33
|
-
values: V;
|
|
34
|
-
}
|
|
35
|
-
export interface MetricQueryResultData<T extends MetricQueryResultType, V> {
|
|
36
|
-
resultType: T;
|
|
37
|
-
result: MetricQueryResultDataEntry<V>[];
|
|
38
38
|
}
|
|
39
|
-
export interface
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
export interface GetMetricDataRequest {
|
|
40
|
+
requests: Array<{
|
|
41
|
+
filters: MetricFilters<MetricFilterKey>;
|
|
42
|
+
metricGroup: MetricGroupName;
|
|
43
|
+
metrics: {
|
|
44
|
+
[key in MetricType]?: MetricRequest;
|
|
45
|
+
};
|
|
46
|
+
}>;
|
|
47
|
+
timeWindow: MetricTimeWindow;
|
|
45
48
|
}
|
|
46
|
-
export type
|
|
47
|
-
|
|
49
|
+
export type MetricHistogram = Array<{
|
|
50
|
+
timestamp: Date;
|
|
51
|
+
value: number;
|
|
52
|
+
}>;
|
|
53
|
+
export type MetricResponse = {
|
|
54
|
+
unit: MetricUnit;
|
|
55
|
+
summary?: number;
|
|
56
|
+
histogram?: MetricHistogram;
|
|
57
|
+
};
|
|
58
|
+
export type GetMetricDataResponse = {
|
|
48
59
|
results: Array<{
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
metricGroup: MetricGroupName;
|
|
61
|
+
metrics: {
|
|
62
|
+
[key in MetricType]?: MetricResponse;
|
|
63
|
+
};
|
|
51
64
|
}>;
|
|
52
65
|
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { Mutation, MutationType } from './mutation.types';
|
|
2
2
|
import { BeforeAndAfterDocs } from './document.types';
|
|
3
3
|
import { Paths } from './types';
|
|
4
|
-
import { Auth, AuthWithBearer } from './context.types';
|
|
5
4
|
export declare class MutationContext<T = any> {
|
|
6
5
|
readonly mutation: Mutation<T>;
|
|
7
6
|
readonly beforeAndAfterDocs: BeforeAndAfterDocs<T>;
|
|
8
7
|
readonly serverTimeStamp: Date;
|
|
9
|
-
|
|
10
|
-
constructor(mutation: Mutation<T>, beforeAndAfterDocs: BeforeAndAfterDocs<T>, serverTimeStamp: Date, auth: Auth | undefined);
|
|
11
|
-
getUserAuth(): AuthWithBearer | undefined;
|
|
8
|
+
constructor(mutation: Mutation<T>, beforeAndAfterDocs: BeforeAndAfterDocs<T>, serverTimeStamp: Date);
|
|
12
9
|
getMutationType(): MutationType;
|
|
13
10
|
affectsPath(path: Paths<T>): boolean;
|
|
14
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClientId, IntegrationId } from './communication.types';
|
|
2
|
-
import { DocTimestamp,
|
|
2
|
+
import { DocTimestamp, FieldName, SquidDocId, SquidDocIdObj, SquidDocument } from './document.types';
|
|
3
3
|
export interface MutateRequest<T = any> {
|
|
4
4
|
clientId: ClientId;
|
|
5
5
|
integrationId: IntegrationId;
|
|
@@ -8,15 +8,15 @@ export interface MutateRequest<T = any> {
|
|
|
8
8
|
export interface ExecuteMutationsResponse {
|
|
9
9
|
timestamp: DocTimestamp;
|
|
10
10
|
idResolutionMap?: IdResolutionMap;
|
|
11
|
-
afterDocs: Record<
|
|
11
|
+
afterDocs: Record<SquidDocId, SquidDocument>;
|
|
12
12
|
}
|
|
13
13
|
export type MutateResponse = Omit<ExecuteMutationsResponse, 'afterDocs'>;
|
|
14
|
-
export type IdResolutionMap = Record<
|
|
14
|
+
export type IdResolutionMap = Record<SquidDocId, SquidDocId>;
|
|
15
15
|
export type Mutation<T = any> = UpdateMutation<T> | InsertMutation<T> | DeleteMutation;
|
|
16
16
|
export type MutationType = 'insert' | 'update' | 'delete';
|
|
17
17
|
interface BaseMutation {
|
|
18
18
|
type: MutationType;
|
|
19
|
-
|
|
19
|
+
squidDocIdObj: SquidDocIdObj;
|
|
20
20
|
}
|
|
21
21
|
export interface DeleteMutation extends BaseMutation {
|
|
22
22
|
type: 'delete';
|
|
@@ -60,7 +60,7 @@ export type ApplyStringFnPropertyMutation = ApplyExtendString | ApplyTrimString;
|
|
|
60
60
|
*/
|
|
61
61
|
export declare function sortUpdateMutationProperties(updateMutation: UpdateMutation): Array<[FieldName, Array<PropertyMutation>]>;
|
|
62
62
|
export declare function mergeMutations(mutationA: Mutation, mutationB: Mutation): Mutation;
|
|
63
|
-
export declare function applyUpdateMutation<T extends
|
|
63
|
+
export declare function applyUpdateMutation<T extends SquidDocument>(doc: T, updateMutation: UpdateMutation<T>): T | undefined;
|
|
64
64
|
export declare function convertInsertToUpdate(insertMutation: InsertMutation): UpdateMutation;
|
|
65
65
|
/**
|
|
66
66
|
* Reduces the list of mutations such that each document will have a single mutation. If for example there are multiple
|
|
@@ -2,13 +2,10 @@ import { IntegrationId } from '../communication.types';
|
|
|
2
2
|
import { CollectionName, FieldName } from '../document.types';
|
|
3
3
|
import { AllOperators, ContextCondition, ContextConditions, FieldSort, GeneralCondition, GeneralConditions, GenericValue, Query } from '../query.types';
|
|
4
4
|
import { Paths } from '../types';
|
|
5
|
-
import { Auth, AuthWithBearer } from '../context.types';
|
|
6
5
|
export declare class QueryContext<T = any> {
|
|
7
6
|
readonly query: Query<T>;
|
|
8
|
-
private readonly auth;
|
|
9
7
|
private readonly parsedConditions;
|
|
10
|
-
constructor(query: Query<T
|
|
11
|
-
getUserAuth(): AuthWithBearer | undefined;
|
|
8
|
+
constructor(query: Query<T>);
|
|
12
9
|
get integrationId(): IntegrationId;
|
|
13
10
|
get collectionName(): CollectionName;
|
|
14
11
|
get limit(): number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IntegrationId } from '../communication.types';
|
|
2
|
-
import { CollectionName, FieldName, PrimitiveFieldType
|
|
2
|
+
import { CollectionName, DocumentData, FieldName, PrimitiveFieldType } from '../document.types';
|
|
3
3
|
import { Operator, Query } from '../query.types';
|
|
4
|
-
export declare class SimpleQueryBuilder<MyDocType extends
|
|
4
|
+
export declare class SimpleQueryBuilder<MyDocType extends DocumentData> {
|
|
5
5
|
protected readonly collectionName: CollectionName;
|
|
6
6
|
protected readonly integrationId: IntegrationId;
|
|
7
7
|
protected readonly query: Query<MyDocType>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TriggerId } from './application.types';
|
|
2
2
|
import { AppId, ClientId, ClientRequestId, IntegrationId } from './communication.types';
|
|
3
|
-
import { CollectionName,
|
|
3
|
+
import { CollectionName, FieldName, PrimitiveFieldType, SquidDocument } from './document.types';
|
|
4
4
|
export type Conditions<Doc = any, F extends FieldName<Doc> = any> = Array<Condition<Doc, F>>;
|
|
5
5
|
export interface Condition<Doc = any, F extends FieldName<Doc> = any> {
|
|
6
6
|
fieldName: F;
|
|
@@ -101,13 +101,13 @@ export type QueryMapping<T extends string> = {
|
|
|
101
101
|
export declare abstract class QueryMappingManager<T> {
|
|
102
102
|
abstract addQuery(appId: AppId, query: Query, key: T): Promise<void>;
|
|
103
103
|
abstract removeQuery(appId: AppId, key: T): Promise<Query | undefined>;
|
|
104
|
-
abstract findQueriesForDocument(appId: AppId, doc:
|
|
104
|
+
abstract findQueriesForDocument(appId: AppId, doc: SquidDocument, collectionName: CollectionName, integrationId: IntegrationId): Promise<Array<T> | undefined>;
|
|
105
105
|
}
|
|
106
106
|
export declare abstract class SimpleQueryMappingManager<T extends string> extends QueryMappingManager<T> {
|
|
107
107
|
abstract getMapping(appId: AppId, collectionName: CollectionName, integrationId: IntegrationId): Promise<QueryMapping<T> | undefined> | (QueryMapping<T> | undefined);
|
|
108
|
-
findQueriesForDocument(appId: AppId, doc:
|
|
108
|
+
findQueriesForDocument(appId: AppId, doc: SquidDocument, collectionName: CollectionName, integrationId: IntegrationId): Promise<Array<T>>;
|
|
109
109
|
}
|
|
110
|
-
export declare function findQueriesForDocumentSync<T extends string>(mapping: QueryMapping<T>, doc:
|
|
110
|
+
export declare function findQueriesForDocumentSync<T extends string>(mapping: QueryMapping<T>, doc: SquidDocument): Array<T>;
|
|
111
111
|
export declare function compareOperator(conditionValue: PrimitiveFieldType, valueInDocument: PrimitiveFieldType, operator: Operator): boolean;
|
|
112
112
|
/** Returns a unique identifier for the query which includes both the client id and the client request id. */
|
|
113
113
|
export declare function getQuerySubscriptionId(clientId: string, clientRequestId: string): QuerySubscriptionId;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { JSONSchema } from 'json-schema-typed';
|
|
2
2
|
export type FieldPlaceholder = '__SQUID_SERVER_TIMESTAMP__' | '__SQUID_CLIENT_IP__' | '__SQUID_USER_ID__' | '__SQUID_API_KEY__';
|
|
3
|
-
export type
|
|
3
|
+
export type BasicFieldType = 'string' | 'integer' | 'number' | 'boolean' | 'map' | 'array' | 'any';
|
|
4
|
+
export type CustomFieldType = 'date' | 'json';
|
|
5
|
+
export type SupportedFieldType = BasicFieldType | CustomFieldType;
|
|
4
6
|
export declare const SUPPORTED_FIELD_TYPES_ARRAY: Array<SupportedFieldType>;
|
|
5
7
|
type ConvertDeep<T extends JSONSchema> = Exclude<T, boolean> & {
|
|
6
8
|
properties?: Record<string, ConvertDeep<JSONSchema>>;
|
|
@@ -13,6 +15,7 @@ type ConvertDeep<T extends JSONSchema> = Exclude<T, boolean> & {
|
|
|
13
15
|
*/
|
|
14
16
|
applyDefaultValueOn?: 'always' | 'empty' | 'updateOrEmpty';
|
|
15
17
|
isDate?: boolean;
|
|
18
|
+
isJSON?: boolean;
|
|
16
19
|
/**
|
|
17
20
|
* Applies to the top level schema, a record in a nested object, or a regular property.
|
|
18
21
|
* Basically, whether this property can participate in an insert mutation.
|
|
@@ -34,6 +37,12 @@ export type TopLevelPropertySchema = PropertySchema & {
|
|
|
34
37
|
* 'Hello' which is a constant.
|
|
35
38
|
*/
|
|
36
39
|
isDefaultComputed?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The database data type that is represented by this property. This is often different from the actual property
|
|
42
|
+
* type, with is a Javascript primitive. For example, for a SMALLINT the dataType would be 'smallint', but the type
|
|
43
|
+
* would be 'integer'.
|
|
44
|
+
*/
|
|
45
|
+
dataType?: string;
|
|
37
46
|
};
|
|
38
47
|
export type CollectionSchema = ConvertDeep<JSONSchema> & {
|
|
39
48
|
properties?: Record<string, TopLevelPropertySchema>;
|
|
@@ -18,7 +18,15 @@ export interface SecretEntry extends SecretMetadata {
|
|
|
18
18
|
value: SecretValue;
|
|
19
19
|
}
|
|
20
20
|
export type SetCustomSecretRequest = Omit<SecretEntry, 'lastUpdated'>;
|
|
21
|
-
export
|
|
21
|
+
export interface DeleteCustomSecretRequest {
|
|
22
|
+
key: SecretKey;
|
|
23
|
+
}
|
|
24
|
+
export interface GetApiKeyRequest {
|
|
25
|
+
apiKeyName: ApiKeyName;
|
|
26
|
+
}
|
|
27
|
+
export interface GetApiKeyResponse {
|
|
28
|
+
apiKey: string | undefined;
|
|
29
|
+
}
|
|
22
30
|
export type DeleteApiKeyRequest = Pick<SecretMetadata, 'key'>;
|
|
23
31
|
export interface ListApplicationSecretMetadataResponse {
|
|
24
32
|
custom: SecretMetadata[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClientId, ClientRequestId, IntegrationId } from './communication.types';
|
|
2
|
-
import { CollectionName, DocTimestamp,
|
|
2
|
+
import { CollectionName, DocTimestamp, SquidDocId, SquidDocument } from './document.types';
|
|
3
3
|
import { MutationType } from './mutation.types';
|
|
4
4
|
export type MessageId = string;
|
|
5
5
|
export type MessageFromClientType = 'acknowledge' | 'catchup' | 'kill';
|
|
@@ -47,14 +47,14 @@ export interface MutationsMessageToClient extends BaseMessageToClient {
|
|
|
47
47
|
payload: Array<MutationResultData>;
|
|
48
48
|
}
|
|
49
49
|
export interface MutationResultData {
|
|
50
|
-
|
|
50
|
+
squidDocId: SquidDocId;
|
|
51
51
|
clientRequestId: ClientRequestId;
|
|
52
52
|
mutationType: MutationType;
|
|
53
53
|
mutationTimestamp: DocTimestamp;
|
|
54
|
-
doc:
|
|
54
|
+
doc: SquidDocument | undefined;
|
|
55
55
|
}
|
|
56
56
|
export interface QueryResultData {
|
|
57
|
-
docs: Array<
|
|
57
|
+
docs: Array<SquidDocument>;
|
|
58
58
|
integrationId: IntegrationId;
|
|
59
59
|
collectionName: CollectionName;
|
|
60
60
|
clientRequestId: ClientRequestId;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { ServiceFunctionName } from './bundle-data.types';
|
|
2
2
|
import { AppId } from './communication.types';
|
|
3
|
-
import {
|
|
4
|
-
import { DocType, FullDocIdStr } from './document.types';
|
|
3
|
+
import { SquidDocId, SquidDocument } from './document.types';
|
|
5
4
|
import { MutationType } from './mutation.types';
|
|
6
5
|
export interface DocTriggerParams {
|
|
7
|
-
|
|
6
|
+
squidDocId: SquidDocId;
|
|
8
7
|
mutationType: MutationType;
|
|
9
|
-
docBefore?:
|
|
10
|
-
docAfter?:
|
|
11
|
-
auth: Auth | undefined;
|
|
8
|
+
docBefore?: SquidDocument;
|
|
9
|
+
docAfter?: SquidDocument;
|
|
12
10
|
}
|
|
13
11
|
export interface TriggerMessage {
|
|
14
12
|
params: DocTriggerParams;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { StatusCode } from './validation';
|
|
2
2
|
export type AssertErrorProvider = () => Error | string;
|
|
3
3
|
export declare function assertTruthy(value: unknown, error?: string | Error | AssertErrorProvider): asserts value;
|
|
4
|
+
export declare function assertDefined(value: unknown, error?: string | Error | AssertErrorProvider): asserts value;
|
|
4
5
|
export declare function assertValidateTruthy(value: unknown, message: string, statusCode?: StatusCode, details?: Record<string, any>): asserts value;
|
|
5
6
|
export declare function truthy<T>(value: T, error?: string | Error | AssertErrorProvider): NonNullable<T>;
|
|
7
|
+
export declare function defined<T>(value: T, error?: string | Error | AssertErrorProvider): NonNullable<T>;
|
|
6
8
|
export declare function validateTruthy<T>(value: T, message: string, statusCode?: StatusCode, details?: Record<string, any>): NonNullable<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare function getInPath(obj: any, path: string): any;
|
|
2
|
-
export declare function setInPath(obj: any, path: string, value: any): void;
|
|
3
|
-
export declare function deleteInPath(obj: any, path: string): void;
|
|
1
|
+
export declare function getInPath(obj: any, path: string, delimiter?: string): any;
|
|
2
|
+
export declare function setInPath(obj: any, path: string, value: any, delimiter?: string): void;
|
|
3
|
+
export declare function deleteInPath(obj: any, path: string, delimiter?: string): void;
|
|
4
4
|
export declare function deepReplace(obj: any, keyName: string, replacer: (from: any) => any): void;
|
|
5
5
|
export declare function replaceKeyInMap<K, T>(map: Map<K, T | undefined>, a: K, b: K): void;
|
|
6
6
|
export declare function replaceKeyInRecord<K extends keyof any, T>(record: Record<K, T>, a: K, b: K): void;
|
|
@@ -3,3 +3,4 @@ export declare function serializeObj(obj: any): string;
|
|
|
3
3
|
export declare function deserializeObj<T = any>(serializedObj: string): T;
|
|
4
4
|
export declare function encodeValueForMapping(value: any): string;
|
|
5
5
|
export declare function decodeValueForMapping(encodedString: string): any;
|
|
6
|
+
export declare function recodeValue(value: any): any;
|