@squidcloud/backend 1.0.210 → 1.0.212
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/public-types.d.ts +1 -0
- package/dist/backend/src/service.d.ts +2 -0
- package/dist/index.js.LICENSE.txt +8 -0
- package/dist/internal-common/src/public-types-backend/ai-chatbot.public-context.d.ts +27 -0
- package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +25 -0
- package/dist/internal-common/src/public-types-backend/bundle-api.public-types.d.ts +101 -0
- package/dist/internal-common/src/public-types-backend/distributed-lock.public-context.d.ts +4 -0
- package/dist/internal-common/src/public-types-backend/graphql.public-context.d.ts +7 -0
- package/dist/internal-common/src/public-types-backend/mutation.public-context.d.ts +14 -0
- package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +18 -0
- package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +123 -0
- package/dist/internal-common/src/public-types-backend/service.public-types.d.ts +29 -0
- package/dist/internal-common/src/public-types-backend/topic.public-context.d.ts +10 -0
- package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -0
- package/package.json +3 -4
|
@@ -6,4 +6,5 @@ export * from '../../internal-common/src/public-types-backend/graphql.public-con
|
|
|
6
6
|
export * from '../../internal-common/src/public-types-backend/mutation.public-context';
|
|
7
7
|
export * from '../../internal-common/src/public-types-backend/native-query.public-context';
|
|
8
8
|
export * from '../../internal-common/src/public-types-backend/query.public-context';
|
|
9
|
+
export * from '../../internal-common/src/public-types-backend/service.public-types';
|
|
9
10
|
export * from '../../internal-common/src/public-types-backend/topic.public-context';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AuthWithApiKey, AuthWithBearer, RunContext, SecretKey, SecretValue, Squid, SquidRegion } from '@squidcloud/client';
|
|
2
|
+
import { ServiceGlobalConfig } from '../../internal-common/src/public-types-backend/service.public-types';
|
|
2
3
|
/**
|
|
3
4
|
* A base class for all the different types of Squid backend services. This class serves as a container
|
|
4
5
|
* for the various methods implemented in the backend in order to customize the Squid backend for an application.
|
|
@@ -9,6 +10,7 @@ export declare class SquidService {
|
|
|
9
10
|
* Your application's region. When developing locally, the region will be set to `local`.
|
|
10
11
|
*/
|
|
11
12
|
readonly region: SquidRegion;
|
|
13
|
+
constructor(config: ServiceGlobalConfig);
|
|
12
14
|
/** The list of your application's secrets as defined in the Squid Cloud Console. */
|
|
13
15
|
get secrets(): Record<SecretKey, SecretValue>;
|
|
14
16
|
/**
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Lodash <https://lodash.com/>
|
|
4
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
5
|
+
* Released under MIT license <https://lodash.com/license>
|
|
6
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
7
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
8
|
+
*/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AiChatbotMutationType, AiChatbotResourceType } from '@squidcloud/client';
|
|
2
|
+
export type AiChatbotContextType = 'text' | 'url' | 'file';
|
|
3
|
+
export interface AiChatbotContextBase {
|
|
4
|
+
type: AiChatbotContextType;
|
|
5
|
+
data: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AiChatbotTextContext extends AiChatbotContextBase {
|
|
8
|
+
type: 'text';
|
|
9
|
+
}
|
|
10
|
+
export interface AiChatbotUrlContext extends AiChatbotContextBase {
|
|
11
|
+
type: 'url';
|
|
12
|
+
}
|
|
13
|
+
export interface AiChatbotFileContext extends AiChatbotContextBase {
|
|
14
|
+
type: 'file';
|
|
15
|
+
}
|
|
16
|
+
export declare class AiChatbotChatContext {
|
|
17
|
+
readonly prompt: string;
|
|
18
|
+
readonly profileId: string;
|
|
19
|
+
}
|
|
20
|
+
/** A context provided to the security rules of an AI Chatbot mutation. */
|
|
21
|
+
export declare class AiChatbotMutationContext {
|
|
22
|
+
readonly type: AiChatbotMutationType;
|
|
23
|
+
readonly resource: AiChatbotResourceType;
|
|
24
|
+
readonly profileId: string;
|
|
25
|
+
readonly payload: any;
|
|
26
|
+
}
|
|
27
|
+
export type AiChatbotContext = AiChatbotTextContext | AiChatbotUrlContext | AiChatbotFileContext;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ApiEndpointId, HttpMethod } from '@squidcloud/client';
|
|
2
|
+
import { IntegrationId } from '@squidcloud/client';
|
|
3
|
+
/** The headers of an API call. */
|
|
4
|
+
export type ApiHeaders = Record<string, string | number | boolean>;
|
|
5
|
+
/** The context of an API call. */
|
|
6
|
+
export declare class ApiCallContext {
|
|
7
|
+
readonly integrationId: IntegrationId;
|
|
8
|
+
readonly endpointId: ApiEndpointId;
|
|
9
|
+
readonly url: string;
|
|
10
|
+
readonly method: HttpMethod;
|
|
11
|
+
readonly body: unknown;
|
|
12
|
+
readonly options: ApiOptions;
|
|
13
|
+
}
|
|
14
|
+
export interface ApiOptions {
|
|
15
|
+
headers?: Record<string, string | number | boolean>;
|
|
16
|
+
queryParams?: Record<string, string | number | boolean>;
|
|
17
|
+
pathParams?: Record<string, string | number | boolean>;
|
|
18
|
+
}
|
|
19
|
+
export interface CallApiRequest<BodyType = any> {
|
|
20
|
+
integrationId: IntegrationId;
|
|
21
|
+
endpointId: ApiEndpointId;
|
|
22
|
+
body?: BodyType;
|
|
23
|
+
overrideMethod?: HttpMethod;
|
|
24
|
+
options: ApiOptions;
|
|
25
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { MutationContext } from './mutation.public-context';
|
|
2
|
+
import { ApiCallContext } from './api-call.public-context';
|
|
3
|
+
import { QueryContext } from './query.public-context';
|
|
4
|
+
import { AiChatbotActionType, DatabaseActionType, StorageActionType, TopicActionType } from '@squidcloud/client';
|
|
5
|
+
import { ClientConnectionState } from '@squidcloud/client';
|
|
6
|
+
import { DocumentData } from '@squidcloud/client';
|
|
7
|
+
import { MutationType } from '@squidcloud/client';
|
|
8
|
+
import { ClientId, SquidDocId } from '@squidcloud/client';
|
|
9
|
+
import { TopicReadContext, TopicWriteContext } from './topic.public-context';
|
|
10
|
+
import { DistributedLockContext } from './distributed-lock.public-context';
|
|
11
|
+
import { GraphqlContext } from './graphql.public-context';
|
|
12
|
+
import { AiChatbotChatContext, AiChatbotMutationContext } from './ai-chatbot.public-context';
|
|
13
|
+
import { StorageContext } from '@squidcloud/client';
|
|
14
|
+
import { NativeQueryContext } from './native-query.public-context';
|
|
15
|
+
export type SecureDatabaseAction<T extends DatabaseActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? ((context: QueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: MutationContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
16
|
+
export type SecureStorageAction<T extends StorageActionType> = T extends 'all' ? () => boolean | Promise<boolean> : (context: StorageContext) => boolean | Promise<boolean>;
|
|
17
|
+
export type SecureTopicAction<T extends TopicActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'read' ? ((context: TopicReadContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: TopicWriteContext<T>) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
18
|
+
export type SecureApiAction = ((context: ApiCallContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
19
|
+
export type SecureNativeQueryAction = ((context: NativeQueryContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
20
|
+
export type SecureDistributedLockAction = ((context: DistributedLockContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
21
|
+
export type SecureGraphQLAction = ((context: GraphqlContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
22
|
+
export type SecureAiChatbotAction<T extends AiChatbotActionType> = T extends 'all' ? () => boolean | Promise<boolean> : T extends 'chat' ? ((context: AiChatbotChatContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>) : ((context: AiChatbotMutationContext) => boolean | Promise<boolean>) | (() => boolean | Promise<boolean>);
|
|
23
|
+
export type ClientConnectionStateChangeAction = (clientId: ClientId, clientConnectionState: ClientConnectionState) => Promise<void> | void;
|
|
24
|
+
export type ExecutableAction = (...args: any[]) => any;
|
|
25
|
+
export type AiFunctionAction<T extends Record<string, any> = any> = (params: T) => any;
|
|
26
|
+
export type TriggerAction = ((request: TriggerRequest) => void | Promise<void>) | (() => void | Promise<void>);
|
|
27
|
+
/** The context provided to a trigger function. */
|
|
28
|
+
export interface TriggerRequest<T extends DocumentData = any> {
|
|
29
|
+
squidDocId: SquidDocId;
|
|
30
|
+
mutationType: MutationType;
|
|
31
|
+
docBefore?: T;
|
|
32
|
+
docAfter?: T;
|
|
33
|
+
}
|
|
34
|
+
export type SchedulerAction = () => void | Promise<void>;
|
|
35
|
+
export type LimitedAction = () => any | Promise<any>;
|
|
36
|
+
export type LimiterScope = 'ip' | 'user' | 'global';
|
|
37
|
+
export type QuotaRenewPeriod = 'hourly' | 'daily' | 'weekly' | 'monthly' | 'quarterly' | 'annually';
|
|
38
|
+
/**
|
|
39
|
+
* Options for rate limiting.
|
|
40
|
+
*
|
|
41
|
+
* @param value Number of executions permitted per second. Note that we
|
|
42
|
+
* permit bursts of up to 3x the specified limit.
|
|
43
|
+
* @param scope What this limit applies to: per user? per IP? global?
|
|
44
|
+
*/
|
|
45
|
+
export interface RateLimitOptions {
|
|
46
|
+
value: number;
|
|
47
|
+
scope?: LimiterScope;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Options for quota limiting.
|
|
51
|
+
*
|
|
52
|
+
* @param value Number of total executions allowed. Note that this would be
|
|
53
|
+
* reset upon any redeployment of the backend.
|
|
54
|
+
* @param scope What this limit applies to: per user? per IP? global?
|
|
55
|
+
*/
|
|
56
|
+
export interface QuotaLimitOptions {
|
|
57
|
+
value: number;
|
|
58
|
+
scope?: LimiterScope;
|
|
59
|
+
renewPeriod?: QuotaRenewPeriod;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Options for rate and quota limiting backend functions.
|
|
63
|
+
*
|
|
64
|
+
* This mirrors the type in Kotlin. It is not the type the developer defines in their code, which is LimiterConfig.
|
|
65
|
+
*
|
|
66
|
+
* @param rateLimit RateLimitOptions configurations. Allows for different limits at different scopes.
|
|
67
|
+
* @param quotaLimit QuotaLimitOptions configurations. Allows for different limits at different scopes.
|
|
68
|
+
*/
|
|
69
|
+
export interface LimiterOptions {
|
|
70
|
+
rateLimit?: RateLimitOptions[];
|
|
71
|
+
quotaLimit?: QuotaLimitOptions[];
|
|
72
|
+
}
|
|
73
|
+
export type LimiterConfig = {
|
|
74
|
+
rateLimit?: number | RateLimitOptions | Array<RateLimitOptions>;
|
|
75
|
+
quotaLimit?: number | QuotaLimitOptions | Array<QuotaLimitOptions>;
|
|
76
|
+
};
|
|
77
|
+
export type WebhookAction = ((request: WebhookRequest) => any) | (() => any);
|
|
78
|
+
/** The context provided to a webhook function. */
|
|
79
|
+
export interface WebhookRequest<T = any> {
|
|
80
|
+
body: T;
|
|
81
|
+
rawBody?: string;
|
|
82
|
+
queryParams: Record<string, string>;
|
|
83
|
+
headers: Record<string, string>;
|
|
84
|
+
httpMethod: 'post' | 'get' | 'put' | 'delete';
|
|
85
|
+
files?: Array<SquidFile>;
|
|
86
|
+
}
|
|
87
|
+
export interface WebhookResponse {
|
|
88
|
+
headers: Record<string, any>;
|
|
89
|
+
body: any;
|
|
90
|
+
statusCode: number;
|
|
91
|
+
__isWebhookResponse__: true;
|
|
92
|
+
}
|
|
93
|
+
export interface SquidFile {
|
|
94
|
+
data: Uint8Array;
|
|
95
|
+
fieldName: string;
|
|
96
|
+
mimetype: string;
|
|
97
|
+
originalName: string;
|
|
98
|
+
size: number;
|
|
99
|
+
encoding?: string;
|
|
100
|
+
}
|
|
101
|
+
export type ActionMethodDecorator<U> = <T extends U>(target: Object, propertyName: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The context provided to a secure GraphQL function. */
|
|
2
|
+
export declare class GraphqlContext {
|
|
3
|
+
readonly isGraphiQL: boolean;
|
|
4
|
+
readonly query: string | undefined;
|
|
5
|
+
readonly variables: string | Record<string, any> | undefined;
|
|
6
|
+
readonly operationName: string | undefined;
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Paths } from '@squidcloud/client';
|
|
2
|
+
import { BeforeAndAfterDocs } from '@squidcloud/client';
|
|
3
|
+
import { Mutation, MutationType } from '@squidcloud/client';
|
|
4
|
+
/** The mutation context that will be provided to the security function. */
|
|
5
|
+
export declare class MutationContext<T = any> {
|
|
6
|
+
readonly mutation: Mutation<T>;
|
|
7
|
+
readonly beforeAndAfterDocs: BeforeAndAfterDocs<T>;
|
|
8
|
+
readonly serverTimeStamp: Date;
|
|
9
|
+
getMutationType(): MutationType;
|
|
10
|
+
get before(): T | undefined;
|
|
11
|
+
get after(): T | undefined;
|
|
12
|
+
/** Returns true if the mutation affects the provided path. */
|
|
13
|
+
affectsPath(path: Paths<T>): boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IntegrationId } from '@squidcloud/client';
|
|
2
|
+
export type NativeQueryRequestType = 'relational' | 'mongo';
|
|
3
|
+
interface BaseNativeQueryRequest {
|
|
4
|
+
type: NativeQueryRequestType;
|
|
5
|
+
integrationId: IntegrationId;
|
|
6
|
+
}
|
|
7
|
+
export interface RelationalNativeQueryRequest extends BaseNativeQueryRequest {
|
|
8
|
+
type: 'relational';
|
|
9
|
+
query: string;
|
|
10
|
+
params: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
export interface MongoNativeQueryRequest extends BaseNativeQueryRequest {
|
|
13
|
+
type: 'mongo';
|
|
14
|
+
collectionName: string;
|
|
15
|
+
aggregationPipeline: Array<any | undefined>;
|
|
16
|
+
}
|
|
17
|
+
export type NativeQueryContext = RelationalNativeQueryRequest | MongoNativeQueryRequest;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { FieldSort, Operator, Query, SimpleCondition } from '@squidcloud/client';
|
|
2
|
+
import { DeepRecord, FieldOf, PartialBy, Paths } from '@squidcloud/client';
|
|
3
|
+
import { CollectionName, DocumentData } from '@squidcloud/client';
|
|
4
|
+
import { IntegrationId } from '@squidcloud/client';
|
|
5
|
+
export declare class QueryContext<T extends DocumentData = any> {
|
|
6
|
+
readonly query: Query<T>;
|
|
7
|
+
/**
|
|
8
|
+
* The ID of the integration being queried.
|
|
9
|
+
*/
|
|
10
|
+
get integrationId(): IntegrationId;
|
|
11
|
+
/**
|
|
12
|
+
* The name of the collection being queried.
|
|
13
|
+
*/
|
|
14
|
+
get collectionName(): CollectionName;
|
|
15
|
+
/**
|
|
16
|
+
* The query limit if one exists, -1 otherwise.
|
|
17
|
+
*/
|
|
18
|
+
get limit(): number;
|
|
19
|
+
/**
|
|
20
|
+
* Verifies that the query's sort order aligns with the provided field sorts. The fields specified in the `sorts`
|
|
21
|
+
* parameter must appear in the exact order at the beginning of the query's sort sequence. The query can include
|
|
22
|
+
* additional fields in its sort order, but only after the specified sorts.
|
|
23
|
+
*
|
|
24
|
+
* @param sorts An array of field sorts.
|
|
25
|
+
* @returns Whether the query's sorts matches the provided field sorts.
|
|
26
|
+
*/
|
|
27
|
+
sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Verifies that the query's sort order exactly matches the provided field sorts. The fields specified in the
|
|
30
|
+
* `sorts` parameter must appear in the exact order in the query's sort sequence. No additional sorts may be present
|
|
31
|
+
* in the query.
|
|
32
|
+
*
|
|
33
|
+
* @param sorts An array of field sorts.
|
|
34
|
+
* @returns Whether the query's sorts exactly match the provided field sorts.
|
|
35
|
+
*/
|
|
36
|
+
sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
|
|
39
|
+
* to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
|
|
40
|
+
* additional conditions, as these only narrow the result set.
|
|
41
|
+
*
|
|
42
|
+
* @param fieldName The name of the field for the condition.
|
|
43
|
+
* @param operator The operator of the condition.
|
|
44
|
+
* @param value The value of the condition.
|
|
45
|
+
* @returns Whether the query is a subquery of the parent condition.
|
|
46
|
+
*/
|
|
47
|
+
isSubqueryOf<F extends Paths<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O> | null): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
|
|
50
|
+
* to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
|
|
51
|
+
* additional conditions, as these only narrow the result set.
|
|
52
|
+
*
|
|
53
|
+
* @param condition The condition to validate.
|
|
54
|
+
* @returns Whether the query is a subquery of the parent condition.
|
|
55
|
+
*/
|
|
56
|
+
isSubqueryOfCondition(condition: GeneralCondition<T>): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Verifies that the query is a subquery of the specified conditions. A subquery is defined as a query that evaluates
|
|
59
|
+
* to a subset of the results that would be obtained by applying the parent conditions. The subquery may also include
|
|
60
|
+
* additional conditions, as these only narrow the result set.
|
|
61
|
+
*
|
|
62
|
+
* @param conditions The conditions to validate.
|
|
63
|
+
* @returns Whether the query includes subquery of the parent conditions.
|
|
64
|
+
*/
|
|
65
|
+
isSubqueryOfConditions(conditions: GeneralConditions<T>): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Verifies that the query is a subquery of the specified query. A subquery is defined as a query that evaluates
|
|
68
|
+
* to a subset of the results that obtained for the parent query, including sorts and limits.
|
|
69
|
+
*
|
|
70
|
+
* @param query The query to validate.
|
|
71
|
+
* @returns Whether the query is a subquery of the parent query.
|
|
72
|
+
*/
|
|
73
|
+
isSubqueryOfQuery(query: Query<T>): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Returns all conditions that apply to any of the specified field names. This method
|
|
76
|
+
* provides a convenient way to retrieve all conditions that involve a specific set of fields.
|
|
77
|
+
*
|
|
78
|
+
* @param fieldNames The field names for which to retrieve conditions.
|
|
79
|
+
* @returns An array of conditions that involve any of the specified field names.
|
|
80
|
+
*/
|
|
81
|
+
getConditionsFor<K extends Paths<T>>(...fieldNames: Array<K>): ContextConditions<T, K>;
|
|
82
|
+
/**
|
|
83
|
+
* Returns all conditions that apply to the specified field name. This method provides
|
|
84
|
+
* a convenient way to retrieve all conditions that involve a specific field.
|
|
85
|
+
*
|
|
86
|
+
* @param fieldName The field name for which to retrieve conditions.
|
|
87
|
+
* @returns An array of conditions that involve the specified field name.
|
|
88
|
+
*/
|
|
89
|
+
getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Returns true if the given document can be a result of the query.
|
|
92
|
+
* The method does not account for limit and sort order.
|
|
93
|
+
*/
|
|
94
|
+
documentMatchesQuery(doc: DocumentData): boolean;
|
|
95
|
+
}
|
|
96
|
+
/** A list of context conditions */
|
|
97
|
+
export type ContextConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<ContextCondition<Doc, F>>;
|
|
98
|
+
/** A Context condition - a condition that replaces multiple '==' or '!=' conditions with 'in' and 'not in'. */
|
|
99
|
+
export type ContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
|
|
100
|
+
export interface InContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'in'> {
|
|
101
|
+
operator: 'in';
|
|
102
|
+
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
103
|
+
}
|
|
104
|
+
export interface NotInContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'not in'> {
|
|
105
|
+
operator: 'not in';
|
|
106
|
+
value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
|
|
107
|
+
}
|
|
108
|
+
export interface OtherContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, Exclude<ContextOperator, 'in' | 'not in'>> {
|
|
109
|
+
operator: Exclude<ContextOperator, 'in' | 'not in'>;
|
|
110
|
+
value: FieldOf<DeepRecord<Doc>, Paths<Doc>> | any;
|
|
111
|
+
}
|
|
112
|
+
/** A condition that includes the 'in' and 'not in' operators. */
|
|
113
|
+
export interface GeneralCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, AllOperators> {
|
|
114
|
+
operator: AllOperators;
|
|
115
|
+
value: any;
|
|
116
|
+
}
|
|
117
|
+
/** A list of general conditions. */
|
|
118
|
+
export type GeneralConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<GeneralCondition<Doc, F>>;
|
|
119
|
+
export type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
|
|
120
|
+
type AllOperators = Operator | 'in' | 'not in';
|
|
121
|
+
/** A generic value that can exist in a query. */
|
|
122
|
+
export type GenericValue<Doc = any, F extends Paths<Doc> = Paths<Doc>, O extends AllOperators = any> = O extends 'in' ? Array<DeepRecord<Doc>[F]> | null : O extends 'not in' ? Array<DeepRecord<Doc>[F]> | null : DeepRecord<Doc>[F] | null;
|
|
123
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
|
+
import { AppId, EnvironmentId, SquidDeveloperId } from '@squidcloud/client';
|
|
4
|
+
import { Auth, RunContext } from '@squidcloud/client';
|
|
5
|
+
import { SecretKey } from '@squidcloud/client';
|
|
6
|
+
/**
|
|
7
|
+
* Immutable part of the service config: this part of the Service config never changes for a service.
|
|
8
|
+
*/
|
|
9
|
+
export interface ServiceGlobalConfig {
|
|
10
|
+
codeDir: string;
|
|
11
|
+
environmentId?: EnvironmentId;
|
|
12
|
+
/** Your applicationId. */
|
|
13
|
+
appId: AppId;
|
|
14
|
+
squidDeveloperId?: SquidDeveloperId;
|
|
15
|
+
backendApiKey: string;
|
|
16
|
+
/**
|
|
17
|
+
* Current states of the secrets.
|
|
18
|
+
* Mutable, and can be dynamically updated in runtime.
|
|
19
|
+
*/
|
|
20
|
+
secrets: Record<SecretKey, any>;
|
|
21
|
+
requestLocalStorage: AsyncLocalStorage<ServiceRequestConfig>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The part of the service config that changes every request.
|
|
25
|
+
*/
|
|
26
|
+
export interface ServiceRequestConfig {
|
|
27
|
+
auth: Auth | undefined;
|
|
28
|
+
context: RunContext;
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IntegrationId } from '@squidcloud/client';
|
|
2
|
+
export interface TopicReadContext {
|
|
3
|
+
integrationId: IntegrationId;
|
|
4
|
+
topicName: string;
|
|
5
|
+
}
|
|
6
|
+
export interface TopicWriteContext<T> {
|
|
7
|
+
integrationId: IntegrationId;
|
|
8
|
+
topicName: string;
|
|
9
|
+
messages: Array<T>;
|
|
10
|
+
}
|