@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,6 +1,8 @@
|
|
|
1
1
|
import { JSONSchema } from 'json-schema-typed';
|
|
2
2
|
export type FieldPlaceholder = '__SQUID_SERVER_TIMESTAMP__' | '__SQUID_CLIENT_IP__' | '__SQUID_USER_ID__' | '__SQUID_API_KEY__';
|
|
3
|
-
export type
|
|
3
|
+
export type BasicFieldType = 'string' | 'integer' | 'number' | 'boolean' | 'map' | 'array' | 'any';
|
|
4
|
+
export type CustomFieldType = 'date' | 'json';
|
|
5
|
+
export type SupportedFieldType = BasicFieldType | CustomFieldType;
|
|
4
6
|
export declare const SUPPORTED_FIELD_TYPES_ARRAY: Array<SupportedFieldType>;
|
|
5
7
|
type ConvertDeep<T extends JSONSchema> = Exclude<T, boolean> & {
|
|
6
8
|
properties?: Record<string, ConvertDeep<JSONSchema>>;
|
|
@@ -13,6 +15,7 @@ type ConvertDeep<T extends JSONSchema> = Exclude<T, boolean> & {
|
|
|
13
15
|
*/
|
|
14
16
|
applyDefaultValueOn?: 'always' | 'empty' | 'updateOrEmpty';
|
|
15
17
|
isDate?: boolean;
|
|
18
|
+
isJSON?: boolean;
|
|
16
19
|
/**
|
|
17
20
|
* Applies to the top level schema, a record in a nested object, or a regular property.
|
|
18
21
|
* Basically, whether this property can participate in an insert mutation.
|
|
@@ -24,6 +27,22 @@ type ConvertDeep<T extends JSONSchema> = Exclude<T, boolean> & {
|
|
|
24
27
|
export type PropertySchema = ConvertDeep<JSONSchema>;
|
|
25
28
|
export type TopLevelPropertySchema = PropertySchema & {
|
|
26
29
|
primaryKey?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the property is computed based on other properties or some formula.
|
|
32
|
+
* If true, readonly also needs to be true and this field should not be part of an insert statement.
|
|
33
|
+
*/
|
|
34
|
+
isComputed?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the default value generated by the database. CURRENT_DATE is something generated by the database vs
|
|
37
|
+
* 'Hello' which is a constant.
|
|
38
|
+
*/
|
|
39
|
+
isDefaultComputed?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The database data type that is represented by this property. This is often different from the actual property
|
|
42
|
+
* type, with is a Javascript primitive. For example, for a SMALLINT the dataType would be 'smallint', but the type
|
|
43
|
+
* would be 'integer'.
|
|
44
|
+
*/
|
|
45
|
+
dataType?: string;
|
|
27
46
|
};
|
|
28
47
|
export type CollectionSchema = ConvertDeep<JSONSchema> & {
|
|
29
48
|
properties?: Record<string, TopLevelPropertySchema>;
|
|
@@ -18,7 +18,15 @@ export interface SecretEntry extends SecretMetadata {
|
|
|
18
18
|
value: SecretValue;
|
|
19
19
|
}
|
|
20
20
|
export type SetCustomSecretRequest = Omit<SecretEntry, 'lastUpdated'>;
|
|
21
|
-
export
|
|
21
|
+
export interface DeleteCustomSecretRequest {
|
|
22
|
+
key: SecretKey;
|
|
23
|
+
}
|
|
24
|
+
export interface GetApiKeyRequest {
|
|
25
|
+
apiKeyName: ApiKeyName;
|
|
26
|
+
}
|
|
27
|
+
export interface GetApiKeyResponse {
|
|
28
|
+
apiKey: string | undefined;
|
|
29
|
+
}
|
|
22
30
|
export type DeleteApiKeyRequest = Pick<SecretMetadata, 'key'>;
|
|
23
31
|
export interface ListApplicationSecretMetadataResponse {
|
|
24
32
|
custom: SecretMetadata[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClientId, ClientRequestId, IntegrationId } from './communication.types';
|
|
2
|
-
import { CollectionName, DocTimestamp,
|
|
2
|
+
import { CollectionName, DocTimestamp, SquidDocId, SquidDocument } from './document.types';
|
|
3
3
|
import { MutationType } from './mutation.types';
|
|
4
4
|
export type MessageId = string;
|
|
5
5
|
export type MessageFromClientType = 'acknowledge' | 'catchup' | 'kill';
|
|
@@ -47,14 +47,14 @@ export interface MutationsMessageToClient extends BaseMessageToClient {
|
|
|
47
47
|
payload: Array<MutationResultData>;
|
|
48
48
|
}
|
|
49
49
|
export interface MutationResultData {
|
|
50
|
-
|
|
50
|
+
squidDocId: SquidDocId;
|
|
51
51
|
clientRequestId: ClientRequestId;
|
|
52
52
|
mutationType: MutationType;
|
|
53
53
|
mutationTimestamp: DocTimestamp;
|
|
54
|
-
doc:
|
|
54
|
+
doc: SquidDocument | undefined;
|
|
55
55
|
}
|
|
56
56
|
export interface QueryResultData {
|
|
57
|
-
docs: Array<
|
|
57
|
+
docs: Array<SquidDocument>;
|
|
58
58
|
integrationId: IntegrationId;
|
|
59
59
|
collectionName: CollectionName;
|
|
60
60
|
clientRequestId: ClientRequestId;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { ServiceFunctionName } from './bundle-data.types';
|
|
2
2
|
import { AppId } from './communication.types';
|
|
3
|
-
import {
|
|
4
|
-
import { DocType, FullDocIdStr } from './document.types';
|
|
3
|
+
import { SquidDocId, SquidDocument } from './document.types';
|
|
5
4
|
import { MutationType } from './mutation.types';
|
|
6
5
|
export interface DocTriggerParams {
|
|
7
|
-
|
|
6
|
+
squidDocId: SquidDocId;
|
|
8
7
|
mutationType: MutationType;
|
|
9
|
-
docBefore?:
|
|
10
|
-
docAfter?:
|
|
11
|
-
auth: Auth | undefined;
|
|
8
|
+
docBefore?: SquidDocument;
|
|
9
|
+
docAfter?: SquidDocument;
|
|
12
10
|
}
|
|
13
11
|
export interface TriggerMessage {
|
|
14
12
|
params: DocTriggerParams;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { StatusCode } from './validation';
|
|
2
2
|
export type AssertErrorProvider = () => Error | string;
|
|
3
3
|
export declare function assertTruthy(value: unknown, error?: string | Error | AssertErrorProvider): asserts value;
|
|
4
|
+
export declare function assertDefined(value: unknown, error?: string | Error | AssertErrorProvider): asserts value;
|
|
4
5
|
export declare function assertValidateTruthy(value: unknown, message: string, statusCode?: StatusCode, details?: Record<string, any>): asserts value;
|
|
5
6
|
export declare function truthy<T>(value: T, error?: string | Error | AssertErrorProvider): NonNullable<T>;
|
|
7
|
+
export declare function defined<T>(value: T, error?: string | Error | AssertErrorProvider): NonNullable<T>;
|
|
6
8
|
export declare function validateTruthy<T>(value: T, message: string, statusCode?: StatusCode, details?: Record<string, any>): NonNullable<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateId(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isDefined<T>(t: T | undefined | null): t is T;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export declare function getInPath(obj: any, path: string): any;
|
|
2
|
-
export declare function setInPath(obj: any, path: string, value: any): void;
|
|
3
|
-
export declare function deleteInPath(obj: any, path: string): void;
|
|
1
|
+
export declare function getInPath(obj: any, path: string, delimiter?: string): any;
|
|
2
|
+
export declare function setInPath(obj: any, path: string, value: any, delimiter?: string): void;
|
|
3
|
+
export declare function deleteInPath(obj: any, path: string, delimiter?: string): void;
|
|
4
4
|
export declare function deepReplace(obj: any, keyName: string, replacer: (from: any) => any): void;
|
|
5
|
+
export declare function replaceKeyInMap<K, T>(map: Map<K, T | undefined>, a: K, b: K): void;
|
|
6
|
+
export declare function replaceKeyInRecord<K extends keyof any, T>(record: Record<K, T>, a: K, b: K): void;
|
|
@@ -3,3 +3,4 @@ export declare function serializeObj(obj: any): string;
|
|
|
3
3
|
export declare function deserializeObj<T = any>(serializedObj: string): T;
|
|
4
4
|
export declare function encodeValueForMapping(value: any): string;
|
|
5
5
|
export declare function decodeValueForMapping(encodedString: string): any;
|
|
6
|
+
export declare function recodeValue(value: any): any;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function unchanged(any: any): any;
|
|
2
|
+
export declare function booleanToInt(boolean: boolean): number;
|
|
3
|
+
export declare function intToBoolean(int: number): boolean;
|
|
4
|
+
export declare function stringToNumber(string: string): number;
|
|
5
|
+
export declare function numberToString(number: number): string;
|
|
6
|
+
export declare function bufferToString(buffer: ArrayBuffer): string;
|
|
7
|
+
export declare function stringToBuffer(string: string): ArrayBuffer;
|
|
8
|
+
export declare function stringToJSON(string: string): JSON;
|
|
9
|
+
export declare function JSONToString(json: JSON): string;
|
|
10
|
+
export declare function moneyStringToNumber(money: string): number;
|
|
11
|
+
export declare function daysPastEpochToDate(days: number): Date;
|
|
12
|
+
export declare function msToDate(ms: number): Date;
|
|
13
|
+
export declare function isoStringToDate(string: string): Date;
|
|
14
|
+
export declare function base64ToString(string: string): string;
|
|
15
|
+
export declare function base64ToBinary(string: string): string;
|
|
16
|
+
export declare function debeziumStringToInterval(string: string): Record<string, number>;
|
|
17
|
+
export declare function msPastMidnightToTimeString(ms: number): string;
|
|
18
|
+
export declare function dateToTimeString(date: Date): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getApplicationUrl(
|
|
1
|
+
export declare function getApplicationUrl(regionPrefix: string, appId: string): string;
|