@squidcloud/backend 1.0.0 → 1.0.2
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/backend/src/service.d.ts +8 -1
- package/dist/common/src/api-call.context.d.ts +17 -0
- package/dist/common/src/application.types.d.ts +13 -21
- 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 +16 -7
- package/dist/common/src/integration.types.d.ts +3 -1
- 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 +8 -4
- 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 +20 -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/id.d.ts +1 -0
- package/dist/common/src/utils/isDefined.d.ts +1 -0
- package/dist/common/src/utils/object.d.ts +5 -3
- package/dist/common/src/utils/serialization.d.ts +1 -0
- package/dist/common/src/utils/transforms.d.ts +18 -0
- package/dist/common/src/utils/url.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/typescript-client/src/collection-reference.d.ts +4 -3
- package/dist/typescript-client/src/collection-reference.factory.d.ts +6 -3
- package/dist/typescript-client/src/data.manager.d.ts +40 -18
- package/dist/typescript-client/src/destruct.manager.d.ts +3 -1
- package/dist/typescript-client/src/document-identity.service.d.ts +12 -0
- package/dist/typescript-client/src/document-reference.d.ts +7 -4
- 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/mutation/mutation-sender.d.ts +3 -3
- package/dist/typescript-client/src/query/query-builder.factory.d.ts +20 -17
- package/dist/typescript-client/src/query/query-subscription.manager.d.ts +14 -11
- package/dist/typescript-client/src/squid.d.ts +7 -6
- package/package.json +3 -2
- package/dist/typescript-client/src/db.dao.d.ts +0 -20
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { Squid } from '@squidcloud/client';
|
|
2
|
-
import { Logger, RunContext, SecretKey, SecretValue, ServiceConfig } from '@squidcloud/common';
|
|
2
|
+
import { AuthWithApiKey, AuthWithBearer, Logger, RunContext, SecretKey, SecretValue, ServiceConfig, SquidRegion } from '@squidcloud/common';
|
|
3
3
|
export declare class SquidService {
|
|
4
4
|
readonly secrets: Record<SecretKey, SecretValue>;
|
|
5
5
|
readonly logger: Logger;
|
|
6
6
|
private readonly backendApiKey;
|
|
7
7
|
readonly context: RunContext;
|
|
8
|
+
readonly codeDir: string;
|
|
9
|
+
readonly region: SquidRegion;
|
|
10
|
+
private readonly auth;
|
|
8
11
|
constructor(config: ServiceConfig);
|
|
9
12
|
get squid(): Squid;
|
|
13
|
+
get assetsDirectory(): string;
|
|
14
|
+
getUserAuth(): AuthWithBearer | undefined;
|
|
15
|
+
getApiKeyAuth(): AuthWithApiKey | undefined;
|
|
16
|
+
isAuthenticated(): boolean;
|
|
10
17
|
}
|
|
@@ -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 {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApplicationBundleData, ServiceFunctionName } from './bundle-data.types';
|
|
2
2
|
import { AppId, IntegrationId } from './communication.types';
|
|
3
3
|
import { CollectionName } from './document.types';
|
|
4
|
-
import { ApiEndpoint, ApiEndpointId, GraphQLConnectionOptions, Integration, IntegrationDataSchema, IntegrationGraphQLSchema, IntegrationType,
|
|
4
|
+
import { ApiEndpoint, ApiEndpointId, GraphQLConnectionOptions, Integration, IntegrationDataSchema, IntegrationGraphQLSchema, IntegrationType, MongoConnectionOptions, MssqlConnectionOptions, MySqlConnectionOptions, PostgresConnectionOptions } from './integration.types';
|
|
5
5
|
export type WebhookId = string;
|
|
6
6
|
export type QueryName = string;
|
|
7
7
|
export type TriggerId = string;
|
|
@@ -33,6 +33,7 @@ export interface Application {
|
|
|
33
33
|
allowedHosts: string[];
|
|
34
34
|
openIdProvider?: OpenIdProvider;
|
|
35
35
|
integrations: Record<IntegrationId, Integration>;
|
|
36
|
+
codeUrl?: string;
|
|
36
37
|
bundleMetadata?: ApplicationBundleData;
|
|
37
38
|
}
|
|
38
39
|
export interface UpdateOpenIdProviderRequest {
|
|
@@ -41,7 +42,8 @@ export interface UpdateOpenIdProviderRequest {
|
|
|
41
42
|
export interface CreateApplicationResponse {
|
|
42
43
|
appId: AppId;
|
|
43
44
|
}
|
|
44
|
-
export type UpsertIntegrationRequest =
|
|
45
|
+
export type UpsertIntegrationRequest = UpsertDataIntegrationRequest | UpsertGraphQLIntegrationRequest | UpsertApiIntegrationRequest;
|
|
46
|
+
export type UpsertDataIntegrationRequest = UpsertInternalIntegrationRequest | UpsertMongoDbIntegrationRequest | UpsertMssqlIntegrationRequest | UpsertMySqlIntegrationRequest | UpsertPostgresIntegrationRequest | UpsertCockroachIntegrationRequest;
|
|
45
47
|
interface BaseUpsertIntegrationRequest {
|
|
46
48
|
id: IntegrationId;
|
|
47
49
|
type: IntegrationType;
|
|
@@ -50,53 +52,43 @@ interface BaseUpsertIntegrationRequest {
|
|
|
50
52
|
interface BaseUpsertDataIntegrationRequest extends BaseUpsertIntegrationRequest {
|
|
51
53
|
supportsExternalChanges?: boolean;
|
|
52
54
|
}
|
|
55
|
+
export interface UpsertInternalIntegrationRequest extends BaseUpsertDataIntegrationRequest {
|
|
56
|
+
type: IntegrationType.internal;
|
|
57
|
+
schema?: IntegrationDataSchema;
|
|
58
|
+
}
|
|
53
59
|
export interface UpsertMongoDbIntegrationRequest extends BaseUpsertDataIntegrationRequest {
|
|
54
60
|
type: IntegrationType.mongo;
|
|
55
61
|
schema?: IntegrationDataSchema;
|
|
56
62
|
configuration: {
|
|
57
|
-
connectionOptions:
|
|
58
|
-
secrets: MongoConnectionSecretOptions;
|
|
59
|
-
ssl?: {
|
|
60
|
-
certificateFile: string;
|
|
61
|
-
validate: boolean;
|
|
62
|
-
};
|
|
63
|
-
};
|
|
63
|
+
connectionOptions: MongoConnectionOptions;
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
export interface UpsertMySqlIntegrationRequest extends BaseUpsertDataIntegrationRequest {
|
|
67
67
|
type: IntegrationType.mysql;
|
|
68
68
|
schema?: IntegrationDataSchema;
|
|
69
69
|
configuration: {
|
|
70
|
-
connectionOptions:
|
|
71
|
-
secrets: MySqlConnectionSecretOptions;
|
|
72
|
-
};
|
|
70
|
+
connectionOptions: MySqlConnectionOptions;
|
|
73
71
|
};
|
|
74
72
|
}
|
|
75
73
|
export interface UpsertMssqlIntegrationRequest extends BaseUpsertDataIntegrationRequest {
|
|
76
74
|
type: IntegrationType.mssql;
|
|
77
75
|
schema?: IntegrationDataSchema;
|
|
78
76
|
configuration: {
|
|
79
|
-
connectionOptions:
|
|
80
|
-
secrets: MssqlConnectionSecretOptions;
|
|
81
|
-
};
|
|
77
|
+
connectionOptions: MssqlConnectionOptions;
|
|
82
78
|
};
|
|
83
79
|
}
|
|
84
80
|
export interface UpsertPostgresIntegrationRequest extends BaseUpsertDataIntegrationRequest {
|
|
85
81
|
type: IntegrationType.postgres;
|
|
86
82
|
schema?: IntegrationDataSchema;
|
|
87
83
|
configuration: {
|
|
88
|
-
connectionOptions:
|
|
89
|
-
secrets: PostgresConnectionSecretOptions;
|
|
90
|
-
};
|
|
84
|
+
connectionOptions: PostgresConnectionOptions;
|
|
91
85
|
};
|
|
92
86
|
}
|
|
93
87
|
export interface UpsertCockroachIntegrationRequest extends BaseUpsertDataIntegrationRequest {
|
|
94
88
|
type: IntegrationType.cockroach;
|
|
95
89
|
schema?: IntegrationDataSchema;
|
|
96
90
|
configuration: {
|
|
97
|
-
connectionOptions:
|
|
98
|
-
secrets: PostgresConnectionSecretOptions;
|
|
99
|
-
};
|
|
91
|
+
connectionOptions: PostgresConnectionOptions;
|
|
100
92
|
};
|
|
101
93
|
}
|
|
102
94
|
export interface UpsertGraphQLIntegrationRequest extends BaseUpsertIntegrationRequest {
|
|
@@ -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,12 +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';
|
|
41
|
+
export * from './utils/error';
|
|
42
|
+
export * from './utils/id';
|
|
43
|
+
export * from './utils/isDefined';
|
|
35
44
|
export * from './utils/lock.manager';
|
|
36
45
|
export * from './utils/object';
|
|
37
46
|
export * from './utils/serialization';
|
|
38
|
-
export * from './utils/
|
|
39
|
-
export * from './utils/error';
|
|
47
|
+
export * from './utils/transforms';
|
|
40
48
|
export * from './utils/url';
|
|
49
|
+
export * from './utils/validation';
|
|
@@ -77,6 +77,7 @@ export interface IntegrationDataSchema {
|
|
|
77
77
|
export interface IntegrationGraphQLSchema {
|
|
78
78
|
introspection: IntrospectionQuery;
|
|
79
79
|
}
|
|
80
|
+
export type IntegrationApiEndpoints = Record<ApiEndpointId, ApiEndpoint>;
|
|
80
81
|
export type IntegrationSchema = IntegrationDataSchema | IntegrationGraphQLSchema;
|
|
81
82
|
interface BaseIntegration {
|
|
82
83
|
id: IntegrationId;
|
|
@@ -90,6 +91,7 @@ export interface BaseDataIntegration extends BaseIntegration {
|
|
|
90
91
|
supportsExternalChanges: boolean;
|
|
91
92
|
}
|
|
92
93
|
export declare function isDataIntegration(integration: any): integration is BaseDataIntegration;
|
|
94
|
+
export declare function isDataIntegrationType(type: IntegrationType): boolean;
|
|
93
95
|
export type HttpMethod = 'post' | 'get' | 'delete' | 'patch' | 'put';
|
|
94
96
|
export type ApiEndpointId = string;
|
|
95
97
|
export type ApiParameterLocation = 'query' | 'body' | 'header' | 'path';
|
|
@@ -111,7 +113,7 @@ export interface ApiEndpoint {
|
|
|
111
113
|
export interface ApiIntegration extends BaseIntegration {
|
|
112
114
|
type: IntegrationType.api;
|
|
113
115
|
baseUrl: string;
|
|
114
|
-
endpoints:
|
|
116
|
+
endpoints: IntegrationApiEndpoints;
|
|
115
117
|
}
|
|
116
118
|
export interface GraphQLIntegration extends BaseIntegration {
|
|
117
119
|
type: IntegrationType.graphql;
|
|
@@ -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 = 'backendBootstrapLatencySum' | 'backendFailureCount' | 'backendFailureFunctionCallCount' | 'backendSuccessFunctionCallCount' | 'backendFunctionCallCount' | 'backendFunctionCallLatencySum';
|
|
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,18 +1,22 @@
|
|
|
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;
|
|
6
6
|
mutations: Array<Mutation<T>>;
|
|
7
7
|
}
|
|
8
|
-
export interface
|
|
8
|
+
export interface ExecuteMutationsResponse {
|
|
9
9
|
timestamp: DocTimestamp;
|
|
10
|
+
idResolutionMap?: IdResolutionMap;
|
|
11
|
+
afterDocs: Record<SquidDocId, SquidDocument>;
|
|
10
12
|
}
|
|
13
|
+
export type MutateResponse = Omit<ExecuteMutationsResponse, 'afterDocs'>;
|
|
14
|
+
export type IdResolutionMap = Record<SquidDocId, SquidDocId>;
|
|
11
15
|
export type Mutation<T = any> = UpdateMutation<T> | InsertMutation<T> | DeleteMutation;
|
|
12
16
|
export type MutationType = 'insert' | 'update' | 'delete';
|
|
13
17
|
interface BaseMutation {
|
|
14
18
|
type: MutationType;
|
|
15
|
-
|
|
19
|
+
squidDocIdObj: SquidDocIdObj;
|
|
16
20
|
}
|
|
17
21
|
export interface DeleteMutation extends BaseMutation {
|
|
18
22
|
type: 'delete';
|
|
@@ -56,7 +60,7 @@ export type ApplyStringFnPropertyMutation = ApplyExtendString | ApplyTrimString;
|
|
|
56
60
|
*/
|
|
57
61
|
export declare function sortUpdateMutationProperties(updateMutation: UpdateMutation): Array<[FieldName, Array<PropertyMutation>]>;
|
|
58
62
|
export declare function mergeMutations(mutationA: Mutation, mutationB: Mutation): Mutation;
|
|
59
|
-
export declare function applyUpdateMutation<T extends
|
|
63
|
+
export declare function applyUpdateMutation<T extends SquidDocument>(doc: T, updateMutation: UpdateMutation<T>): T | undefined;
|
|
60
64
|
export declare function convertInsertToUpdate(insertMutation: InsertMutation): UpdateMutation;
|
|
61
65
|
/**
|
|
62
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;
|