@squidcloud/client 1.0.168 → 1.0.169

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.
Files changed (105) hide show
  1. package/dist/cjs/index.js +17 -10
  2. package/dist/internal-common/src/public-types/ai-assistant.public-types.d.ts +25 -0
  3. package/dist/internal-common/src/public-types/ai-chatbot.public-context.d.ts +12 -0
  4. package/dist/internal-common/src/public-types/ai-chatbot.public-types.d.ts +31 -0
  5. package/dist/internal-common/src/public-types/api-call.public-context.d.ts +14 -0
  6. package/dist/internal-common/src/public-types/application.public-types.d.ts +149 -0
  7. package/dist/internal-common/src/public-types/base-query-builder.public-types.d.ts +147 -0
  8. package/dist/internal-common/src/public-types/bundle-api.public-types.d.ts +57 -0
  9. package/dist/internal-common/src/public-types/bundle-data.public-types.d.ts +8 -0
  10. package/dist/internal-common/src/public-types/communication.public-types.d.ts +12 -0
  11. package/dist/internal-common/src/public-types/context.public-types.d.ts +40 -0
  12. package/dist/internal-common/src/public-types/distributed-lock.public-context.d.ts +4 -0
  13. package/dist/internal-common/src/public-types/document.public-types.d.ts +32 -0
  14. package/dist/internal-common/src/public-types/graphql.public-context.d.ts +7 -0
  15. package/dist/internal-common/src/public-types/graphql.public-types.d.ts +9 -0
  16. package/dist/internal-common/src/public-types/http-status.enum.d.ts +50 -0
  17. package/dist/internal-common/src/public-types/integration.public-types.d.ts +61 -0
  18. package/dist/internal-common/src/public-types/integrations/ai_chatbot.types.d.ts +32 -0
  19. package/dist/internal-common/src/public-types/integrations/api.types.d.ts +81 -0
  20. package/dist/internal-common/src/public-types/integrations/auth.types.d.ts +54 -0
  21. package/dist/internal-common/src/public-types/integrations/database.types.d.ts +206 -0
  22. package/dist/internal-common/src/public-types/integrations/observability.types.d.ts +24 -0
  23. package/dist/internal-common/src/public-types/integrations/queue-types.d.ts +40 -0
  24. package/dist/internal-common/src/public-types/integrations/schemas.d.ts +70 -0
  25. package/dist/internal-common/src/public-types/mutation.public-context.d.ts +14 -0
  26. package/dist/internal-common/src/public-types/mutation.public-types.d.ts +53 -0
  27. package/dist/internal-common/src/public-types/native-query.public-context.d.ts +7 -0
  28. package/dist/internal-common/src/public-types/native-query.public-types.d.ts +16 -0
  29. package/dist/internal-common/src/public-types/pagination.public-types.d.ts +62 -0
  30. package/dist/internal-common/src/public-types/query.public-context.d.ts +137 -0
  31. package/dist/internal-common/src/public-types/query.public-types.d.ts +64 -0
  32. package/dist/internal-common/src/public-types/regions.public-types.d.ts +5 -0
  33. package/dist/internal-common/src/public-types/schema.public-types.d.ts +46 -0
  34. package/dist/internal-common/src/public-types/secret.public-types.d.ts +16 -0
  35. package/dist/internal-common/src/public-types/serialized-query.public-types.d.ts +24 -0
  36. package/dist/internal-common/src/public-types/socket.public-types.d.ts +5 -0
  37. package/dist/internal-common/src/public-types/topic.public-context.d.ts +10 -0
  38. package/dist/internal-common/src/public-types/typescript.public-types.d.ts +15 -0
  39. package/dist/internal-common/src/public-utils/id-utils.d.ts +6 -0
  40. package/dist/internal-common/src/types/ai-assistant.types.d.ts +1 -0
  41. package/dist/internal-common/src/types/ai-chatbot.types.d.ts +1 -0
  42. package/dist/internal-common/src/types/api.types.d.ts +2 -0
  43. package/dist/internal-common/src/types/backend-function.types.d.ts +1 -0
  44. package/dist/internal-common/src/types/backend-run.types.d.ts +1 -0
  45. package/dist/internal-common/src/types/bundle-data.types.d.ts +1 -0
  46. package/dist/internal-common/src/types/communication.types.d.ts +1 -0
  47. package/dist/internal-common/src/types/document.types.d.ts +1 -0
  48. package/dist/internal-common/src/types/mutation.types.d.ts +1 -0
  49. package/dist/internal-common/src/types/openapi.types.d.ts +1 -0
  50. package/dist/internal-common/src/types/query.types.d.ts +1 -0
  51. package/dist/internal-common/src/types/secret.types.d.ts +11 -0
  52. package/dist/internal-common/src/types/socket.types.d.ts +1 -0
  53. package/dist/internal-common/src/utils/array.d.ts +1 -0
  54. package/dist/internal-common/src/utils/assert.d.ts +1 -0
  55. package/dist/internal-common/src/utils/global.utils.d.ts +1 -0
  56. package/dist/internal-common/src/utils/http.d.ts +2 -0
  57. package/dist/internal-common/src/utils/lock.manager.d.ts +14 -0
  58. package/dist/internal-common/src/utils/object.d.ts +5 -0
  59. package/dist/internal-common/src/utils/serialization.d.ts +5 -0
  60. package/dist/internal-common/src/utils/validation.d.ts +24 -0
  61. package/dist/internal-common/src/websocket.impl.d.ts +21 -0
  62. package/dist/node_modules/json-schema-typed/draft-2020-12.d.ts +1239 -0
  63. package/dist/typescript-client/src/ai-assistant-client.d.ts +73 -0
  64. package/dist/typescript-client/src/ai-chatbot-client.d.ts +168 -0
  65. package/dist/typescript-client/src/ai-chatbot-client.factory.d.ts +1 -0
  66. package/dist/typescript-client/src/ai.types.d.ts +60 -0
  67. package/dist/typescript-client/src/api.manager.d.ts +11 -0
  68. package/dist/typescript-client/src/auth.manager.d.ts +27 -0
  69. package/dist/typescript-client/src/backend-function.manager.d.ts +9 -0
  70. package/dist/typescript-client/src/backend-transforms.d.ts +0 -0
  71. package/dist/typescript-client/src/client-id.service.d.ts +27 -0
  72. package/dist/typescript-client/src/collection-reference.d.ts +80 -0
  73. package/dist/typescript-client/src/collection-reference.factory.d.ts +1 -0
  74. package/dist/typescript-client/src/connection-details.d.ts +23 -0
  75. package/dist/typescript-client/src/data.manager.d.ts +5 -0
  76. package/dist/typescript-client/src/destruct.manager.d.ts +13 -0
  77. package/dist/typescript-client/src/distributed-lock.manager.d.ts +16 -0
  78. package/dist/typescript-client/src/document-identity.service.d.ts +1 -0
  79. package/dist/typescript-client/src/document-reference.d.ts +149 -0
  80. package/dist/typescript-client/src/document-reference.factory.d.ts +1 -0
  81. package/dist/typescript-client/src/document-store.d.ts +14 -0
  82. package/dist/typescript-client/src/graphql-client.d.ts +14 -0
  83. package/dist/typescript-client/src/graphql-client.factory.d.ts +11 -0
  84. package/dist/typescript-client/src/index.d.ts +11 -0
  85. package/dist/typescript-client/src/mutation/mutation-sender.d.ts +1 -0
  86. package/dist/typescript-client/src/native-query-manager.d.ts +7 -0
  87. package/dist/typescript-client/src/public-types.d.ts +37 -0
  88. package/dist/typescript-client/src/public-utils.d.ts +1 -0
  89. package/dist/typescript-client/src/query/deserializer.d.ts +3 -0
  90. package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +161 -0
  91. package/dist/typescript-client/src/query/local-query-manager.d.ts +1 -0
  92. package/dist/typescript-client/src/query/query-builder.factory.d.ts +77 -0
  93. package/dist/typescript-client/src/query/query-sender.d.ts +1 -0
  94. package/dist/typescript-client/src/query/query-subscription.manager.d.ts +2 -0
  95. package/dist/typescript-client/src/query/query.types.d.ts +49 -0
  96. package/dist/typescript-client/src/queue.manager.d.ts +7 -0
  97. package/dist/typescript-client/src/rate-limiter.d.ts +32 -0
  98. package/dist/typescript-client/src/rpc.manager.d.ts +30 -0
  99. package/dist/typescript-client/src/secret.client.d.ts +23 -0
  100. package/dist/typescript-client/src/socket.manager.d.ts +1 -0
  101. package/dist/typescript-client/src/squid.d.ts +245 -0
  102. package/dist/typescript-client/src/state/state.service.spec.d.ts +1 -0
  103. package/dist/typescript-client/src/testing/setup-tests.d.ts +1 -0
  104. package/dist/typescript-client/src/types.d.ts +6 -0
  105. package/package.json +3 -1
@@ -0,0 +1,14 @@
1
+ import { Paths } from './typescript.public-types';
2
+ import { BeforeAndAfterDocs } from './document.public-types';
3
+ import { Mutation, MutationType } from './mutation.public-types';
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,53 @@
1
+ import { SquidDocIdObj } from './document.public-types';
2
+ interface BaseMutation {
3
+ type: MutationType;
4
+ squidDocIdObj: SquidDocIdObj;
5
+ }
6
+ /** A mutation on a document. */
7
+ export type Mutation<T = any> = UpdateMutation<T> | InsertMutation<T> | DeleteMutation;
8
+ /** The mutation type. */
9
+ export type MutationType = 'insert' | 'update' | 'delete';
10
+ export interface DeleteMutation extends BaseMutation {
11
+ type: 'delete';
12
+ }
13
+ export interface UpdateMutation<T = any> extends BaseMutation {
14
+ type: 'update';
15
+ /** The updated properties */
16
+ properties: {
17
+ [key in keyof T & string]?: Array<PropertyMutation<T[key]>>;
18
+ };
19
+ }
20
+ export interface InsertMutation<T = any> extends BaseMutation {
21
+ type: 'insert';
22
+ /** The inserted document */
23
+ properties: T;
24
+ }
25
+ /** A representation of a single property update */
26
+ export type PropertyMutation<Value = any> = ApplyNumericFnPropertyMutation | ApplyStringFnPropertyMutation | ValueUpdatePropertyMutation<Value> | RemovePropertyMutation;
27
+ /** A value update property mutation */
28
+ export interface ValueUpdatePropertyMutation<Value = any> {
29
+ type: 'update';
30
+ value: Value;
31
+ }
32
+ /** Applying a numeric function to a property */
33
+ export interface ApplyNumericFnPropertyMutation {
34
+ type: 'applyNumericFn';
35
+ fn: 'increment';
36
+ value: number;
37
+ }
38
+ /** A property update that removes a property from a document */
39
+ export interface RemovePropertyMutation {
40
+ type: 'removeProperty';
41
+ }
42
+ interface ApplyExtendString {
43
+ type: 'applyStringFn';
44
+ fn: 'extendString';
45
+ value: string;
46
+ }
47
+ interface ApplyTrimString {
48
+ type: 'applyStringFn';
49
+ fn: 'trim';
50
+ }
51
+ /** A property mutation that modifies a string */
52
+ export type ApplyStringFnPropertyMutation = ApplyExtendString | ApplyTrimString;
53
+ export {};
@@ -0,0 +1,7 @@
1
+ import { ClientId } from './communication.public-types';
2
+ /** The context provided to the secure native query function. */
3
+ export declare class NativeQueryContext {
4
+ readonly query: string;
5
+ readonly params: Record<string, any>;
6
+ readonly clientId: ClientId;
7
+ }
@@ -0,0 +1,16 @@
1
+ export type NativeQueryRequestType = 'relational' | 'mongo';
2
+ interface BaseNativeQueryRequest {
3
+ type: NativeQueryRequestType;
4
+ }
5
+ export interface RelationalNativeQueryRequest extends BaseNativeQueryRequest {
6
+ type: 'relational';
7
+ query: string;
8
+ params: Record<string, any>;
9
+ }
10
+ export interface MongoNativeQueryRequest extends BaseNativeQueryRequest {
11
+ type: 'mongo';
12
+ collectionName: string;
13
+ aggregationPipeline: Array<any | undefined>;
14
+ }
15
+ export type NativeQueryRequest = RelationalNativeQueryRequest | MongoNativeQueryRequest;
16
+ export {};
@@ -0,0 +1,62 @@
1
+ import { Observable } from 'rxjs';
2
+ /** The state of a pagination. */
3
+ export interface PaginationState<ReturnType> {
4
+ /** The page data. */
5
+ data: Array<ReturnType>;
6
+ /** Whether there is a next page. */
7
+ hasNext: boolean;
8
+ /** Whether there is a previous page. */
9
+ hasPrev: boolean;
10
+ }
11
+ /** Pagination options */
12
+ export interface PaginationOptions {
13
+ /** Whether to show real-time updates. Defaults to true. */
14
+ subscribe: boolean;
15
+ /** The number of items in a page. Defaults to 100. */
16
+ pageSize: number;
17
+ }
18
+ interface InternalState<ReturnType> {
19
+ data: ReturnType[];
20
+ extractedData: any[];
21
+ numBefore: number;
22
+ numAfter: number;
23
+ }
24
+ export declare class Pagination<ReturnType> {
25
+ private readonly options;
26
+ private internalStateObserver;
27
+ private firstElement;
28
+ private readonly isDestroyed;
29
+ private templateSnapshotEmitter;
30
+ private snapshotSubject;
31
+ private onFirstPage;
32
+ private navigatingToLastPage;
33
+ private lastElement;
34
+ private goToFirstPage;
35
+ private static compareValues;
36
+ private compare;
37
+ private dataReceived;
38
+ private doNewQuery;
39
+ private waitForInternalState;
40
+ private internalStateToState;
41
+ /** Unsubscribes from the pagination. */
42
+ unsubscribe(): void;
43
+ prevInternal(internalState: InternalState<ReturnType>): void;
44
+ /** Returns a promise that resolves when the previous page of data is available. */
45
+ prev(): Promise<PaginationState<ReturnType>>;
46
+ /** Returns a promise that resolves when the next page of data is available. */
47
+ next(): Promise<PaginationState<ReturnType>>;
48
+ /** Returns a promise that resolves when the page data is available. */
49
+ waitForData(): Promise<PaginationState<ReturnType>>;
50
+ /** Returns an observable that emits the current state of the pagination. */
51
+ observeState(): Observable<PaginationState<ReturnType>>;
52
+ /** Jumps to the first page of the pagination. */
53
+ first(): Promise<PaginationState<ReturnType>>;
54
+ /** Refreshes the current page of the pagination. */
55
+ refreshPage(): Promise<PaginationState<ReturnType>>;
56
+ /**
57
+ * Jumps to the last page of the pagination. This page will always have the last <pageSize> elements of the
58
+ * underlying query, regardless of whether the total document count is evenly divisible by the page size.
59
+ */
60
+ last(): Promise<PaginationState<ReturnType>>;
61
+ }
62
+ export {};
@@ -0,0 +1,137 @@
1
+ import { FieldSort, Operator, Query, SimpleCondition } from './query.public-types';
2
+ import { DeepRecord, FieldOf, PartialBy, Paths } from './typescript.public-types';
3
+ import { CollectionName, DocumentData } from './document.public-types';
4
+ import { IntegrationId } from './communication.public-types';
5
+ export declare class QueryContext<T extends DocumentData = any> {
6
+ readonly query: Query<T>;
7
+ private readonly parsedConditions;
8
+ /**
9
+ * The ID of the integration being queried.
10
+ */
11
+ get integrationId(): IntegrationId;
12
+ /**
13
+ * The name of the collection being queried.
14
+ */
15
+ get collectionName(): CollectionName;
16
+ /**
17
+ * The query limit if one exists, -1 otherwise.
18
+ */
19
+ get limit(): number;
20
+ /**
21
+ * Verifies that the query's sort order aligns with the provided field sorts. The fields specified in the `sorts`
22
+ * parameter must appear in the exact order at the beginning of the query's sort sequence. The query can include
23
+ * additional fields in its sort order, but only after the specified sorts.
24
+ *
25
+ * @param sorts An array of field sorts.
26
+ * @returns Whether the query's sorts matches the provided field sorts.
27
+ */
28
+ sortedBy(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
29
+ /**
30
+ * Verifies that the query's sort order exactly matches the provided field sorts. The fields specified in the
31
+ * `sorts` parameter must appear in the exact order in the query's sort sequence. No additional sorts may be present
32
+ * in the query.
33
+ *
34
+ * @param sorts An array of field sorts.
35
+ * @returns Whether the query's sorts exactly match the provided field sorts.
36
+ */
37
+ sortedByExact(sorts: Array<PartialBy<FieldSort<T>, 'asc'>>): boolean;
38
+ /**
39
+ * Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
40
+ * to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
41
+ * additional conditions, as these only narrow the result set.
42
+ *
43
+ * @param fieldName The name of the field for the condition.
44
+ * @param operator The operator of the condition.
45
+ * @param value The value of the condition.
46
+ * @returns Whether the query is a subquery of the parent condition.
47
+ */
48
+ isSubqueryOf<F extends Paths<T>, O extends AllOperators>(fieldName: F, operator: O, value: GenericValue<T, F, O> | null): boolean;
49
+ /**
50
+ * Verifies that the query is a subquery of the specified condition. A subquery is defined as a query that evaluates
51
+ * to a subset of the results that would be obtained by applying the parent condition. The subquery may also include
52
+ * additional conditions, as these only narrow the result set.
53
+ *
54
+ * @param condition The condition to validate.
55
+ * @returns Whether the query is a subquery of the parent condition.
56
+ */
57
+ isSubqueryOfCondition(condition: GeneralCondition<T>): boolean;
58
+ /**
59
+ * Verifies that the query is a subquery of the specified conditions. A subquery is defined as a query that evaluates
60
+ * to a subset of the results that would be obtained by applying the parent conditions. The subquery may also include
61
+ * additional conditions, as these only narrow the result set.
62
+ *
63
+ * @param conditions The conditions to validate.
64
+ * @returns Whether the query includes subquery of the parent conditions.
65
+ */
66
+ isSubqueryOfConditions(conditions: GeneralConditions<T>): boolean;
67
+ /**
68
+ * Verifies that the query is a subquery of the specified query. A subquery is defined as a query that evaluates
69
+ * to a subset of the results that obtained for the parent query, including sorts and limits.
70
+ *
71
+ * @param query The query to validate.
72
+ * @returns Whether the query is a subquery of the parent query.
73
+ */
74
+ isSubqueryOfQuery(query: Query<T>): boolean;
75
+ /**
76
+ * Returns all conditions that apply to any of the specified field names. This method
77
+ * provides a convenient way to retrieve all conditions that involve a specific set of fields.
78
+ *
79
+ * @param fieldNames The field names for which to retrieve conditions.
80
+ * @returns An array of conditions that involve any of the specified field names.
81
+ */
82
+ getConditionsFor<K extends Paths<T>>(...fieldNames: Array<K>): ContextConditions<T, K>;
83
+ /**
84
+ * Returns all conditions that apply to the specified field name. This method provides
85
+ * a convenient way to retrieve all conditions that involve a specific field.
86
+ *
87
+ * @param fieldName The field name for which to retrieve conditions.
88
+ * @returns An array of conditions that involve the specified field name.
89
+ */
90
+ getConditionsForField<K extends Paths<T>>(fieldName: K): ContextConditions<T>;
91
+ /**
92
+ * Returns true if the given document can be a result of the query.
93
+ * The method does not account for limit and sort order.
94
+ */
95
+ documentMatchesQuery(doc: DocumentData): boolean;
96
+ /**
97
+ * Compares a condition against a given operator and value to determine if the
98
+ * provided condition is a subset of the operator and value. A condition is
99
+ * considered a subset if all values that satisfy (return true for) the
100
+ * condition also satisfy the operator and value.
101
+ *
102
+ * This is done using the underlying CompareTable, which provides a comparison
103
+ * function for each operator pair, or undefined if the comparison would
104
+ * always be false, regardless of the values.
105
+ */
106
+ private evaluateSubset;
107
+ private evaluateIncludes;
108
+ private parseConditions;
109
+ }
110
+ /** A list of context conditions */
111
+ export type ContextConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<ContextCondition<Doc, F>>;
112
+ /** A Context condition - a condition that replaces multiple '==' or '!=' conditions with 'in' and 'not in'. */
113
+ type ContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = InContextCondition<Doc, F> | NotInContextCondition<Doc, F> | OtherContextCondition<Doc, F>;
114
+ interface InContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'in'> {
115
+ operator: 'in';
116
+ value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
117
+ }
118
+ interface NotInContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, 'not in'> {
119
+ operator: 'not in';
120
+ value: Array<FieldOf<DeepRecord<Doc>, Paths<Doc>> | any>;
121
+ }
122
+ interface OtherContextCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, Exclude<ContextOperator, 'in' | 'not in'>> {
123
+ operator: Exclude<ContextOperator, 'in' | 'not in'>;
124
+ value: FieldOf<DeepRecord<Doc>, Paths<Doc>> | any;
125
+ }
126
+ /** A condition that includes the 'in' and 'not in' operators. */
127
+ interface GeneralCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> extends SimpleCondition<Doc, F, AllOperators> {
128
+ operator: AllOperators;
129
+ value: any;
130
+ }
131
+ /** A list of general conditions. */
132
+ type GeneralConditions<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>> = Array<GeneralCondition<Doc, F>>;
133
+ type ContextOperator = Exclude<Operator, '==' | '!='> | 'in' | 'not in';
134
+ type AllOperators = Operator | 'in' | 'not in';
135
+ /** A generic value that can exist in a query. */
136
+ 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;
137
+ export {};
@@ -0,0 +1,64 @@
1
+ import { CollectionName, DocumentData, FieldName } from './document.public-types';
2
+ import { Paths } from './typescript.public-types';
3
+ import { ClientRequestId } from './communication.public-types';
4
+ /**
5
+ * An alias for a join result. This is used to disambiguate fields in the result.
6
+ */
7
+ export type Alias = string;
8
+ /**
9
+ * A join condition.
10
+ * The join conditions defines the alias for the left side of the join and the field names to join on.
11
+ */
12
+ export interface JoinCondition {
13
+ leftAlias: Alias;
14
+ left: FieldName;
15
+ right: FieldName;
16
+ isInner: boolean;
17
+ }
18
+ /** A list of query conditions. */
19
+ export type Condition<Doc extends DocumentData = any> = SimpleCondition<Doc> | CompositeCondition<Doc>;
20
+ export type Conditions<Doc extends DocumentData = any> = Array<Condition<Doc>>;
21
+ /** A single field query condition. */
22
+ export interface SimpleCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>, MyOperator = Operator> {
23
+ fieldName: F;
24
+ operator: MyOperator;
25
+ value: any;
26
+ }
27
+ /**
28
+ * A composite fields query condition.
29
+ * Just a list of simple conditions with specific set of operators. It should be
30
+ * evaluated this way:
31
+ * If A, B, C are the conditions and A` = A with '==' operator:
32
+ * A || (A' && B) || (A' && B' && C)
33
+ */
34
+ export interface CompositeCondition<Doc extends DocumentData = any> {
35
+ fields: Array<SimpleCondition<Doc, Paths<Doc>, CompositeConditionOperator>>;
36
+ }
37
+ export declare function isSimpleCondition(condition: Condition): condition is SimpleCondition;
38
+ type CompositeConditionOperator = '>=' | '<=' | '>' | '<';
39
+ /** An operator in a query condition. */
40
+ export type Operator = '==' | '!=' | CompositeConditionOperator | 'like' | 'not like' | 'like_cs' | 'not like_cs';
41
+ /** A definition of a sort by a filed. */
42
+ export interface FieldSort<Doc> {
43
+ fieldName: FieldName<Doc>;
44
+ asc: boolean;
45
+ }
46
+ /** A query object. */
47
+ export interface Query<Doc extends DocumentData = any> {
48
+ collectionName: CollectionName;
49
+ integrationId: string;
50
+ conditions: Conditions<Doc>;
51
+ sortOrder: Array<FieldSort<Doc>>;
52
+ limit: number;
53
+ limitBy?: {
54
+ limit: number;
55
+ fields: Array<FieldName<Doc>>;
56
+ reverseSort: boolean;
57
+ };
58
+ }
59
+ export interface QueryRegisterRequest {
60
+ clientRequestId: ClientRequestId;
61
+ query: Query;
62
+ parentClientRequestId: ClientRequestId;
63
+ }
64
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The list of supported Squid regions.
3
+ */
4
+ export declare const SUPPORTED_SQUID_REGIONS: readonly ["us-east-1.aws"];
5
+ export type SupportedSquidRegion = (typeof SUPPORTED_SQUID_REGIONS)[number];
@@ -0,0 +1,46 @@
1
+ import { JSONSchema } from 'json-schema-typed';
2
+ type ConvertDeep<T extends JSONSchema> = Exclude<T, boolean> & {
3
+ properties?: Record<string, ConvertDeep<JSONSchema>>;
4
+ patternProperties?: Record<string, ConvertDeep<JSONSchema>>;
5
+ nullable?: boolean;
6
+ /**
7
+ * The default value will be applied (default to 'empty'):
8
+ * 'always' - no matter what the client sent, both on update and insert. In case of readOnly - applies only on insert.
9
+ * 'empty' - only if the value of the field is empty (undefined)
10
+ * 'updateOrEmpty' - no matter what the client sent, updating the record will use the default value
11
+ */
12
+ applyDefaultValueOn?: 'always' | 'empty' | 'updateOrEmpty';
13
+ isDate?: boolean;
14
+ isJSON?: boolean;
15
+ /**
16
+ * Applies to the top level schema, a record in a nested object, or a regular property.
17
+ * Basically, whether this property can participate in an insert mutation.
18
+ */
19
+ insertable?: boolean;
20
+ /** Applies to the top level schema or a record in a nested object. */
21
+ deletable?: boolean;
22
+ };
23
+ export type PropertySchema = ConvertDeep<JSONSchema>;
24
+ export type TopLevelPropertySchema = PropertySchema & {
25
+ primaryKey?: boolean;
26
+ /**
27
+ * Whether the property is computed based on other properties or some formula.
28
+ * If true, readonly also needs to be true and this field should not be part of an insert statement.
29
+ */
30
+ isComputed?: boolean;
31
+ /**
32
+ * Whether the default value generated by the database. CURRENT_DATE is something generated by the database vs
33
+ * 'Hello' which is a constant.
34
+ */
35
+ isDefaultComputed?: boolean;
36
+ /**
37
+ * The database data type that is represented by this property. This is often different from the actual property
38
+ * type, with is a Javascript primitive. For example, for a SMALLINT the dataType would be 'smallint', but the type
39
+ * would be 'integer'.
40
+ */
41
+ dataType?: string;
42
+ };
43
+ export type CollectionSchema = Omit<ConvertDeep<JSONSchema>, 'properties'> & {
44
+ properties?: Record<string, TopLevelPropertySchema>;
45
+ };
46
+ export {};
@@ -0,0 +1,16 @@
1
+ /** A type alias for an ApiKey. */
2
+ export type ApiKey = string;
3
+ /** The secret key, an alias for a string. */
4
+ export type SecretKey = string;
5
+ /** The secret value. */
6
+ export type SecretValue = string | number | boolean;
7
+ export interface SecretMetadata {
8
+ key: SecretKey;
9
+ lastUpdated: number;
10
+ }
11
+ export interface SecretEntry<T extends SecretValue = SecretValue> extends SecretMetadata {
12
+ value: T;
13
+ }
14
+ export interface ApiKeyEntry extends SecretMetadata {
15
+ value: string;
16
+ }
@@ -0,0 +1,24 @@
1
+ import { DocumentData } from './document.public-types';
2
+ import { Alias, JoinCondition, Query } from './query.public-types';
3
+ export type SerializedSimpleQuery = {
4
+ type: 'simple';
5
+ query: Query;
6
+ dereference: boolean;
7
+ };
8
+ export type SerializedJoinQuery = {
9
+ type: 'join';
10
+ grouped: boolean;
11
+ dereference: boolean;
12
+ root: {
13
+ alias: Alias;
14
+ query: Query;
15
+ };
16
+ leftToRight: Record<Alias, Alias[]>;
17
+ joins: Record<Alias, Query<DocumentData>>;
18
+ joinConditions: Record<Alias, JoinCondition>;
19
+ };
20
+ export type SerializedMergedQuery = {
21
+ type: 'merged';
22
+ queries: Array<SerializedQuery>;
23
+ };
24
+ export type SerializedQuery = SerializedSimpleQuery | SerializedJoinQuery | SerializedMergedQuery;
@@ -0,0 +1,5 @@
1
+ export declare enum ClientConnectionState {
2
+ CONNECTED = "CONNECTED",
3
+ DISCONNECTED = "DISCONNECTED",
4
+ REMOVED = "REMOVED"
5
+ }
@@ -0,0 +1,10 @@
1
+ import { IntegrationId } from './communication.public-types';
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
+ }
@@ -0,0 +1,15 @@
1
+ export interface Type<T> extends Function {
2
+ new (...args: any[]): T;
3
+ }
4
+ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
5
+ type PropertiesWithPrefix<Prefix extends string> = {
6
+ [key in `${Prefix}${string}`]: any;
7
+ };
8
+ type Pred = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
9
+ export type DeepRecord<T, RemainingDepth extends number & keyof Pred = 5, Prefix extends string = ''> = RemainingDepth extends 0 ? PropertiesWithPrefix<Prefix> : {
10
+ [k in keyof T]-?: k extends string | number ? Record<`${Prefix}${k}`, T[k]> | (Required<T>[k] extends any[] ? never : Required<T>[k] extends object ? DeepRecord<Required<T>[k], Pred[RemainingDepth], `${Prefix}${k}.`> : never) : never;
11
+ }[keyof T];
12
+ export type UnionKeys<T> = T extends any ? keyof T : never;
13
+ export type FieldOf<T, K extends UnionKeys<T>> = Extract<T, Record<K, any>>[K];
14
+ export type Paths<T> = UnionKeys<DeepRecord<T>>;
15
+ export {};
@@ -0,0 +1,6 @@
1
+ /** Generates a UUID-style ID. */
2
+ export declare function generateId(): string;
3
+ /** Default length if ID produced by `generateShortId`. */
4
+ export declare const DEFAULT_SHORT_ID_LENGTH = 18;
5
+ /** Generates an ID of the given `length` using lowercase latin letters and digits.. */
6
+ export declare function generateShortId(length?: number): string;
@@ -0,0 +1,2 @@
1
+ /** The query parameters of an API call. */
2
+ export type ApiQueryParams = Record<string, string | number | boolean>;
@@ -0,0 +1 @@
1
+ export type ChatId = string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { SecretKey, SecretValue } from '../public-types/secret.public-types';
2
+ export type SetSecretEntry = {
3
+ key: SecretKey;
4
+ value?: SecretValue;
5
+ };
6
+ export declare const BACKEND_API_KEY = "_BACKEND_API_KEY";
7
+ export declare const APP_API_KEY = "APP_API_KEY";
8
+ export interface SetSecretRequestEntry {
9
+ key: SecretKey;
10
+ value: SecretValue;
11
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function getApplicationUrl(regionPrefix: string, appId: string, path: string): string;
2
+ export declare function getApplicationHttpHeaders(regionPrefix: string, appId: string): Record<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,5 @@
1
+ export declare function getInPath(obj: Readonly<Record<string, unknown>>, path: string, delimiter?: string): any;
2
+ export declare function setInPath(obj: object, path: string, value: unknown, delimiter?: string): void;
3
+ export declare function deleteInPath(obj: object, path: string, delimiter?: string): void;
4
+ export declare function replaceKeyInMap<K, T>(map: Map<K, T | undefined>, a: K, b: K): void;
5
+ export declare function replaceKeyInRecord<K extends keyof any, T>(record: Record<K, T>, a: K, b: K): void;
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,24 @@
1
+ import { HttpStatus } from '../public-types/http-status.enum';
2
+ export type StatusCode = HttpStatus.BAD_REQUEST | HttpStatus.NOT_FOUND | HttpStatus.FORBIDDEN | HttpStatus.UNAUTHORIZED | HttpStatus.CONFLICT;
3
+ export declare class ValidationError extends Error {
4
+ readonly statusCode: StatusCode;
5
+ readonly details?: any;
6
+ constructor(error: string, statusCode: StatusCode, details?: Record<string, any>);
7
+ }
8
+ export declare function isValidId(id: unknown): boolean;
9
+ export declare function validateId(id: unknown, message: string): void;
10
+ export declare function validateFieldSort(fieldSort: unknown): void;
11
+ export declare function validateMutations(mutations: unknown): void;
12
+ export declare function validateQueryLimit(limit: unknown): void;
13
+ /** Returns true if the value is not an empty string (undefined/null are considered empty). */
14
+ export declare function isNotEmpty(value: string | undefined | null): value is string;
15
+ /**
16
+ * All type names returned by 'typeof' supported by JavaScript:
17
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof}.
18
+ * and a few other supported types.
19
+ */
20
+ export type JavascriptTypeName = 'undefined' | 'object' | 'boolean' | 'number' | 'bigint' | 'string' | 'symbol' | 'function';
21
+ /** Returns true if 'typeof' of the 'value' is 'type' or 'type[]'. */
22
+ export declare function isRightType(value: unknown, type: JavascriptTypeName): boolean;
23
+ /** Returns true if 'obj' has only keys listed in the 'keys'. Object can't be an array. */
24
+ export declare function hasOnlyKeys(obj: object, keys: string[]): boolean;
@@ -0,0 +1,21 @@
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
+ timeout?: 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
+ export declare function createWebSocketWrapper(url: string, opts?: Options): WebSocketWrapper;
21
+ export {};