hcloud-sdk 18.0.0 → 19.0.0
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/changelog.md +86 -175
- package/lib/Hcloud.d.ts +18 -3
- package/lib/Hcloud.js +113 -21
- package/lib/helper/ErrorHelper.js +5 -2
- package/lib/helper/ValidationHelper.d.ts +6 -4
- package/lib/helper/ValidationHelper.js +30 -18
- package/lib/interfaces/agent/logging/cloudwatch.d.ts +23 -0
- package/lib/interfaces/agent/logging/index.d.ts +2 -0
- package/lib/interfaces/{fuse → agent/logging}/index.js +2 -3
- package/lib/interfaces/agent/logging/log-collector.d.ts +35 -0
- package/lib/interfaces/agent/logging/log-collector.js +2 -0
- package/lib/interfaces/agent/module/index.d.ts +7 -0
- package/lib/interfaces/agent/module/index.js +2 -0
- package/lib/interfaces/auditor/index.d.ts +0 -1
- package/lib/interfaces/auditor/index.js +0 -1
- package/lib/interfaces/axios/index.d.ts +5 -0
- package/lib/interfaces/cosmo/asset/index.d.ts +40 -9
- package/lib/interfaces/cosmo/asset/index.js +9 -1
- package/lib/interfaces/cosmo/comment/index.d.ts +4 -1
- package/lib/interfaces/cosmo/event/index.d.ts +34 -5
- package/lib/interfaces/cosmo/event/index.js +16 -2
- package/lib/interfaces/cosmo/share/index.d.ts +89 -7
- package/lib/interfaces/cosmo/share/index.js +21 -0
- package/lib/interfaces/cosmo/space/index.d.ts +6 -0
- package/lib/interfaces/cosmo/stats/index.d.ts +11 -0
- package/lib/interfaces/cosmo/stats/index.js +2 -0
- package/lib/interfaces/cosmo/tag/tag.d.ts +2 -1
- package/lib/interfaces/global/Products.d.ts +0 -1
- package/lib/interfaces/global/Products.js +0 -1
- package/lib/interfaces/global/Views.d.ts +0 -1
- package/lib/interfaces/global/Views.js +0 -1
- package/lib/interfaces/high5/space/event/stream/design/StreamDesign.d.ts +1 -0
- package/lib/interfaces/high5/space/event/stream/node/index.d.ts +1 -0
- package/lib/interfaces/high5/space/execution/index.d.ts +1 -0
- package/lib/interfaces/high5/space/job/index.d.ts +64 -19
- package/lib/interfaces/high5/space/job/index.js +9 -6
- package/lib/interfaces/high5/wave/dependentInputs.d.ts +42 -0
- package/lib/interfaces/high5/wave/dependentInputs.js +144 -0
- package/lib/interfaces/high5/wave/dependentInputsValidation.d.ts +22 -0
- package/lib/interfaces/high5/wave/dependentInputsValidation.js +220 -0
- package/lib/interfaces/idp/index.d.ts +3 -3
- package/lib/interfaces/idp/index.js +3 -3
- package/lib/interfaces/idp/oauth/device.d.ts +18 -0
- package/lib/interfaces/idp/oauth/device.js +2 -0
- package/lib/interfaces/idp/oauth/index.d.ts +17 -4
- package/lib/interfaces/idp/organization/index.d.ts +1 -0
- package/lib/interfaces/idp/organization/index.js +1 -0
- package/lib/interfaces/idp/organization/settings/oauthApp/index.d.ts +4 -0
- package/lib/interfaces/idp/user/Message.d.ts +1 -0
- package/lib/interfaces/idp/user/Scopes.d.ts +1 -9
- package/lib/interfaces/idp/user/Scopes.js +0 -12
- package/lib/interfaces/idp/user/index.d.ts +3 -0
- package/lib/interfaces/mailer/index.d.ts +20 -1
- package/lib/interfaces/mailer/index.js +14 -2
- package/lib/interfaces/nats/index.d.ts +30 -32
- package/lib/interfaces/nats/index.js +103 -117
- package/lib/interfaces/shorts/index.d.ts +7 -0
- package/lib/interfaces/shorts/index.js +6 -0
- package/lib/service/agent/bundle/dev/index.js +4 -1
- package/lib/service/agent/bundle/index.js +4 -1
- package/lib/service/agent/context/index.js +4 -1
- package/lib/service/agent/index.d.ts +6 -0
- package/lib/service/agent/index.js +18 -1
- package/lib/service/agent/installer/index.js +4 -1
- package/lib/service/agent/logging/index.d.ts +69 -0
- package/lib/service/agent/logging/index.js +117 -0
- package/lib/service/agent/module/index.d.ts +36 -0
- package/lib/service/agent/module/index.js +65 -0
- package/lib/service/auditor/index.js +4 -1
- package/lib/service/auditor/internal/index.js +4 -1
- package/lib/service/bouncer/features/index.js +4 -1
- package/lib/service/bouncer/index.js +5 -2
- package/lib/service/cosmo/asset/index.d.ts +49 -3
- package/lib/service/cosmo/asset/index.js +111 -5
- package/lib/service/cosmo/comment/index.d.ts +7 -36
- package/lib/service/cosmo/comment/index.js +18 -43
- package/lib/service/cosmo/event/index.js +4 -1
- package/lib/service/cosmo/folder/index.js +4 -1
- package/lib/service/cosmo/index.d.ts +3 -0
- package/lib/service/cosmo/index.js +11 -1
- package/lib/service/cosmo/internal/index.js +4 -1
- package/lib/service/cosmo/internal/space/index.js +4 -1
- package/lib/service/cosmo/location/index.js +4 -1
- package/lib/service/cosmo/namespace/index.d.ts +15 -1
- package/lib/service/cosmo/namespace/index.js +21 -1
- package/lib/service/cosmo/organization/index.js +4 -1
- package/lib/service/cosmo/permissions/index.js +4 -1
- package/lib/service/cosmo/production/index.js +4 -1
- package/lib/service/cosmo/share/index.d.ts +37 -29
- package/lib/service/cosmo/share/index.js +47 -35
- package/lib/service/cosmo/space/index.d.ts +28 -1
- package/lib/service/cosmo/space/index.js +45 -1
- package/lib/service/cosmo/stats/index.d.ts +35 -0
- package/lib/service/cosmo/stats/index.js +58 -0
- package/lib/service/cosmo/tag/index.js +4 -1
- package/lib/service/dali/DaliAvatar.d.ts +0 -6
- package/lib/service/dali/DaliAvatar.js +4 -11
- package/lib/service/dali/avatar/DaliCosmoSpace.js +4 -1
- package/lib/service/dali/avatar/DaliHigh5Pool.d.ts +2 -1
- package/lib/service/dali/avatar/DaliHigh5Pool.js +5 -2
- package/lib/service/dali/avatar/DaliHigh5Space.d.ts +2 -1
- package/lib/service/dali/avatar/DaliHigh5Space.js +5 -2
- package/lib/service/dali/avatar/DaliOAuthApp.d.ts +2 -1
- package/lib/service/dali/avatar/DaliOAuthApp.js +5 -2
- package/lib/service/dali/avatar/DaliOrganization.d.ts +2 -1
- package/lib/service/dali/avatar/DaliOrganization.js +5 -2
- package/lib/service/dali/avatar/DaliServiceAccount.d.ts +1 -1
- package/lib/service/dali/avatar/DaliServiceAccount.js +6 -3
- package/lib/service/dali/avatar/DaliTeam.d.ts +2 -1
- package/lib/service/dali/avatar/DaliTeam.js +5 -2
- package/lib/service/dali/avatar/DaliUser.d.ts +2 -1
- package/lib/service/dali/avatar/DaliUser.js +5 -2
- package/lib/service/dali/index.js +4 -1
- package/lib/service/high5/execution/index.js +4 -1
- package/lib/service/high5/execution/log/index.js +4 -1
- package/lib/service/high5/execution/status/index.js +4 -1
- package/lib/service/high5/index.js +4 -1
- package/lib/service/high5/internal/index.js +4 -1
- package/lib/service/high5/internal/space/index.js +4 -1
- package/lib/service/high5/internal/space/job/index.js +4 -1
- package/lib/service/high5/internal/space/job/log/index.js +4 -1
- package/lib/service/high5/joinToken/index.js +4 -1
- package/lib/service/high5/space/database/document/array/index.js +4 -1
- package/lib/service/high5/space/database/document/index.js +4 -1
- package/lib/service/high5/space/database/document/number/index.js +4 -1
- package/lib/service/high5/space/database/index.js +4 -1
- package/lib/service/high5/space/event/index.js +4 -1
- package/lib/service/high5/space/event/stream/design/DesignOperations.js +4 -1
- package/lib/service/high5/space/event/stream/design/index.js +6 -3
- package/lib/service/high5/space/event/stream/design/snapshot/index.js +4 -1
- package/lib/service/high5/space/event/stream/index.js +4 -1
- package/lib/service/high5/space/execution/index.js +4 -1
- package/lib/service/high5/space/execution/log/index.js +4 -1
- package/lib/service/high5/space/execution/status/index.js +4 -1
- package/lib/service/high5/space/index.d.ts +10 -0
- package/lib/service/high5/space/index.js +25 -5
- package/lib/service/high5/space/job/index.js +4 -1
- package/lib/service/high5/space/job/log/index.js +4 -1
- package/lib/service/high5/space/node/index.js +4 -1
- package/lib/service/high5/space/pool/index.d.ts +11 -0
- package/lib/service/high5/space/pool/index.js +22 -1
- package/lib/service/high5/space/secret/index.js +4 -1
- package/lib/service/high5/space/stat/index.js +4 -1
- package/lib/service/high5/space/wave/index.js +4 -1
- package/lib/service/high5/space/webhook/index.js +4 -1
- package/lib/service/high5/space/webhook/log/index.js +4 -1
- package/lib/service/high5/stat/index.js +4 -1
- package/lib/service/high5/wave/index.js +4 -1
- package/lib/service/high5/wave/s3/index.js +5 -2
- package/lib/service/idp/guest/index.js +4 -1
- package/lib/service/idp/index.js +4 -1
- package/lib/service/idp/internal/index.js +4 -1
- package/lib/service/idp/oauth/device.d.ts +131 -0
- package/lib/service/idp/oauth/device.js +177 -0
- package/lib/service/idp/oauth/index.d.ts +3 -0
- package/lib/service/idp/oauth/index.js +11 -1
- package/lib/service/idp/organization/index.d.ts +9 -0
- package/lib/service/idp/organization/index.js +22 -3
- package/lib/service/idp/organization/license/index.js +4 -1
- package/lib/service/idp/organization/member/index.js +5 -2
- package/lib/service/idp/organization/member/invitations/index.d.ts +19 -0
- package/lib/service/idp/organization/member/invitations/index.js +23 -1
- package/lib/service/idp/organization/service-accounts/index.d.ts +11 -1
- package/lib/service/idp/organization/service-accounts/index.js +22 -2
- package/lib/service/idp/organization/settings/domain/index.js +4 -1
- package/lib/service/idp/organization/settings/domain/saml/index.js +4 -1
- package/lib/service/idp/organization/settings/index.js +4 -1
- package/lib/service/idp/organization/settings/oauth/index.d.ts +10 -0
- package/lib/service/idp/organization/settings/oauth/index.js +21 -1
- package/lib/service/idp/organization/stat/index.js +4 -1
- package/lib/service/idp/organization/team/index.d.ts +10 -0
- package/lib/service/idp/organization/team/index.js +21 -1
- package/lib/service/idp/registration/index.js +4 -1
- package/lib/service/idp/user/index.d.ts +8 -0
- package/lib/service/idp/user/index.js +20 -3
- package/lib/service/idp/user/license/index.js +4 -1
- package/lib/service/idp/user/message/index.d.ts +1 -0
- package/lib/service/idp/user/message/index.js +4 -1
- package/lib/service/idp/user/password/index.js +4 -1
- package/lib/service/idp/user/settings/connections/index.js +4 -1
- package/lib/service/idp/user/settings/general/index.js +4 -1
- package/lib/service/idp/user/settings/index.js +4 -1
- package/lib/service/idp/user/settings/notifications/index.js +4 -1
- package/lib/service/idp/user/settings/oauthApps/index.js +4 -1
- package/lib/service/idp/user/settings/pats/index.js +4 -1
- package/lib/service/idp/user/settings/twoFactor/index.js +4 -1
- package/lib/service/idp/user/settings/twoFactor/totp/index.js +4 -1
- package/lib/service/mailer/index.js +5 -2
- package/lib/service/mailer/internal/index.d.ts +2 -2
- package/lib/service/mailer/internal/index.js +5 -2
- package/lib/service/mothership/index.js +4 -1
- package/lib/service/nats/index.d.ts +7 -0
- package/lib/service/nats/index.js +19 -1
- package/lib/service/shorts/index.js +4 -1
- package/lib/service/shorts/internal/index.d.ts +6 -3
- package/lib/service/shorts/internal/index.js +20 -6
- package/lib/utils/bouncer/features/Provider.js +0 -1
- package/package.json +2 -2
- package/lib/interfaces/fuse/index.d.ts +0 -3
- package/lib/interfaces/fuse/space/cronjob/Cronjob.d.ts +0 -38
- package/lib/interfaces/fuse/space/cronjob/Cronjob.js +0 -8
- package/lib/interfaces/fuse/space/cronjob/CronjobLog.d.ts +0 -16
- package/lib/interfaces/fuse/space/index.d.ts +0 -22
- package/lib/interfaces/fuse/space/index.js +0 -11
- package/lib/service/dali/avatar/DaliFuseSpace.d.ts +0 -32
- package/lib/service/dali/avatar/DaliFuseSpace.js +0 -59
- package/lib/service/fuse/index.d.ts +0 -20
- package/lib/service/fuse/index.js +0 -48
- package/lib/service/fuse/internal/index.d.ts +0 -10
- package/lib/service/fuse/internal/index.js +0 -32
- package/lib/service/fuse/internal/space/cronjob/index.d.ts +0 -7
- package/lib/service/fuse/internal/space/cronjob/index.js +0 -17
- package/lib/service/fuse/internal/space/cronjob/log/index.d.ts +0 -17
- package/lib/service/fuse/internal/space/cronjob/log/index.js +0 -34
- package/lib/service/fuse/internal/space/index.d.ts +0 -26
- package/lib/service/fuse/internal/space/index.js +0 -51
- package/lib/service/fuse/space/cronjob/index.d.ts +0 -145
- package/lib/service/fuse/space/cronjob/index.js +0 -201
- package/lib/service/fuse/space/cronjob/log/index.d.ts +0 -35
- package/lib/service/fuse/space/cronjob/log/index.js +0 -58
- package/lib/service/fuse/space/index.d.ts +0 -97
- package/lib/service/fuse/space/index.js +0 -153
- /package/lib/interfaces/{fuse/space/cronjob/CronjobLog.js → agent/logging/cloudwatch.js} +0 -0
|
@@ -46,6 +46,7 @@ export interface DesignerNodeInput {
|
|
|
46
46
|
advanced?: boolean;
|
|
47
47
|
type: StreamNodeSpecificationInputType;
|
|
48
48
|
selectedLanguage?: StringMap;
|
|
49
|
+
expression?: boolean;
|
|
49
50
|
example: string | number | boolean | string[] | StringMap | StringMap[] | SortedStringMap[];
|
|
50
51
|
value?: string | number | boolean | string[] | StringMap | StringMap[] | SortedStringMap[];
|
|
51
52
|
mandatory?: boolean;
|
|
@@ -1,7 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Header, HttpMethod, ReducedSpace } from "../../../global";
|
|
1
|
+
import { ReducedSpace } from "../../../global";
|
|
3
2
|
import { ReducedOrganization } from "../../../idp/organization";
|
|
4
3
|
import { ReducedUser } from "../../../idp/user";
|
|
4
|
+
import { ReducedEvent } from "../event";
|
|
5
|
+
declare enum IntervalType {
|
|
6
|
+
MINUTE = "minute",
|
|
7
|
+
HOUR = "hour",
|
|
8
|
+
DAY = "day",
|
|
9
|
+
MONTH = "month",
|
|
10
|
+
YEAR = "year",
|
|
11
|
+
CUSTOM = "custom"
|
|
12
|
+
}
|
|
13
|
+
interface MinuteCronjob {
|
|
14
|
+
type: IntervalType.MINUTE;
|
|
15
|
+
values: {
|
|
16
|
+
minute: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
interface HourCronjob {
|
|
20
|
+
type: IntervalType.HOUR;
|
|
21
|
+
values: {
|
|
22
|
+
hour: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
interface DayCronjob {
|
|
26
|
+
type: IntervalType.DAY;
|
|
27
|
+
values: {
|
|
28
|
+
hour: number;
|
|
29
|
+
minute: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
interface MonthCronjob {
|
|
33
|
+
type: IntervalType.MONTH;
|
|
34
|
+
values: {
|
|
35
|
+
day: number;
|
|
36
|
+
hour: number;
|
|
37
|
+
minute: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface YearCronjob {
|
|
41
|
+
type: IntervalType.YEAR;
|
|
42
|
+
values: {
|
|
43
|
+
month: number;
|
|
44
|
+
day: number;
|
|
45
|
+
hour: number;
|
|
46
|
+
minute: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
interface CustomCronjob {
|
|
50
|
+
type: IntervalType.CUSTOM;
|
|
51
|
+
values: {
|
|
52
|
+
year: number;
|
|
53
|
+
month: number;
|
|
54
|
+
day: number;
|
|
55
|
+
hour: number;
|
|
56
|
+
minute: number;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
type CronjobType = MinuteCronjob | HourCronjob | DayCronjob | MonthCronjob | YearCronjob | CustomCronjob;
|
|
5
60
|
export interface Job {
|
|
6
61
|
_id: string;
|
|
7
62
|
name: string;
|
|
@@ -9,30 +64,20 @@ export interface Job {
|
|
|
9
64
|
organization: ReducedOrganization;
|
|
10
65
|
creator: ReducedUser;
|
|
11
66
|
space: ReducedSpace;
|
|
12
|
-
|
|
13
|
-
httpMethod: HttpMethod;
|
|
14
|
-
acceptInvalidSSL: boolean;
|
|
67
|
+
targetEvent: ReducedEvent;
|
|
15
68
|
timezone: string;
|
|
16
69
|
description?: string;
|
|
17
|
-
|
|
18
|
-
body?: string;
|
|
70
|
+
payload?: string;
|
|
19
71
|
enabled?: boolean;
|
|
72
|
+
target: string;
|
|
20
73
|
createDate: number;
|
|
21
74
|
modifyDate: number;
|
|
22
75
|
nextExecution?: number[];
|
|
23
76
|
lastStatus?: number;
|
|
24
77
|
lastTriggered?: number;
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
export type HmacSettings = {
|
|
28
|
-
headerName: string;
|
|
29
|
-
secret: string;
|
|
30
|
-
algorithm: HmacHashingAlgo;
|
|
31
|
-
};
|
|
32
|
-
export declare enum HmacHashingAlgo {
|
|
33
|
-
SHA_1 = "SHA-1",
|
|
34
|
-
SHA_256 = "SHA-256"
|
|
78
|
+
time?: CronjobType;
|
|
35
79
|
}
|
|
36
|
-
export type JobCreate = Pick<Job, "name" | "expression" | "
|
|
37
|
-
|
|
80
|
+
export type JobCreate = Pick<Job, "name" | "expression" | "payload" | "target" | "enabled" | "description" | "lastStatus" | "lastTriggered" | "time"> & {
|
|
81
|
+
targetEvent: string;
|
|
38
82
|
};
|
|
83
|
+
export {};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
var IntervalType;
|
|
4
|
+
(function (IntervalType) {
|
|
5
|
+
IntervalType["MINUTE"] = "minute";
|
|
6
|
+
IntervalType["HOUR"] = "hour";
|
|
7
|
+
IntervalType["DAY"] = "day";
|
|
8
|
+
IntervalType["MONTH"] = "month";
|
|
9
|
+
IntervalType["YEAR"] = "year";
|
|
10
|
+
IntervalType["CUSTOM"] = "custom";
|
|
11
|
+
})(IntervalType || (IntervalType = {}));
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type Primitive = string | number | boolean | null | Date | undefined;
|
|
2
|
+
type InputObject = Record<string, Primitive | Primitive[] | Record<string, Primitive>>;
|
|
3
|
+
type ComparisonCondition<T extends Primitive> = {
|
|
4
|
+
$eq?: T;
|
|
5
|
+
$ne?: T;
|
|
6
|
+
$gt?: T;
|
|
7
|
+
$gte?: T;
|
|
8
|
+
$lt?: T;
|
|
9
|
+
$lte?: T;
|
|
10
|
+
};
|
|
11
|
+
type StringCondition = {
|
|
12
|
+
$contains?: string;
|
|
13
|
+
$startsWith?: string;
|
|
14
|
+
$endsWith?: string;
|
|
15
|
+
$regex?: string;
|
|
16
|
+
};
|
|
17
|
+
type ArrayCondition<T extends Primitive> = {
|
|
18
|
+
$in?: T[];
|
|
19
|
+
$nin?: T[];
|
|
20
|
+
};
|
|
21
|
+
type MetaCondition = {
|
|
22
|
+
$exists?: boolean;
|
|
23
|
+
$type?: "string" | "number" | "boolean" | "object";
|
|
24
|
+
};
|
|
25
|
+
type FieldCondition<T extends Primitive = Primitive> = ComparisonCondition<T> & StringCondition & ArrayCondition<T> & MetaCondition;
|
|
26
|
+
type FieldQuery<T extends InputObject> = {
|
|
27
|
+
[K in keyof T]?: T[K] extends Primitive ? T[K] | FieldCondition<T[K]> : T[K] extends Primitive[] ? T[K] | ArrayCondition<T[K][number]> : T[K] extends Record<string, Primitive> ? NestedFieldQuery<T[K]> | Query<T[K]> : never;
|
|
28
|
+
};
|
|
29
|
+
/** Allows dot-notation-style conditions on nested object fields */
|
|
30
|
+
type NestedFieldQuery<T extends Record<string, Primitive>> = {
|
|
31
|
+
[K in keyof T]?: T[K] | FieldCondition<T[K]>;
|
|
32
|
+
};
|
|
33
|
+
type LogicalQuery<T extends InputObject> = {
|
|
34
|
+
$and?: Query<T>[];
|
|
35
|
+
$or?: Query<T>[];
|
|
36
|
+
$nor?: Query<T>[];
|
|
37
|
+
$not?: Query<T>;
|
|
38
|
+
};
|
|
39
|
+
type Query<T extends InputObject = InputObject> = FieldQuery<T> & LogicalQuery<T>;
|
|
40
|
+
declare function matchesQuery<T extends InputObject>(input: T, query: Query<T>): boolean;
|
|
41
|
+
export type { Primitive, InputObject, FieldCondition, Query };
|
|
42
|
+
export { matchesQuery };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable complexity */
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Primitive & input types
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.matchesQuery = matchesQuery;
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Engine implementation
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
function matchesQuery(input, query) {
|
|
12
|
+
for (const key of Object.keys(query)) {
|
|
13
|
+
if (key === "$and") {
|
|
14
|
+
const clauses = query.$and;
|
|
15
|
+
if (!clauses.every(subQuery => matchesQuery(input, subQuery)))
|
|
16
|
+
return false;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (key === "$or") {
|
|
20
|
+
const clauses = query.$or;
|
|
21
|
+
if (!clauses.some(subQuery => matchesQuery(input, subQuery)))
|
|
22
|
+
return false;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (key === "$nor") {
|
|
26
|
+
const clauses = query.$nor;
|
|
27
|
+
if (clauses.some(subQuery => matchesQuery(input, subQuery)))
|
|
28
|
+
return false;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (key === "$not") {
|
|
32
|
+
if (matchesQuery(input, query.$not))
|
|
33
|
+
return false;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
// Field-level check
|
|
37
|
+
const fieldKey = key;
|
|
38
|
+
const fieldValue = input[fieldKey];
|
|
39
|
+
const condition = query[fieldKey];
|
|
40
|
+
if (condition === undefined)
|
|
41
|
+
continue;
|
|
42
|
+
// Nested object: recurse into it as a sub-query
|
|
43
|
+
if (fieldValue !== null &&
|
|
44
|
+
typeof fieldValue === "object" &&
|
|
45
|
+
!Array.isArray(fieldValue) &&
|
|
46
|
+
!(fieldValue instanceof Date) &&
|
|
47
|
+
!isFieldCondition(condition)) {
|
|
48
|
+
if (!matchesQuery(fieldValue, condition))
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
else if (isFieldCondition(condition)) {
|
|
52
|
+
if (!matchesCondition(fieldValue, condition))
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
if (!isEqual(fieldValue, condition))
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
function matchesCondition(value, condition) {
|
|
63
|
+
// Comparison
|
|
64
|
+
if ("$eq" in condition && !isEqual(value, condition.$eq))
|
|
65
|
+
return false;
|
|
66
|
+
if ("$ne" in condition && isEqual(value, condition.$ne))
|
|
67
|
+
return false;
|
|
68
|
+
if (value === null || value === undefined) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if ("$gt" in condition && !(value > condition.$gt))
|
|
72
|
+
return false;
|
|
73
|
+
if ("$gte" in condition && !(value >= condition.$gte))
|
|
74
|
+
return false;
|
|
75
|
+
if ("$lt" in condition && !(value < condition.$lt))
|
|
76
|
+
return false;
|
|
77
|
+
if ("$lte" in condition && !(value <= condition.$lte))
|
|
78
|
+
return false;
|
|
79
|
+
// String
|
|
80
|
+
if ("$contains" in condition) {
|
|
81
|
+
if (typeof value !== "string" || !value.includes(condition.$contains))
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if ("$startsWith" in condition) {
|
|
85
|
+
if (typeof value !== "string" || !value.startsWith(condition.$startsWith))
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if ("$endsWith" in condition) {
|
|
89
|
+
if (typeof value !== "string" || !value.endsWith(condition.$endsWith))
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if ("$regex" in condition) {
|
|
93
|
+
if (typeof value !== "string" || !new RegExp(condition.$regex).test(value))
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
// Array membership
|
|
97
|
+
if ("$in" in condition && !condition.$in.some(o => isEqual(value, o)))
|
|
98
|
+
return false;
|
|
99
|
+
if ("$nin" in condition && condition.$nin.some(o => isEqual(value, o)))
|
|
100
|
+
return false;
|
|
101
|
+
// Meta
|
|
102
|
+
if ("$exists" in condition) {
|
|
103
|
+
const exists = value !== undefined && value !== null;
|
|
104
|
+
if (condition.$exists !== exists)
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if ("$type" in condition && typeof value !== condition.$type)
|
|
108
|
+
return false;
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
// Helpers
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
function isFieldCondition(value) {
|
|
115
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
116
|
+
return false;
|
|
117
|
+
const operators = [
|
|
118
|
+
"$eq",
|
|
119
|
+
"$ne",
|
|
120
|
+
"$gt",
|
|
121
|
+
"$gte",
|
|
122
|
+
"$lt",
|
|
123
|
+
"$lte",
|
|
124
|
+
"$contains",
|
|
125
|
+
"$startsWith",
|
|
126
|
+
"$endsWith",
|
|
127
|
+
"$regex",
|
|
128
|
+
"$in",
|
|
129
|
+
"$nin",
|
|
130
|
+
"$exists",
|
|
131
|
+
"$type",
|
|
132
|
+
];
|
|
133
|
+
return Object.keys(value).some(k => operators.includes(k));
|
|
134
|
+
}
|
|
135
|
+
function isEqual(a, b) {
|
|
136
|
+
if (a === b)
|
|
137
|
+
return true;
|
|
138
|
+
if (a instanceof Date && b instanceof Date)
|
|
139
|
+
return a.getTime() === b.getTime();
|
|
140
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
141
|
+
return a.length === b.length && a.every((v, i) => isEqual(v, b[i]));
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ValidationSuccess = {
|
|
2
|
+
valid: true;
|
|
3
|
+
};
|
|
4
|
+
export type ValidationError = {
|
|
5
|
+
valid: false;
|
|
6
|
+
errors: QueryValidationError[];
|
|
7
|
+
};
|
|
8
|
+
export type ValidationResult = ValidationSuccess | ValidationError;
|
|
9
|
+
export type QueryValidationError = {
|
|
10
|
+
/** JSONPath-style location of the offending node, e.g. "$and[0].age" */
|
|
11
|
+
path: string;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Validates the structure of a query object against the query schema.
|
|
16
|
+
* Returns a discriminated union: { valid: true } or { valid: false, errors[] }.
|
|
17
|
+
*
|
|
18
|
+
* Does NOT validate field names against a specific InputObject — it only
|
|
19
|
+
* checks that the query itself is structurally sound (correct operator
|
|
20
|
+
* positions, correct operand types, no unknown operators, etc.).
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateQuery(query: unknown): ValidationResult;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateQuery = validateQuery;
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Constants
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
const LOGICAL_OPERATORS = new Set(["$and", "$or", "$nor", "$not"]);
|
|
8
|
+
const FIELD_OPERATORS = new Set([
|
|
9
|
+
"$eq",
|
|
10
|
+
"$ne",
|
|
11
|
+
"$gt",
|
|
12
|
+
"$gte",
|
|
13
|
+
"$lt",
|
|
14
|
+
"$lte",
|
|
15
|
+
"$contains",
|
|
16
|
+
"$startsWith",
|
|
17
|
+
"$endsWith",
|
|
18
|
+
"$regex",
|
|
19
|
+
"$in",
|
|
20
|
+
"$nin",
|
|
21
|
+
"$exists",
|
|
22
|
+
"$type",
|
|
23
|
+
]);
|
|
24
|
+
const VALID_TYPES = new Set(["string", "number", "boolean", "object"]);
|
|
25
|
+
const PRIMITIVE_JS_TYPES = new Set(["string", "number", "boolean"]);
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Public API
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
/**
|
|
30
|
+
* Validates the structure of a query object against the query schema.
|
|
31
|
+
* Returns a discriminated union: { valid: true } or { valid: false, errors[] }.
|
|
32
|
+
*
|
|
33
|
+
* Does NOT validate field names against a specific InputObject — it only
|
|
34
|
+
* checks that the query itself is structurally sound (correct operator
|
|
35
|
+
* positions, correct operand types, no unknown operators, etc.).
|
|
36
|
+
*/
|
|
37
|
+
function validateQuery(query) {
|
|
38
|
+
const errors = [];
|
|
39
|
+
validateNode(query, "$", errors);
|
|
40
|
+
return errors.length === 0 ? { valid: true } : { valid: false, errors };
|
|
41
|
+
}
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Internal recursive validator
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
function validateNode(node, path, errors) {
|
|
46
|
+
if (node === null || typeof node !== "object" || Array.isArray(node)) {
|
|
47
|
+
errors.push({ path, message: `Query node must be a plain object, got ${formatType(node)}` });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
for (const [key, value] of Object.entries(node)) {
|
|
51
|
+
const childPath = `${path}.${key}`;
|
|
52
|
+
if (LOGICAL_OPERATORS.has(key)) {
|
|
53
|
+
validateLogicalOperator(key, value, childPath, errors);
|
|
54
|
+
}
|
|
55
|
+
else if (key.startsWith("$")) {
|
|
56
|
+
errors.push({ path: childPath, message: `Unknown operator "${key}"` });
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Field key — value is either a primitive, an array, a condition object,
|
|
60
|
+
// or a nested sub-query object.
|
|
61
|
+
validateFieldValue(value, childPath, errors);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function validateLogicalOperator(op, value, path, errors) {
|
|
66
|
+
if (op === "$not") {
|
|
67
|
+
// $not takes a single sub-query object
|
|
68
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
69
|
+
errors.push({ path, message: `"$not" must be a query object, got ${formatType(value)}` });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
validateNode(value, path, errors);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
// $and / $or / $nor take a non-empty array of sub-query objects
|
|
76
|
+
if (!Array.isArray(value)) {
|
|
77
|
+
errors.push({ path, message: `"${op}" must be an array, got ${formatType(value)}` });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (value.length === 0) {
|
|
81
|
+
errors.push({ path, message: `"${op}" array must not be empty` });
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
for (let i = 0; i < value.length; i++) {
|
|
85
|
+
validateNode(value[i], `${path}[${i}]`, errors);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function validateFieldValue(value, path, errors) {
|
|
89
|
+
// Plain primitive — shorthand equality
|
|
90
|
+
if (isPrimitive(value))
|
|
91
|
+
return;
|
|
92
|
+
// Array — must be an array of primitives (shorthand $in-style direct value)
|
|
93
|
+
if (Array.isArray(value)) {
|
|
94
|
+
for (let i = 0; i < value.length; i++) {
|
|
95
|
+
if (!isPrimitive(value[i])) {
|
|
96
|
+
errors.push({
|
|
97
|
+
path: `${path}[${i}]`,
|
|
98
|
+
message: `Array field values must be primitives, got ${formatType(value[i])}`,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (value === null || typeof value !== "object") {
|
|
105
|
+
errors.push({ path, message: `Field value must be a primitive, array, or object, got ${formatType(value)}` });
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const keys = Object.keys(value);
|
|
109
|
+
const hasOperatorKeys = keys.some(k => k.startsWith("$"));
|
|
110
|
+
const hasFieldKeys = keys.some(k => !k.startsWith("$"));
|
|
111
|
+
if (hasOperatorKeys && hasFieldKeys) {
|
|
112
|
+
errors.push({ path, message: "Field condition must not mix operator keys and plain field keys" });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (hasOperatorKeys) {
|
|
116
|
+
// Treat as a FieldCondition object
|
|
117
|
+
validateFieldCondition(value, path, errors);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// Treat as a nested sub-query object
|
|
121
|
+
validateNode(value, path, errors);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function validateFieldCondition(condition, path, errors) {
|
|
125
|
+
for (const [op, operand] of Object.entries(condition)) {
|
|
126
|
+
const opPath = `${path}.${op}`;
|
|
127
|
+
if (!FIELD_OPERATORS.has(op)) {
|
|
128
|
+
errors.push({ path: opPath, message: `Unknown field operator "${op}"` });
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
switch (op) {
|
|
132
|
+
// Operand must be a primitive
|
|
133
|
+
case "$eq":
|
|
134
|
+
case "$ne":
|
|
135
|
+
case "$gt":
|
|
136
|
+
case "$gte":
|
|
137
|
+
case "$lt":
|
|
138
|
+
case "$lte":
|
|
139
|
+
if (!isPrimitive(operand)) {
|
|
140
|
+
errors.push({ path: opPath, message: `"${op}" operand must be a primitive, got ${formatType(operand)}` });
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
// Operand must be a string
|
|
144
|
+
case "$contains":
|
|
145
|
+
case "$startsWith":
|
|
146
|
+
case "$endsWith":
|
|
147
|
+
case "$regex":
|
|
148
|
+
if (typeof operand !== "string") {
|
|
149
|
+
errors.push({ path: opPath, message: `"${op}" operand must be a string, got ${formatType(operand)}` });
|
|
150
|
+
}
|
|
151
|
+
// Extra: validate that $regex is a valid regular expression
|
|
152
|
+
if (op === "$regex") {
|
|
153
|
+
try {
|
|
154
|
+
new RegExp(operand);
|
|
155
|
+
}
|
|
156
|
+
catch (_a) {
|
|
157
|
+
errors.push({ path: opPath, message: `"$regex" operand is not a valid regular expression` });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
// Operand must be a non-empty array of primitives
|
|
162
|
+
case "$in":
|
|
163
|
+
case "$nin":
|
|
164
|
+
if (!Array.isArray(operand)) {
|
|
165
|
+
errors.push({ path: opPath, message: `"${op}" operand must be an array, got ${formatType(operand)}` });
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
if (operand.length === 0) {
|
|
169
|
+
errors.push({ path: opPath, message: `"${op}" operand array must not be empty` });
|
|
170
|
+
}
|
|
171
|
+
for (let i = 0; i < operand.length; i++) {
|
|
172
|
+
if (!isPrimitive(operand[i])) {
|
|
173
|
+
errors.push({
|
|
174
|
+
path: `${opPath}[${i}]`,
|
|
175
|
+
message: `"${op}" array elements must be primitives, got ${formatType(operand[i])}`,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
// Operand must be a boolean
|
|
182
|
+
case "$exists":
|
|
183
|
+
if (typeof operand !== "boolean") {
|
|
184
|
+
errors.push({ path: opPath, message: `"$exists" operand must be a boolean, got ${formatType(operand)}` });
|
|
185
|
+
}
|
|
186
|
+
break;
|
|
187
|
+
// Operand must be one of the valid type strings
|
|
188
|
+
case "$type":
|
|
189
|
+
if (typeof operand !== "string" || !VALID_TYPES.has(operand)) {
|
|
190
|
+
errors.push({
|
|
191
|
+
path: opPath,
|
|
192
|
+
message: `"$type" operand must be one of: ${[...VALID_TYPES].map(t => `"${t}"`).join(", ")}, got ${formatType(operand)}`,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
default:
|
|
197
|
+
errors.push({ path: opPath, message: `Unknown field operator "${op}"` });
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// ---------------------------------------------------------------------------
|
|
203
|
+
// Helpers
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
function isPrimitive(value) {
|
|
206
|
+
if (value === null)
|
|
207
|
+
return true;
|
|
208
|
+
if (value instanceof Date)
|
|
209
|
+
return true;
|
|
210
|
+
return PRIMITIVE_JS_TYPES.has(typeof value);
|
|
211
|
+
}
|
|
212
|
+
function formatType(value) {
|
|
213
|
+
if (value === null)
|
|
214
|
+
return "null";
|
|
215
|
+
if (value instanceof Date)
|
|
216
|
+
return "Date";
|
|
217
|
+
if (Array.isArray(value))
|
|
218
|
+
return "array";
|
|
219
|
+
return typeof value;
|
|
220
|
+
}
|
|
@@ -2,17 +2,17 @@ export * from "./oauth";
|
|
|
2
2
|
export * from "./organization";
|
|
3
3
|
export * from "./organization/member";
|
|
4
4
|
export * from "./organization/member/invitations";
|
|
5
|
-
export * from "./organization/
|
|
5
|
+
export * from "./organization/service-accounts";
|
|
6
6
|
export * from "./organization/settings/domain";
|
|
7
7
|
export * from "./organization/settings/domain/saml";
|
|
8
8
|
export * from "./organization/settings/oauthApp";
|
|
9
|
-
export * from "./organization/
|
|
9
|
+
export * from "./organization/team";
|
|
10
|
+
export * from "./user";
|
|
10
11
|
export * from "./user/GeneralSettings";
|
|
11
12
|
export * from "./user/Pat";
|
|
12
13
|
export * from "./user/Scopes";
|
|
13
14
|
export * from "./user/SuccessfulAuth";
|
|
14
15
|
export * from "./user/Totp";
|
|
15
|
-
export * from "./user";
|
|
16
16
|
export declare enum PreLoginPath {
|
|
17
17
|
LOGIN = "LOGIN",
|
|
18
18
|
REGISTER = "REGISTER",
|
|
@@ -19,17 +19,17 @@ __exportStar(require("./oauth"), exports);
|
|
|
19
19
|
__exportStar(require("./organization"), exports);
|
|
20
20
|
__exportStar(require("./organization/member"), exports);
|
|
21
21
|
__exportStar(require("./organization/member/invitations"), exports);
|
|
22
|
-
__exportStar(require("./organization/
|
|
22
|
+
__exportStar(require("./organization/service-accounts"), exports);
|
|
23
23
|
__exportStar(require("./organization/settings/domain"), exports);
|
|
24
24
|
__exportStar(require("./organization/settings/domain/saml"), exports);
|
|
25
25
|
__exportStar(require("./organization/settings/oauthApp"), exports);
|
|
26
|
-
__exportStar(require("./organization/
|
|
26
|
+
__exportStar(require("./organization/team"), exports);
|
|
27
|
+
__exportStar(require("./user"), exports);
|
|
27
28
|
__exportStar(require("./user/GeneralSettings"), exports);
|
|
28
29
|
__exportStar(require("./user/Pat"), exports);
|
|
29
30
|
__exportStar(require("./user/Scopes"), exports);
|
|
30
31
|
__exportStar(require("./user/SuccessfulAuth"), exports);
|
|
31
32
|
__exportStar(require("./user/Totp"), exports);
|
|
32
|
-
__exportStar(require("./user"), exports);
|
|
33
33
|
var PreLoginPath;
|
|
34
34
|
(function (PreLoginPath) {
|
|
35
35
|
PreLoginPath["LOGIN"] = "LOGIN";
|